Fix syntax highlighting

pull/1/head
yflory 8 years ago
parent 335898a4c7
commit 5694505719

@ -3,33 +3,6 @@
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/bower_components/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="/bower_components/codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" href="/bower_components/codemirror/addon/fold/foldgutter.css" />
<script src="/bower_components/codemirror/mode/javascript/javascript.js"></script>
<script src="/bower_components/codemirror/addon/mode/loadmode.js"></script>
<script src="/bower_components/codemirror/mode/meta.js"></script>
<script src="/bower_components/codemirror/addon/mode/overlay.js"></script>
<script src="/bower_components/codemirror/addon/mode/multiplex.js"></script>
<script src="/bower_components/codemirror/addon/mode/simple.js"></script>
<script src="/bower_components/codemirror/addon/edit/closebrackets.js"></script>
<script src="/bower_components/codemirror/addon/edit/matchbrackets.js"></script>
<script src="/bower_components/codemirror/addon/edit/trailingspace.js"></script>
<script src="/bower_components/codemirror/addon/selection/active-line.js"></script>
<script src="/bower_components/codemirror/addon/search/search.js"></script>
<script src="/bower_components/codemirror/addon/search/match-highlighter.js"></script>
<script src="/bower_components/codemirror/addon/search/searchcursor.js"></script>
<script src="/bower_components/codemirror/addon/dialog/dialog.js"></script>
<script src="/bower_components/codemirror/addon/fold/foldcode.js"></script>
<script src="/bower_components/codemirror/addon/fold/foldgutter.js"></script>
<script src="/bower_components/codemirror/addon/fold/brace-fold.js"></script>
<script src="/bower_components/codemirror/addon/fold/xml-fold.js"></script>
<script src="/bower_components/codemirror/addon/fold/markdown-fold.js"></script>
<script src="/bower_components/codemirror/addon/fold/comment-fold.js"></script>
<script src="/bower_components/codemirror/addon/display/placeholder.js"></script>
<script async data-bootload="inner.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.1.15"></script>
<style> .loading-hidden { display: none; } </style>
</head>

@ -3,6 +3,10 @@ define([
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/code/code.less',
'less!/customize/src/less/toolbar.less',
'css!cm/lib/codemirror.css',
'css!cm/addon/dialog/dialog.css',
'css!cm/addon/fold/foldgutter.css',
], function ($) {
$('.loading-hidden').removeClass('loading-hidden');
});

