]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/code-editor.js
Split out codemirror JS to its own module
[bookstack] / resources / js / components / code-editor.js
index 2e3506ec7a428d7dc0c146e8ec1d4e446ce8979f..a8a2c0c6f0ac793f0c36f7913533a148176a30f5 100644 (file)
@@ -1,4 +1,3 @@
-import Code from "../services/code";
 import {onChildEvent, onEnterPress, onSelect} from "../services/dom";
 
 /**
@@ -63,13 +62,17 @@ class CodeEditor {
         this.show();
         this.updateEditorMode(language);
 
-        Code.setContent(this.editor, code);
+        window.importVersioned('code').then(Code => {
+            Code.setContent(this.editor, code);
+        });
     }
 
-    show() {
+    async show() {
+        const Code = await window.importVersioned('code');
         if (!this.editor) {
             this.editor = Code.popupEditor(this.editorInput, this.languageInput.value);
         }
+
         this.loadHistory();
         this.popup.components.popup.show(() => {
             Code.updateLayout(this.editor);
@@ -84,7 +87,8 @@ class CodeEditor {
         this.addHistory();
     }
 
-    updateEditorMode(language) {
+    async updateEditorMode(language) {
+        const Code = await window.importVersioned('code');
         Code.setMode(this.editor, language, this.editor.getValue());
     }