mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#5237 Adding missing shape
This commit is contained in:
parent
406c0d869b
commit
460e027b6e
@ -21,6 +21,7 @@ import { lean_right } from './shapes/leanRight.js';
|
||||
import { lean_left } from './shapes/leanLeft.js';
|
||||
import { trapezoid } from './shapes/trapezoid.js';
|
||||
import { inv_trapezoid } from './shapes/invertedTrapezoid.js';
|
||||
import { labelRect } from './shapes/labelRect.js';
|
||||
|
||||
const shapes = {
|
||||
state,
|
||||
@ -45,6 +46,7 @@ const shapes = {
|
||||
lean_left,
|
||||
trapezoid,
|
||||
inv_trapezoid,
|
||||
labelRect,
|
||||
};
|
||||
|
||||
let nodeElems = {};
|
||||
|
@ -70,36 +70,3 @@ export const drawRect = async (parent: SVGAElement, node: Node, options: RectOpt
|
||||
|
||||
return shapeSvg;
|
||||
};
|
||||
|
||||
export const labelRect = async (parent: SVGElement, node: Node) => {
|
||||
const { shapeSvg } = await labelHelper(parent, node, 'label');
|
||||
|
||||
// log.trace('Classes = ', node.class);
|
||||
// add the rect
|
||||
const rect = shapeSvg.insert('rect', ':first-child');
|
||||
|
||||
// Hide the rect we are only after the label
|
||||
const totalWidth = 0;
|
||||
const totalHeight = 0;
|
||||
rect.attr('width', totalWidth).attr('height', totalHeight);
|
||||
shapeSvg.attr('class', 'label edgeLabel');
|
||||
|
||||
// if (node.props) {
|
||||
// const propKeys = new Set(Object.keys(node.props));
|
||||
// if (node.props.borders) {
|
||||
// applyNodePropertyBorders(rect, node.borders, totalWidth, totalHeight);
|
||||
// propKeys.delete('borders');
|
||||
// }
|
||||
// propKeys.forEach((propKey) => {
|
||||
// log.warn(`Unknown node property ${propKey}`);
|
||||
// });
|
||||
// }
|
||||
|
||||
updateNodeBounds(node, rect);
|
||||
|
||||
node.intersect = function (point) {
|
||||
return intersect.rect(node, point);
|
||||
};
|
||||
|
||||
return shapeSvg;
|
||||
};
|
||||
|
@ -0,0 +1,49 @@
|
||||
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||
import { drawRect } from './drawRect.js';
|
||||
import { labelHelper, updateNodeBounds } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
|
||||
export const roundedRect = async (parent: SVGAElement, node: Node) => {
|
||||
const options = {
|
||||
rx: 5,
|
||||
ry: 5,
|
||||
classes: '',
|
||||
labelPaddingX: (node?.padding || 0) * 1,
|
||||
labelPaddingY: (node?.padding || 0) * 1,
|
||||
} as RectOptions;
|
||||
|
||||
return drawRect(parent, node, options);
|
||||
};
|
||||
|
||||
export const labelRect = async (parent: SVGElement, node: Node) => {
|
||||
const { shapeSvg } = await labelHelper(parent, node, 'label');
|
||||
|
||||
// log.trace('Classes = ', node.class);
|
||||
// add the rect
|
||||
const rect = shapeSvg.insert('rect', ':first-child');
|
||||
|
||||
// Hide the rect we are only after the label
|
||||
const totalWidth = 0;
|
||||
const totalHeight = 0;
|
||||
rect.attr('width', totalWidth).attr('height', totalHeight);
|
||||
shapeSvg.attr('class', 'label edgeLabel');
|
||||
|
||||
// if (node.props) {
|
||||
// const propKeys = new Set(Object.keys(node.props));
|
||||
// if (node.props.borders) {
|
||||
// applyNodePropertyBorders(rect, node.borders, totalWidth, totalHeight);
|
||||
// propKeys.delete('borders');
|
||||
// }
|
||||
// propKeys.forEach((propKey) => {
|
||||
// log.warn(`Unknown node property ${propKey}`);
|
||||
// });
|
||||
// }
|
||||
|
||||
updateNodeBounds(node, rect);
|
||||
|
||||
node.intersect = function (point) {
|
||||
return intersect.rect(node, point);
|
||||
};
|
||||
|
||||
return shapeSvg;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user