mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 15:59:51 +02:00
fixed issue for without label shapes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
import { log } from '$root/logger.js';
|
||||||
import { labelHelper, getNodeClasses, updateNodeBounds } from './util.js';
|
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||||
|
import type { SVG } from '$root/diagram-api/types.js';
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import {
|
import {
|
||||||
styles2String,
|
styles2String,
|
||||||
@@ -22,11 +23,14 @@ function createLine(r: number) {
|
|||||||
M ${pointQ1.x},${pointQ1.y} L ${pointQ3.x},${pointQ3.y}`;
|
M ${pointQ1.x},${pointQ1.y} L ${pointQ3.x},${pointQ3.y}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const crossedCircle = async (parent: SVGAElement, node: Node) => {
|
export const crossedCircle = (parent: SVG, node: Node) => {
|
||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
node.label = '';
|
node.label = '';
|
||||||
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
|
const shapeSvg = parent
|
||||||
|
.insert('g')
|
||||||
|
.attr('class', getNodeClasses(node))
|
||||||
|
.attr('id', node.domId ?? node.id);
|
||||||
const radius = Math.max(30, node?.width ?? 0);
|
const radius = Math.max(30, node?.width ?? 0);
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
|
|
||||||
@@ -46,8 +50,6 @@ export const crossedCircle = async (parent: SVGAElement, node: Node) => {
|
|||||||
const crossedCircle = shapeSvg.insert(() => circleNode, ':first-child');
|
const crossedCircle = shapeSvg.insert(() => circleNode, ':first-child');
|
||||||
crossedCircle.insert(() => lineNode);
|
crossedCircle.insert(() => lineNode);
|
||||||
|
|
||||||
crossedCircle.attr('class', 'basic label-container');
|
|
||||||
|
|
||||||
if (cssStyles && node.look !== 'handDrawn') {
|
if (cssStyles && node.look !== 'handDrawn') {
|
||||||
crossedCircle.selectAll('path').attr('style', cssStyles);
|
crossedCircle.selectAll('path').attr('style', cssStyles);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { log } from '$root/logger.js';
|
import { log } from '$root/logger.js';
|
||||||
import { labelHelper, getNodeClasses, updateNodeBounds } from './util.js';
|
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
|
import type { SVG } from '$root/diagram-api/types.js';
|
||||||
import {
|
import {
|
||||||
styles2String,
|
styles2String,
|
||||||
userNodeOverrides,
|
userNodeOverrides,
|
||||||
@@ -8,11 +9,14 @@ import {
|
|||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
|
|
||||||
export const filledCircle = async (parent: SVGAElement, node: Node) => {
|
export const filledCircle = (parent: SVG, node: Node) => {
|
||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.label = '';
|
node.label = '';
|
||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
|
const shapeSvg = parent
|
||||||
|
.insert('g')
|
||||||
|
.attr('class', getNodeClasses(node))
|
||||||
|
.attr('id', node.domId ?? node.id);
|
||||||
const radius = 7;
|
const radius = 7;
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
|
|
||||||
@@ -29,7 +33,7 @@ export const filledCircle = async (parent: SVGAElement, node: Node) => {
|
|||||||
|
|
||||||
const filledCircle = shapeSvg.insert(() => circleNode, ':first-child');
|
const filledCircle = shapeSvg.insert(() => circleNode, ':first-child');
|
||||||
|
|
||||||
filledCircle.attr('class', 'basic label-container');
|
// filledCircle.attr('class', 'basic label-container');
|
||||||
|
|
||||||
if (cssStyles && node.look !== 'handDrawn') {
|
if (cssStyles && node.look !== 'handDrawn') {
|
||||||
filledCircle.selectAll('path').attr('style', cssStyles);
|
filledCircle.selectAll('path').attr('style', cssStyles);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { log } from '$root/logger.js';
|
import { log } from '$root/logger.js';
|
||||||
import { labelHelper, getNodeClasses, updateNodeBounds } from './util.js';
|
import { getNodeClasses, updateNodeBounds } from './util.js';
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
|
import type { SVG } from '$root/diagram-api/types.js';
|
||||||
import {
|
import {
|
||||||
styles2String,
|
styles2String,
|
||||||
userNodeOverrides,
|
userNodeOverrides,
|
||||||
@@ -9,11 +10,14 @@ import rough from 'roughjs';
|
|||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
import { createPathFromPoints } from './util.js';
|
import { createPathFromPoints } from './util.js';
|
||||||
|
|
||||||
export const lightningBolt = async (parent: SVGAElement, node: Node) => {
|
export const lightningBolt = (parent: SVG, node: Node) => {
|
||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.label = '';
|
node.label = '';
|
||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
|
const shapeSvg = parent
|
||||||
|
.insert('g')
|
||||||
|
.attr('class', getNodeClasses(node))
|
||||||
|
.attr('id', node.domId ?? node.id);
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
const height = 80;
|
const height = 80;
|
||||||
const width = 80;
|
const width = 80;
|
||||||
@@ -42,8 +46,6 @@ export const lightningBolt = async (parent: SVGAElement, node: Node) => {
|
|||||||
|
|
||||||
const lightningBolt = shapeSvg.insert(() => lineNode, ':first-child');
|
const lightningBolt = shapeSvg.insert(() => lineNode, ':first-child');
|
||||||
|
|
||||||
lightningBolt.attr('class', 'basic label-container');
|
|
||||||
|
|
||||||
if (cssStyles && node.look !== 'handDrawn') {
|
if (cssStyles && node.look !== 'handDrawn') {
|
||||||
lightningBolt.selectAll('path').attr('style', cssStyles);
|
lightningBolt.selectAll('path').attr('style', cssStyles);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user