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:
Nick O'Leary
2021-06-04 13:53:01 +01:00
parent e042ef05a4
commit e9e64f6a44
2 changed files with 76 additions and 13 deletions

View File

@@ -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
};
})();