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 67a924775..8904d7b39 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 @@ -694,11 +694,23 @@ RED.nodes = (function() { /** * Converts a node to an exportable JSON Object **/ - function convertNode(n, exportCreds) { + function convertNode(n, opts) { + var exportCreds = true; + var exportDimensions = false; + if (opts === false) { + exportCreds = false; + } else if (typeof opts === "object") { + if (opts.hasOwnProperty("credentials")) { + exportCreds = opts.credentials; + } + if (opts.hasOwnProperty("dimensions")) { + exportDimensions = opts.dimensions; + } + } + if (n.type === 'tab') { return convertWorkspace(n); } - exportCreds = exportCreds || false; var node = {}; node.id = n.id; node.type = n.type; @@ -771,6 +783,19 @@ RED.nodes = (function() { if (n._def.category != "config") { node.x = n.x; node.y = n.y; + if (exportDimensions) { + if (!n.hasOwnProperty('w')) { + // This node has not yet been drawn in the view. So we need + // to explicitly calculate its dimensions. Store the result + // on the node as if it had been drawn will save us doing + // it again + var dimensions = RED.view.calculateNodeDimensions(n); + n.w = dimensions[0]; + n.h = dimensions[1]; + } + node.w = n.w; + node.h = n.h; + } node.wires = []; for(var i=0;i0?7:0))/20)) ); + } + }catch(err) { + console.log("Error",node); + } + return result; + } + return { init: init, state:function(state) { @@ -5275,6 +5299,7 @@ RED.view = (function() { return clipboard }, redrawStatus: redrawStatus, - showQuickAddDialog:showQuickAddDialog + showQuickAddDialog:showQuickAddDialog, + calculateNodeDimensions: calculateNodeDimensions }; })();