Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new diagram type - Block Diagram #5221

Merged
merged 76 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
86e1bb3
#3358 First commit with basic grammar and 1st test
knsv Jul 5, 2023
791e676
Rename BlockDiagram to Block
nirname Jul 7, 2023
fee2b24
Small cleanup
nirname Jul 7, 2023
975f36c
Fixed block diagram parser import
nirname Jul 7, 2023
c10f765
Adding some more tests
knsv Jul 9, 2023
d165e8a
Started block diag db development
nirname Jul 10, 2023
e251baa
Started layout and rendering
nirname Jul 10, 2023
13114eb
Merge branch 'develop' into 3358-blocks-diagram
knsv Jul 25, 2023
b9531d5
Adding support for compound blocks
knsv Aug 8, 2023
5fc99f1
#3358 Adding db calls from node statements
knsv Aug 28, 2023
aa7f5a8
before refactoring
knsv Sep 1, 2023
8a55b21
Saving data from compound blocks
knsv Sep 1, 2023
e52de6c
Some cleanup
knsv Sep 1, 2023
5f1cfc7
Support for compound blocks with id, title and type
knsv Sep 1, 2023
1e864a5
Rendering, tmp commit before refactoring
knsv Sep 5, 2023
ccdb803
Rendering, interim
knsv Sep 5, 2023
836d3a8
WIP
knsv Sep 14, 2023
b4e3254
#3358 Recursive positioning
knsv Oct 3, 2023
f00871a
#3358 Recursive positioning
knsv Oct 3, 2023
c8d155c
#3358 Recursive positioning
knsv Oct 3, 2023
da79b37
#3358 Recursive positioning paddings
knsv Oct 4, 2023
a641fd5
#3358 Adding support for column statements
knsv Oct 15, 2023
74a9e86
#3358 Putting the elements back in
knsv Oct 15, 2023
5619f87
#3358 Adding support for space blocks and different shapes
knsv Oct 20, 2023
f3f25c7
#3358 Adding support for space blocks and different shapes
knsv Oct 20, 2023
7198fe5
Parsing of block arrows with directions, creating a dedicated new nod…
knsv Oct 26, 2023
03c59ad
Parsing of block arrows with directions, creating a dedicated new nod…
knsv Oct 26, 2023
df858dc
#3358 Adding arrows to syntax
knsv Nov 20, 2023
2ed4469
#3358 Adding arrows to rendering
knsv Jan 4, 2024
d0eca26
#3358 Multiple arrows
knsv Jan 4, 2024
72135c2
#3358 Edge labels
knsv Jan 4, 2024
275e01a
#3358 Adding support for classDef and class statements
knsv Jan 5, 2024
818cb2f
#3358 Adding support for style statements
knsv Jan 5, 2024
809c450
#3358 Support for adding tests and fixed issues for some shapes
knsv Jan 8, 2024
7043892
#3358 Fix for layout where a siebling has wider siize
knsv Jan 8, 2024
1d18757
#3358 Sieblinmg height alignment
knsv Jan 8, 2024
bbc7fe6
#3358 Fix for width of composite blocks
knsv Jan 18, 2024
a0d328d
#3358 Removed logging, fixed som tests
knsv Jan 18, 2024
1230da7
#3358 Some cleanup
knsv Jan 18, 2024
8e14720
#3358 Removed logging som type fixes
knsv Jan 18, 2024
173ba2e
Final console.log removed
knsv Jan 18, 2024
bf64509
Merge branch 'develop' into 3358-blocks-diagram
knsv Jan 18, 2024
5553cbb
Update docs
knsv Jan 18, 2024
d075766
#3358 Doc updates after viewing the page
knsv Jan 18, 2024
b4dece8
Merge branch '3358-blocks-diagram' of github.com:mermaid-js/mermaid i…
knsv Jan 18, 2024
d96425d
#3358 Reviving arrow heads after merging develop
knsv Jan 19, 2024
fe89b95
#3358 Adjusting docs and a bug fix for nested blocks
knsv Jan 22, 2024
c85b248
Merge branch 'develop' into 3358-blocks-diagram
knsv Jan 22, 2024
1629a91
Updated lockfile
knsv Jan 22, 2024
1965f69
Update packages/mermaid/src/schemas/config.schema.yaml
knsv Jan 29, 2024
37d7c7e
#3358 Second set of changes after review
knsv Jan 29, 2024
5aab2ba
Merge branch '3358-blocks-diagram' of github.com:mermaid-js/mermaid i…
knsv Jan 29, 2024
bfa8111
#3358 Third set of changes after review
knsv Jan 29, 2024
dae8a13
Update packages/mermaid/src/defaultConfig.ts
knsv Jan 30, 2024
4823cf5
Update packages/mermaid/src/diagrams/block/blockDB.ts
knsv Jan 30, 2024
1023797
Merge branch 'develop' into 3358-blocks-diagram
knsv Jan 30, 2024
4a14d99
Update packages/mermaid/src/diagrams/block/blockRenderer.ts
knsv Jan 30, 2024
2f8f9dd
Update packages/mermaid/src/diagrams/block/blockDB.ts
knsv Jan 30, 2024
452cb83
#3358 Review changes
knsv Jan 30, 2024
8f8ce2f
Merge branch '3358-blocks-diagram' of github.com:mermaid-js/mermaid i…
knsv Jan 30, 2024
010fc70
Update packages/mermaid/src/diagrams/block/blockTypes.ts
knsv Jan 30, 2024
4a04ce6
Update cypress/integration/rendering/block.spec.ts
knsv Jan 30, 2024
df9b801
#3358 Some fixes
knsv Jan 30, 2024
907006f
#3358 Some fixes
knsv Jan 30, 2024
b99b1bf
#3358 Another set of review changes
knsv Jan 30, 2024
dbcb800
Update docs
knsv Jan 30, 2024
8fdf512
Merge branch 'develop' into 3358-blocks-diagram
knsv Jan 30, 2024
7bcdea9
#3358n Updated lockfile
knsv Jan 30, 2024
6fce617
3358 Adding types for blockArrowHelper
knsv Jan 30, 2024
2bfd5a9
Merge branch 'develop' into 3358-blocks-diagram
sidharthv96 Jan 31, 2024
4786cfb
#3358 Renaming of IOperation to ActionFun
knsv Jan 31, 2024
cd7003e
Merge branch '3358-blocks-diagram' of github.com:mermaid-js/mermaid i…
knsv Jan 31, 2024
13d0b61
Merge branch 'develop' into 3358-blocks-diagram
ashishjain0512 Jan 31, 2024
16149ab
#3358 Fix after review
knsv Feb 1, 2024
d3c5b02
Merge branch '3358-blocks-diagram' of github.com:mermaid-js/mermaid i…
knsv Feb 1, 2024
a7afc11
#3358 Removing redundant file
knsv Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .vite/jsonSchemaPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
'gitGraph',
'c4',
'sankey',
'block',
] as const;

