mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
chore: Rename RenderOptions interface to avoid duplication.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { log } from '../../../logger.js';
|
||||
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||
import type { Node, RenderOptions } from '../../types.d.ts';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.d.ts';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||
|
||||
export const filledCircle = (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables } }: RenderOptions
|
||||
{ config: { themeVariables } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
node.label = '';
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node, RenderOptions } from '../../types.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import rough from 'roughjs';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||
|
||||
export const forkJoin = (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ dir, config: { state, themeVariables } }: RenderOptions
|
||||
{ dir, config: { state, themeVariables } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { nodeStyles } = styles2String(node);
|
||||
node.label = '';
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import { log } from '../../../logger.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
import type { Node, RenderOptions } from '../../types.d.ts';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
import { getIconSVG } from '../../icons.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.d.ts';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
|
||||
export const icon = async (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables, flowchart } }: RenderOptions
|
||||
{ config: { themeVariables, flowchart } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
@@ -59,7 +59,11 @@ export const icon = async (
|
||||
if (node.icon) {
|
||||
const iconElem = shapeSvg.append('g');
|
||||
iconElem.html(
|
||||
`<g>${await getIconSVG(node.icon, { height: iconSize, width: iconSize, fallbackPrefix: '' })}</g>`
|
||||
`<g>${await getIconSVG(node.icon, {
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fallbackPrefix: '',
|
||||
})}</g>`
|
||||
);
|
||||
const iconBBox = iconElem.node().getBBox();
|
||||
const iconWidth = iconBBox.width;
|
||||
@@ -68,19 +72,27 @@ export const icon = async (
|
||||
const iconY = iconBBox.y;
|
||||
iconElem.attr(
|
||||
'transform',
|
||||
`translate(${-iconWidth / 2 - iconX},${topLabel ? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY : -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY})`
|
||||
`translate(${-iconWidth / 2 - iconX},${
|
||||
topLabel
|
||||
? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY
|
||||
: -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY
|
||||
})`
|
||||
);
|
||||
iconElem.selectAll('path').attr('fill', stylesMap.get('stroke') || nodeBorder);
|
||||
}
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${
|
||||
topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height
|
||||
})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
'transform',
|
||||
`translate(${0},${topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2})`
|
||||
`translate(${0},${
|
||||
topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2
|
||||
})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, outerShape);
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import { log } from '../../../logger.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
import type { Node, RenderOptions } from '../../types.d.ts';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
import { getIconSVG } from '../../icons.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.d.ts';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
|
||||
export const iconCircle = async (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables, flowchart } }: RenderOptions
|
||||
{ config: { themeVariables, flowchart } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
@@ -40,7 +40,11 @@ export const iconCircle = async (
|
||||
const iconElem = shapeSvg.append('g');
|
||||
if (node.icon) {
|
||||
iconElem.html(
|
||||
`<g>${await getIconSVG(node.icon, { height: iconSize, width: iconSize, fallbackPrefix: '' })}</g>`
|
||||
`<g>${await getIconSVG(node.icon, {
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fallbackPrefix: '',
|
||||
})}</g>`
|
||||
);
|
||||
}
|
||||
const iconBBox = iconElem.node().getBBox();
|
||||
@@ -65,17 +69,25 @@ export const iconCircle = async (
|
||||
const outerShape = shapeSvg.insert(() => outerNode);
|
||||
iconElem.attr(
|
||||
'transform',
|
||||
`translate(${-iconWidth / 2 - iconX},${topLabel ? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY : -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY})`
|
||||
`translate(${-iconWidth / 2 - iconX},${
|
||||
topLabel
|
||||
? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY
|
||||
: -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY
|
||||
})`
|
||||
);
|
||||
iconElem.selectAll('path').attr('fill', stylesMap.get('stroke') || nodeBorder);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${
|
||||
topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height
|
||||
})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
'transform',
|
||||
`translate(${0},${topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2})`
|
||||
`translate(${0},${
|
||||
topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2
|
||||
})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, outerShape);
|
||||
|
@@ -1,17 +1,17 @@
|
||||
import { log } from '../../../logger.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
import type { Node, RenderOptions } from '../../types.d.ts';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
import { getIconSVG } from '../../icons.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.d.ts';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { createRoundedRectPathD } from './roundedRectPath.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
|
||||
export const iconRounded = async (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables, flowchart } }: RenderOptions
|
||||
{ config: { themeVariables, flowchart } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
@@ -64,7 +64,11 @@ export const iconRounded = async (
|
||||
if (node.icon) {
|
||||
const iconElem = shapeSvg.append('g');
|
||||
iconElem.html(
|
||||
`<g>${await getIconSVG(node.icon, { height: iconSize, width: iconSize, fallbackPrefix: '' })}</g>`
|
||||
`<g>${await getIconSVG(node.icon, {
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fallbackPrefix: '',
|
||||
})}</g>`
|
||||
);
|
||||
const iconBBox = iconElem.node().getBBox();
|
||||
const iconWidth = iconBBox.width;
|
||||
@@ -73,19 +77,27 @@ export const iconRounded = async (
|
||||
const iconY = iconBBox.y;
|
||||
iconElem.attr(
|
||||
'transform',
|
||||
`translate(${-iconWidth / 2 - iconX},${topLabel ? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY : -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY})`
|
||||
`translate(${-iconWidth / 2 - iconX},${
|
||||
topLabel
|
||||
? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY
|
||||
: -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY
|
||||
})`
|
||||
);
|
||||
iconElem.selectAll('path').attr('fill', stylesMap.get('stroke') ?? nodeBorder);
|
||||
}
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${
|
||||
topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height
|
||||
})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
'transform',
|
||||
`translate(${0},${topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2})`
|
||||
`translate(${0},${
|
||||
topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2
|
||||
})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, outerShape);
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import { log } from '../../../logger.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
import type { Node, RenderOptions } from '../../types.d.ts';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
import { getIconSVG } from '../../icons.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.d.ts';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
|
||||
export const iconSquare = async (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables, flowchart } }: RenderOptions
|
||||
{ config: { themeVariables, flowchart } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
@@ -63,7 +63,11 @@ export const iconSquare = async (
|
||||
if (node.icon) {
|
||||
const iconElem = shapeSvg.append('g');
|
||||
iconElem.html(
|
||||
`<g>${await getIconSVG(node.icon, { height: iconSize, width: iconSize, fallbackPrefix: '' })}</g>`
|
||||
`<g>${await getIconSVG(node.icon, {
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fallbackPrefix: '',
|
||||
})}</g>`
|
||||
);
|
||||
const iconBBox = iconElem.node().getBBox();
|
||||
const iconWidth = iconBBox.width;
|
||||
@@ -72,19 +76,27 @@ export const iconSquare = async (
|
||||
const iconY = iconBBox.y;
|
||||
iconElem.attr(
|
||||
'transform',
|
||||
`translate(${-iconWidth / 2 - iconX},${topLabel ? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY : -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY})`
|
||||
`translate(${-iconWidth / 2 - iconX},${
|
||||
topLabel
|
||||
? bbox.height / 2 + labelPadding / 2 - iconHeight / 2 - iconY
|
||||
: -bbox.height / 2 - labelPadding / 2 - iconHeight / 2 - iconY
|
||||
})`
|
||||
);
|
||||
iconElem.selectAll('path').attr('fill', stylesMap.get('stroke') ?? nodeBorder);
|
||||
}
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${
|
||||
topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height
|
||||
})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
'transform',
|
||||
`translate(${0},${topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2})`
|
||||
`translate(${0},${
|
||||
topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2
|
||||
})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, outerShape);
|
||||
|
@@ -1,15 +1,15 @@
|
||||
import { log } from '../../../logger.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
import type { Node, RenderOptions } from '../../types.d.ts';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import { log } from '../../../logger.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.d.ts';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
|
||||
export const imageSquare = async (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { flowchart } }: RenderOptions
|
||||
{ config: { flowchart } }: ShapeRenderOptions
|
||||
) => {
|
||||
const img = new Image();
|
||||
img.src = node?.img ?? '';
|
||||
@@ -92,12 +92,18 @@ export const imageSquare = async (
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -imageHeight / 2 - bbox.height / 2 - labelPadding / 2 : imageHeight / 2 - bbox.height / 2 + labelPadding / 2})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${
|
||||
topLabel
|
||||
? -imageHeight / 2 - bbox.height / 2 - labelPadding / 2
|
||||
: imageHeight / 2 - bbox.height / 2 + labelPadding / 2
|
||||
})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
'transform',
|
||||
`translate(${0},${topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2})`
|
||||
`translate(${0},${
|
||||
topLabel ? bbox.height / 2 + labelPadding / 2 : -bbox.height / 2 - labelPadding / 2
|
||||
})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, outerShape);
|
||||
|
@@ -1,14 +1,13 @@
|
||||
import { getNodeClasses, labelHelper, updateNodeBounds } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node } from '../../types.js';
|
||||
import rough from 'roughjs';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import type { RenderOptions } from '../../types.js';
|
||||
import { getNodeClasses, labelHelper, updateNodeBounds } from './util.js';
|
||||
|
||||
export const note = async (
|
||||
parent: SVGAElement,
|
||||
node: Node,
|
||||
{ config: { themeVariables } }: RenderOptions
|
||||
{ config: { themeVariables } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { updateNodeBounds } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node, RenderOptions } from '../../types.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import rough from 'roughjs';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
import { updateNodeBounds } from './util.js';
|
||||
|
||||
export const stateEnd = (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables } }: RenderOptions
|
||||
{ config: { themeVariables } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { updateNodeBounds } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node, RenderOptions } from '../../types.js';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import rough from 'roughjs';
|
||||
import type { SVG } from '../../../diagram-api/types.js';
|
||||
import type { Node, ShapeRenderOptions } from '../../types.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { solidStateFill } from './handDrawnShapeStyles.js';
|
||||
import { updateNodeBounds } from './util.js';
|
||||
|
||||
export const stateStart = (
|
||||
parent: SVG,
|
||||
node: Node,
|
||||
{ config: { themeVariables } }: RenderOptions
|
||||
{ config: { themeVariables } }: ShapeRenderOptions
|
||||
) => {
|
||||
const { lineColor } = themeVariables;
|
||||
|
||||
|
@@ -144,7 +144,7 @@ export type LayoutMethod =
|
||||
| 'osage'
|
||||
| 'grid';
|
||||
|
||||
export interface RenderOptions {
|
||||
export interface ShapeRenderOptions {
|
||||
config: MermaidConfig;
|
||||
dir: string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user