Add proper syntax highlighting for codemirror and make theme footer & header use codemirror

This commit is contained in:
Kevin Chung
2020-04-26 02:32:28 -04:00
parent c9d31b67aa
commit 6099abf1a1
12 changed files with 227 additions and 149 deletions

View File

@@ -1 +1,4 @@
@import "~codemirror/lib/codemirror.css"; @import "~codemirror/lib/codemirror.css";
.CodeMirror {
font-size: 12px;
}

View File

@@ -7,6 +7,8 @@ import CTFd from "core/CTFd";
import { default as helpers } from "core/helpers"; import { default as helpers } from "core/helpers";
import $ from "jquery"; import $ from "jquery";
import { ezQuery, ezProgressBar } from "core/ezq"; import { ezQuery, ezProgressBar } from "core/ezq";
import CodeMirror from "codemirror";
import 'codemirror/mode/htmlmixed/htmlmixed.js';
function loadTimestamp(place, timestamp) { function loadTimestamp(place, timestamp) {
if (typeof timestamp == "string") { if (typeof timestamp == "string") {
@@ -233,6 +235,26 @@ function insertTimezones(target) {
} }
$(() => { $(() => {
CodeMirror.fromTextArea(
document.getElementById("theme-header"),
{
lineNumbers: true,
lineWrapping: true,
mode: "htmlmixed",
htmlMode: true
}
);
CodeMirror.fromTextArea(
document.getElementById("theme-footer"),
{
lineNumbers: true,
lineWrapping: true,
mode: "htmlmixed",
htmlMode: true
}
);
insertTimezones($("#start-timezone")); insertTimezones($("#start-timezone"));
insertTimezones($("#end-timezone")); insertTimezones($("#end-timezone"));
insertTimezones($("#freeze-timezone")); insertTimezones($("#freeze-timezone"));

View File

@@ -4,6 +4,7 @@ import $ from "jquery";
import CTFd from "core/CTFd"; import CTFd from "core/CTFd";
import { default as helpers } from "core/helpers"; import { default as helpers } from "core/helpers";
import CodeMirror from "codemirror"; import CodeMirror from "codemirror";
import 'codemirror/mode/htmlmixed/htmlmixed.js';
import { ezQuery, ezToast } from "core/ezq"; import { ezQuery, ezToast } from "core/ezq";
function get_filetype_icon_class(filename) { function get_filetype_icon_class(filename) {
@@ -206,7 +207,7 @@ $(() => {
{ {
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
mode: "xml", mode: "htmlmixed",
htmlMode: true htmlMode: true
} }
); );

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,9 @@
{% extends "admin/base.html" %} {% extends "admin/base.html" %}
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="{{ url_for('views.themes', theme='admin', path='css/codemirror.css') }}">
{% endblock %}
{% block content %} {% block content %}
<div class="jumbotron"> <div class="jumbotron">
<div class="container"> <div class="container">