|
18 | 18 | autoCloseTags: true,
|
19 | 19 | autoFormatOnStart: false,
|
20 | 20 | autoFormatOnUncomment: true,
|
| 21 | + autoLoadCodeMirror: true, |
21 | 22 | continueComments: true,
|
22 | 23 | enableCodeFolding: true,
|
23 | 24 | enableCodeFormatting: true,
|
|
188 | 189 | // Load the content
|
189 | 190 | this.setValueOf('main', 'data', oldData = editor.getData());
|
190 | 191 |
|
191 |
| - if (!IsStyleSheetAlreadyLoaded(rootPath + 'css/codemirror.min.css')) { |
192 |
| - CKEDITOR.document.appendStyleSheet(rootPath + 'css/codemirror.min.css'); |
193 |
| - } |
| 192 | + if (config.autoLoadCodeMirror) { |
194 | 193 |
|
195 |
| - if (config.theme.length && config.theme != 'default' && !IsStyleSheetAlreadyLoaded(rootPath + 'theme/' + config.theme + '.css')) { |
196 |
| - CKEDITOR.document.appendStyleSheet(rootPath + 'theme/' + config.theme + '.css'); |
197 |
| - } |
| 194 | + if (!IsStyleSheetAlreadyLoaded(rootPath + 'css/codemirror.min.css')) { |
| 195 | + CKEDITOR.document.appendStyleSheet(rootPath + 'css/codemirror.min.css'); |
| 196 | + } |
198 | 197 |
|
199 |
| - if (typeof (CodeMirror) == 'undefined') { |
| 198 | + if (config.theme.length && |
| 199 | + config.theme != 'default' && |
| 200 | + !IsStyleSheetAlreadyLoaded(rootPath + 'theme/' + config.theme + '.css')) { |
| 201 | + CKEDITOR.document.appendStyleSheet(rootPath + 'theme/' + config.theme + '.css'); |
| 202 | + } |
200 | 203 |
|
201 |
| - CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.min.js', function() { |
| 204 | + if (typeof (CodeMirror) == 'undefined') { |
202 | 205 |
|
203 |
| - CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() { |
204 |
| - loadCodeMirrorInline(editor, textArea); |
205 |
| - }); |
206 |
| - }); |
| 206 | + CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.min.js', |
| 207 | + function() { |
| 208 | + |
| 209 | + CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), |
| 210 | + function() { |
| 211 | + loadCodeMirrorInline(editor, textArea); |
| 212 | + }); |
| 213 | + }); |
207 | 214 |
|
208 | 215 |
|
209 |
| - } else { |
210 |
| - //loadCodeMirrorInline(editor, textArea); |
211 |
| - if (CodeMirror.prototype['autoFormatAll']) { |
212 |
| - loadCodeMirrorInline(editor, textArea); |
213 | 216 | } else {
|
214 |
| - // loading the add-on scripts. |
215 |
| - CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() { |
| 217 | + //loadCodeMirrorInline(editor, textArea); |
| 218 | + if (CodeMirror.prototype['autoFormatAll']) { |
216 | 219 | loadCodeMirrorInline(editor, textArea);
|
217 |
| - }); |
| 220 | + } else { |
| 221 | + // loading the add-on scripts. |
| 222 | + CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), |
| 223 | + function() { |
| 224 | + loadCodeMirrorInline(editor, textArea); |
| 225 | + }); |
| 226 | + } |
218 | 227 | }
|
| 228 | + |
219 | 229 | }
|
220 | 230 | },
|
221 | 231 | onCancel: function (event) {
|
|
255 | 265 |
|
256 | 266 | // Avoid unnecessary setData. Also preserve selection
|
257 | 267 | // when user changed his mind and goes back to wysiwyg editing.
|
258 |
| - if (newData === oldData) |
| 268 | + if (newData === oldData) { |
| 269 | + editor.fire('blur', this); |
| 270 | + editor.fire('focus', this); |
259 | 271 | return true;
|
| 272 | + } |
260 | 273 |
|
261 | 274 | // Set data asynchronously to avoid errors in IE.
|
262 | 275 | CKEDITOR.env.ie ? CKEDITOR.tools.setTimeout(setData, 0, this, newData) : setData.call(this, newData);
|
|
529 | 542 | }
|
530 | 543 |
|
531 | 544 | editor.addMode('source', function (callback) {
|
532 |
| - if (!IsStyleSheetAlreadyLoaded(rootPath + 'css/codemirror.min.css')) { |
533 |
| - CKEDITOR.document.appendStyleSheet(rootPath + 'css/codemirror.min.css'); |
| 545 | + if (!config.autoLoadCodeMirror) { |
| 546 | + return; |
534 | 547 | }
|
535 | 548 |
|
536 |
| - if (config.theme.length && config.theme != 'default' && !IsStyleSheetAlreadyLoaded(rootPath + 'theme/' + config.theme + '.css')) { |
537 |
| - CKEDITOR.document.appendStyleSheet(rootPath + 'theme/' + config.theme + '.css'); |
538 |
| - } |
| 549 | + if (!IsStyleSheetAlreadyLoaded(rootPath + 'css/codemirror.min.css')) { |
| 550 | + CKEDITOR.document.appendStyleSheet(rootPath + 'css/codemirror.min.css'); |
| 551 | + } |
| 552 | + |
| 553 | + if (config.theme.length && |
| 554 | + config.theme != 'default' && |
| 555 | + !IsStyleSheetAlreadyLoaded(rootPath + 'theme/' + config.theme + '.css')) { |
| 556 | + CKEDITOR.document.appendStyleSheet(rootPath + 'theme/' + config.theme + '.css'); |
| 557 | + } |
539 | 558 |
|
540 | 559 | if (typeof (CodeMirror) == 'undefined') {
|
541 | 560 |
|
542 |
| - CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.min.js', function() { |
| 561 | + CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.min.js', |
| 562 | + function() { |
543 | 563 |
|
544 |
| - CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() { |
545 |
| - loadCodeMirror(editor); |
546 |
| - callback(); |
| 564 | + CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), |
| 565 | + function() { |
| 566 | + loadCodeMirror(editor); |
| 567 | + callback(); |
| 568 | + }); |
547 | 569 | });
|
548 |
| - }); |
549 | 570 | } else {
|
550 | 571 | if (CodeMirror.prototype['autoFormatAll']) {
|
551 | 572 | loadCodeMirror(editor);
|
552 | 573 | callback();
|
553 | 574 | } else {
|
554 | 575 | // loading the add-on scripts.
|
555 |
| - CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() { |
556 |
| - loadCodeMirror(editor); |
557 |
| - callback(); |
558 |
| - }); |
| 576 | + CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), |
| 577 | + function() { |
| 578 | + loadCodeMirror(editor); |
| 579 | + callback(); |
| 580 | + }); |
559 | 581 | }
|
560 | 582 | }
|
561 | 583 | });
|
|
600 | 622 | }
|
601 | 623 |
|
602 | 624 | break;
|
| 625 | + case "twig": |
| 626 | + { |
| 627 | + scriptFiles.push(rootPath + 'js/codemirror.mode.twig.min.js'); |
| 628 | + } |
| 629 | + |
| 630 | + break; |
603 | 631 | default:
|
604 | 632 | scriptFiles.push(rootPath + 'js/codemirror.mode.htmlmixed.min.js');
|
605 | 633 | }
|
|
920 | 948 |
|
921 | 949 | editor.on('instanceReady', function (evt) {
|
922 | 950 |
|
923 |
| - // Fix native context menu |
924 |
| - editor.container.getPrivate().events.contextmenu.listeners.splice(0, 1); |
| 951 | + //editor.container.getPrivate().events.contextmenu.listeners.splice(0, 1); |
925 | 952 |
|
926 | 953 | var selectAllCommand = editor.commands.selectAll;
|
927 | 954 |
|
|
0 commit comments