From a4a27611dd94ecbb6ebb85ee49fd12c83984596e Mon Sep 17 00:00:00 2001 From: omkarht Date: Tue, 1 Jul 2025 18:11:41 +0530 Subject: [PATCH] fix: minor refinement --- .../src/diagrams/sequence/sequenceRenderer.ts | 12 ++++++++---- packages/mermaid/src/diagrams/sequence/svgDraw.js | 12 ++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts b/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts index e44431928..d390ebada 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts +++ b/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts @@ -1076,10 +1076,11 @@ export const draw = async function (_text: string, id: string, _version: string, for (const box of bounds.models.boxes) { box.height = bounds.getVerticalPos() - box.y; bounds.insert(box.x, box.y, box.x + box.width, box.height); - box.startx = box.x; - box.starty = box.y; - box.stopx = box.startx + box.width; - box.stopy = box.starty + box.height; + const boxPadding = conf.boxMargin * 2; + box.startx = box.x - boxPadding; + box.starty = box.y - boxPadding * 0.25; + box.stopx = box.startx + box.width + 2 * boxPadding; + box.stopy = box.starty + box.height + boxPadding * 0.75; box.stroke = 'rgb(0,0,0, 0.5)'; svgDraw.drawBox(diagram, box, conf); } @@ -1344,6 +1345,9 @@ async function calculateActorMargins( return (total += actors.get(aKey).width + (actors.get(aKey).margin || 0)); }, 0); + const standardBoxPadding = conf.boxMargin * 8; + totalWidth += standardBoxPadding; + totalWidth -= 2 * conf.boxTextMargin; if (box.wrap) { box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont); diff --git a/packages/mermaid/src/diagrams/sequence/svgDraw.js b/packages/mermaid/src/diagrams/sequence/svgDraw.js index 5304f57f5..6b8fa0208 100644 --- a/packages/mermaid/src/diagrams/sequence/svgDraw.js +++ b/packages/mermaid/src/diagrams/sequence/svgDraw.js @@ -712,13 +712,13 @@ const drawActorTypeControl = function (elem, actor, conf, isFooter) { .attr('marker-end', 'url(#filled-head-control)'); const bounds = actElem.node().getBBox(); - actor.height = bounds.height + conf.boxTextMargin; + actor.height = bounds.height + 2 * (conf?.sequence?.labelBoxHeight ?? 0); _drawTextCandidateFunc(conf, hasKatex(actor.description))( actor.description, actElem, rect.x, - rect.y + (!isFooter ? 30 : 40), + rect.y + 30, rect.width, rect.height, { class: `actor ${ACTOR_MAN_FIGURE_CLASS}` }, @@ -774,8 +774,8 @@ const drawActorTypeEntity = function (elem, actor, conf, isFooter) { .attr('stroke', '#333') .attr('stroke-width', 2); - const boundBox = actElem.node().getBBox(); - actor.height = boundBox.height + conf.boxTextMargin; + const bounds = actElem.node().getBBox(); + actor.height = bounds.height + (conf.sequence.labelBoxHeight ?? 0); if (!isFooter) { actorCnt++; @@ -916,7 +916,7 @@ const drawActorTypeDatabase = function (elem, actor, conf, isFooter) { const lastPath = cylinderGroup.select('path:last-child'); if (lastPath.node()) { const bounds = lastPath.node().getBBox(); - actor.height = bounds.height + 2 * conf.boxTextMargin; + actor.height = bounds.height + (conf.sequence.labelBoxHeight ?? 0); } return actor.height; @@ -989,7 +989,7 @@ const drawActorTypeBoundary = function (elem, actor, conf, isFooter) { .attr('width', actor.width); const bounds = actElem.node().getBBox(); - actor.height = bounds.height + conf.boxTextMargin; + actor.height = bounds.height + (conf.sequence.labelBoxHeight ?? 0); _drawTextCandidateFunc(conf, hasKatex(actor.description))( actor.description,