Merge pull request #6833 from mermaid-js/6611-block-diagram-arrow-direction

6611: Block diagram shows incorrect arrow direction
This commit is contained in:
Knut Sveidqvist
2025-08-08 07:24:02 +00:00
committed by GitHub
3 changed files with 22 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: correctly render non-directional lines for '---' in block diagrams

View File

@@ -393,6 +393,17 @@ describe('Block diagram', () => {
overflow:3 overflow:3
short:1 short:1
also_overflow:2 also_overflow:2
`,
{}
);
});
it('BL31: edge without arrow syntax should render with no arrowheads', () => {
imgSnapshotTest(
`block-beta
a
b
a --- b
`, `,
{} {}
); );

View File

@@ -238,13 +238,15 @@ export function edgeTypeStr2Type(typeStr: string): string {
} }
export function edgeStrToEdgeData(typeStr: string): string { export function edgeStrToEdgeData(typeStr: string): string {
switch (typeStr.trim()) { switch (typeStr.replace(/^[\s-]+|[\s-]+$/g, '')) {
case '--x': case 'x':
return 'arrow_cross'; return 'arrow_cross';
case '--o': case 'o':
return 'arrow_circle'; return 'arrow_circle';
default: case '>':
return 'arrow_point'; return 'arrow_point';
default:
return '';
} }
} }