mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add tooltip for coping Mustache path
This commit is contained in:
@@ -226,20 +226,21 @@ RED.utils = (function() {
|
||||
var tools = $('<span class="red-ui-debug-msg-tools"></span>').appendTo(obj);
|
||||
var copyTools = $('<span class="red-ui-debug-msg-tools-copy button-group"></span>').appendTo(tools);
|
||||
if (!!key) {
|
||||
var mustachePath = key.replace(/\["([^\]]+)"\]/g,'.$1').replace(/\[([0-9]+)\]/g,'.$1');
|
||||
var copyPath = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-terminal"></i></button>').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 = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-clipboard"></i></button>').appendTo(copyTools).on("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user