mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Ensure monaco exists before attempting cleanup
This commit is contained in:
parent
ffbd140a97
commit
22db24509d
@ -99,20 +99,6 @@ RED.editor.codeEditor.monaco = (function() {
|
|||||||
|
|
||||||
const modulesCache = {};
|
const modulesCache = {};
|
||||||
|
|
||||||
RED.events.on("editor:close",function() {
|
|
||||||
//catch all - when editor is closed, ensure lod models that are not explicitly destroyed by a call to .destroy() are dumped
|
|
||||||
let models = monaco.editor.getModels();
|
|
||||||
if(models && models.length) {
|
|
||||||
console.warn("Cleaning up monaco models left behind. Any node that calls createEditor() should call .destroy().")
|
|
||||||
for (let index = 0; index < models.length; index++) {
|
|
||||||
const model = models[index];
|
|
||||||
if(!model.isDisposed()) {
|
|
||||||
model.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to load/reload types.
|
* Helper function to load/reload types.
|
||||||
* @param {string} mod - type lib to load. Only known libs are currently supported.
|
* @param {string} mod - type lib to load. Only known libs are currently supported.
|
||||||
@ -176,6 +162,21 @@ RED.editor.codeEditor.monaco = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Handles orphaned models
|
||||||
|
//ensure loaded models that are not explicitly destroyed by a call to .destroy() are disposed
|
||||||
|
RED.events.on("editor:close",function() {
|
||||||
|
let models = window.monaco ? monaco.editor.getModels() : null;
|
||||||
|
if(models && models.length) {
|
||||||
|
console.warn("Cleaning up monaco models left behind. Any node that calls createEditor() should call .destroy().")
|
||||||
|
for (let index = 0; index < models.length; index++) {
|
||||||
|
const model = models[index];
|
||||||
|
if(!model.isDisposed()) {
|
||||||
|
model.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
window.MonacoEnvironment = window.MonacoEnvironment || {};
|
window.MonacoEnvironment = window.MonacoEnvironment || {};
|
||||||
window.MonacoEnvironment.getWorkerUrl = function (moduleId, label) {
|
window.MonacoEnvironment.getWorkerUrl = function (moduleId, label) {
|
||||||
|
Loading…
Reference in New Issue
Block a user