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 9683bf4a9..70c09d188 100755 --- 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 @@ -1758,11 +1758,18 @@ RED.view = (function() { return calculateTextDimensions(str,className,offset,0)[0]; } + var textDimensionPlaceholder = {}; function calculateTextDimensions(str,className,offsetW,offsetH) { - var sp = $('',{class: className,style: "position: absolute; top: -1000px"}).text(str||"").appendTo("#red-ui-editor"); - var w = sp.width(); - var h = sp.height(); - sp.remove(); + if (!textDimensionPlaceholder[className]) { + textDimensionPlaceholder[className] = document.createElement("span"); + textDimensionPlaceholder[className].className = className; + textDimensionPlaceholder[className].style.position = "absolute"; + textDimensionPlaceholder[className].style.top = "-1000px"; + document.getElementById("red-ui-editor").appendChild(textDimensionPlaceholder[className]); + } + textDimensionPlaceholder[className].textContent = (str||""); + var w = textDimensionPlaceholder[className].offsetWidth; + var h = textDimensionPlaceholder[className].offsetHeight; return [offsetW+w,offsetH+h]; } @@ -2564,10 +2571,12 @@ RED.view = (function() { var hideLabel = d.hasOwnProperty('l')?!d.l : isLink; node.attr("id",d.id); var l = RED.utils.getNodeLabel(d); - if (hideLabel) { - d.w = node_height; - } else { - d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) ); + if (d.w === undefined) { + if (hideLabel) { + d.w = node_height; + } else { + d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) ); + } } d.h = Math.max(node_height,(d.outputs||0) * 15);