mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 15:59:51 +02:00
Merge branch 'alanaV11' into pebr/neo-style
This commit is contained in:
@@ -813,6 +813,9 @@ const addNodeFromVertex = (
|
|||||||
domId: vertex.domId,
|
domId: vertex.domId,
|
||||||
isGroup,
|
isGroup,
|
||||||
look,
|
look,
|
||||||
|
link: vertex.link,
|
||||||
|
linkTarget: vertex.linkTarget,
|
||||||
|
tooltip: getTooltip(vertex.id),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -8,6 +8,7 @@ import { setupViewPortForSVG } from '../../rendering-util/setupViewPortForSVG.js
|
|||||||
import { getDirection } from './flowDb.js';
|
import { getDirection } from './flowDb.js';
|
||||||
|
|
||||||
import utils from '../../utils.js';
|
import utils from '../../utils.js';
|
||||||
|
import { select } from 'd3';
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
const conf: Record<string, any> = {};
|
const conf: Record<string, any> = {};
|
||||||
@@ -32,6 +33,15 @@ export const draw = async function (text: string, id: string, _version: string,
|
|||||||
log.info('Drawing state diagram (v2)', id);
|
log.info('Drawing state diagram (v2)', id);
|
||||||
const { securityLevel, state: conf, layout } = getConfig();
|
const { securityLevel, state: conf, layout } = getConfig();
|
||||||
|
|
||||||
|
// Handle root and document for when rendering in sandbox mode
|
||||||
|
let sandboxElement;
|
||||||
|
if (securityLevel === 'sandbox') {
|
||||||
|
sandboxElement = select('#i' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore - document is always available
|
||||||
|
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;
|
||||||
|
|
||||||
const DIR = getDirection();
|
const DIR = getDirection();
|
||||||
|
|
||||||
// The getData method provided in all supported diagrams is used to extract the data from the parsed structure
|
// The getData method provided in all supported diagrams is used to extract the data from the parsed structure
|
||||||
@@ -60,6 +70,41 @@ export const draw = async function (text: string, id: string, _version: string,
|
|||||||
diag.db.getDiagramTitle()
|
diag.db.getDiagramTitle()
|
||||||
);
|
);
|
||||||
setupViewPortForSVG(svg, padding, 'flowchart', conf?.useMaxWidth || false);
|
setupViewPortForSVG(svg, padding, 'flowchart', conf?.useMaxWidth || false);
|
||||||
|
|
||||||
|
// If node has a link, wrap it in an anchor SVG object.
|
||||||
|
data4Layout.nodes.forEach((vertex) => {
|
||||||
|
if (vertex.link) {
|
||||||
|
const node = select('#' + id + ' [id="' + vertex.id + '"]');
|
||||||
|
if (node) {
|
||||||
|
const link = doc.createElementNS('http://www.w3.org/2000/svg', 'a');
|
||||||
|
link.setAttributeNS('http://www.w3.org/2000/svg', 'class', vertex.cssClasses);
|
||||||
|
link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener');
|
||||||
|
if (securityLevel === 'sandbox') {
|
||||||
|
link.setAttributeNS('http://www.w3.org/2000/svg', 'target', '_top');
|
||||||
|
} else if (vertex.linkTarget) {
|
||||||
|
link.setAttributeNS('http://www.w3.org/2000/svg', 'target', vertex.linkTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
const linkNode = node.insert(function () {
|
||||||
|
return link;
|
||||||
|
}, ':first-child');
|
||||||
|
|
||||||
|
const shape = node.select('.label-container');
|
||||||
|
if (shape) {
|
||||||
|
linkNode.append(function () {
|
||||||
|
return shape.node();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const label = node.select('.label');
|
||||||
|
if (label) {
|
||||||
|
linkNode.append(function () {
|
||||||
|
return label.node();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@@ -15,7 +15,8 @@ interface Node {
|
|||||||
description?: string[];
|
description?: string[];
|
||||||
parentId?: string;
|
parentId?: string;
|
||||||
position?: string; // Keep, this is for notes 'left of', 'right of', etc. Move into nodeNode
|
position?: string; // Keep, this is for notes 'left of', 'right of', etc. Move into nodeNode
|
||||||
cssStyles?: string; // Renamed from `styles` to `cssStyles`
|
cssStyles?: string[]; // Renamed from `styles` to `cssStyles`
|
||||||
|
cssCompiledStyles?: string[];
|
||||||
cssClasses?: string; // Renamed from `classes` to `cssClasses`
|
cssClasses?: string; // Renamed from `classes` to `cssClasses`
|
||||||
// style?: string; //REMOVE ✅
|
// style?: string; //REMOVE ✅
|
||||||
// class?: string; //REMOVE ✅
|
// class?: string; //REMOVE ✅
|
||||||
@@ -23,7 +24,7 @@ interface Node {
|
|||||||
// props?: Record<string, unknown>; //REMOVE ✅
|
// props?: Record<string, unknown>; //REMOVE ✅
|
||||||
// type: string; // REMOVE, replace with isGroup: boolean, default false ✅
|
// type: string; // REMOVE, replace with isGroup: boolean, default false ✅
|
||||||
// borders?: string; //REMOVE ✅
|
// borders?: string; //REMOVE ✅
|
||||||
labelStyle?: string;
|
labelStyle?: string; // REMOVE - use cssStyles instead ✅
|
||||||
|
|
||||||
// Flowchart specific properties
|
// Flowchart specific properties
|
||||||
labelType?: string; // REMOVE? Always use markdown string, need to check for KaTeX - ⏳ wait with this one
|
labelType?: string; // REMOVE? Always use markdown string, need to check for KaTeX - ⏳ wait with this one
|
||||||
@@ -34,6 +35,7 @@ interface Node {
|
|||||||
haveCallback?: boolean;
|
haveCallback?: boolean;
|
||||||
link?: string;
|
link?: string;
|
||||||
linkTarget?: string;
|
linkTarget?: string;
|
||||||
|
tooltip?: string;
|
||||||
padding?: number; //REMOVE?, use from LayoutData.config - Keep, this could be shape specific
|
padding?: number; //REMOVE?, use from LayoutData.config - Keep, this could be shape specific
|
||||||
shape?: string;
|
shape?: string;
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
|
Reference in New Issue
Block a user