/**
Expand Down
386 changes: 386 additions & 0 deletions cypress/integration/rendering/block.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,386 @@
import { imgSnapshotTest } from '../../helpers/util';
/* eslint-disable no-useless-escape */
describe('Block diagram', () => {
it('BL1: should calculate the block widths', () => {
imgSnapshotTest(
`block-beta
columns 2
block
id2["I am a wide one"]
id1
end
id["Next row"]
`
);
});

it('BL2: should handle colums statement in sub-blocks', () => {
imgSnapshotTest(
`block-beta
id1["Hello"]
block
columns 3
id2["to"]
id3["the"]
id4["World"]
id5["World"]
end
`,
{}
);
});

it('BL3: should align block widths and handle colums statement in sub-blocks', () => {
imgSnapshotTest(
`block-beta
block
columns 1
id1
id2
id2.1
end
id3
id4
`,
{}
);
});

it('BL4: should align block widths and handle colums statements in deeper sub-blocks then 1 level', () => {
imgSnapshotTest(
`block-beta
columns 1
block
columns 1
block
columns 3
id1
id2
id2.1(("XYZ"))
end
id48
end
id3
`,
{}
);
});

it('BL5: should align block widths and handle colums statements in deeper sub-blocks then 1 level (alt)', () => {
imgSnapshotTest(
`block-beta
columns 1
block
id1
id2
block
columns 1
id3("Wider then")
id5(("id5"))
end
end
id4
`,
{}
);
});

it('BL6: should handle block arrows and spece statements', () => {
imgSnapshotTest(
`block-beta
columns 3
space:3
ida idb idc
id1 id2
blockArrowId<["Label"]>(right)
blockArrowId2<["Label"]>(left)
blockArrowId3<["Label"]>(up)
blockArrowId4<["Label"]>(down)
blockArrowId5<["Label"]>(x)
blockArrowId6<["Label"]>(y)
blockArrowId6<["Label"]>(x, down)
`,
{}
);
});

it('BL7: should handle different types of edges', () => {
imgSnapshotTest(
`block-beta
columns 3
A space:5
A --o B
A --> C
A --x D
`,
{}
);
});

it('BL8: should handle sub-blocks without columns statements', () => {
imgSnapshotTest(
`block-beta
columns 2
C A B
block
D
E
end
`,
{}
);
});

it('BL9: should handle edges from blocks in sub blocks to other blocks', () => {
imgSnapshotTest(
`block-beta
columns 3
B space
block
D
end
D --> B
`,
{}
);
});

it('BL10: should handle edges from composite blocks', () => {
imgSnapshotTest(
`block-beta
columns 3
B space
block BL
D
end
BL --> B
`,
{}
);
});

it('BL11: should handle edges to composite blocks', () => {
imgSnapshotTest(
`block-beta
columns 3
B space
block BL
D
end
B --> BL
`,
{}
);
});

it('BL12: edges should handle labels', () => {
imgSnapshotTest(
`block-beta
A
space
A -- "apa" --> E
`,
{}
);
});

it('BL13: should handle block arrows in different directions', () => {
imgSnapshotTest(
`block-beta
columns 3
space blockArrowId1<["down"]>(down) space
blockArrowId2<["right"]>(right) blockArrowId3<["Sync"]>(x, y) blockArrowId4<["left"]>(left)
space blockArrowId5<["up"]>(up) space
blockArrowId6<["x"]>(x) space blockArrowId7<["y"]>(y)
`,
{}
);
});

it('BL14: should style statements and class statements', () => {
imgSnapshotTest(
`block-beta
A
B
classDef blue fill:#66f,stroke:#333,stroke-width:2px;
class A blue
style B fill:#f9F,stroke:#333,stroke-width:4px
`,
{}
);
});

it('BL15: width alignment - D and E should share available space', () => {
imgSnapshotTest(
`block-beta
block
D
E
end
db("This is the text in the box")
`,
{}
);
});

it('BL16: width alignment - C should be as wide as the composite block', () => {
imgSnapshotTest(
`block-beta
block
A("This is the text")
B
end
C
`,
{}
);
});

it('BL16: width alignment - blocks shold be equal in width', () => {
imgSnapshotTest(
`block-beta
A("This is the text")
B
C
`,
{}
);
});

it('BL17: block types 1 - square, rounded and circle', () => {
imgSnapshotTest(
`block-beta
A["square"]
B("rounded")
C(("circle"))
`,
{}
);
});

it('BL18: block types 2 - odd, diamond and hexagon', () => {
imgSnapshotTest(
`block-beta
A>"rect_left_inv_arrow"]
B{"diamond"}
C{{"hexagon"}}
`,
{}
);
});

it('BL19: block types 3 - stadium', () => {
imgSnapshotTest(
`block-beta
A(["stadium"])
`,
{}
);
});

it('BL20: block types 4 - lean right, lean left, trapezoid and inv trapezoid', () => {
imgSnapshotTest(
`block-beta
A[/"lean right"/]
B[\"lean left"\]
C[/"trapezoid"\]
D[\"trapezoid alt"/]
`,
{}
);
});

it('BL21: block types 1 - square, rounded and circle', () => {
imgSnapshotTest(
`block-beta
A["square"]
B("rounded")
C(("circle"))
`,
{}
);
});

it('BL22: sizing - it should be possible to make a block wider', () => {
imgSnapshotTest(
`block-beta
A("rounded"):2
B:2
C
`,
{}
);
});

it('BL23: sizing - it should be possible to make a composite block wider', () => {
imgSnapshotTest(
`block-beta
block:2
A
end
B
`,
{}
);
});

it('BL24: block in the middle with space on each side', () => {
imgSnapshotTest(
`block-beta
columns 3
space
middle["In the middle"]
space
`,
{}
);
});
it('BL25: space and an edge', () => {
imgSnapshotTest(
`block-beta
columns 5
A space B
A --x B
`,
{}
);
});
it('BL26: block sizes for regular blocks', () => {
imgSnapshotTest(
`block-beta
columns 3
a["A wide one"] b:2 c:2 d
`,
{}
);
});
it('BL27: composite block with a set width - f should use the available space', () => {
imgSnapshotTest(
`block-beta
columns 3
a:3
block:e:3
f
end
g
`,
{}
);
});
it('BL23: composite block with a set width - f and g should split the available space', () => {
imgSnapshotTest(
`block-beta
columns 3
a:3
block:e:3
f
g
end
h
i
j
`,
{}
);
});
});