mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-12 10:39:44 +02:00
Compare commits
1 Commits
renovate/p
...
6790-Fix-n
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2ee7ef09c4 |
@@ -603,10 +603,6 @@
|
||||
</div>
|
||||
<div class="test">
|
||||
<pre class="mermaid">
|
||||
---
|
||||
config:
|
||||
theme: dark
|
||||
---
|
||||
classDiagram
|
||||
test ()--() test2
|
||||
</pre>
|
||||
|
@@ -78,7 +78,7 @@
|
||||
"d3-sankey": "^0.12.3",
|
||||
"dagre-d3-es": "7.0.11",
|
||||
"dayjs": "^1.11.18",
|
||||
"dompurify": "^3.2.7",
|
||||
"dompurify": "^3.2.5",
|
||||
"katex": "^0.16.22",
|
||||
"khroma": "^2.1.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
@@ -627,7 +627,7 @@ export class ClassDB implements DiagramDB {
|
||||
padding: config.class!.padding ?? 16,
|
||||
// parent node must be one of [rect, roundedWithTitle, noteGroup, divider]
|
||||
shape: 'rect',
|
||||
cssStyles: [],
|
||||
cssStyles: ['fill: none', 'stroke: black'],
|
||||
look: config.look,
|
||||
};
|
||||
nodes.push(node);
|
||||
|
@@ -13,30 +13,6 @@ const getStyles = (options) =>
|
||||
|
||||
}
|
||||
|
||||
.cluster-label text {
|
||||
fill: ${options.titleColor};
|
||||
}
|
||||
.cluster-label span {
|
||||
color: ${options.titleColor};
|
||||
}
|
||||
.cluster-label span p {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.cluster rect {
|
||||
fill: ${options.clusterBkg};
|
||||
stroke: ${options.clusterBorder};
|
||||
stroke-width: 1px;
|
||||
}
|
||||
|
||||
.cluster text {
|
||||
fill: ${options.titleColor};
|
||||
}
|
||||
|
||||
.cluster span {
|
||||
color: ${options.titleColor};
|
||||
}
|
||||
|
||||
.nodeLabel, .edgeLabel {
|
||||
color: ${options.classText};
|
||||
}
|
||||
|
@@ -27,6 +27,53 @@ import { log } from '../../../logger.js';
|
||||
import { getSubGraphTitleMargins } from '../../../utils/subGraphTitleMargins.js';
|
||||
import { getConfig } from '../../../diagram-api/diagramAPI.js';
|
||||
|
||||
/**
|
||||
* Apply absolute note positioning after dagre layout
|
||||
* This fixes the issue where TB and LR directions position notes differently
|
||||
* by making note positioning truly absolute
|
||||
*/
|
||||
const positionNotes = (graph) => {
|
||||
const noteStatePairs = [];
|
||||
|
||||
graph.nodes().forEach((nodeId) => {
|
||||
const node = graph.node(nodeId);
|
||||
if (node.position && node.shape === 'note') {
|
||||
const edges = graph.nodeEdges(nodeId);
|
||||
|
||||
for (const edge of edges) {
|
||||
const otherNodeId = edge.v === nodeId ? edge.w : edge.v;
|
||||
const otherNode = graph.node(otherNodeId);
|
||||
|
||||
if (otherNode && otherNode.shape !== 'note' && otherNode.shape !== 'noteGroup') {
|
||||
noteStatePairs.push({
|
||||
noteId: nodeId,
|
||||
noteNode: node,
|
||||
stateId: otherNodeId,
|
||||
stateNode: otherNode,
|
||||
position: node.position,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
noteStatePairs.forEach(({ noteNode, stateNode, position }) => {
|
||||
const spacing = 60;
|
||||
|
||||
let noteX = noteNode.x;
|
||||
let noteY = stateNode.y;
|
||||
|
||||
if (position === 'right of') {
|
||||
noteX = stateNode.x + stateNode.width / 2 + spacing + noteNode.width / 2;
|
||||
} else if (position === 'left of') {
|
||||
noteX = stateNode.x - stateNode.width / 2 - spacing - noteNode.width / 2;
|
||||
}
|
||||
|
||||
noteNode.x = noteX;
|
||||
noteNode.y = noteY;
|
||||
});
|
||||
};
|
||||
|
||||
const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, siteConfig) => {
|
||||
log.warn('Graph in recursive render:XAX', graphlibJson.write(graph), parentCluster);
|
||||
const dir = graph.graph().rankdir;
|
||||
@@ -164,6 +211,9 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
|
||||
dagreLayout(graph);
|
||||
|
||||
// Apply absolute note positioning after dagre layout
|
||||
positionNotes(graph);
|
||||
|
||||
log.info('Graph after layout:', JSON.stringify(graphlibJson.write(graph)));
|
||||
// Move the nodes to the correct place
|
||||
let diff = 0;
|
||||
|
@@ -130,6 +130,7 @@ const lollipop = (elem, type, id) => {
|
||||
.attr('markerHeight', 240)
|
||||
.attr('orient', 'auto')
|
||||
.append('circle')
|
||||
.attr('stroke', 'black')
|
||||
.attr('fill', 'transparent')
|
||||
.attr('cx', 7)
|
||||
.attr('cy', 7)
|
||||
@@ -146,6 +147,7 @@ const lollipop = (elem, type, id) => {
|
||||
.attr('markerHeight', 240)
|
||||
.attr('orient', 'auto')
|
||||
.append('circle')
|
||||
.attr('stroke', 'black')
|
||||
.attr('fill', 'transparent')
|
||||
.attr('cx', 7)
|
||||
.attr('cy', 7)
|
||||
|
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -257,8 +257,8 @@ importers:
|
||||
specifier: ^1.11.18
|
||||
version: 1.11.18
|
||||
dompurify:
|
||||
specifier: ^3.2.7
|
||||
version: 3.2.7
|
||||
specifier: ^3.2.5
|
||||
version: 3.2.6
|
||||
katex:
|
||||
specifier: ^0.16.22
|
||||
version: 0.16.22
|
||||
@@ -5166,8 +5166,8 @@ packages:
|
||||
resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==}
|
||||
engines: {node: '>= 4'}
|
||||
|
||||
dompurify@3.2.7:
|
||||
resolution: {integrity: sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==}
|
||||
dompurify@3.2.6:
|
||||
resolution: {integrity: sha512-/2GogDQlohXPZe6D6NOgQvXLPSYBqIWMnZ8zzOhn09REE4eyAzb+Hed3jhoM9OkuaJ8P6ZGTTVWQKAi8ieIzfQ==}
|
||||
|
||||
domutils@3.2.2:
|
||||
resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==}
|
||||
@@ -13803,7 +13803,7 @@ snapshots:
|
||||
class-variance-authority: 0.7.1
|
||||
clsx: 2.1.1
|
||||
color-string: 2.1.2
|
||||
dompurify: 3.2.7
|
||||
dompurify: 3.2.6
|
||||
highlight.js: 10.7.3
|
||||
html-to-image: 1.11.13
|
||||
immer: 10.1.3
|
||||
@@ -15416,7 +15416,7 @@ snapshots:
|
||||
dependencies:
|
||||
domelementtype: 2.3.0
|
||||
|
||||
dompurify@3.2.7:
|
||||
dompurify@3.2.6:
|
||||
optionalDependencies:
|
||||
'@types/trusted-types': 2.0.7
|
||||
|
||||
|
Reference in New Issue
Block a user