mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 14:29:25 +02:00
updated Traingle shape
This commit is contained in:
@@ -8,11 +8,14 @@ import {
|
|||||||
} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js';
|
} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
import { createPathFromPoints } from './util.js';
|
import { createPathFromPoints } from './util.js';
|
||||||
|
import { evaluate } from '$root/diagrams/common/common.js';
|
||||||
|
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||||
|
|
||||||
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 { 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 w = bbox.width + (node.padding ?? 0);
|
const w = bbox.width + (node.padding ?? 0);
|
||||||
const h = w + bbox.height;
|
const h = w + bbox.height;
|
||||||
@@ -55,7 +58,7 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
|||||||
|
|
||||||
label.attr(
|
label.attr(
|
||||||
'transform',
|
'transform',
|
||||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - (bbox.height + (node.padding ?? 0) - (bbox.y - (bbox.top ?? 0)))})`
|
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - (bbox.height + (node.padding ?? 0) / (useHtmlLabels ? 2 : 1) - (bbox.y - (bbox.top ?? 0)))})`
|
||||||
);
|
);
|
||||||
|
|
||||||
node.intersect = function (point) {
|
node.intersect = function (point) {
|
||||||
|
Reference in New Issue
Block a user