mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-19 08:16:42 +02:00
fix for triangle
This commit is contained in:
@@ -8,15 +8,31 @@ import { createPathFromPoints } from './util.js';
|
||||
import { evaluate } from '../../../diagrams/common/common.js';
|
||||
import { getConfig } from '../../../diagram-api/diagramAPI.js';
|
||||
|
||||
const MIN_HEIGHT = 25;
|
||||
const MIN_WIDTH = 25;
|
||||
|
||||
export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
const nodePadding = node.padding ?? 0;
|
||||
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
|
||||
|
||||
if (node.width || node.height) {
|
||||
node.width = (node?.width ?? 0) - labelPaddingX * 4;
|
||||
if (node.width < MIN_WIDTH) {
|
||||
node.width = MIN_WIDTH;
|
||||
}
|
||||
|
||||
node.height = node?.height ?? 0;
|
||||
if (node.height < MIN_HEIGHT) {
|
||||
node.height = MIN_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
const useHtmlLabels = evaluate(getConfig().flowchart?.htmlLabels);
|
||||
|
||||
const nodePadding = node.padding ?? 0;
|
||||
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
|
||||
const w = Math.max(bbox.width + (labelPaddingX ?? 0), node?.width ?? 0);
|
||||
const w = Math.max(bbox.width, node?.width ?? 0) + labelPaddingX;
|
||||
const h = Math.max(w + bbox.height, node?.height ?? 0);
|
||||
|
||||
const tw = w + bbox.height;
|
||||
|
Reference in New Issue
Block a user