Skip to content

Commit

Permalink
Render the text and line in correct position
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimWassouf committed Aug 17, 2023
1 parent 6d55b70 commit 2a0bfea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/rendering/sequencediagram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ context('Sequence diagram', () => {
imgSnapshotTest(
`
sequenceDiagram
Alice -->> Bob: wrap: "\`This is a super long message with wrap enabled with **markdown bold, a whole lot of bold** and *italics*\`"
Alice -->> Bob: wrap: "\`This is a super long message with wrap enabled with **markdown bold, a whole lot of bold** and *italics*. Maybe the line isn't solved after all\`"
`,
{
htmlLabels: true,
Expand Down
7 changes: 7 additions & 0 deletions packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ const drawMessage = function (diagram, msgModel, lineStartY: number, diagObj: Di

if (textType) {
drawMarkdownText(diagram, textObj);

bounds.bumpVerticalPos(textObj.height);
//bounds.insert(msgModel.startx, msgModel.starty, msgModel.stopx, msgModel.stopy);
bounds.models.addMessage(msgModel);
//TODO figure out why 3 makes the padding between the line and markdown text
//to look like the padding between strings and lines
lineStartY += textObj.height - 3 * textObj.textMargin;
} else {
drawText(diagram, textObj);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/mermaid/src/diagrams/sequence/svgDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const drawMarkdownText = function (elem, textData) {

const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize);

const yfunc = calculateYFunc(textData);
const yfunc = calculateYFunc(textData, bbox.height);
textData = setXAndAnchor(textData);

if (textData.anchor !== undefined) {
Expand Down Expand Up @@ -238,6 +238,8 @@ export const drawMarkdownText = function (elem, textData) {
innerLabel.attr('transform', 'translate(' + -bbox.width / 2 + ', ' + -bbox.height / 2 + ')');
messageLabel.attr('transform', `translate(${textData.x}, ${yfunc() + textData.textMargin})`);

textData.height = bbox.height;

return labelText;
};

Expand Down

0 comments on commit 2a0bfea

Please sign in to comment.