mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-14 01:34:19 +01:00
fix: failing ER diagram tests
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -81,7 +81,7 @@ const createLabel = async (_vertexText, style, isTitle, isNode) => {
|
||||
return vertexNode;
|
||||
} else {
|
||||
const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
||||
svgLabel.setAttribute('style', style.replace('color:', 'fill:'));
|
||||
svgLabel.setAttribute('style', style ? style.replace('color:', 'fill:') : '');
|
||||
let rows = [];
|
||||
if (typeof vertexText === 'string') {
|
||||
rows = vertexText.split(/\\n|\n|<br\s*\/?>/gi);
|
||||
|
||||
@@ -62,9 +62,12 @@ export async function erBox<T extends SVGGraphicsElement>(parent: D3Selection<T>
|
||||
|
||||
// drawRect doesn't center non-htmlLabels correctly as of now, so translate label
|
||||
if (!evaluate(config.htmlLabels)) {
|
||||
const textElement = shapeSvg.select('text');
|
||||
const bbox = (textElement.node() as SVGTextElement)?.getBBox();
|
||||
textElement.attr('transform', `translate(${-bbox.width / 2}, 0)`);
|
||||
const textElement = shapeSvg.select('.label text');
|
||||
const textNode = textElement.node() as SVGTextElement;
|
||||
if (textNode) {
|
||||
const bbox = textNode.getBBox();
|
||||
textElement.attr('transform', `translate(${-bbox.width / 2}, 0)`);
|
||||
}
|
||||
}
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user