Skip to content

Commit 70c9e6e

Browse files
committed
Merge branch 'develop' of https://github.com/mermaid-js/mermaid into fix-markdown-labels-6087
2 parents 1f8ba55 + 18f51eb commit 70c9e6e

File tree

15 files changed

+150
-17
lines changed

15 files changed

+150
-17
lines changed

.changeset/brave-memes-flash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix: Support edge animation in hand drawn look

.changeset/busy-mirrors-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix: Resolved parsing error where direction TD was not recognized within subgraphs

.changeset/curly-apes-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix: Improve participant parsing and prevent recursive loops on invalid syntax

cypress/helpers/util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface CypressConfig {
66
listUrl?: boolean;
77
listId?: string;
88
name?: string;
9+
screenshot?: boolean;
910
}
1011
type CypressMermaidConfig = MermaidConfig & CypressConfig;
1112

@@ -90,7 +91,7 @@ export const renderGraph = (
9091

9192
export const openURLAndVerifyRendering = (
9293
url: string,
93-
options: CypressMermaidConfig,
94+
{ screenshot = true, ...options }: CypressMermaidConfig,
9495
validation?: any
9596
): void => {
9697
const name: string = (options.name ?? cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
@@ -103,7 +104,9 @@ export const openURLAndVerifyRendering = (
103104
cy.get('svg').should(validation);
104105
}
105106

106-
verifyScreenshot(name);
107+
if (screenshot) {
108+
verifyScreenshot(name);
109+
}
107110
};
108111

109112
export const verifyScreenshot = (name: string): void => {

cypress/integration/rendering/flowchart-handDrawn.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,4 +1029,19 @@ graph TD
10291029
}
10301030
);
10311031
});
1032+
1033+
it('FDH49: should add edge animation', () => {
1034+
renderGraph(
1035+
`
1036+
flowchart TD
1037+
A(["Start"]) L_A_B_0@--> B{"Decision"}
1038+
B --> C["Option A"] & D["Option B"]
1039+
style C stroke-width:4px,stroke-dasharray: 5
1040+
L_A_B_0@{ animation: slow }
1041+
L_B_D_0@{ animation: fast }`,
1042+
{ look: 'handDrawn', screenshot: false }
1043+
);
1044+
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
1045+
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
1046+
});
10321047
});

cypress/integration/rendering/flowchart.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,21 @@ describe('Graph', () => {
774774
expect(svg).to.not.have.attr('style');
775775
});
776776
});
777+
it('40: should add edge animation', () => {
778+
renderGraph(
779+
`
780+
flowchart TD
781+
A(["Start"]) L_A_B_0@--> B{"Decision"}
782+
B --> C["Option A"] & D["Option B"]
783+
style C stroke-width:4px,stroke-dasharray: 5
784+
L_A_B_0@{ animation: slow }
785+
L_B_D_0@{ animation: fast }`,
786+
{ screenshot: false }
787+
);
788+
// Verify animation classes are applied to both edges
789+
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
790+
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
791+
});
777792
it('58: handle styling with style expressions', () => {
778793
imgSnapshotTest(
779794
`
@@ -973,6 +988,21 @@ graph TD
973988
}
974989
);
975990
});
991+
992+
it('70: should render a subgraph with direction TD', () => {
993+
imgSnapshotTest(
994+
`
995+
flowchart LR
996+
subgraph A
997+
direction TD
998+
a --> b
999+
end
1000+
`,
1001+
{
1002+
fontFamily: 'courier',
1003+
}
1004+
);
1005+
});
9761006
it('#5824: should be able to render string and markdown labels', () => {
9771007
imgSnapshotTest(
9781008
`

cypress/platform/yari.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,10 @@ <h2>Full Example</h2>
603603
</div>
604604
<div class="test">
605605
<pre class="mermaid">
606+
---
607+
config:
608+
theme: dark
609+
---
606610
classDiagram
607611
test ()--() test2
608612
</pre>

packages/mermaid/src/diagrams/class/classDb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ export class ClassDB implements DiagramDB {
627627
padding: config.class!.padding ?? 16,
628628
// parent node must be one of [rect, roundedWithTitle, noteGroup, divider]
629629
shape: 'rect',
630-
cssStyles: ['fill: none', 'stroke: black'],
630+
cssStyles: [],
631631
look: config.look,
632632
};
633633
nodes.push(node);

packages/mermaid/src/diagrams/class/styles.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@ const getStyles = (options) =>
1313
1414
}
1515
16+
.cluster-label text {
17+
fill: ${options.titleColor};
18+
}
19+
.cluster-label span {
20+
color: ${options.titleColor};
21+
}
22+
.cluster-label span p {
23+
background-color: transparent;
24+
}
25+
26+
.cluster rect {
27+
fill: ${options.clusterBkg};
28+
stroke: ${options.clusterBorder};
29+
stroke-width: 1px;
30+
}
31+
32+
.cluster text {
33+
fill: ${options.titleColor};
34+
}
35+
36+
.cluster span {
37+
color: ${options.titleColor};
38+
}
39+
1640
.nodeLabel, .edgeLabel {
1741
color: ${options.classText};
1842
}

packages/mermaid/src/diagrams/flowchart/parser/flow.jison

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ that id.
140140
.*direction\s+BT[^\n]* return 'direction_bt';
141141
.*direction\s+RL[^\n]* return 'direction_rl';
142142
.*direction\s+LR[^\n]* return 'direction_lr';
143+
.*direction\s+TD[^\n]* return 'direction_td';
143144

144145
[^\s\"]+\@(?=[^\{\"]) { return 'LINK_ID'; }
145146
[0-9]+ return 'NUM';
@@ -626,6 +627,8 @@ direction
626627
{ $$={stmt:'dir', value:'RL'};}
627628
| direction_lr
628629
{ $$={stmt:'dir', value:'LR'};}
630+
| direction_td
631+
{ $$={stmt:'dir', value:'TD'};}
629632
;
630633

631634
%%

0 commit comments

Comments
 (0)