From bde5a2b7cd899db029e76c49f2cbc3676712527a Mon Sep 17 00:00:00 2001 From: Kazuhito Yokoi Date: Mon, 7 Feb 2022 13:58:17 +0900 Subject: [PATCH] Add tooltip for coping Mustache path --- .../@node-red/editor-client/src/js/ui/utils.js | 17 +++++++++-------- .../@node-red/nodes/locales/en-US/messages.json | 1 + .../@node-red/nodes/locales/ja/messages.json | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js index 1e0e8a2f0..68f87688e 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js @@ -226,20 +226,21 @@ RED.utils = (function() { var tools = $('').appendTo(obj); var copyTools = $('').appendTo(tools); if (!!key) { + var mustachePath = key.replace(/\["([^\]]+)"\]/g,'.$1').replace(/\[([0-9]+)\]/g,'.$1'); var copyPath = $('').appendTo(copyTools).on("click", function(e) { e.preventDefault(); e.stopPropagation(); - var mustachePath; - if (e.ctrlKey || e.metaKey) { - mustachePath = key.replace(/\["([^\]]+)"\]/g,'.$1').replace(/\[([0-9]+)\]/g,'.$1'); - } - if (!mustachePath || key === mustachePath) { - RED.clipboard.copyText(key,copyPath,"clipboard.copyMessagePath"); - } else { + if ((e.ctrlKey || e.metaKey) && key !== mustachePath) { RED.clipboard.copyText(mustachePath,copyPath,"clipboard.copyMessagePathForMustache"); + } else { + RED.clipboard.copyText(key,copyPath,"clipboard.copyMessagePath"); } }) - RED.popover.tooltip(copyPath,RED._("node-red:debug.sidebar.copyPath")); + if (key !== mustachePath) { + RED.popover.tooltip(copyPath,RED._("node-red:debug.sidebar.copyPathForMustache")); + } else { + RED.popover.tooltip(copyPath,RED._("node-red:debug.sidebar.copyPath")); + } } var copyPayload = $('').appendTo(copyTools).on("click", function(e) { e.preventDefault(); diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index ecc5d905c..9bce1ec26 100755 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -148,6 +148,7 @@ "filterLog": "Filter messages", "openWindow": "Open in new window", "copyPath": "Copy path", + "copyPathForMustache": "Copy path (Mustache path by ctrl+click)", "copyPayload": "Copy value", "pinPath": "Pin open", "selectAll": "select all", diff --git a/packages/node_modules/@node-red/nodes/locales/ja/messages.json b/packages/node_modules/@node-red/nodes/locales/ja/messages.json index 70b813554..b1ba9fb53 100644 --- a/packages/node_modules/@node-red/nodes/locales/ja/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/ja/messages.json @@ -148,6 +148,7 @@ "filterLog": "ログのフィルタリング", "openWindow": "新しいウィンドウで開く", "copyPath": "パスをコピー", + "copyPathForMustache": "パスをコピー(Ctrl+クリックでMustacheパス)", "copyPayload": "値をコピー", "pinPath": "展開を固定", "selectAll": "全てを選択",