Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@
},
"pnpm": {
"patchedDependencies": {
"roughjs": "patches/roughjs.patch",
"dagre-d3-es@7.0.14": "patches/dagre-d3-es@7.0.14.patch"
"roughjs": "patches/roughjs.patch"
},
"onlyBuiltDependencies": [
"canvas",
Expand Down
24 changes: 14 additions & 10 deletions packages/mermaid/src/diagrams/flowchart/flowDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,18 @@ You have to call mermaid.initialize.`

const result = uniq(list.flat());
const nodeList = result.nodeList;
let dir = result.dir;
// Normalize TD ("top-down" alias) to the canonical TB ("top-bottom") that dagre expects,
// mirroring the same normalisation in setDirection() for the top-level graph direction.
if (dir === 'TD') {
dir = 'TB';
}
// Preserve the raw user-authored direction value (e.g. 'TD') on the subGraph
// object so that tests and callers see what the user actually wrote.
// Normalization to dagre's canonical 'TB' happens in getData() when the dir
// is consumed by the layout engine.
const rawDir = result.dir;
// Capture whether the user explicitly wrote a direction keyword BEFORE any
// inheritDir override, so that explicitDir is true only for user-authored
// direction statements.
const hasExplicitDir = rawDir !== undefined;
const flowchartConfig = getConfig().flowchart ?? {};
dir =
dir ??
const dir =
rawDir ??
(flowchartConfig.inheritDir
? (this.getDirection() ?? (getConfig() as any).direction ?? undefined)
: undefined);
Expand All @@ -729,6 +732,7 @@ You have to call mermaid.initialize.`
title: title.trim(),
classes: [],
dir,
hasExplicitDir,
labelType: this.sanitizeNodeLabelType(_title?.type),
};

Expand Down Expand Up @@ -1122,8 +1126,8 @@ You have to call mermaid.initialize.`
cssCompiledStyles: this.getCompiledStyles(subGraph.classes),
cssClasses: subGraph.classes.join(' '),
shape: 'rect',
dir: subGraph.dir,
explicitDir: !!subGraph.dir, // true only when the user wrote an explicit 'direction X' keyword
dir: subGraph.dir === 'TD' ? 'TB' : subGraph.dir, // normalize TD→TB for dagre
explicitDir: subGraph.hasExplicitDir, // true only when the user wrote an explicit 'direction X' keyword
isGroup: true,
look: config.look,
});
Expand Down
1 change: 1 addition & 0 deletions packages/mermaid/src/diagrams/flowchart/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface FlowClass {
export interface FlowSubGraph {
classes: string[];
dir?: string;
hasExplicitDir: boolean;
id: string;
labelType: string;
nodes: string[];
Expand Down
143 changes: 0 additions & 143 deletions patches/dagre-d3-es@7.0.14.patch

This file was deleted.

7 changes: 2 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.