1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

provide extra libs and call to refresh

This commit is contained in:
Steve-Mcl 2021-04-29 18:00:23 +01:00
parent cc7def89af
commit c475536388

View File

@ -384,6 +384,13 @@
onchange: function(tab) { onchange: function(tab) {
$("#func-tabs-content").children().hide(); $("#func-tabs-content").children().hide();
$("#" + tab.id).show(); $("#" + tab.id).show();
let editor = $("#" + tab.id).find('.monaco-editor').first();
if(editor.length) {
if(that.editor.nodered && that.editor.type == "monaco") {
that.editor.nodered.refreshModuleLibs(getLibsList());
}
RED.tray.resize();
}
} }
}); });
tabs.addTab({ tabs.addTab({
@ -417,7 +424,7 @@
} }
}); });
var buildEditor = function(id, value, defaultValue) { var buildEditor = function(id, value, defaultValue, extraLibs) {
var editor = RED.editor.createEditor({ var editor = RED.editor.createEditor({
id: id, id: id,
mode: 'ace/mode/nrjavascript', mode: 'ace/mode/nrjavascript',
@ -435,7 +442,8 @@
clearTimeout: true, clearTimeout: true,
setInterval: true, setInterval: true,
clearInterval: true clearInterval: true
} },
extraLibs: extraLibs
}); });
if (defaultValue && value === "") { if (defaultValue && value === "") {
editor.moveCursorTo(defaultValue.split("\n").length - 1, 0); editor.moveCursorTo(defaultValue.split("\n").length - 1, 0);
@ -443,7 +451,7 @@
return editor; return editor;
} }
this.initEditor = buildEditor('node-input-init-editor',$("#node-input-initialize").val(),RED._("node-red:function.text.initialize")) this.initEditor = buildEditor('node-input-init-editor',$("#node-input-initialize").val(),RED._("node-red:function.text.initialize"))
this.editor = buildEditor('node-input-func-editor',$("#node-input-func").val()) this.editor = buildEditor('node-input-func-editor',$("#node-input-func").val(), undefined, that.libs || [])
this.finalizeEditor = buildEditor('node-input-finalize-editor',$("#node-input-finalize").val(),RED._("node-red:function.text.finalize")) this.finalizeEditor = buildEditor('node-input-finalize-editor',$("#node-input-finalize").val(),RED._("node-red:function.text.finalize"))
RED.library.create({ RED.library.create({