mirror of https://github.com/node-red/node-red.git
defer initialization of Monaco and ACE editors until they are loaded
parent
865aa4f765
commit
adf324c99c
|
|
@ -2321,7 +2321,6 @@ RED.editor = (function() {
|
|||
}
|
||||
return {
|
||||
init: function() {
|
||||
if(window.ace) { window.ace.config.set('basePath', 'vendor/ace'); }
|
||||
RED.tray.init();
|
||||
RED.actions.add("core:confirm-edit-tray", function() {
|
||||
$(document.activeElement).blur();
|
||||
|
|
@ -2333,7 +2332,6 @@ RED.editor = (function() {
|
|||
$("#node-dialog-cancel").trigger("click");
|
||||
$("#node-config-dialog-cancel").trigger("click");
|
||||
});
|
||||
RED.editor.codeEditor.init();
|
||||
},
|
||||
generateViewStateId: generateViewStateId,
|
||||
edit: showEditDialog,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,15 @@
|
|||
if (!selectedCodeEditor || (editorChoice === MONACO && (browser.ie || !window.monaco))) {
|
||||
selectedCodeEditor = RED.editor.codeEditor[defaultEditor];
|
||||
}
|
||||
// On first uncached load, editor may not yet be downloaded and in the DOM, so we check for the presence in `window` and defer
|
||||
// initialization until the editor is actually loaded. Not relevant for basic editor as it is always present.
|
||||
if (editorChoice === MONACO && !window.monaco) {
|
||||
console.debug("Monaco editor is not yet loaded, delaying initialization");
|
||||
return
|
||||
} else if (editorChoice === ACE && !window.ace) {
|
||||
console.debug("ACE editor is not yet loaded, delaying initialization");
|
||||
return
|
||||
}
|
||||
initialised = selectedCodeEditor.init();
|
||||
} catch (error) {
|
||||
selectedCodeEditor = null;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ RED.editor.codeEditor.ace = (function() {
|
|||
var initOptions = {};
|
||||
|
||||
function init(options) {
|
||||
window.ace.config.set('basePath', 'vendor/ace');
|
||||
initOptions = options || {};
|
||||
initialised = true;
|
||||
return initialised;
|
||||
|
|
|
|||
Loading…
Reference in New Issue