mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-21 23:19:53 +02:00
@@ -3,7 +3,6 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
|||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
import type { Node } from '../../types.js';
|
import type { Node } from '../../types.js';
|
||||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||||
import rough from 'roughjs';
|
|
||||||
import type { D3Selection } from '../../../types.js';
|
import type { D3Selection } from '../../../types.js';
|
||||||
import { handleUndefinedAttr } from '../../../utils.js';
|
import { handleUndefinedAttr } from '../../../utils.js';
|
||||||
import type { Bounds, Point } from '../../../types.js';
|
import type { Bounds, Point } from '../../../types.js';
|
||||||
@@ -69,11 +68,14 @@ export async function bang<T extends SVGGraphicsElement>(parent: D3Selection<T>,
|
|||||||
H0 V0 Z`;
|
H0 V0 Z`;
|
||||||
|
|
||||||
if (node.look === 'handDrawn') {
|
if (node.look === 'handDrawn') {
|
||||||
|
// @ts-expect-error -- Passing a D3.Selection seems to work for some reason
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {});
|
const options = userNodeOverrides(node, {});
|
||||||
const roughNode = rc.path(path, options);
|
const roughNode = rc.path(path, options);
|
||||||
bangElem = shapeSvg.insert(() => roughNode, ':first-child');
|
bangElem = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
bangElem.attr('class', 'basic label-container').attr('style', handleUndefinedAttr(cssStyles));
|
bangElem
|
||||||
|
.attr('class', 'basic label-container')
|
||||||
|
.attr('style', handleUndefinedAttr(node.cssStyles));
|
||||||
} else {
|
} else {
|
||||||
bangElem = shapeSvg
|
bangElem = shapeSvg
|
||||||
.insert('path', ':first-child')
|
.insert('path', ':first-child')
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import rough from 'roughjs';
|
|
||||||
import { log } from '../../../logger.js';
|
import { log } from '../../../logger.js';
|
||||||
import type { Bounds, D3Selection, Point } from '../../../types.js';
|
import type { Bounds, D3Selection, Point } from '../../../types.js';
|
||||||
import { handleUndefinedAttr } from '../../../utils.js';
|
import { handleUndefinedAttr } from '../../../utils.js';
|
||||||
@@ -44,15 +43,17 @@ export async function circle<T extends SVGGraphicsElement>(
|
|||||||
label.attr('transform', `translate(${labelXOffset}, ${labelYOffset})`);
|
label.attr('transform', `translate(${labelXOffset}, ${labelYOffset})`);
|
||||||
|
|
||||||
let circleElem;
|
let circleElem;
|
||||||
const { cssStyles } = node;
|
|
||||||
|
|
||||||
if (node.look === 'handDrawn') {
|
if (node.look === 'handDrawn') {
|
||||||
|
// @ts-expect-error -- Passing a D3.Selection seems to work for some reason
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {});
|
const options = userNodeOverrides(node, {});
|
||||||
const roughNode = rc.circle(0, 0, radius * 2, options);
|
const roughNode = rc.circle(0, 0, radius * 2, options);
|
||||||
|
|
||||||
circleElem = shapeSvg.insert(() => roughNode, ':first-child');
|
circleElem = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
circleElem.attr('class', 'basic label-container').attr('style', handleUndefinedAttr(cssStyles));
|
circleElem
|
||||||
|
.attr('class', 'basic label-container')
|
||||||
|
.attr('style', handleUndefinedAttr(node.cssStyles));
|
||||||
} else {
|
} else {
|
||||||
circleElem = shapeSvg
|
circleElem = shapeSvg
|
||||||
.insert('circle', ':first-child')
|
.insert('circle', ':first-child')
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import rough from 'roughjs';
|
|
||||||
import { log } from '../../../logger.js';
|
import { log } from '../../../logger.js';
|
||||||
import type { Bounds, D3Selection, Point } from '../../../types.js';
|
import type { Bounds, D3Selection, Point } from '../../../types.js';
|
||||||
import { handleUndefinedAttr } from '../../../utils.js';
|
import { handleUndefinedAttr } from '../../../utils.js';
|
||||||
@@ -48,7 +47,6 @@ export async function cloud<T extends SVGGraphicsElement>(parent: D3Selection<T>
|
|||||||
const r3 = 0.35 * w;
|
const r3 = 0.35 * w;
|
||||||
const r4 = 0.2 * w;
|
const r4 = 0.2 * w;
|
||||||
|
|
||||||
const { cssStyles } = node;
|
|
||||||
let cloudElem;
|
let cloudElem;
|
||||||
|
|
||||||
// Cloud path
|
// Cloud path
|
||||||
@@ -69,11 +67,14 @@ export async function cloud<T extends SVGGraphicsElement>(parent: D3Selection<T>
|
|||||||
H0 V0 Z`;
|
H0 V0 Z`;
|
||||||
|
|
||||||
if (node.look === 'handDrawn') {
|
if (node.look === 'handDrawn') {
|
||||||
|
// @ts-expect-error -- Passing a D3.Selection seems to work for some reason
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {});
|
const options = userNodeOverrides(node, {});
|
||||||
const roughNode = rc.path(path, options);
|
const roughNode = rc.path(path, options);
|
||||||
cloudElem = shapeSvg.insert(() => roughNode, ':first-child');
|
cloudElem = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
cloudElem.attr('class', 'basic label-container').attr('style', handleUndefinedAttr(cssStyles));
|
cloudElem
|
||||||
|
.attr('class', 'basic label-container')
|
||||||
|
.attr('style', handleUndefinedAttr(node.cssStyles));
|
||||||
} else {
|
} else {
|
||||||
cloudElem = shapeSvg
|
cloudElem = shapeSvg
|
||||||
.insert('path', ':first-child')
|
.insert('path', ':first-child')
|
||||||
|
@@ -2,7 +2,6 @@ import { labelHelper, updateNodeBounds, getNodeClasses, createPathFromPoints } f
|
|||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
import type { Node } from '../../types.js';
|
import type { Node } from '../../types.js';
|
||||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||||
import rough from 'roughjs';
|
|
||||||
import type { D3Selection } from '../../../types.js';
|
import type { D3Selection } from '../../../types.js';
|
||||||
|
|
||||||
export const createHexagonPathD = (
|
export const createHexagonPathD = (
|
||||||
@@ -51,6 +50,7 @@ export async function hexagon<T extends SVGGraphicsElement>(parent: D3Selection<
|
|||||||
const labelYOffset = -bbox.height / 2;
|
const labelYOffset = -bbox.height / 2;
|
||||||
label.attr('transform', `translate(${labelXOffset}, ${labelYOffset})`);
|
label.attr('transform', `translate(${labelXOffset}, ${labelYOffset})`);
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
|
// @ts-expect-error -- Passing a D3.Selection seems to work for some reason
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {});
|
const options = userNodeOverrides(node, {});
|
||||||
|
|
||||||
|
@@ -2,7 +2,6 @@ import { labelHelper, updateNodeBounds, getNodeClasses, createPathFromPoints } f
|
|||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
import type { Node } from '../../types.js';
|
import type { Node } from '../../types.js';
|
||||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||||
import rough from 'roughjs';
|
|
||||||
import type { D3Selection } from '../../../types.js';
|
import type { D3Selection } from '../../../types.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,6 +120,7 @@ export async function roundedRect<T extends SVGGraphicsElement>(
|
|||||||
const radius = node.radius || 5;
|
const radius = node.radius || 5;
|
||||||
const taper = node.taper || 5; // Taper width for the rounded corners
|
const taper = node.taper || 5; // Taper width for the rounded corners
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
|
// @ts-expect-error -- Passing a D3.Selection seems to work for some reason
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {});
|
const options = userNodeOverrides(node, {});
|
||||||
if (node.stroke) {
|
if (node.stroke) {
|
||||||
|
Reference in New Issue
Block a user