diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index fc344b10b..90444a09a 100644 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -150,6 +150,15 @@ }, "clipboard": { "nodes": "Nodes", + "node": "__count__ node", + "node_plural": "__count__ nodes", + "configNode": "__count__ configuration node", + "configNode_plural": "__count__ configuration nodes", + "node_plural": "__count__ nodes", + "flow": "__count__ flow", + "flow_plural": "__count__ flows", + "subflow": "__count__ subflow", + "subflow_plural": "__count__ subflows", "selectNodes": "Select the text above and copy to the clipboard.", "pasteNodes": "Paste nodes here", "importNodes": "Import nodes", @@ -157,6 +166,7 @@ "importUnrecognised": "Imported unrecognised type:", "importUnrecognised_plural": "Imported unrecognised types:", "nodesExported": "Nodes exported to clipboard", + "nodesImported": "Imported:", "nodeCopied": "__count__ node copied", "nodeCopied_plural": "__count__ nodes copied", "invalidFlow": "Invalid flow: __message__", diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 657dee511..63a841beb 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -764,7 +764,6 @@ RED.nodes = (function() { } if (!isInitialLoad && unknownTypes.length > 0) { var typeList = "
"+RED._("clipboard.importUnrecognised",{count:unknownTypes.length})+"
"+typeList,"error",false,10000); } diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js index a1b6fc79f..12ccb3cb3 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js @@ -75,8 +75,10 @@ RED.clipboard = (function() { $(this).parent().find(".ui-dialog-titlebar-close").hide(); }, close: function(e) { - popover.close(true); - currentPopoverError = null; + if (popover) { + popover.close(true); + currentPopoverError = null; + } } }); @@ -115,91 +117,98 @@ RED.clipboard = (function() { ''; } - function validateImport() { - var importInput = $("#clipboard-import"); - var v = importInput.val().trim(); - if (v === "") { - popover.close(true); - currentPopoverError = null; - importInput.removeClass("input-error"); - $("#clipboard-dialog-ok").button("disable"); - return; - } - try { - if (!/^\[[\s\S]*\]$/m.test(v)) { - throw new Error(RED._("clipboard.import.errors.notArray")); - } - var res = JSON.parse(v); - for (var i=0;i').appendTo(parseError);
- $('').text(v.substring(errorPos-12,errorPos)).appendTo(code)
- $('').text(v.charAt(errorPos)).appendTo(code);
- $('').text(v.substring(errorPos+1,errorPos+12)).appendTo(code);
- }
- popover.close(true).setContent(message).open();
- currentPopoverError = errString;
- }
- } else {
- currentPopoverError = null;
- }
- $("#clipboard-dialog-ok").button("disable");
+ function validateImport() {
+ if (validateImportTimeout) {
+ clearTimeout(validateImportTimeout);
}
+ validateImportTimeout = setTimeout(function() {
+ var importInput = $("#clipboard-import");
+ var v = importInput.val().trim();
+ if (v === "") {
+ popover.close(true);
+ currentPopoverError = null;
+ importInput.removeClass("input-error");
+ $("#clipboard-dialog-ok").button("disable");
+ return;
+ }
+ try {
+ if (!/^\[[\s\S]*\]$/m.test(v)) {
+ throw new Error(RED._("clipboard.import.errors.notArray"));
+ }
+ var res = JSON.parse(v);
+ for (var i=0;i').text(errString);
+ var errorPos;
+ // Chrome error messages
+ var m = /at position (\d+)/i.exec(errString);
+ if (m) {
+ errorPos = parseInt(m[1]);
+ } else {
+ // Firefox error messages
+ m = /at line (\d+) column (\d+)/i.exec(errString);
+ if (m) {
+ var line = parseInt(m[1])-1;
+ var col = parseInt(m[2])-1;
+ var lines = v.split("\n");
+ errorPos = 0;
+ for (var i=0;i').appendTo(message);
+ var code = $('').appendTo(parseError);
+ $('').text(v.substring(errorPos-12,errorPos)).appendTo(code)
+ $('').text(v.charAt(errorPos)).appendTo(code);
+ $('').text(v.substring(errorPos+1,errorPos+12)).appendTo(code);
+ }
+ popover.close(true).setContent(message).open();
+ currentPopoverError = errString;
+ }
+ } else {
+ currentPopoverError = null;
+ }
+ $("#clipboard-dialog-ok").button("disable");
+ }
+ },100);
}
function importNodes() {
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js
index d14f93cfa..4459812b1 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js
@@ -2853,6 +2853,34 @@ RED.view = (function() {
updateActiveNodes();
redraw();
+
+ var counts = [];
+ var newNodeCount = 0;
+ var newConfigNodeCount = 0;
+ new_nodes.forEach(function(n) {
+ if (n.hasOwnProperty("x") && n.hasOwnProperty("y")) {
+ newNodeCount++;
+ } else {
+ newConfigNodeCount++;
+ }
+ })
+ if (new_workspaces.length > 0) {
+ counts.push(RED._("clipboard.flow",{count:new_workspaces.length}));
+ }
+ if (newNodeCount > 0) {
+ counts.push(RED._("clipboard.node",{count:newNodeCount}));
+ }
+ if (newConfigNodeCount > 0) {
+ counts.push(RED._("clipboard.configNode",{count:newNodeCount}));
+ }
+ if (new_subflows.length > 0) {
+ counts.push(RED._("clipboard.subflow",{count:new_subflows.length}));
+ }
+ if (counts.length > 0) {
+ var countList = "- "+counts.join("
- ")+"
";
+ RED.notify(""+RED._("clipboard.nodesImported")+"
"+countList);
+ }
+
}
} catch(error) {
if (error.code != "NODE_RED") {