mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-11 18:19:42 +02:00
Compare commits
1 Commits
6790-Fix-n
...
renovate/p
Author | SHA1 | Date | |
---|---|---|---|
![]() |
07dee704c5 |
@@ -78,7 +78,7 @@
|
||||
"d3-sankey": "^0.12.3",
|
||||
"dagre-d3-es": "7.0.11",
|
||||
"dayjs": "^1.11.18",
|
||||
"dompurify": "^3.2.5",
|
||||
"dompurify": "^3.2.7",
|
||||
"katex": "^0.16.22",
|
||||
"khroma": "^2.1.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
@@ -27,53 +27,6 @@ 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;
|
||||
@@ -211,9 +164,6 @@ 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;
|
||||
|
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.5
|
||||
version: 3.2.6
|
||||
specifier: ^3.2.7
|
||||
version: 3.2.7
|
||||
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.6:
|
||||
resolution: {integrity: sha512-/2GogDQlohXPZe6D6NOgQvXLPSYBqIWMnZ8zzOhn09REE4eyAzb+Hed3jhoM9OkuaJ8P6ZGTTVWQKAi8ieIzfQ==}
|
||||
dompurify@3.2.7:
|
||||
resolution: {integrity: sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==}
|
||||
|
||||
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.6
|
||||
dompurify: 3.2.7
|
||||
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.6:
|
||||
dompurify@3.2.7:
|
||||
optionalDependencies:
|
||||
'@types/trusted-types': 2.0.7
|
||||
|
||||
|
Reference in New Issue
Block a user