mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	| @@ -31,7 +31,7 @@ | ||||
|         function setMode(mode, cb) | ||||
|         function getRange(); | ||||
|         function replace(range, text) | ||||
|         function selectAll  | ||||
|         function selectAll | ||||
|         function clearSelection | ||||
|         function getSelectedText() | ||||
|         function destroy() | ||||
| @@ -153,9 +153,9 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|  | ||||
|     function init(options) { | ||||
|  | ||||
|         //Handles orphaned models  | ||||
|         //Handles orphaned models | ||||
|         //ensure loaded models that are not explicitly destroyed by a call to .destroy() are disposed | ||||
|         RED.events.on("editor:close",function() {  | ||||
|         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().") | ||||
| @@ -744,10 +744,10 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|  | ||||
|         //by default, set javascript editors to text mode. | ||||
|         //when element becomes visible, it will be (re) set to javascript mode | ||||
|         //this is to ensure multiple editors sharing the model dont present its  | ||||
|         //this is to ensure multiple editors sharing the model dont present its | ||||
|         //consts & lets to each other | ||||
|         if(editorOptions.language == "javascript") { | ||||
|             editorOptions._language = editorOptions.language;  | ||||
|             editorOptions._language = editorOptions.language; | ||||
|             editorOptions.language = "text" | ||||
|         } | ||||
|  | ||||
| @@ -921,6 +921,15 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|         /*********** Create the monaco editor ***************/ | ||||
|         var ed = monaco.editor.create(el, editorOptions); | ||||
|  | ||||
|         //Unbind ctrl-Enter (default action is to insert a newline in editor) This permits the shortcut to close the tray. | ||||
|         try { | ||||
|             ed._standaloneKeybindingService.addDynamicKeybinding( | ||||
|                 '-editor.action.insertLineAfter', // command ID prefixed by '-' | ||||
|                 null, // keybinding | ||||
|                 () => {} // need to pass an empty handler | ||||
|             ); | ||||
|         } catch (error) { } | ||||
|  | ||||
|         ed.nodered = { | ||||
|             refreshModuleLibs: refreshModuleLibs //expose this for function node externalModules refresh | ||||
|         } | ||||
| @@ -967,7 +976,7 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|             if (cb && typeof cb == "function") { | ||||
|                 cb(); | ||||
|             } | ||||
|             if(resize) {  | ||||
|             if(resize) { | ||||
|                 this.resize(); //cause a call to layout() | ||||
|             } | ||||
|         } | ||||
| @@ -1218,7 +1227,7 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|         } | ||||
|         ed._mode = editorOptions.language; | ||||
|  | ||||
|         //as models are signleton, consts and let are avialable to other javascript instances  | ||||
|         //as models are signleton, consts and let are avialable to other javascript instances | ||||
|         //so when not focused, set editor mode to text temporarily to avoid multiple defs | ||||
|  | ||||
|         if(editorOptions._language) { | ||||
| @@ -1240,15 +1249,15 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|             try { | ||||
|                 var options = { | ||||
|                     root: $(element).closest("div.red-ui-tray-content")[0] || document, | ||||
|                     attributes: true,  | ||||
|                     childList: true,  | ||||
|                     attributes: true, | ||||
|                     childList: true, | ||||
|                 }; | ||||
|                 var observer = new IntersectionObserver(function(entries, observer) { | ||||
|                     entries.forEach(function(entry) { | ||||
|                         callback(entry.intersectionRatio > 0, 5, entry.target); | ||||
|                     }); | ||||
|                 }, options); | ||||
|                 observer.observe(element);  | ||||
|                 observer.observe(element); | ||||
|             } catch (e1) { | ||||
|                 //browser not supporting IntersectionObserver? then fall back to polling! | ||||
|                 try { | ||||
| @@ -1267,7 +1276,7 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|         function onVisibilityChange(visible, delay, element) { | ||||
|             if(visible) { | ||||
|                 if(ed._mode == "javascript" && ed._tempMode == "text") { | ||||
|                     ed._tempMode = "";  | ||||
|                     ed._tempMode = ""; | ||||
|                     setTimeout(function() { | ||||
|                         if(element.parentElement) { //ensure el is still in DOM | ||||
|                             ed.setMode('javascript', undefined, false); | ||||
| @@ -1277,7 +1286,7 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|             } else if(ed._mode == "javascript" && ed._tempMode != "text") { | ||||
|                 if(element.parentElement) { //ensure el is still in DOM | ||||
|                     ed.setMode('text', undefined, false); | ||||
|                     ed._tempMode = "text";  | ||||
|                     ed._tempMode = "text"; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @@ -1353,4 +1362,4 @@ RED.editor.codeEditor.monaco = (function() { | ||||
|          */ | ||||
|         create: create | ||||
|     } | ||||
| })(); | ||||
| })(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user