@ -42,7 +42,7 @@ define([
Cryptpad.errorLoadingScreen(Messages.websocketError);
};
var andThen = function (CMeditor) {
var andThen = function () {
var $iframe = $('#pad-iframe').contents();
var $contentContainer = $iframe.find('#editorContainer');
var $previewContainer = $iframe.find('#previewContainer');
@ -58,7 +58,7 @@ define([
}
});
var CodeMirror = Cryptpad.createCodemirror(CMeditor, ifrw, Cryptpad);
var CodeMirror = Cryptpad.createCodemirror(ifrw, Cryptpad);
$iframe.find('.CodeMirror').addClass('fullPage');
editor = CodeMirror.editor;
@ -430,9 +430,9 @@ define([
var interval = 100;
var second = function (CM) {
var first = function () {
Cryptpad.ready(function () {
andThen(CM);
andThen();
Cryptpad.reportAppUsage();
});
Cryptpad.onError(function (info) {
@ -442,17 +442,6 @@ define([
});
};
var first = function () {
if (ifrw.CodeMirror) {
// it exists, call your continuation
second(ifrw.CodeMirror);
} else {
console.log("CodeMirror was not defined. Trying again in %sms", interval);
// try again in 'interval' ms
setTimeout(first, interval);
}
};
first();
});
});

@ -10,6 +10,7 @@ define([], function () {
"json.sortify": "/bower_components/json.sortify/dist/JSON.sortify",
//"pdfjs-dist/build/pdf": "/bower_components/pdfjs-dist/build/pdf",
//"pdfjs-dist/build/pdf.worker": "/bower_components/pdfjs-dist/build/pdf.worker"
cm: '/bower_components/codemirror'
},
map: {
'*': {

@ -2,18 +2,42 @@ define([
'jquery',
'/common/modes.js',
'/common/themes.js',
'cm/lib/codemirror',
'cm/mode/javascript/javascript',
'cm/mode/markdown/markdown',
'cm/addon/mode/loadmode',
'cm/mode/meta',
'cm/addon/mode/overlay',
'cm/addon/mode/multiplex',
'cm/addon/mode/simple',
'cm/addon/edit/closebrackets',
'cm/addon/edit/matchbrackets',
'cm/addon/edit/trailingspace',
'cm/addon/selection/active-line',
'cm/addon/search/search',
'cm/addon/search/match-highlighter',
'cm/addon/search/searchcursor',
'cm/addon/dialog/dialog',
'cm/addon/fold/foldcode',
'cm/addon/fold/foldgutter',
'cm/addon/fold/brace-fold',
'cm/addon/fold/xml-fold',
'cm/addon/fold/markdown-fold',
'cm/addon/fold/comment-fold',
'cm/addon/display/placeholder',
'/bower_components/file-saver/FileSaver.min.js'
], function ($, Modes, Themes) {
], function ($, Modes, Themes, CMeditor) {
var saveAs = window.saveAs;
var module = {};
module.create = function (CMeditor, ifrw, Cryptpad) {
module.create = function (ifrw, Cryptpad, defaultMode) {
var exp = {};
var Messages = Cryptpad.Messages;
var CodeMirror = exp.CodeMirror = CMeditor;
CodeMirror.modeURL = "/bower_components/codemirror/mode/%N/%N.js";
CodeMirror.modeURL = "cm/mode/%N/%N";
var $pad = $('#pad-iframe');
var $textarea = exp.$textarea = $pad.contents().find('#editor1');
@ -43,14 +67,16 @@ define([
extraKeys: {"Shift-Ctrl-R": undefined},
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
mode: "javascript",
mode: defaultMode || "javascript",
readOnly: true
});
editor.setValue(Messages.codeInitialState);
var setMode = exp.setMode = function (mode, cb) {
exp.highlightMode = mode;
if (mode !== "text") { CMeditor.autoLoadMode(editor, mode); }
if (mode !== "text") {
CMeditor.autoLoadMode(editor, mode);
}
editor.setOption('mode', mode);
if (exp.$language) {
var name = exp.$language.find('a[data-value="' + mode + '"]').text() || undefined;

@ -54,11 +54,9 @@ define(function () {
"jsx jsx .jsx",
"julia julia",
"livescript livescript",
"loadmode.js loadmode.js",
"lua lua",
"markdown markdown .md",
"mathematica mathematica",
"meta.js meta.js",
"mirc mirc",
"mllike mllike",
"modelica modelica",

@ -6,34 +6,6 @@
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/bower_components/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="/bower_components/codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" href="/bower_components/codemirror/addon/fold/foldgutter.css" />
<script src="/bower_components/codemirror/mode/javascript/javascript.js"></script>
<script src="/bower_components/codemirror/addon/mode/loadmode.js"></script>
<script src="/bower_components/codemirror/mode/meta.js"></script>
<script src="/bower_components/codemirror/addon/mode/overlay.js"></script>
<script src="/bower_components/codemirror/addon/mode/multiplex.js"></script>
<script src="/bower_components/codemirror/addon/mode/simple.js"></script>
<script src="/bower_components/codemirror/addon/edit/closebrackets.js"></script>
<script src="/bower_components/codemirror/addon/edit/matchbrackets.js"></script>
<script src="/bower_components/codemirror/addon/edit/trailingspace.js"></script>
<script src="/bower_components/codemirror/addon/selection/active-line.js"></script>
<script src="/bower_components/codemirror/addon/search/search.js"></script>
<script src="/bower_components/codemirror/addon/search/match-highlighter.js"></script>
<script src="/bower_components/codemirror/addon/search/searchcursor.js"></script>
<script src="/bower_components/codemirror/addon/dialog/dialog.js"></script>
<script src="/bower_components/codemirror/addon/fold/foldcode.js"></script>
<script src="/bower_components/codemirror/addon/fold/foldgutter.js"></script>
<script src="/bower_components/codemirror/addon/fold/brace-fold.js"></script>
<script src="/bower_components/codemirror/addon/fold/xml-fold.js"></script>
<script src="/bower_components/codemirror/addon/fold/markdown-fold.js"></script>
<script src="/bower_components/codemirror/addon/fold/comment-fold.js"></script>
<script src="/bower_components/codemirror/addon/display/placeholder.js"></script>
<script async data-bootload="inner.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.1.15"></script>
<style>.loading-hidden { display: none; } </style>
</head>

@ -50,10 +50,10 @@ define([
Cryptpad.errorLoadingScreen(Messages.websocketError);
};
var andThen = function (CMeditor) {
var andThen = function () {
var $iframe = $('#pad-iframe').contents();
var $contentContainer = $iframe.find('#editorContainer');
var CodeMirror = Cryptpad.createCodemirror(CMeditor, ifrw, Cryptpad);
var CodeMirror = Cryptpad.createCodemirror(ifrw, Cryptpad, 'slide');
editor = CodeMirror.editor;
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
@ -697,9 +697,9 @@ define([
var interval = 100;
var second = function (CM) {
var first = function () {
Cryptpad.ready(function () {
andThen(CM);
andThen();
Cryptpad.reportAppUsage();
});
Cryptpad.onError(function (info) {
@ -709,17 +709,6 @@ define([
});
};
var first = function () {
if (ifrw.CodeMirror) {
// it exists, call your continuation
second(ifrw.CodeMirror);
} else {
console.log("CodeMirror was not defined. Trying again in %sms", interval);
// try again in 'interval' ms
setTimeout(first, interval);
}
};
first();
});
});

Loading…
Cancel
Save