Merge pull request #6716 from mermaid-js/6664-text-going-outside-node

6664: Text rendering issue in flowchart note elements
This commit is contained in:
shubham-mermaid
2025-07-09 13:18:26 +00:00
committed by GitHub

View File

@@ -17,7 +17,7 @@ export async function note<T extends SVGGraphicsElement>(
if (!useHtmlLabels) {
node.centerLabel = true;
}
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const totalWidth = Math.max(bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
const totalHeight = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
const x = -totalWidth / 2;
@@ -50,6 +50,11 @@ export async function note<T extends SVGGraphicsElement>(
rect.selectAll('path').attr('style', nodeStyles);
}
label.attr(
'transform',
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) - (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, rect);
node.intersect = function (point) {