0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-17 22:02:05 +00:00

Split out codemirror JS to its own module

Added a cache-compatible module loading system/pattern to the codebase.
This commit is contained in:
Dan Brown 2022-02-08 11:10:01 +00:00
parent 130dc05517
commit a2bcf765a8
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
10 changed files with 73 additions and 56 deletions
resources/js/components

View 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());
}