mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 08:46:43 +01:00
lazy / dynamic loading of CKEditor and Code mirror
This commit is contained in:
@@ -17,26 +17,34 @@ const sqlConsole = (function() {
|
||||
width: $(window).width(),
|
||||
height: $(window).height(),
|
||||
open: function() {
|
||||
CodeMirror.keyMap.default["Shift-Tab"] = "indentLess";
|
||||
CodeMirror.keyMap.default["Tab"] = "indentMore";
|
||||
|
||||
CodeMirror.modeURL = 'libraries/codemirror/mode/%N/%N.js';
|
||||
|
||||
codeEditor = CodeMirror($query[0], {
|
||||
value: "",
|
||||
viewportMargin: Infinity,
|
||||
indentUnit: 4,
|
||||
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: false }
|
||||
});
|
||||
|
||||
codeEditor.setOption("mode", "text/x-sqlite");
|
||||
CodeMirror.autoLoadMode(codeEditor, "sql");
|
||||
|
||||
codeEditor.focus();
|
||||
initEditor();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function initEditor() {
|
||||
if (!codeEditor) {
|
||||
await requireLibrary(CODE_MIRROR);
|
||||
|
||||
CodeMirror.keyMap.default["Shift-Tab"] = "indentLess";
|
||||
CodeMirror.keyMap.default["Tab"] = "indentMore";
|
||||
|
||||
CodeMirror.modeURL = 'libraries/codemirror/mode/%N/%N.js';
|
||||
|
||||
codeEditor = CodeMirror($query[0], {
|
||||
value: "",
|
||||
viewportMargin: Infinity,
|
||||
indentUnit: 4,
|
||||
highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: false}
|
||||
});
|
||||
|
||||
codeEditor.setOption("mode", "text/x-sqlite");
|
||||
CodeMirror.autoLoadMode(codeEditor, "sql");
|
||||
}
|
||||
|
||||
codeEditor.focus();
|
||||
}
|
||||
|
||||
async function execute() {
|
||||
const sqlQuery = codeEditor.getValue();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user