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:
parent
130dc05517
commit
a2bcf765a8
10 changed files with 73 additions and 56 deletions
resources/js/components
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue