mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add option to RED.nodes.createCompleteNodeSet to include node dimensions
This allows the linter to use a flow json with more than just position information.
This commit is contained in:
@@ -5044,6 +5044,30 @@ RED.view = (function() {
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
function calculateNodeDimensions(node) {
|
||||
var result = [node_width,node_height];
|
||||
try {
|
||||
var isLink = (node.type === "link in" || node.type === "link out")
|
||||
var hideLabel = node.hasOwnProperty('l')?!node.l : isLink;
|
||||
var label = RED.utils.getNodeLabel(node, node.type);
|
||||
var labelParts = getLabelParts(label, "red-ui-flow-node-label");
|
||||
if (hideLabel) {
|
||||
result[1] = Math.max(node_height,(node.outputs || 0) * 15);
|
||||
} else {
|
||||
result[1] = Math.max(6+24*labelParts.lines.length,(node.outputs || 0) * 15, 30);
|
||||
}
|
||||
if (hideLabel) {
|
||||
result[0] = node_height;
|
||||
} else {
|
||||
result[0] = Math.max(node_width,20*(Math.ceil((labelParts.width+50+(node._def.inputs>0?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
|
||||
};
|
||||
})();
|
||||
|
Reference in New Issue
Block a user