mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-28 03:39:38 +02:00
Fixed sizing of diamond shape
This commit is contained in:
@@ -18,8 +18,9 @@ function applyStyle(dom, styleFn) {
|
||||
}
|
||||
}
|
||||
|
||||
async function addHtmlSpan(element, node, width, classes, addBackground = false) {
|
||||
async function addHtmlSpan(element, node, _width, classes, addBackground = false) {
|
||||
const fo = element.append('foreignObject');
|
||||
const width = _width < 0 ? 0 : _width;
|
||||
// This is not the final width but used in order to make sure the foreign
|
||||
// object in firefox gets a width at all. The final width is fetched from the div
|
||||
fo.attr('width', `${10 * width}px`);
|
||||
|
@@ -21,15 +21,15 @@ export const question = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
||||
node.labelStyle = labelStyles;
|
||||
const padding = node.padding ?? 0;
|
||||
if (node.width || node.height) {
|
||||
node.width = (node?.width ?? 0) - padding * 8;
|
||||
if (node.width < 10) {
|
||||
if ((node.width ?? 10) < 10) {
|
||||
node.width = 10;
|
||||
}
|
||||
node.width = (node?.width ?? 0) - padding * 8;
|
||||
|
||||
node.height = (node?.height ?? 0) - padding * 8;
|
||||
if (node.height < 10) {
|
||||
if ((node.height ?? 10) < 10) {
|
||||
node.height = 10;
|
||||
}
|
||||
node.height = (node?.height ?? 0) - padding * 8;
|
||||
}
|
||||
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
@@ -34,7 +34,7 @@ export const labelHelper = async (parent, node, _classes) => {
|
||||
let text;
|
||||
text = await createText(labelEl, sanitizeText(decodeEntities(label), getConfig()), {
|
||||
useHtmlLabels,
|
||||
width: node.width || getConfig().flowchart.wrappingWidth,
|
||||
width: node.width < 0 ? 0 : node.width || getConfig().flowchart.wrappingWidth,
|
||||
cssClasses: 'markdown-node-label',
|
||||
style: node.labelStyle,
|
||||
addSvgBackground: !!node.icon || !!node.img,
|
||||
@@ -88,11 +88,10 @@ export const labelHelper = async (parent, node, _classes) => {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bbox = div.getBoundingClientRect();
|
||||
dv.attr('width', bbox.width);
|
||||
if (node.height && node.height < bbox.height) {
|
||||
bbox.height = node.height;
|
||||
bbox.height = node.height < 0 ? 0 : node.height;
|
||||
}
|
||||
dv.attr('height', bbox.height);
|
||||
}
|
||||
|
Reference in New Issue
Block a user