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
@ -98,20 +98,6 @@ RED.editor.codeEditor.monaco = (function() {
|
|||||||
const defaultServerSideTypes = [ knownModules["node-red-util"], knownModules["node-red-func"], knownModules["globals"], knownModules["console"], knownModules["buffer"] ];
|
const defaultServerSideTypes = [ knownModules["node-red-util"], knownModules["node-red-func"], knownModules["globals"], knownModules["console"], knownModules["buffer"] ];
|
||||||
|
|
||||||
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.
|
||||||
@ -175,6 +161,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 || {};
|
||||||
|
Loading…
Reference in New Issue
Block a user