diff --git a/editor/js/nodes.js b/editor/js/nodes.js index b2d8477b9..fdb9ac76b 100644 --- a/editor/js/nodes.js +++ b/editor/js/nodes.js @@ -594,7 +594,7 @@ RED.nodes = (function() { return true; } - function importNodes(newNodesObj,createNewIds) { + function importNodes(newNodesObj,createNewIds,createMissingWorkspace) { var i; var n; var newNodes; @@ -668,6 +668,7 @@ RED.nodes = (function() { var nid; var def; var configNode; + var missingWorkspace = null; // Find all tabs and subflow templates for (i=0;i a.selected").attr('id') === 'import-tab-new'); $( this ).dialog( "close" ); } } @@ -79,7 +79,7 @@ RED.clipboard = (function() { exportNodesDialog = '
'+ - ''+ + ''+ ''+ ''+ ''+ @@ -100,6 +100,13 @@ RED.clipboard = (function() { ''+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + ''+ '
'; } @@ -123,6 +130,8 @@ RED.clipboard = (function() { function importNodes() { dialogContainer.empty(); dialogContainer.append($(importNodesDialog)); + dialogContainer.i18n(); + $("#clipboard-dialog-ok").show(); $("#clipboard-dialog-cancel").show(); $("#clipboard-dialog-close").hide(); @@ -131,6 +140,15 @@ RED.clipboard = (function() { $("#clipboard-import").keyup(validateImport); $("#clipboard-import").on('paste',function() { setTimeout(validateImport,10)}); + $("#import-tab > a").click(function(evt) { + evt.preventDefault(); + if ($(this).hasClass('disabled') || $(this).hasClass('selected')) { + return; + } + $(this).parent().children().removeClass('selected'); + $(this).addClass('selected'); + }); + dialog.dialog("option","title",RED._("clipboard.importNodes")).dialog("open"); } diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index 7d41d335c..f0cbc6d79 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -1389,7 +1389,7 @@ RED.view = (function() { options.push({name:"delete",disabled:(moving_set.length===0 && selected_link === null),onselect:function() {deleteSelection();}}); options.push({name:"cut",disabled:(moving_set.length===0),onselect:function() {copySelection();deleteSelection();}}); options.push({name:"copy",disabled:(moving_set.length===0),onselect:function() {copySelection();}}); - options.push({name:"paste",disabled:(clipboard.length===0),onselect:function() {importNodes(clipboard,true);}}); + options.push({name:"paste",disabled:(clipboard.length===0),onselect:function() {importNodes(clipboard,false,true);}}); options.push({name:"edit",disabled:(moving_set.length != 1),onselect:function() { RED.editor.edit(mdn);}}); options.push({name:"select",onselect:function() {selectAll();}}); options.push({name:"undo",disabled:(RED.history.depth() === 0),onselect:function() {RED.history.pop();}}); @@ -2194,19 +2194,22 @@ RED.view = (function() { * - all "selected" * - attached to mouse for placing - "IMPORT_DRAGGING" */ - function importNodes(newNodesStr,touchImport) { + function importNodes(newNodesStr,addNewFlow,touchImport) { try { var activeSubflowChanged; if (activeSubflow) { activeSubflowChanged = activeSubflow.changed; } - var result = RED.nodes.import(newNodesStr,true); + var result = RED.nodes.import(newNodesStr,true,addNewFlow); if (result) { var new_nodes = result[0]; var new_links = result[1]; var new_workspaces = result[2]; var new_subflows = result[3]; - + var new_default_workspace = result[4]; + if (addNewFlow && new_default_workspace) { + RED.workspaces.show(new_default_workspace.id); + } var new_ms = new_nodes.filter(function(n) { return n.hasOwnProperty("x") && n.hasOwnProperty("y") && n.z == RED.workspaces.active() }).map(function(n) { return {n:n};}); var new_node_ids = new_nodes.map(function(n){ return n.id; }); diff --git a/editor/js/ui/workspaces.js b/editor/js/ui/workspaces.js index 3b43243fe..62060b0b2 100644 --- a/editor/js/ui/workspaces.js +++ b/editor/js/ui/workspaces.js @@ -20,7 +20,7 @@ RED.workspaces = (function() { var activeWorkspace = 0; var workspaceIndex = 0; - function addWorkspace(ws) { + function addWorkspace(ws,skipHistoryEntry) { if (ws) { workspace_tabs.addTab(ws); workspace_tabs.resize(); @@ -34,9 +34,12 @@ RED.workspaces = (function() { RED.nodes.addWorkspace(ws); workspace_tabs.addTab(ws); workspace_tabs.activateTab(tabId); - RED.history.push({t:'add',workspaces:[ws],dirty:RED.nodes.dirty()}); - RED.nodes.dirty(true); + if (!skipHistoryEntry) { + RED.history.push({t:'add',workspaces:[ws],dirty:RED.nodes.dirty()}); + RED.nodes.dirty(true); + } } + return ws; } function deleteWorkspace(ws) { if (workspace_tabs.count() == 1) { diff --git a/red/api/locales/en-US/editor.json b/red/api/locales/en-US/editor.json index d6136cdb9..aa0d202df 100644 --- a/red/api/locales/en-US/editor.json +++ b/red/api/locales/en-US/editor.json @@ -95,6 +95,10 @@ "compact":"compact", "formatted":"formatted", "copy": "Export to clipboard" + }, + "import": { + "import": "Import to", + "newFlow": "new flow" } }, "deploy": {