#5237 State diagram bugfixes

This commit is contained in:
Knut Sveidqvist
2024-05-31 10:52:23 +02:00
parent 8bb340182c
commit 520e06d2eb
7 changed files with 30 additions and 10 deletions

View File

@@ -136,13 +136,17 @@ sequenceDiagram
</pre </pre
> >
<pre id="diagram" class="mermaid2"> <pre id="diagram" class="mermaid">
%%{init: {"layout": "elk", "mergeEdges": true} }%%
stateDiagram stateDiagram
A --> B S:Stillas
</pre </pre
> >
<pre id="diagram" class="mermaid"> <pre id="diagram" class="mermaid">
stateDiagram
state "This is a state description" as S
</pre
>
<pre id="diagram" class="mermaid2">
%%{init: {"layout": "elk", "mergeEdges": true} }%% %%{init: {"layout": "elk", "mergeEdges": true} }%%
flowchart flowchart
A --> B(This is B) A --> B(This is B)
@@ -254,8 +258,8 @@ stateDiagram-v2
handdrawnSeed: 12, handdrawnSeed: 12,
look: 'handdrawn', look: 'handdrawn',
'elk.nodePlacement.strategy': 'NETWORK_SIMPLEX', 'elk.nodePlacement.strategy': 'NETWORK_SIMPLEX',
// layout: 'dagre', layout: 'dagre',
layout: 'elk', // layout: 'elk',
flowchart: { titleTopMargin: 10 }, flowchart: { titleTopMargin: 10 },
// fontFamily: 'Caveat', // fontFamily: 'Caveat',
// fontFamily: 'Kalam', // fontFamily: 'Kalam',

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mermaid-chart/mermaid", "name": "@mermaid-chart/mermaid",
"version": "11.0.0-beta.3", "version": "11.0.0-beta.6",
"description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"type": "module", "type": "module",
"module": "./dist/mermaid.core.mjs", "module": "./dist/mermaid.core.mjs",

View File

@@ -408,3 +408,8 @@ export const dataFetcher = (
setupDoc(parsedItem, parsedItem.doc, diagramStates, nodes, edges, !altFlag, useRough, look); setupDoc(parsedItem, parsedItem.doc, diagramStates, nodes, edges, !altFlag, useRough, look);
} }
}; };
export const reset = () => {
nodeDb = {};
graphItemCount = 0;
};

View File

@@ -11,7 +11,7 @@ import {
setDiagramTitle, setDiagramTitle,
getDiagramTitle, getDiagramTitle,
} from '../common/commonDb.js'; } from '../common/commonDb.js';
import { dataFetcher } from './dataFetcher.js'; import { dataFetcher, reset as resetDataFetching } from './dataFetcher.js';
import { import {
DEFAULT_DIAGRAM_DIRECTION, DEFAULT_DIAGRAM_DIRECTION,
@@ -584,9 +584,8 @@ export const getData = () => {
const config = getConfig(); const config = getConfig();
const useRough = config.look === 'handdrawn'; const useRough = config.look === 'handdrawn';
const look = config.look; const look = config.look;
resetDataFetching();
dataFetcher(undefined, getRootDocV2(), diagramStates, nodes, edges, true, useRough, look); dataFetcher(undefined, getRootDocV2(), diagramStates, nodes, edges, true, useRough, look);
console.log('State Nodes XDX:', nodes);
return { nodes, edges, other: {}, config }; return { nodes, edges, other: {}, config };
}; };

View File

@@ -36,6 +36,7 @@ const shapes = {
choice, choice,
note, note,
roundedRect, roundedRect,
rectWithTitle: roundedRect,
squareRect, squareRect,
stadium, stadium,
subroutine, subroutine,

View File

@@ -0,0 +1,12 @@
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
import { drawRect } from './drawRect.js';
export const roundedRect = async (parent: SVGAElement, node: Node) => {
const options = {
rx: 5,
ry: 5,
classes: '',
} as RectOptions;
return drawRect(parent, node, options);
};

View File

@@ -8,6 +8,5 @@ export const roundedRect = async (parent: SVGAElement, node: Node) => {
classes: '', classes: '',
} as RectOptions; } as RectOptions;
console.log('roundedRect XDX');
return drawRect(parent, node, options); return drawRect(parent, node, options);
}; };