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

Saving the node description property to the library

This commit is contained in:
Kazuhito Yokoi 2020-03-02 05:50:32 +00:00
parent c9ad5bea93
commit 6675fdf3c2
3 changed files with 22 additions and 13 deletions

View File

@ -1638,6 +1638,7 @@ RED.editor = (function() {
};
editorTabs.addTab(descriptionTab);
nodeInfoEditor = buildDescriptionForm(descriptionTab.content,node);
node.nodeInfoEditor = nodeInfoEditor;
}
var appearanceTab = {

View File

@ -64,12 +64,14 @@ RED.library = (function() {
var queryArgs = [];
var data = {};
for (var i=0; i<activeLibrary.fields.length; i++) {
for (var i=0; i < activeLibrary.fields.length; i++) {
var field = activeLibrary.fields[i];
if (field == "name") {
if (field === "name") {
data.name = name;
} else if (field === "info") {
data.info = activeLibrary.nodeInfoEditor.getValue().replace(/\n/g, "\\n");
} else {
data[field] = $("#"+elementPrefix+field).val();
data[field] = $("#" + elementPrefix + field).val();
}
}
data.text = activeLibrary.editor.getValue();
@ -518,14 +520,19 @@ RED.library = (function() {
{
text: RED._("common.label.load"),
class: "primary",
click: function() {
click: function () {
if (selectedLibraryItem) {
var elementPrefix = activeLibrary.elementPrefix || "node-input-";
for (var i=0; i<activeLibrary.fields.length; i++) {
for (var i = 0; i < activeLibrary.fields.length; i++) {
var field = activeLibrary.fields[i];
$("#"+elementPrefix+field).val(selectedLibraryItem[field]);
if (field === "info") {
var nodeInfo = selectedLibraryItem[field].replace(/\\n/g, "\n");
activeLibrary.nodeInfoEditor.setValue(nodeInfo, -1);
} else {
$("#" + elementPrefix + field).val(selectedLibraryItem[field]);
}
}
activeLibrary.editor.setValue(libraryEditor.getValue(),-1);
activeLibrary.editor.setValue(libraryEditor.getValue(), -1);
}
$( this ).dialog( "close" );
}

View File

@ -71,12 +71,13 @@
});
RED.library.create({
url:"functions", // where to get the data from
type:"function", // the type of object the library is for
editor:this.editor, // the field name the main text body goes to
mode:"ace/mode/nrjavascript",
fields:['name','outputs'],
ext:"js"
url: "functions", // where to get the data from
type: "function", // the type of object the library is for
editor: this.editor, // the field name the main text body goes to
nodeInfoEditor: this.nodeInfoEditor,
mode: "ace/mode/nrjavascript",
fields: ['name', 'outputs', 'info'],
ext: "js"
});
this.editor.focus();