mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-12 18:49:37 +02:00
resolve visual regression issues and fix broken diagram in PR
This commit is contained in:
@@ -78,9 +78,8 @@ const processHtmlContent = async function (textElem, node, conf, isVirtual = fal
|
|||||||
foreignObject.attr('x', -node.width / 2).attr('y', 3);
|
foreignObject.attr('x', -node.width / 2).attr('y', 3);
|
||||||
|
|
||||||
div.style('width', node.width + 'px');
|
div.style('width', node.width + 'px');
|
||||||
} else {
|
|
||||||
bbox.height = divBBox.height;
|
|
||||||
}
|
}
|
||||||
|
bbox.height = divBBox.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,9 +598,7 @@ export const drawNode = async function (elem, node, fullSection, conf) {
|
|||||||
|
|
||||||
if (hasHtml) {
|
if (hasHtml) {
|
||||||
const bbox = await processHtmlContent(textElem, node, conf, false);
|
const bbox = await processHtmlContent(textElem, node, conf, false);
|
||||||
|
node.height = bbox.height + node.padding;
|
||||||
const fontSize = conf.fontSize?.replace ? conf.fontSize.replace('px', '') : conf.fontSize;
|
|
||||||
node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding;
|
|
||||||
node.height = Math.max(node.height, node.maxHeight);
|
node.height = Math.max(node.height, node.maxHeight);
|
||||||
node.width = node.width + 2 * node.padding;
|
node.width = node.width + 2 * node.padding;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -126,6 +126,9 @@ export const draw = async function (text: string, id: string, version: string, d
|
|||||||
};
|
};
|
||||||
maxEventLineLengthTemp += await svgDraw.getVirtualNodeHeight(svg, eventNode, conf);
|
maxEventLineLengthTemp += await svgDraw.getVirtualNodeHeight(svg, eventNode, conf);
|
||||||
}
|
}
|
||||||
|
if (task.events.length > 0) {
|
||||||
|
maxEventLineLengthTemp += (task.events.length - 1) * 10;
|
||||||
|
}
|
||||||
maxEventLineLength = Math.max(maxEventLineLength, maxEventLineLengthTemp);
|
maxEventLineLength = Math.max(maxEventLineLength, maxEventLineLengthTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,16 +288,9 @@ export const drawTasks = async function (
|
|||||||
lineWrapper
|
lineWrapper
|
||||||
.append('line')
|
.append('line')
|
||||||
.attr('x1', masterX + 190 / 2)
|
.attr('x1', masterX + 190 / 2)
|
||||||
.attr('y1', masterY + maxTaskHeight) // One section head + one task + margins
|
.attr('y1', masterY + maxTaskHeight) // Start from bottom of task box
|
||||||
.attr('x2', masterX + 190 / 2) // Subtract stroke width so arrow point is retained
|
.attr('x2', masterX + 190 / 2) // Same x coordinate for vertical line
|
||||||
.attr(
|
.attr('y2', masterY + maxTaskHeight + 100 + maxEventLineLength + 100) // End at consistent depth with ample padding for visible dashed lines and arrowheads
|
||||||
'y2',
|
|
||||||
masterY +
|
|
||||||
maxTaskHeight +
|
|
||||||
(isWithoutSections ? maxTaskHeight : maxSectionHeight) +
|
|
||||||
maxEventLineLength +
|
|
||||||
120
|
|
||||||
)
|
|
||||||
.attr('stroke-width', 2)
|
.attr('stroke-width', 2)
|
||||||
.attr('stroke', 'black')
|
.attr('stroke', 'black')
|
||||||
.attr('marker-end', 'url(#arrowhead)')
|
.attr('marker-end', 'url(#arrowhead)')
|
||||||
|
Reference in New Issue
Block a user