mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-22 17:56:43 +02:00
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:
@@ -17,7 +17,7 @@ export async function note<T extends SVGGraphicsElement>(
|
|||||||
if (!useHtmlLabels) {
|
if (!useHtmlLabels) {
|
||||||
node.centerLabel = true;
|
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 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 totalHeight = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
|
||||||
const x = -totalWidth / 2;
|
const x = -totalWidth / 2;
|
||||||
@@ -50,6 +50,11 @@ export async function note<T extends SVGGraphicsElement>(
|
|||||||
rect.selectAll('path').attr('style', nodeStyles);
|
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);
|
updateNodeBounds(node, rect);
|
||||||
|
|
||||||
node.intersect = function (point) {
|
node.intersect = function (point) {
|
||||||
|
Reference in New Issue
Block a user