From cac1779c22f50234ffece7ccaf915557fb5fb2b3 Mon Sep 17 00:00:00 2001 From: omkarht Date: Mon, 12 May 2025 15:14:20 +0530 Subject: [PATCH 1/2] Fix: apply proper styling for Mermaid ER diagrams --- .../rendering-elements/shapes/erBox.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/erBox.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/erBox.ts index 23c6fb091..9dd4c90e2 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/erBox.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/erBox.ts @@ -40,7 +40,7 @@ export async function erBox(parent: D3Selection let TEXT_PADDING = config.er?.entityPadding ?? 6; const { cssStyles } = node; - const { labelStyles } = styles2String(node); + const { labelStyles, nodeStyles } = styles2String(node); // Draw rect if no attributes are found if (entityNode.attributes.length === 0 && node.label) { @@ -295,6 +295,18 @@ export async function erBox(parent: D3Selection updateNodeBounds(node, rect); + if (nodeStyles && node.look !== 'handDrawn') { + const allStyle = nodeStyles.split(';'); + const strokeStyles = allStyle + ?.filter((e) => { + return e.includes('stroke'); + }) + ?.map((s) => `${s}`) + .join('; '); + shapeSvg.selectAll('path').attr('style', strokeStyles ?? ''); + shapeSvg.selectAll('.row-rect-even path').attr('style', nodeStyles); + } + node.intersect = function (point) { return intersect.rect(node, point); }; From b1cf29127348602137552405e3300dee1697f0de Mon Sep 17 00:00:00 2001 From: omkarht Date: Mon, 12 May 2025 15:23:35 +0530 Subject: [PATCH 2/2] added changeset --- .changeset/curly-coats-tell.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/curly-coats-tell.md diff --git a/.changeset/curly-coats-tell.md b/.changeset/curly-coats-tell.md new file mode 100644 index 000000000..65672267c --- /dev/null +++ b/.changeset/curly-coats-tell.md @@ -0,0 +1,5 @@ +--- +'mermaid': patch +--- + +Fix stroke styles for ER diagram to correctly apply path and row-specific styles