From bba57f8d2b6ecc8accd58c794109c7f13c0a070f Mon Sep 17 00:00:00 2001 From: Kazuhito Yokoi Date: Mon, 6 Aug 2018 21:39:37 +0900 Subject: [PATCH] Add node description property UI --- editor/js/nodes.js | 4 ++++ editor/js/ui/editor.js | 22 ++++++++++++++++++++++ editor/js/ui/tab-info.js | 4 ++++ red/api/editor/locales/en-US/editor.json | 1 + red/api/editor/locales/ja/editor.json | 1 + 5 files changed, 32 insertions(+) diff --git a/editor/js/nodes.js b/editor/js/nodes.js index 12ff3e682..062654ca2 100644 --- a/editor/js/nodes.js +++ b/editor/js/nodes.js @@ -509,6 +509,9 @@ RED.nodes = (function() { node.icon = n.icon; } } + if (n.info) { + node.info = n.info; + } } return node; } @@ -947,6 +950,7 @@ RED.nodes = (function() { inputLabels: n.inputLabels, outputLabels: n.outputLabels, icon: n.icon, + info: n.info, changed:false, _config:{} }; diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index e0445be54..344914b5e 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -20,6 +20,7 @@ RED.editor = (function() { var editing_node = null; var editing_config_node = null; var subflowEditor; + var nodeInfoEditor; var editTrayWidthCache = {}; @@ -839,6 +840,20 @@ RED.editor = (function() { }) $('
').text(node.icon).appendTo(iconRow); } + + if (node.type.indexOf("subflow") != 0 && node.type !== "comment") { + $('
').appendTo(dialogForm); + $('
').appendTo(dialogForm); + $('
').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) { @@ -1126,6 +1141,10 @@ RED.editor = (function() { } } + if (node.type.indexOf("subflow") != 0 && node.type !== "comment") { + node.info = nodeInfoEditor.getValue(); + } + if (changed) { var wasChanged = editing_node.changed; editing_node.changed = true; @@ -1240,6 +1259,9 @@ RED.editor = (function() { RED.sidebar.info.refresh(editing_node); } RED.workspaces.refresh(); + if (node.type.indexOf("subflow") != 0 && node.type !== "comment") { + nodeInfoEditor.destroy(); + } RED.view.redraw(true); editStack.pop(); }, diff --git a/editor/js/ui/tab-info.js b/editor/js/ui/tab-info.js index 78dc246c0..a2664a7fe 100644 --- a/editor/js/ui/tab-info.js +++ b/editor/js/ui/tab-info.js @@ -277,6 +277,10 @@ RED.sidebar.info = (function() { // TODO: help infoText = infoText + marked(textInfo); } + if (node.info) { + infoSection.title.text(RED._("sidebar.info.nodeHelp")); + infoText = marked(node.info || "") || ('' + RED._("sidebar.info.none") + ''); + } if (infoText) { setInfoText(infoText); } diff --git a/red/api/editor/locales/en-US/editor.json b/red/api/editor/locales/en-US/editor.json index 689b030b1..ae81d7a07 100644 --- a/red/api/editor/locales/en-US/editor.json +++ b/red/api/editor/locales/en-US/editor.json @@ -267,6 +267,7 @@ "defaultLabel": "use default label", "searchIcons": "Search icons", "useDefault": "use default", + "description": "Description", "errors": { "scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it" } diff --git a/red/api/editor/locales/ja/editor.json b/red/api/editor/locales/ja/editor.json index 3da5791dd..a52ec733a 100644 --- a/red/api/editor/locales/ja/editor.json +++ b/red/api/editor/locales/ja/editor.json @@ -266,6 +266,7 @@ "defaultLabel": "既定の名前を使用", "searchIcons": "アイコンを検索", "useDefault": "デフォルトを使用", + "description": "詳細", "errors": { "scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします" }