mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-10 02:49:40 +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 { evaluate } from '../../../diagrams/common/common.js';
|
||||||
import { getConfig } from '../../../diagram-api/diagramAPI.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> => {
|
export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.labelStyle = labelStyles;
|
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 { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||||
const useHtmlLabels = evaluate(getConfig().flowchart?.htmlLabels);
|
const useHtmlLabels = evaluate(getConfig().flowchart?.htmlLabels);
|
||||||
|
|
||||||
const nodePadding = node.padding ?? 0;
|
const w = Math.max(bbox.width, node?.width ?? 0) + labelPaddingX;
|
||||||
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
|
|
||||||
const w = Math.max(bbox.width + (labelPaddingX ?? 0), node?.width ?? 0);
|
|
||||||
const h = Math.max(w + bbox.height, node?.height ?? 0);
|
const h = Math.max(w + bbox.height, node?.height ?? 0);
|
||||||
|
|
||||||
const tw = w + bbox.height;
|
const tw = w + bbox.height;
|
||||||
|
Reference in New Issue
Block a user