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

Merge pull request #1856 from kazuhitoyokoi/master-nodedescriptionproperty

Add node description property UI
This commit is contained in:
Nick O'Leary 2018-09-07 12:23:41 +01:00 committed by GitHub
commit 0529eed0c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 0 deletions

View File

@ -509,6 +509,9 @@ RED.nodes = (function() {
node.icon = n.icon; node.icon = n.icon;
} }
} }
if (n.info) {
node.info = n.info;
}
} }
return node; return node;
} }
@ -947,6 +950,7 @@ RED.nodes = (function() {
inputLabels: n.inputLabels, inputLabels: n.inputLabels,
outputLabels: n.outputLabels, outputLabels: n.outputLabels,
icon: n.icon, icon: n.icon,
info: n.info,
changed:false, changed:false,
_config:{} _config:{}
}; };

View File

@ -20,6 +20,7 @@ RED.editor = (function() {
var editing_node = null; var editing_node = null;
var editing_config_node = null; var editing_config_node = null;
var subflowEditor; var subflowEditor;
var nodeInfoEditor;
var editTrayWidthCache = {}; var editTrayWidthCache = {};
@ -839,6 +840,20 @@ RED.editor = (function() {
}) })
$('<div class="uneditable-input" id="node-settings-icon">').text(node.icon).appendTo(iconRow); $('<div class="uneditable-input" id="node-settings-icon">').text(node.icon).appendTo(iconRow);
} }
if (node.type.indexOf("subflow") != 0 && node.type !== "comment") {
$('<hr>').appendTo(dialogForm);
$('<div class="form-row"><span data-i18n="editor.description"></span><div id="node-label-form-info"></div></div>').appendTo(dialogForm);
$('<div style="height: 150px;" class="node-text-editor" id="node-info-input-info-editor" ></div>').appendTo(dialogForm);
nodeInfoEditor = RED.editor.createEditor({
id: 'node-info-input-info-editor',
mode: 'ace/mode/markdown',
value: ""
});
if (node.info) {
nodeInfoEditor.getSession().setValue(node.info, -1);
}
}
} }
function updateLabels(editing_node, changes, outputMap) { function updateLabels(editing_node, changes, outputMap) {
@ -1126,6 +1141,10 @@ RED.editor = (function() {
} }
} }
if (node.type.indexOf("subflow") != 0 && node.type !== "comment") {
node.info = nodeInfoEditor.getValue();
}
if (changed) { if (changed) {
var wasChanged = editing_node.changed; var wasChanged = editing_node.changed;
editing_node.changed = true; editing_node.changed = true;
@ -1240,6 +1259,9 @@ RED.editor = (function() {
RED.sidebar.info.refresh(editing_node); RED.sidebar.info.refresh(editing_node);
} }
RED.workspaces.refresh(); RED.workspaces.refresh();
if (node.type.indexOf("subflow") != 0 && node.type !== "comment") {
nodeInfoEditor.destroy();
}
RED.view.redraw(true); RED.view.redraw(true);
editStack.pop(); editStack.pop();
}, },

View File

@ -277,6 +277,10 @@ RED.sidebar.info = (function() {
// TODO: help // TODO: help
infoText = infoText + marked(textInfo); infoText = infoText + marked(textInfo);
} }
if (node.info) {
infoSection.title.text(RED._("sidebar.info.nodeHelp"));
infoText = marked(node.info || "") || ('<span class="node-info-none">' + RED._("sidebar.info.none") + '</span>');
}
if (infoText) { if (infoText) {
setInfoText(infoText); setInfoText(infoText);
} }

View File

@ -267,6 +267,7 @@
"defaultLabel": "use default label", "defaultLabel": "use default label",
"searchIcons": "Search icons", "searchIcons": "Search icons",
"useDefault": "use default", "useDefault": "use default",
"description": "Description",
"errors": { "errors": {
"scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it" "scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it"
} }

View File

@ -266,6 +266,7 @@
"defaultLabel": "既定の名前を使用", "defaultLabel": "既定の名前を使用",
"searchIcons": "アイコンを検索", "searchIcons": "アイコンを検索",
"useDefault": "デフォルトを使用", "useDefault": "デフォルトを使用",
"description": "詳細",
"errors": { "errors": {
"scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします" "scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします"
} }