|
|
@ -2,18 +2,42 @@ define([
|
|
|
|
'jquery',
|
|
|
|
'jquery',
|
|
|
|
'/common/modes.js',
|
|
|
|
'/common/modes.js',
|
|
|
|
'/common/themes.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'
|
|
|
|
'/bower_components/file-saver/FileSaver.min.js'
|
|
|
|
], function ($, Modes, Themes) {
|
|
|
|
], function ($, Modes, Themes, CMeditor) {
|
|
|
|
var saveAs = window.saveAs;
|
|
|
|
var saveAs = window.saveAs;
|
|
|
|
var module = {};
|
|
|
|
var module = {};
|
|
|
|
|
|
|
|
|
|
|
|
module.create = function (CMeditor, ifrw, Cryptpad) {
|
|
|
|
module.create = function (ifrw, Cryptpad, defaultMode) {
|
|
|
|
var exp = {};
|
|
|
|
var exp = {};
|
|
|
|
|
|
|
|
|
|
|
|
var Messages = Cryptpad.Messages;
|
|
|
|
var Messages = Cryptpad.Messages;
|
|
|
|
|
|
|
|
|
|
|
|
var CodeMirror = exp.CodeMirror = CMeditor;
|
|
|
|
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 $pad = $('#pad-iframe');
|
|
|
|
var $textarea = exp.$textarea = $pad.contents().find('#editor1');
|
|
|
|
var $textarea = exp.$textarea = $pad.contents().find('#editor1');
|
|
|
@ -43,14 +67,16 @@ define([
|
|
|
|
extraKeys: {"Shift-Ctrl-R": undefined},
|
|
|
|
extraKeys: {"Shift-Ctrl-R": undefined},
|
|
|
|
foldGutter: true,
|
|
|
|
foldGutter: true,
|
|
|
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
|
|
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
|
|
|
mode: "javascript",
|
|
|
|
mode: defaultMode || "javascript",
|
|
|
|
readOnly: true
|
|
|
|
readOnly: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
editor.setValue(Messages.codeInitialState);
|
|
|
|
editor.setValue(Messages.codeInitialState);
|
|
|
|
|
|
|
|
|
|
|
|
var setMode = exp.setMode = function (mode, cb) {
|
|
|
|
var setMode = exp.setMode = function (mode, cb) {
|
|
|
|
exp.highlightMode = mode;
|
|
|
|
exp.highlightMode = mode;
|
|
|
|
if (mode !== "text") { CMeditor.autoLoadMode(editor, mode); }
|
|
|
|
if (mode !== "text") {
|
|
|
|
|
|
|
|
CMeditor.autoLoadMode(editor, mode);
|
|
|
|
|
|
|
|
}
|
|
|
|
editor.setOption('mode', mode);
|
|
|
|
editor.setOption('mode', mode);
|
|
|
|
if (exp.$language) {
|
|
|
|
if (exp.$language) {
|
|
|
|
var name = exp.$language.find('a[data-value="' + mode + '"]').text() || undefined;
|
|
|
|
var name = exp.$language.find('a[data-value="' + mode + '"]').text() || undefined;
|
|
|
|