mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-06 15:49:44 +02:00
Compare commits
114 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3877b88e6e | ||
![]() |
bb6c36c6af | ||
![]() |
a4892069d2 | ||
![]() |
5d71afc56a | ||
![]() |
6413cc5ad3 | ||
![]() |
69cc6ddaeb | ||
![]() |
4465a661d0 | ||
![]() |
246e5f5b8b | ||
![]() |
4c11e8ec68 | ||
![]() |
df7ba0a897 | ||
![]() |
b7dd2bb2ce | ||
![]() |
dfca6ae893 | ||
![]() |
09fdd2cd0c | ||
![]() |
15ed52f64a | ||
![]() |
ac6759078b | ||
![]() |
6a9a09c08f | ||
![]() |
77908e8059 | ||
![]() |
2ea68c607c | ||
![]() |
41a6697dc3 | ||
![]() |
953c31cd11 | ||
![]() |
a483a53e26 | ||
![]() |
a3745ca492 | ||
![]() |
571423e909 | ||
![]() |
3873ec941b | ||
![]() |
8188bf1d57 | ||
![]() |
c19319f115 | ||
![]() |
ff3bdfd282 | ||
![]() |
4130386447 | ||
![]() |
9c04595ae8 | ||
![]() |
d1c7f1c2e3 | ||
![]() |
f67b972fdf | ||
![]() |
222fafe686 | ||
![]() |
45c461cd8a | ||
![]() |
afcf1d5f53 | ||
![]() |
4a7a672d96 | ||
![]() |
9cbbfe3a06 | ||
![]() |
c2db4640aa | ||
![]() |
bec7f2eaf0 | ||
![]() |
556f37284c | ||
![]() |
929b421c71 | ||
![]() |
cd67f7a63a | ||
![]() |
59810783d6 | ||
![]() |
0eae5120eb | ||
![]() |
2de2cb64f8 | ||
![]() |
f458e9c003 | ||
![]() |
aa36aee4ee | ||
![]() |
e10bb774e6 | ||
![]() |
3a2f6659a6 | ||
![]() |
2210c73ae8 | ||
![]() |
44d7dfe993 | ||
![]() |
87dc13365f | ||
![]() |
adc15c2989 | ||
![]() |
c69ef282b5 | ||
![]() |
8938d3656e | ||
![]() |
6b7699444a | ||
![]() |
926783fe4c | ||
![]() |
8c293df7af | ||
![]() |
8ce9d2f02f | ||
![]() |
09687e407e | ||
![]() |
ad7630f091 | ||
![]() |
a14b384f65 | ||
![]() |
0e8952984b | ||
![]() |
3d4cfe60af | ||
![]() |
b3235c762e | ||
![]() |
30d8eee631 | ||
![]() |
5c77aa6e8e | ||
![]() |
77f2a57155 | ||
![]() |
91ec41762a | ||
![]() |
7abe279b4a | ||
![]() |
ce04c82356 | ||
![]() |
7746091c98 | ||
![]() |
748ee19b4a | ||
![]() |
7a6d73762e | ||
![]() |
20bbe6cfb0 | ||
![]() |
583d905b88 | ||
![]() |
40479aef77 | ||
![]() |
ab276ccdfe | ||
![]() |
5178de7fef | ||
![]() |
d3d5f12d3c | ||
![]() |
db51adcc26 | ||
![]() |
f38c6a661a | ||
![]() |
3d016ba800 | ||
![]() |
bfeb3a8b3c | ||
![]() |
e73894bfbd | ||
![]() |
c2c753ce7d | ||
![]() |
a352cf3ae5 | ||
![]() |
35f3d57cf3 | ||
![]() |
9bd5652b88 | ||
![]() |
0924a1cef0 | ||
![]() |
0b56686f4d | ||
![]() |
9a398c0a76 | ||
![]() |
db3edb61b4 | ||
![]() |
f4a3f33f36 | ||
![]() |
2305bbed93 | ||
![]() |
a900a8cc17 | ||
![]() |
d48a4bd13d | ||
![]() |
d5c4ea30db | ||
![]() |
979960e8e4 | ||
![]() |
24ee6746f4 | ||
![]() |
4c76b4189c | ||
![]() |
c6dfc9306f | ||
![]() |
d3577eb59b | ||
![]() |
066b7a0d0b | ||
![]() |
be46ace02e | ||
![]() |
e6fc278861 | ||
![]() |
73045b5c6d | ||
![]() |
f6d1f6c825 | ||
![]() |
eae664937d | ||
![]() |
fabaddb10e | ||
![]() |
b18cb6933a | ||
![]() |
6d3ebab529 | ||
![]() |
4369b6cda2 | ||
![]() |
952d360010 | ||
![]() |
f84b6237cf |
4
.github/workflows/update-browserlist.yml
vendored
4
.github/workflows/update-browserlist.yml
vendored
@@ -11,8 +11,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: npx browserslist@latest --update-db
|
- run: npx browserslist@latest --update-db
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
uses: EndBug/add-and-commit@v7
|
uses: EndBug/add-and-commit@v8.0.1
|
||||||
with:
|
with:
|
||||||
author_name: ${{ github.actor }}
|
author_name: ${{ github.actor }}
|
||||||
author_email: ${{ github.actor }}@users.noreply.github.com
|
author_email: ${{ github.actor }}@users.noreply.github.com
|
||||||
message: 'Update Browserslist'
|
message: 'chore: update browsers list'
|
||||||
|
0
.husky/commit-msg
Normal file → Executable file
0
.husky/commit-msg
Normal file → Executable file
0
.husky/pre-commit
Normal file → Executable file
0
.husky/pre-commit
Normal file → Executable file
238
README.md
238
README.md
@@ -35,32 +35,29 @@ For a more detailed introduction to Mermaid and some of its more basic uses, loo
|
|||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
__The following are some examples of the diagrams, charts and graphs that can be made using Mermaid and the Markdown-inspired text specific to it. Click here jump into the [text syntax](https://mermaid-js.github.io/mermaid/#/n00b-syntaxReference).__
|
__The following are some examples of the diagrams, charts and graphs that can be made using Mermaid and the Markdown-inspired text specific to it. Click here jump into the [text syntax](https://mermaid-js.github.io/mermaid/#/n00b-syntaxReference).__
|
||||||
<table>
|
|
||||||
<!-- <Flowchart> -->
|
<!-- <Flowchart> -->
|
||||||
<tr><td colspan=2 align="center">
|
|
||||||
<b>Flow</b></br>
|
## Flowchart [<a href="http://mermaid-js.github.io/mermaid/#/flowchart">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBBW0hhcmRdIC0tPnxUZXh0fCBCKFJvdW5kKVxuICAgIEIgLS0-IEN7RGVjaXNpb259XG4gICAgQyAtLT58T25lfCBEW1Jlc3VsdCAxXVxuICAgIEMgLS0-fFR3b3wgRVtSZXN1bHQgMl0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/flowchart">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBBW0hhcmRdIC0tPnxUZXh0fCBCKFJvdW5kKVxuICAgIEIgLS0-IEN7RGVjaXNpb259XG4gICAgQyAtLT58T25lfCBEW1Jlc3VsdCAxXVxuICAgIEMgLS0-fFR3b3wgRVtSZXN1bHQgMl0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
|
|
||||||
</td></tr>
|
```
|
||||||
<tr>
|
flowchart LR
|
||||||
<td><pre>
|
|
||||||
graph TD
|
|
||||||
A[Hard] -->|Text| B(Round)
|
A[Hard] -->|Text| B(Round)
|
||||||
B --> C{Decision}
|
B --> C{Decision}
|
||||||
C -->|One| D[Result 1]
|
C -->|One| D[Result 1]
|
||||||
C -->|Two| E[Result 2]
|
C -->|Two| E[Result 2]
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-flow.png" />
|
flowchart LR
|
||||||
</td>
|
A[Hard] -->|Text| B(Round)
|
||||||
</tr>
|
B --> C{Decision}
|
||||||
<!-- </Flowchart> -->
|
C -->|One| D[Result 1]
|
||||||
<!-- <Sequence> -->
|
C -->|Two| E[Result 2]
|
||||||
<tr><td colspan=2 align="center">
|
```
|
||||||
<b>Sequence</b><br />
|
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/sequenceDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic2VxdWVuY2VEaWFncmFtXG5BbGljZS0-PkpvaG46IEhlbGxvIEpvaG4sIGhvdyBhcmUgeW91P1xubG9vcCBIZWFsdGhjaGVja1xuICAgIEpvaG4tPj5Kb2huOiBGaWdodCBhZ2FpbnN0IGh5cG9jaG9uZHJpYVxuZW5kXG5Ob3RlIHJpZ2h0IG9mIEpvaG46IFJhdGlvbmFsIHRob3VnaHRzIVxuSm9obi0tPj5BbGljZTogR3JlYXQhXG5Kb2huLT4-Qm9iOiBIb3cgYWJvdXQgeW91P1xuQm9iLS0-PkpvaG46IEpvbGx5IGdvb2QhIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
|
||||||
</td></tr>
|
## Sequence diagram [<a href="http://mermaid-js.github.io/mermaid/#/sequenceDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic2VxdWVuY2VEaWFncmFtXG5BbGljZS0-PkpvaG46IEhlbGxvIEpvaG4sIGhvdyBhcmUgeW91P1xubG9vcCBIZWFsdGhjaGVja1xuICAgIEpvaG4tPj5Kb2huOiBGaWdodCBhZ2FpbnN0IGh5cG9jaG9uZHJpYVxuZW5kXG5Ob3RlIHJpZ2h0IG9mIEpvaG46IFJhdGlvbmFsIHRob3VnaHRzIVxuSm9obi0tPj5BbGljZTogR3JlYXQhXG5Kb2huLT4-Qm9iOiBIb3cgYWJvdXQgeW91P1xuQm9iLS0-PkpvaG46IEpvbGx5IGdvb2QhIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
||||||
<tr>
|
|
||||||
<td><pre>
|
```
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
Alice->>John: Hello John, how are you?
|
Alice->>John: Hello John, how are you?
|
||||||
loop Healthcheck
|
loop Healthcheck
|
||||||
@@ -70,43 +67,48 @@ Note right of John: Rational thoughts!
|
|||||||
John-->>Alice: Great!
|
John-->>Alice: Great!
|
||||||
John->>Bob: How about you?
|
John->>Bob: How about you?
|
||||||
Bob-->>John: Jolly good!
|
Bob-->>John: Jolly good!
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-sequence.png" />
|
sequenceDiagram
|
||||||
</td>
|
Alice->>John: Hello John, how are you?
|
||||||
</tr>
|
loop Healthcheck
|
||||||
<!-- </Sequence> -->
|
John->>John: Fight against hypochondria
|
||||||
<!-- <Gantt> -->
|
end
|
||||||
<tr><td colspan=2 align="center">
|
Note right of John: Rational thoughts!
|
||||||
<b>Gantt</b><br />
|
John-->>Alice: Great!
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/gantt">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2FudHRcbnNlY3Rpb24gU2VjdGlvblxuQ29tcGxldGVkIDpkb25lLCAgICBkZXMxLCAyMDE0LTAxLTA2LDIwMTQtMDEtMDhcbkFjdGl2ZSAgICAgICAgOmFjdGl2ZSwgIGRlczIsIDIwMTQtMDEtMDcsIDNkXG5QYXJhbGxlbCAxICAgOiAgICAgICAgIGRlczMsIGFmdGVyIGRlczEsIDFkXG5QYXJhbGxlbCAyICAgOiAgICAgICAgIGRlczQsIGFmdGVyIGRlczEsIDFkXG5QYXJhbGxlbCAzICAgOiAgICAgICAgIGRlczUsIGFmdGVyIGRlczMsIDFkXG5QYXJhbGxlbCA0ICAgOiAgICAgICAgIGRlczYsIGFmdGVyIGRlczQsIDFkIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
John->>Bob: How about you?
|
||||||
</td></tr>
|
Bob-->>John: Jolly good!
|
||||||
<tr>
|
```
|
||||||
<td><pre>
|
|
||||||
|
## Gantt chart [<a href="http://mermaid-js.github.io/mermaid/#/gantt">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2FudHRcbnNlY3Rpb24gU2VjdGlvblxuQ29tcGxldGVkIDpkb25lLCAgICBkZXMxLCAyMDE0LTAxLTA2LDIwMTQtMDEtMDhcbkFjdGl2ZSAgICAgICAgOmFjdGl2ZSwgIGRlczIsIDIwMTQtMDEtMDcsIDNkXG5QYXJhbGxlbCAxICAgOiAgICAgICAgIGRlczMsIGFmdGVyIGRlczEsIDFkXG5QYXJhbGxlbCAyICAgOiAgICAgICAgIGRlczQsIGFmdGVyIGRlczEsIDFkXG5QYXJhbGxlbCAzICAgOiAgICAgICAgIGRlczUsIGFmdGVyIGRlczMsIDFkXG5QYXJhbGxlbCA0ICAgOiAgICAgICAgIGRlczYsIGFmdGVyIGRlczQsIDFkIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
||||||
|
|
||||||
|
```
|
||||||
gantt
|
gantt
|
||||||
section Section
|
section Section
|
||||||
Completed :done, des1, 2014-01-06,2014-01-08
|
Completed :done, des1, 2014-01-06,2014-01-08
|
||||||
Active :active, des2, 2014-01-07, 3d
|
Active :active, des2, 2014-01-07, 3d
|
||||||
Parallel 1 : des3, after des1, 1d
|
Parallel 1 : des3, after des1, 1d
|
||||||
Parallel 2 : des4, after des1, 1d
|
Parallel 2 : des4, after des1, 1d
|
||||||
Parallel 3 : des5, after des3, 1d
|
Parallel 3 : des5, after des3, 1d
|
||||||
Parallel 4 : des6, after des4, 1d
|
Parallel 4 : des6, after des4, 1d
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-gantt.png" />
|
gantt
|
||||||
</td>
|
section Section
|
||||||
</tr>
|
Completed :done, des1, 2014-01-06,2014-01-08
|
||||||
<!-- </Gantt> -->
|
Active :active, des2, 2014-01-07, 3d
|
||||||
<!-- <Class> -->
|
Parallel 1 : des3, after des1, 1d
|
||||||
<tr><td colspan=2 align="center">
|
Parallel 2 : des4, after des1, 1d
|
||||||
<b>Class</b><br />
|
Parallel 3 : des5, after des3, 1d
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/classDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG5DbGFzczAxIDx8LS0gQXZlcnlMb25nQ2xhc3MgOiBDb29sXG48PGludGVyZmFjZT4-IENsYXNzMDFcbkNsYXNzMDkgLS0-IEMyIDogV2hlcmUgYW0gaT9cbkNsYXNzMDkgLS0qIEMzXG5DbGFzczA5IC0tfD4gQ2xhc3MwN1xuQ2xhc3MwNyA6IGVxdWFscygpXG5DbGFzczA3IDogT2JqZWN0W10gZWxlbWVudERhdGFcbkNsYXNzMDEgOiBzaXplKClcbkNsYXNzMDEgOiBpbnQgY2hpbXBcbkNsYXNzMDEgOiBpbnQgZ29yaWxsYVxuY2xhc3MgQ2xhc3MxMCB7XG4gID4-c2VydmljZT4-XG4gIGludCBpZFxuICBzaXplKClcbn0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
|
Parallel 4 : des6, after des4, 1d
|
||||||
</td></tr>
|
```
|
||||||
<tr>
|
|
||||||
<td><pre>
|
## Class diagram [<a href="http://mermaid-js.github.io/mermaid/#/classDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG5DbGFzczAxIDx8LS0gQXZlcnlMb25nQ2xhc3MgOiBDb29sXG48PGludGVyZmFjZT4-IENsYXNzMDFcbkNsYXNzMDkgLS0-IEMyIDogV2hlcmUgYW0gaT9cbkNsYXNzMDkgLS0qIEMzXG5DbGFzczA5IC0tfD4gQ2xhc3MwN1xuQ2xhc3MwNyA6IGVxdWFscygpXG5DbGFzczA3IDogT2JqZWN0W10gZWxlbWVudERhdGFcbkNsYXNzMDEgOiBzaXplKClcbkNsYXNzMDEgOiBpbnQgY2hpbXBcbkNsYXNzMDEgOiBpbnQgZ29yaWxsYVxuY2xhc3MgQ2xhc3MxMCB7XG4gID4-c2VydmljZT4-XG4gIGludCBpZFxuICBzaXplKClcbn0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
|
||||||
|
|
||||||
|
```
|
||||||
classDiagram
|
classDiagram
|
||||||
Class01 <|-- AveryLongClass : Cool
|
Class01 <|-- AveryLongClass : Cool
|
||||||
<<interface>> Class01
|
<<Interface>> Class01
|
||||||
Class09 --> C2 : Where am i?
|
Class09 --> C2 : Where am i?
|
||||||
Class09 --* C3
|
Class09 --* C3
|
||||||
Class09 --|> Class07
|
Class09 --|> Class07
|
||||||
@@ -116,23 +118,32 @@ Class01 : size()
|
|||||||
Class01 : int chimp
|
Class01 : int chimp
|
||||||
Class01 : int gorilla
|
Class01 : int gorilla
|
||||||
class Class10 {
|
class Class10 {
|
||||||
<<service>>
|
<<service>>
|
||||||
int id
|
int id
|
||||||
size()
|
size()
|
||||||
}
|
}
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-class.png" />
|
classDiagram
|
||||||
</td>
|
Class01 <|-- AveryLongClass : Cool
|
||||||
</tr>
|
<<Interface>> Class01
|
||||||
<!-- </Class> -->
|
Class09 --> C2 : Where am i?
|
||||||
<!-- <State> -->
|
Class09 --* C3
|
||||||
<tr><td colspan=2 align="center">
|
Class09 --|> Class07
|
||||||
<b>State</b><br />
|
Class07 : equals()
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/stateDiagram">docs</a> - <a href="https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtLXYyXG4gICAgWypdIC0tPiBTdGlsbFxuICAgIFN0aWxsIC0tPiBbKl1cbiAgICBTdGlsbCAtLT4gTW92aW5nXG4gICAgTW92aW5nIC0tPiBTdGlsbFxuICAgIE1vdmluZyAtLT4gQ3Jhc2hcbiAgICBDcmFzaCAtLT4gWypdIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQiLCJ0aGVtZVZhcmlhYmxlcyI6eyJiYWNrZ3JvdW5kIjoid2hpdGUiLCJwcmltYXJ5Q29sb3IiOiIjRUNFQ0ZGIiwic2Vjb25kYXJ5Q29sb3IiOiIjZmZmZmRlIiwidGVydGlhcnlDb2xvciI6ImhzbCg4MCwgMTAwJSwgOTYuMjc0NTA5ODAzOSUpIiwicHJpbWFyeUJvcmRlckNvbG9yIjoiaHNsKDI0MCwgNjAlLCA4Ni4yNzQ1MDk4MDM5JSkiLCJzZWNvbmRhcnlCb3JkZXJDb2xvciI6ImhzbCg2MCwgNjAlLCA4My41Mjk0MTE3NjQ3JSkiLCJ0ZXJ0aWFyeUJvcmRlckNvbG9yIjoiaHNsKDgwLCA2MCUsIDg2LjI3NDUwOTgwMzklKSIsInByaW1hcnlUZXh0Q29sb3IiOiIjMTMxMzAwIiwic2Vjb25kYXJ5VGV4dENvbG9yIjoiIzAwMDAyMSIsInRlcnRpYXJ5VGV4dENvbG9yIjoicmdiKDkuNTAwMDAwMDAwMSwgOS41MDAwMDAwMDAxLCA5LjUwMDAwMDAwMDEpIiwibGluZUNvbG9yIjoiIzMzMzMzMyIsInRleHRDb2xvciI6IiMzMzMiLCJtYWluQmtnIjoiI0VDRUNGRiIsInNlY29uZEJrZyI6IiNmZmZmZGUiLCJib3JkZXIxIjoiIzkzNzBEQiIsImJvcmRlcjIiOiIjYWFhYTMzIiwiYXJyb3doZWFkQ29sb3IiOiIjMzMzMzMzIiwiZm9udEZhbWlseSI6IlwidHJlYnVjaGV0IG1zXCIsIHZlcmRhbmEsIGFyaWFsIiwiZm9udFNpemUiOiIxNnB4IiwibGFiZWxCYWNrZ3JvdW5kIjoiI2U4ZThlOCIsIm5vZGVCa2ciOiIjRUNFQ0ZGIiwibm9kZUJvcmRlciI6IiM5MzcwREIiLCJjbHVzdGVyQmtnIjoiI2ZmZmZkZSIsImNsdXN0ZXJCb3JkZXIiOiIjYWFhYTMzIiwiZGVmYXVsdExpbmtDb2xvciI6IiMzMzMzMzMiLCJ0aXRsZUNvbG9yIjoiIzMzMyIsImVkZ2VMYWJlbEJhY2tncm91bmQiOiIjZThlOGU4IiwiYWN0b3JCb3JkZXIiOiJoc2woMjU5LjYyNjE2ODIyNDMsIDU5Ljc3NjUzNjMxMjglLCA4Ny45MDE5NjA3ODQzJSkiLCJhY3RvckJrZyI6IiNFQ0VDRkYiLCJhY3RvclRleHRDb2xvciI6ImJsYWNrIiwiYWN0b3JMaW5lQ29sb3IiOiJncmV5Iiwic2lnbmFsQ29sb3IiOiIjMzMzIiwic2lnbmFsVGV4dENvbG9yIjoiIzMzMyIsImxhYmVsQm94QmtnQ29sb3IiOiIjRUNFQ0ZGIiwibGFiZWxCb3hCb3JkZXJDb2xvciI6ImhzbCgyNTkuNjI2MTY4MjI0MywgNTkuNzc2NTM2MzEyOCUsIDg3LjkwMTk2MDc4NDMlKSIsImxhYmVsVGV4dENvbG9yIjoiYmxhY2siLCJsb29wVGV4dENvbG9yIjoiYmxhY2siLCJub3RlQm9yZGVyQ29sb3IiOiIjYWFhYTMzIiwibm90ZUJrZ0NvbG9yIjoiI2ZmZjVhZCIsIm5vdGVUZXh0Q29sb3IiOiJibGFjayIsImFjdGl2YXRpb25Cb3JkZXJDb2xvciI6IiM2NjYiLCJhY3RpdmF0aW9uQmtnQ29sb3IiOiIjZjRmNGY0Iiwic2VxdWVuY2VOdW1iZXJDb2xvciI6IndoaXRlIiwic2VjdGlvbkJrZ0NvbG9yIjoicmdiYSgxMDIsIDEwMiwgMjU1LCAwLjQ5KSIsImFsdFNlY3Rpb25Ca2dDb2xvciI6IndoaXRlIiwic2VjdGlvbkJrZ0NvbG9yMiI6IiNmZmY0MDAiLCJ0YXNrQm9yZGVyQ29sb3IiOiIjNTM0ZmJjIiwidGFza0JrZ0NvbG9yIjoiIzhhOTBkZCIsInRhc2tUZXh0TGlnaHRDb2xvciI6IndoaXRlIiwidGFza1RleHRDb2xvciI6IndoaXRlIiwidGFza1RleHREYXJrQ29sb3IiOiJibGFjayIsInRhc2tUZXh0T3V0c2lkZUNvbG9yIjoiYmxhY2siLCJ0YXNrVGV4dENsaWNrYWJsZUNvbG9yIjoiIzAwMzE2MyIsImFjdGl2ZVRhc2tCb3JkZXJDb2xvciI6IiM1MzRmYmMiLCJhY3RpdmVUYXNrQmtnQ29sb3IiOiIjYmZjN2ZmIiwiZ3JpZENvbG9yIjoibGlnaHRncmV5IiwiZG9uZVRhc2tCa2dDb2xvciI6ImxpZ2h0Z3JleSIsImRvbmVUYXNrQm9yZGVyQ29sb3IiOiJncmV5IiwiY3JpdEJvcmRlckNvbG9yIjoiI2ZmODg4OCIsImNyaXRCa2dDb2xvciI6InJlZCIsInRvZGF5TGluZUNvbG9yIjoicmVkIiwibGFiZWxDb2xvciI6ImJsYWNrIiwiZXJyb3JCa2dDb2xvciI6IiM1NTIyMjIiLCJlcnJvclRleHRDb2xvciI6IiM1NTIyMjIiLCJjbGFzc1RleHQiOiIjMTMxMzAwIiwiZmlsbFR5cGUwIjoiI0VDRUNGRiIsImZpbGxUeXBlMSI6IiNmZmZmZGUiLCJmaWxsVHlwZTIiOiJoc2woMzA0LCAxMDAlLCA5Ni4yNzQ1MDk4MDM5JSkiLCJmaWxsVHlwZTMiOiJoc2woMTI0LCAxMDAlLCA5My41Mjk0MTE3NjQ3JSkiLCJmaWxsVHlwZTQiOiJoc2woMTc2LCAxMDAlLCA5Ni4yNzQ1MDk4MDM5JSkiLCJmaWxsVHlwZTUiOiJoc2woLTQsIDEwMCUsIDkzLjUyOTQxMTc2NDclKSIsImZpbGxUeXBlNiI6ImhzbCg4LCAxMDAlLCA5Ni4yNzQ1MDk4MDM5JSkiLCJmaWxsVHlwZTciOiJoc2woMTg4LCAxMDAlLCA5My41Mjk0MTE3NjQ3JSkifX0sInVwZGF0ZUVkaXRvciI6ZmFsc2V9">live editor</a>]
|
Class07 : Object[] elementData
|
||||||
</td></tr>
|
Class01 : size()
|
||||||
<tr>
|
Class01 : int chimp
|
||||||
<td><pre>
|
Class01 : int gorilla
|
||||||
|
class Class10 {
|
||||||
|
<<service>>
|
||||||
|
int id
|
||||||
|
size()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## State diagram [<a href="http://mermaid-js.github.io/mermaid/#/stateDiagram">docs</a> - <a href="https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtLXYyXG4gICAgWypdIC0tPiBTdGlsbFxuICAgIFN0aWxsIC0tPiBbKl1cbiAgICBTdGlsbCAtLT4gTW92aW5nXG4gICAgTW92aW5nIC0tPiBTdGlsbFxuICAgIE1vdmluZyAtLT4gQ3Jhc2hcbiAgICBDcmFzaCAtLT4gWypdIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQiLCJ0aGVtZVZhcmlhYmxlcyI6eyJiYWNrZ3JvdW5kIjoid2hpdGUiLCJwcmltYXJ5Q29sb3IiOiIjRUNFQ0ZGIiwic2Vjb25kYXJ5Q29sb3IiOiIjZmZmZmRlIiwidGVydGlhcnlDb2xvciI6ImhzbCg4MCwgMTAwJSwgOTYuMjc0NTA5ODAzOSUpIiwicHJpbWFyeUJvcmRlckNvbG9yIjoiaHNsKDI0MCwgNjAlLCA4Ni4yNzQ1MDk4MDM5JSkiLCJzZWNvbmRhcnlCb3JkZXJDb2xvciI6ImhzbCg2MCwgNjAlLCA4My41Mjk0MTE3NjQ3JSkiLCJ0ZXJ0aWFyeUJvcmRlckNvbG9yIjoiaHNsKDgwLCA2MCUsIDg2LjI3NDUwOTgwMzklKSIsInByaW1hcnlUZXh0Q29sb3IiOiIjMTMxMzAwIiwic2Vjb25kYXJ5VGV4dENvbG9yIjoiIzAwMDAyMSIsInRlcnRpYXJ5VGV4dENvbG9yIjoicmdiKDkuNTAwMDAwMDAwMSwgOS41MDAwMDAwMDAxLCA5LjUwMDAwMDAwMDEpIiwibGluZUNvbG9yIjoiIzMzMzMzMyIsInRleHRDb2xvciI6IiMzMzMiLCJtYWluQmtnIjoiI0VDRUNGRiIsInNlY29uZEJrZyI6IiNmZmZmZGUiLCJib3JkZXIxIjoiIzkzNzBEQiIsImJvcmRlcjIiOiIjYWFhYTMzIiwiYXJyb3doZWFkQ29sb3IiOiIjMzMzMzMzIiwiZm9udEZhbWlseSI6IlwidHJlYnVjaGV0IG1zXCIsIHZlcmRhbmEsIGFyaWFsIiwiZm9udFNpemUiOiIxNnB4IiwibGFiZWxCYWNrZ3JvdW5kIjoiI2U4ZThlOCIsIm5vZGVCa2ciOiIjRUNFQ0ZGIiwibm9kZUJvcmRlciI6IiM5MzcwREIiLCJjbHVzdGVyQmtnIjoiI2ZmZmZkZSIsImNsdXN0ZXJCb3JkZXIiOiIjYWFhYTMzIiwiZGVmYXVsdExpbmtDb2xvciI6IiMzMzMzMzMiLCJ0aXRsZUNvbG9yIjoiIzMzMyIsImVkZ2VMYWJlbEJhY2tncm91bmQiOiIjZThlOGU4IiwiYWN0b3JCb3JkZXIiOiJoc2woMjU5LjYyNjE2ODIyNDMsIDU5Ljc3NjUzNjMxMjglLCA4Ny45MDE5NjA3ODQzJSkiLCJhY3RvckJrZyI6IiNFQ0VDRkYiLCJhY3RvclRleHRDb2xvciI6ImJsYWNrIiwiYWN0b3JMaW5lQ29sb3IiOiJncmV5Iiwic2lnbmFsQ29sb3IiOiIjMzMzIiwic2lnbmFsVGV4dENvbG9yIjoiIzMzMyIsImxhYmVsQm94QmtnQ29sb3IiOiIjRUNFQ0ZGIiwibGFiZWxCb3hCb3JkZXJDb2xvciI6ImhzbCgyNTkuNjI2MTY4MjI0MywgNTkuNzc2NTM2MzEyOCUsIDg3LjkwMTk2MDc4NDMlKSIsImxhYmVsVGV4dENvbG9yIjoiYmxhY2siLCJsb29wVGV4dENvbG9yIjoiYmxhY2siLCJub3RlQm9yZGVyQ29sb3IiOiIjYWFhYTMzIiwibm90ZUJrZ0NvbG9yIjoiI2ZmZjVhZCIsIm5vdGVUZXh0Q29sb3IiOiJibGFjayIsImFjdGl2YXRpb25Cb3JkZXJDb2xvciI6IiM2NjYiLCJhY3RpdmF0aW9uQmtnQ29sb3IiOiIjZjRmNGY0Iiwic2VxdWVuY2VOdW1iZXJDb2xvciI6IndoaXRlIiwic2VjdGlvbkJrZ0NvbG9yIjoicmdiYSgxMDIsIDEwMiwgMjU1LCAwLjQ5KSIsImFsdFNlY3Rpb25Ca2dDb2xvciI6IndoaXRlIiwic2VjdGlvbkJrZ0NvbG9yMiI6IiNmZmY0MDAiLCJ0YXNrQm9yZGVyQ29sb3IiOiIjNTM0ZmJjIiwidGFza0JrZ0NvbG9yIjoiIzhhOTBkZCIsInRhc2tUZXh0TGlnaHRDb2xvciI6IndoaXRlIiwidGFza1RleHRDb2xvciI6IndoaXRlIiwidGFza1RleHREYXJrQ29sb3IiOiJibGFjayIsInRhc2tUZXh0T3V0c2lkZUNvbG9yIjoiYmxhY2siLCJ0YXNrVGV4dENsaWNrYWJsZUNvbG9yIjoiIzAwMzE2MyIsImFjdGl2ZVRhc2tCb3JkZXJDb2xvciI6IiM1MzRmYmMiLCJhY3RpdmVUYXNrQmtnQ29sb3IiOiIjYmZjN2ZmIiwiZ3JpZENvbG9yIjoibGlnaHRncmV5IiwiZG9uZVRhc2tCa2dDb2xvciI6ImxpZ2h0Z3JleSIsImRvbmVUYXNrQm9yZGVyQ29sb3IiOiJncmV5IiwiY3JpdEJvcmRlckNvbG9yIjoiI2ZmODg4OCIsImNyaXRCa2dDb2xvciI6InJlZCIsInRvZGF5TGluZUNvbG9yIjoicmVkIiwibGFiZWxDb2xvciI6ImJsYWNrIiwiZXJyb3JCa2dDb2xvciI6IiM1NTIyMjIiLCJlcnJvclRleHRDb2xvciI6IiM1NTIyMjIiLCJjbGFzc1RleHQiOiIjMTMxMzAwIiwiZmlsbFR5cGUwIjoiI0VDRUNGRiIsImZpbGxUeXBlMSI6IiNmZmZmZGUiLCJmaWxsVHlwZTIiOiJoc2woMzA0LCAxMDAlLCA5Ni4yNzQ1MDk4MDM5JSkiLCJmaWxsVHlwZTMiOiJoc2woMTI0LCAxMDAlLCA5My41Mjk0MTE3NjQ3JSkiLCJmaWxsVHlwZTQiOiJoc2woMTc2LCAxMDAlLCA5Ni4yNzQ1MDk4MDM5JSkiLCJmaWxsVHlwZTUiOiJoc2woLTQsIDEwMCUsIDkzLjUyOTQxMTc2NDclKSIsImZpbGxUeXBlNiI6ImhzbCg4LCAxMDAlLCA5Ni4yNzQ1MDk4MDM5JSkiLCJmaWxsVHlwZTciOiJoc2woMTg4LCAxMDAlLCA5My41Mjk0MTE3NjQ3JSkifX0sInVwZGF0ZUVkaXRvciI6ZmFsc2V9">live editor</a>]
|
||||||
|
```
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> Still
|
[*] --> Still
|
||||||
Still --> [*]
|
Still --> [*]
|
||||||
@@ -140,46 +151,36 @@ Still --> Moving
|
|||||||
Moving --> Still
|
Moving --> Still
|
||||||
Moving --> Crash
|
Moving --> Crash
|
||||||
Crash --> [*]
|
Crash --> [*]
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-state.png" />
|
stateDiagram-v2
|
||||||
</td>
|
[*] --> Still
|
||||||
</tr>
|
Still --> [*]
|
||||||
<!-- </State> -->
|
Still --> Moving
|
||||||
<!-- <Pie> -->
|
Moving --> Still
|
||||||
<tr><td colspan=2 align="center">
|
Moving --> Crash
|
||||||
<b>Pie</b><br />
|
Crash --> [*]
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/pie">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoicGllXG5cIkRvZ3NcIiA6IDQyLjk2XG5cIkNhdHNcIiA6IDUwLjA1XG5cIlJhdHNcIiA6IDEwLjAxIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
```
|
||||||
</td></tr>
|
|
||||||
<tr>
|
### Pie chart [<a href="http://mermaid-js.github.io/mermaid/#/pie">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoicGllXG5cIkRvZ3NcIiA6IDQyLjk2XG5cIkNhdHNcIiA6IDUwLjA1XG5cIlJhdHNcIiA6IDEwLjAxIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
||||||
<td><pre>
|
|
||||||
|
```
|
||||||
pie
|
pie
|
||||||
"Dogs" : 386
|
"Dogs" : 386
|
||||||
"Cats" : 85
|
"Cats" : 85
|
||||||
"Rats" : 15
|
"Rats" : 15
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-pie.png" />
|
pie
|
||||||
</td>
|
"Dogs" : 386
|
||||||
</tr>
|
"Cats" : 85
|
||||||
<!-- </Pie> -->
|
"Rats" : 15
|
||||||
<!-- <Git> -->
|
```
|
||||||
<tr><td colspan=2 align="center">
|
|
||||||
<b>Git</b><br />
|
## Git graph [experimental - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2l0R3JhcGg6XG5vcHRpb25zXG57XG4gICAgXCJub2RlU3BhY2luZ1wiOiAxNTAsXG4gICAgXCJub2RlUmFkaXVzXCI6IDEwXG59XG5lbmRcbmNvbW1pdFxuYnJhbmNoIG5ld2JyYW5jaFxuY2hlY2tvdXQgbmV3YnJhbmNoXG5jb21taXRcbmNvbW1pdFxuY2hlY2tvdXQgbWFzdGVyXG5jb21taXRcbmNvbW1pdFxubWVyZ2UgbmV3YnJhbmNoXG4iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
|
||||||
[experimental - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2l0R3JhcGg6XG5vcHRpb25zXG57XG4gICAgXCJub2RlU3BhY2luZ1wiOiAxNTAsXG4gICAgXCJub2RlUmFkaXVzXCI6IDEwXG59XG5lbmRcbmNvbW1pdFxuYnJhbmNoIG5ld2JyYW5jaFxuY2hlY2tvdXQgbmV3YnJhbmNoXG5jb21taXRcbmNvbW1pdFxuY2hlY2tvdXQgbWFzdGVyXG5jb21taXRcbmNvbW1pdFxubWVyZ2UgbmV3YnJhbmNoXG4iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
|
|
||||||
</td></tr>
|
## User Journey diagram [<a href="http://mermaid-js.github.io/mermaid/#/user-journey">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtXG4gICAgWypdIC0tPiBTdGlsbFxuICAgIFN0aWxsIC0tPiBbKl1cbiAgICBTdGlsbCAtLT4gTW92aW5nXG4gICAgTW92aW5nIC0tPiBTdGlsbFxuICAgIE1vdmluZyAtLT4gQ3Jhc2hcbiAgICBDcmFzaCAtLT4gWypdIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
||||||
<tr>
|
```
|
||||||
<td colspan="2" align="center"><i>Coming soon!</i></td>
|
|
||||||
</tr>
|
|
||||||
<!-- </Git> -->
|
|
||||||
<!-- <Journey> -->
|
|
||||||
<tr><td colspan=2 align="center">
|
|
||||||
<b>User Journey</b><br />
|
|
||||||
[<a href="http://mermaid-js.github.io/mermaid/#/user-journey">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtXG4gICAgWypdIC0tPiBTdGlsbFxuICAgIFN0aWxsIC0tPiBbKl1cbiAgICBTdGlsbCAtLT4gTW92aW5nXG4gICAgTW92aW5nIC0tPiBTdGlsbFxuICAgIE1vdmluZyAtLT4gQ3Jhc2hcbiAgICBDcmFzaCAtLT4gWypdIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
|
|
||||||
</td></tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<pre>
|
|
||||||
journey
|
journey
|
||||||
title My working day
|
title My working day
|
||||||
section Go to work
|
section Go to work
|
||||||
@@ -189,14 +190,18 @@ pie
|
|||||||
section Go home
|
section Go home
|
||||||
Go downstairs: 5: Me
|
Go downstairs: 5: Me
|
||||||
Sit down: 3: Me
|
Sit down: 3: Me
|
||||||
</pre></td>
|
```
|
||||||
<td align="center">
|
```mermaid
|
||||||
<img alt="User Journey Diagram" src="img/gray-user-journey.png" />
|
journey
|
||||||
</td>
|
title My working day
|
||||||
</tr>
|
section Go to work
|
||||||
<!-- </Journey> -->
|
Make tea: 5: Me
|
||||||
|
Go upstairs: 3: Me
|
||||||
</table>
|
Do work: 1: Me, Cat
|
||||||
|
section Go home
|
||||||
|
Go downstairs: 5: Me
|
||||||
|
Sit down: 3: Me
|
||||||
|
```
|
||||||
|
|
||||||
## Related projects
|
## Related projects
|
||||||
|
|
||||||
@@ -210,6 +215,9 @@ Mermaid is a growing community and is always accepting new contributors. There's
|
|||||||
|
|
||||||
Detailed information about how to contribute can be found in the [contribution guide](CONTRIBUTING.md)
|
Detailed information about how to contribute can be found in the [contribution guide](CONTRIBUTING.md)
|
||||||
|
|
||||||
|
## Reporting vulnerabilities
|
||||||
|
To report a vulnerability, please e-mail security@mermaid.live with a description of the issue, the steps you took to create the issue, affected versions, and if known, mitigations for the issue.
|
||||||
|
|
||||||
## Appreciation
|
## Appreciation
|
||||||
A quick note from Knut Sveidqvist:
|
A quick note from Knut Sveidqvist:
|
||||||
>*Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries!*
|
>*Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries!*
|
||||||
@@ -220,4 +228,4 @@ A quick note from Knut Sveidqvist:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Mermaid was created by Knut Sveidqvist for easier documentation.*
|
*Mermaid was created by Knut Sveidqvist for easier documentation.*
|
@@ -40,7 +40,7 @@ __下面是一些使用 Mermaid 和类 Markdown 语法创建的图表示例。
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><pre>
|
<td><pre>
|
||||||
graph TD
|
flowchart TD
|
||||||
A[Hard] -->|Text| B(Round)
|
A[Hard] -->|Text| B(Round)
|
||||||
B --> C{Decision}
|
B --> C{Decision}
|
||||||
C -->|One| D[Result 1]
|
C -->|One| D[Result 1]
|
||||||
@@ -207,6 +207,10 @@ Mermaid 是一个不断发展中的社区,并且还在接收新的贡献者。
|
|||||||
|
|
||||||
关于如何贡献的详细信息可以在 [贡献指南](CONTRIBUTING.md) 中找到。
|
关于如何贡献的详细信息可以在 [贡献指南](CONTRIBUTING.md) 中找到。
|
||||||
|
|
||||||
|
## 报告漏洞
|
||||||
|
|
||||||
|
如果想要报告漏洞,请发送邮件到 security@mermaid.live, 并附上问题的描述、复现问题的步骤、受影响的版本,以及解决问题的方案(如果有的话)。
|
||||||
|
|
||||||
## 鸣谢
|
## 鸣谢
|
||||||
来自 Knut Sveidqvist:
|
来自 Knut Sveidqvist:
|
||||||
>*特别感谢 [d3](http://d3js.org/) 和 [dagre-d3](https://github.com/cpettitt/dagre-d3) 这两个优秀的项目,它们提供了图形布局和绘图工具库! *
|
>*特别感谢 [d3](http://d3js.org/) 和 [dagre-d3](https://github.com/cpettitt/dagre-d3) 这两个优秀的项目,它们提供了图形布局和绘图工具库! *
|
||||||
|
@@ -110,4 +110,9 @@ describe('XSS', () => {
|
|||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
cy.get('#the-malware').should('not.exist');
|
cy.get('#the-malware').should('not.exist');
|
||||||
});
|
});
|
||||||
|
it('should sanitize cardinalities properly in class diagrams', () => {
|
||||||
|
cy.visit('http://localhost:9000/xss18.html');
|
||||||
|
cy.wait(1000);
|
||||||
|
cy.get('#the-malware').should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -183,11 +183,58 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
cy.get('svg');
|
cy.get('svg');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render entities with keys', () => {
|
||||||
|
renderGraph(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
AUTHOR_WITH_LONG_ENTITY_NAME {
|
||||||
|
string name PK
|
||||||
|
}
|
||||||
|
AUTHOR_WITH_LONG_ENTITY_NAME }|..|{ BOOK : writes
|
||||||
|
BOOK {
|
||||||
|
float price
|
||||||
|
string author FK
|
||||||
|
string title PK
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
cy.get('svg');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render entities with comments', () => {
|
||||||
|
renderGraph(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
AUTHOR_WITH_LONG_ENTITY_NAME {
|
||||||
|
string name "comment"
|
||||||
|
}
|
||||||
|
AUTHOR_WITH_LONG_ENTITY_NAME }|..|{ BOOK : writes
|
||||||
|
BOOK {
|
||||||
|
string author
|
||||||
|
string title "author comment"
|
||||||
|
float price "price comment"
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
cy.get('svg');
|
||||||
|
});
|
||||||
|
|
||||||
it('should render entities with keys and comments', () => {
|
it('should render entities with keys and comments', () => {
|
||||||
renderGraph(
|
renderGraph(
|
||||||
`
|
`
|
||||||
erDiagram
|
erDiagram
|
||||||
BOOK { string title PK "comment"}
|
AUTHOR_WITH_LONG_ENTITY_NAME {
|
||||||
|
string name PK "comment"
|
||||||
|
}
|
||||||
|
AUTHOR_WITH_LONG_ENTITY_NAME }|..|{ BOOK : writes
|
||||||
|
BOOK {
|
||||||
|
string description
|
||||||
|
float price "price comment"
|
||||||
|
string title PK "title comment"
|
||||||
|
string author FK
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
|
105
cypress/platform/xss18.html
Normal file
105
cypress/platform/xss18.html
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css?family=Montserrat&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
/* background: rgb(221, 208, 208); */
|
||||||
|
/* background:#333; */
|
||||||
|
font-family: 'Arial';
|
||||||
|
/* font-size: 18px !important; */
|
||||||
|
}
|
||||||
|
h1 { color: grey;}
|
||||||
|
.mermaid2 {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.mermaid svg {
|
||||||
|
/* font-size: 18px !important; */
|
||||||
|
}
|
||||||
|
.malware {
|
||||||
|
position: fixed;
|
||||||
|
bottom:0;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
|
height: 150px;
|
||||||
|
background: red;
|
||||||
|
color: black;
|
||||||
|
display: flex;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 72px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Security check</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div id="diagram" class="mermaid"></div>
|
||||||
|
<div id="res" class=""></div>
|
||||||
|
<script src="./mermaid.js"></script>
|
||||||
|
<script>
|
||||||
|
mermaid.parseError = function (err, hash) {
|
||||||
|
// console.error('Mermaid error: ', err);
|
||||||
|
};
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
arrowMarkerAbsolute: true,
|
||||||
|
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
|
||||||
|
logLevel: 0,
|
||||||
|
state: {
|
||||||
|
defaultRenderer: 'dagre-d3',
|
||||||
|
},
|
||||||
|
flowchart: {
|
||||||
|
// defaultRenderer: 'dagre-wrapper',
|
||||||
|
nodeSpacing: 10,
|
||||||
|
curve: 'cardinal',
|
||||||
|
htmlLabels: true,
|
||||||
|
},
|
||||||
|
htmlLabels: true,
|
||||||
|
// gantt: { axisFormat: '%m/%d/%Y' },
|
||||||
|
sequence: { actorFontFamily: 'courier', actorMargin: 50, showSequenceNumbers: false },
|
||||||
|
// sequenceDiagram: { actorMargin: 300 } // deprecated
|
||||||
|
// fontFamily: '"times", sans-serif',
|
||||||
|
// fontFamily: 'courier',
|
||||||
|
fontSize: 18,
|
||||||
|
curve: 'basis',
|
||||||
|
// securityLevel: 'loose',
|
||||||
|
startOnLoad: false,
|
||||||
|
secure: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize'],
|
||||||
|
// themeVariables: {relationLabelColor: 'red'}
|
||||||
|
});
|
||||||
|
function callback() {
|
||||||
|
alert('It worked');
|
||||||
|
}
|
||||||
|
function xssAttack() {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.id = 'the-malware';
|
||||||
|
div.className = 'malware';
|
||||||
|
div.innerHTML = 'XSS Succeeded';
|
||||||
|
document.getElementsByTagName('body')[0].appendChild(div);
|
||||||
|
throw new Error('XSS Succeded');
|
||||||
|
}
|
||||||
|
|
||||||
|
var diagram = `classDiagram
|
||||||
|
Class "<img/src='x'/onerror=xssAttack(1)>" <--> "<img/src='x'/onerror=xssAttack(2)>" C2: Cool label`;
|
||||||
|
|
||||||
|
// // var diagram = "stateDiagram-v2\n";
|
||||||
|
// // diagram += "<img/src='1'/onerror"
|
||||||
|
// diagram += '//via.placeholder.com/64\' width=64 />"]';
|
||||||
|
// console.log(diagram);
|
||||||
|
// document.querySelector('#diagram').innerHTML = diagram;
|
||||||
|
mermaid.render('diagram', diagram, (res) => {
|
||||||
|
console.log(res);
|
||||||
|
document.querySelector('#res').innerHTML = res;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
107
cypress/platform/xss19.html
Normal file
107
cypress/platform/xss19.html
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css?family=Montserrat&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
/* background: rgb(221, 208, 208); */
|
||||||
|
/* background:#333; */
|
||||||
|
font-family: 'Arial';
|
||||||
|
/* font-size: 18px !important; */
|
||||||
|
}
|
||||||
|
h1 { color: grey;}
|
||||||
|
.mermaid2 {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.mermaid svg {
|
||||||
|
/* font-size: 18px !important; */
|
||||||
|
}
|
||||||
|
.malware {
|
||||||
|
position: fixed;
|
||||||
|
bottom:0;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
|
height: 150px;
|
||||||
|
background: red;
|
||||||
|
color: black;
|
||||||
|
display: flex;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 72px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Security check</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div id="diagram" class="mermaid"></div>
|
||||||
|
<div id="res" class=""></div>
|
||||||
|
<script src="./mermaid.js"></script>
|
||||||
|
<script>
|
||||||
|
mermaid.parseError = function (err, hash) {
|
||||||
|
// console.error('Mermaid error: ', err);
|
||||||
|
};
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
arrowMarkerAbsolute: true,
|
||||||
|
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
|
||||||
|
logLevel: 0,
|
||||||
|
state: {
|
||||||
|
defaultRenderer: 'dagre-d3',
|
||||||
|
},
|
||||||
|
flowchart: {
|
||||||
|
// defaultRenderer: 'dagre-wrapper',
|
||||||
|
nodeSpacing: 10,
|
||||||
|
curve: 'cardinal',
|
||||||
|
htmlLabels: true,
|
||||||
|
},
|
||||||
|
htmlLabels: true,
|
||||||
|
// gantt: { axisFormat: '%m/%d/%Y' },
|
||||||
|
sequence: { actorFontFamily: 'courier', actorMargin: 50, showSequenceNumbers: false },
|
||||||
|
// sequenceDiagram: { actorMargin: 300 } // deprecated
|
||||||
|
// fontFamily: '"times", sans-serif',
|
||||||
|
// fontFamily: 'courier',
|
||||||
|
fontSize: 18,
|
||||||
|
curve: 'basis',
|
||||||
|
// securityLevel: 'loose',
|
||||||
|
startOnLoad: false,
|
||||||
|
secure: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize'],
|
||||||
|
// themeVariables: {relationLabelColor: 'red'}
|
||||||
|
});
|
||||||
|
function callback() {
|
||||||
|
alert('It worked');
|
||||||
|
}
|
||||||
|
function xssAttack() {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.id = 'the-malware';
|
||||||
|
div.className = 'malware';
|
||||||
|
div.innerHTML = 'XSS Succeeded';
|
||||||
|
document.getElementsByTagName('body')[0].appendChild(div);
|
||||||
|
throw new Error('XSS Succeded');
|
||||||
|
}
|
||||||
|
|
||||||
|
var diagram = `classDiagram
|
||||||
|
class Shape{
|
||||||
|
<<<img/src='1'/`;
|
||||||
|
|
||||||
|
// // var diagram = "stateDiagram-v2\n";
|
||||||
|
diagram += `onerror=xssAttack()>>>
|
||||||
|
}`;
|
||||||
|
// diagram += '//via.placeholder.com/64\' width=64 />"]';
|
||||||
|
// console.log(diagram);
|
||||||
|
// document.querySelector('#diagram').innerHTML = diagram;
|
||||||
|
mermaid.render('diagram', diagram, (res) => {
|
||||||
|
console.log(res);
|
||||||
|
document.querySelector('#res').innerHTML = res;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@@ -37,6 +37,13 @@ https://codepen.io/janzeteachesit/pen/OWWZKN
|
|||||||
|
|
||||||
https://codepen.io/Ryuno-Ki/pen/LNxwgR
|
https://codepen.io/Ryuno-Ki/pen/LNxwgR
|
||||||
|
|
||||||
|
## Mermaid in open source docs
|
||||||
|
|
||||||
|
[K8s.io Diagram Guide](https://kubernetes.io/docs/contribute/style/diagram-guide/)
|
||||||
|
|
||||||
|
[K8s.dev blog: Improve your documentation with Mermaid.js diagrams](https://www.kubernetes.dev/blog/2021/12/01/improve-your-documentation-with-mermaid.js-diagrams/)
|
||||||
|
|
||||||
|
|
||||||
## Jupyter Integration with mermaid-js
|
## Jupyter Integration with mermaid-js
|
||||||
|
|
||||||
Here's an example of Python integration with mermaid-js which uses the mermaid.ink service, that displays the graph in a Jupyter notebook.
|
Here's an example of Python integration with mermaid-js which uses the mermaid.ink service, that displays the graph in a Jupyter notebook.
|
||||||
|
@@ -41,7 +41,7 @@ A single instance of a class in the diagram contains three compartments:
|
|||||||
|
|
||||||
- The top compartment contains the name of the class. It is printed in bold and centered, and the first letter is capitalized. It may also contain optional annotation text describing the nature of the class.
|
- The top compartment contains the name of the class. It is printed in bold and centered, and the first letter is capitalized. It may also contain optional annotation text describing the nature of the class.
|
||||||
- The middle compartment contains the attributes of the class. They are left-aligned and the first letter is lowercase.
|
- The middle compartment contains the attributes of the class. They are left-aligned and the first letter is lowercase.
|
||||||
The bottom compartment contains the operations the class can execute. They are also left-aligned and the first letter is lowercase.
|
- The bottom compartment contains the operations the class can execute. They are also left-aligned and the first letter is lowercase.
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
classDiagram
|
classDiagram
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
**Edit this Page** [](https://github.com/mermaid-js/mermaid/blob/develop/docs/directives.md)
|
**Edit this Page** [](https://github.com/mermaid-js/mermaid/blob/develop/docs/directives.md)
|
||||||
|
|
||||||
## Directives
|
## Directives
|
||||||
Directives gives a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration.
|
Directives gives a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration.
|
||||||
|
|
||||||
Directives are divided into two sets or orders, by priority in parsing. The first set, containing 'init' or 'initialize' directives are loaded ahead of any other directive. While the other set, containing all other kinds of directives are parsed and factored into the rendering, only after 'init' and the desired graph-type are declared.
|
Directives are divided into two sets or orders, by priority in parsing. The first set, containing 'init' or 'initialize' directives are loaded ahead of any other directive. While the other set, containing all other kinds of directives are parsed and factored into the rendering, only after 'init' and the desired graph-type are declared.
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Directives are divided into two sets or orders, by priority in parsing. The firs
|
|||||||
init would be an argument-directive: %%{init: { **insert argument here**}}%%
|
init would be an argument-directive: %%{init: { **insert argument here**}}%%
|
||||||
|
|
||||||
The json object that is passed as {**argument** } must be valid key value pairs and encased in quotation marks or it will be ignored.
|
The json object that is passed as {**argument** } must be valid key value pairs and encased in quotation marks or it will be ignored.
|
||||||
Valid Key Value pairs can be found in config.
|
Valid Key Value pairs can be found in config.
|
||||||
|
|
||||||
The init/initialize directive is parsed earlier in the flow, this allows the incorporation of `%%init%%` directives into the mermaid diagram that is being rendered. Example:
|
The init/initialize directive is parsed earlier in the flow, this allows the incorporation of `%%init%%` directives into the mermaid diagram that is being rendered. Example:
|
||||||
```mmd
|
```mmd
|
||||||
@@ -27,11 +27,11 @@ graph >
|
|||||||
A-->B
|
A-->B
|
||||||
```
|
```
|
||||||
|
|
||||||
will set the `logLevel` to `debug` and the `theme` to `dark` for a flowchart diagram, changing the appearance of the diagram itself.
|
will set the `logLevel` to `debug` and the `theme` to `dark` for a flowchart diagram, changing the appearance of the diagram itself.
|
||||||
|
|
||||||
Note: 'init' or 'initialize' are both acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. This means:
|
Note: 'init' or 'initialize' are both acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. This means:
|
||||||
|
|
||||||
```mmd
|
```mmd2
|
||||||
%%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%%
|
%%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%%
|
||||||
%%{initialize: { 'logLevel': 'fatal', "theme":'dark', 'startOnLoad': true } }%%
|
%%{initialize: { 'logLevel': 'fatal', "theme":'dark', 'startOnLoad': true } }%%
|
||||||
...
|
...
|
||||||
@@ -54,7 +54,7 @@ This will then be sent to `mermaid.initialize(...)` for rendering.
|
|||||||
|
|
||||||
In this category are any directives that come after the graph type declaration. Essentially, these directives will only be processed after the init directive. Each individual graph type will handle these directives. As an example:
|
In this category are any directives that come after the graph type declaration. Essentially, these directives will only be processed after the init directive. Each individual graph type will handle these directives. As an example:
|
||||||
|
|
||||||
```mmd
|
```
|
||||||
%%{init: { 'logLevel': 'debug', 'theme': 'dark' } }%%
|
%%{init: { 'logLevel': 'debug', 'theme': 'dark' } }%%
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
%%{config: { 'fontFamily': 'Menlo', 'fontSize': 18, 'fontWeight': 400} }%%
|
%%{config: { 'fontFamily': 'Menlo', 'fontSize': 18, 'fontWeight': 400} }%%
|
||||||
@@ -79,6 +79,6 @@ Init directives and any other non-multiline directives should be backwards compa
|
|||||||
|
|
||||||
Multiline directives, however, will pose an issue and will render an error. This is unavoidable.
|
Multiline directives, however, will pose an issue and will render an error. This is unavoidable.
|
||||||
|
|
||||||
# example
|
# example
|
||||||
|
|
||||||
|
|
||||||
|
@@ -137,20 +137,20 @@ The `type` and `name` values must begin with an alphabetic character and may con
|
|||||||
|
|
||||||
#### Attribute Keys and Comments
|
#### Attribute Keys and Comments
|
||||||
|
|
||||||
Attributes may also have a `key` or comment defined. Keys can be "PK" or "FK", for Primary Key or Foreign Key. And a `comment` is defined by quotes at the end of an attribute. Comments themselves cannot have quote characters in them.
|
Attributes may also have a `key` or comment defined. Keys can be "PK" or "FK", for Primary Key or Foreign Key. And a `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
erDiagram
|
erDiagram
|
||||||
CAR ||--o{ NAMED-DRIVER : allows
|
CAR ||--o{ NAMED-DRIVER : allows
|
||||||
CAR {
|
CAR {
|
||||||
string allowedDriver FK 'The license of the allowed driver'
|
string allowedDriver FK "The license of the allowed driver"
|
||||||
string registrationNumber
|
string registrationNumber
|
||||||
string make
|
string make
|
||||||
string model
|
string model
|
||||||
}
|
}
|
||||||
PERSON ||--o{ NAMED-DRIVER : is
|
PERSON ||--o{ NAMED-DRIVER : is
|
||||||
PERSON {
|
PERSON {
|
||||||
string driversLicense PK 'The license #'
|
string driversLicense PK "The license #"
|
||||||
string firstName
|
string firstName
|
||||||
string lastName
|
string lastName
|
||||||
int age
|
int age
|
||||||
|
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
|
|
||||||
It is important to remember that when a date, day, or collection of dates specific to a task are "excluded", the Gantt Chart will accomodate those changes by extending an equal number of days, towards the right, not by creating a gap inside the task.
|
It is important to remember that when a date, day, or collection of dates specific to a task are "excluded", the Gantt Chart will accomodate those changes by extending an equal number of days, towards the right, not by creating a gap inside the task.
|
||||||
As shown here 
|
As shown here 
|
||||||
|
|
||||||
|
|
||||||
However, if the excluded dates are between two tasks that are set to start consecutively, the excluded dates will be skipped graphically and left blank, and the following task will begin after the end of the excluded dates.
|
However, if the excluded dates are between two tasks that are set to start consecutively, the excluded dates will be skipped graphically and left blank, and the following task will begin after the end of the excluded dates.
|
||||||
As shown here 
|
As shown here 
|
||||||
|
|
||||||
A Gantt chart is useful for tracking the amount of time it would take before a project is finished, but it can also be used to graphically represent "non-working days", with a few tweaks.
|
A Gantt chart is useful for tracking the amount of time it would take before a project is finished, but it can also be used to graphically represent "non-working days", with a few tweaks.
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ They also serve as proof of concept, for the variety of things that can be built
|
|||||||
- [Azure Devops](https://docs.microsoft.com/en-us/azure/devops/project/wiki/wiki-markdown-guidance?view=azure-devops#add-mermaid-diagrams-to-a-wiki-page) (**Native support**)
|
- [Azure Devops](https://docs.microsoft.com/en-us/azure/devops/project/wiki/wiki-markdown-guidance?view=azure-devops#add-mermaid-diagrams-to-a-wiki-page) (**Native support**)
|
||||||
- [Tuleap](https://docs.tuleap.org/user-guide/writing-in-tuleap.html#graphs) (**Native support**)
|
- [Tuleap](https://docs.tuleap.org/user-guide/writing-in-tuleap.html#graphs) (**Native support**)
|
||||||
- [Joplin](https://joplinapp.org) (**Native support**)
|
- [Joplin](https://joplinapp.org) (**Native support**)
|
||||||
|
- [Notion](https://notion.so) (**Native support**)
|
||||||
- [GitHub](https://github.com)
|
- [GitHub](https://github.com)
|
||||||
- [GitHub action: Compile mermaid to image](https://github.com/neenjaw/compile-mermaid-markdown-action)
|
- [GitHub action: Compile mermaid to image](https://github.com/neenjaw/compile-mermaid-markdown-action)
|
||||||
- [svg-generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
|
- [svg-generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
|
||||||
@@ -74,7 +75,8 @@ They also serve as proof of concept, for the variety of things that can be built
|
|||||||
- [Flowcharts](https://www.dokuwiki.org/plugin:flowcharts?s[]=mermaid)
|
- [Flowcharts](https://www.dokuwiki.org/plugin:flowcharts?s[]=mermaid)
|
||||||
- [ComboStrap](https://combostrap.com/mermaid)
|
- [ComboStrap](https://combostrap.com/mermaid)
|
||||||
- [TiddlyWiki](https://tiddlywiki.com/)
|
- [TiddlyWiki](https://tiddlywiki.com/)
|
||||||
- [mermaid-tw5-plugin](https://github.com/michaeljmcd/mermaid-tw5-plugin)
|
- [mermaid-tw5: full js library](https://github.com/efurlanm/mermaid-tw5)
|
||||||
|
- [tw5-mermaid: wrapper for Mermaid Live](https://github.com/jasonmhoule/tw5-mermaid)
|
||||||
|
|
||||||
## Editor Plugins
|
## Editor Plugins
|
||||||
|
|
||||||
@@ -130,7 +132,7 @@ They also serve as proof of concept, for the variety of things that can be built
|
|||||||
- [jSDoc](https://jsdoc.app/)
|
- [jSDoc](https://jsdoc.app/)
|
||||||
- [jsdoc-mermaid](https://github.com/Jellyvision/jsdoc-mermaid)
|
- [jsdoc-mermaid](https://github.com/Jellyvision/jsdoc-mermaid)
|
||||||
- [MkDocs](https://mkdocs.org)
|
- [MkDocs](https://mkdocs.org)
|
||||||
- [MarkdownMermaid](https://github.com/sebastienwarin/mkdocs-mermaid-plugin)
|
- [mkdocs-mermaid2-plugin](https://github.com/fralau/mkdocs-mermaid2-plugin)
|
||||||
- [Type Doc](https://typedoc.org/)
|
- [Type Doc](https://typedoc.org/)
|
||||||
- [typedoc-plugin-mermaid](https://www.npmjs.com/package/typedoc-plugin-mermaid)
|
- [typedoc-plugin-mermaid](https://www.npmjs.com/package/typedoc-plugin-mermaid)
|
||||||
- [Docsy Hugo Theme](https://www.docsy.dev/docs/adding-content/lookandfeel/#diagrams-with-mermaid) (Native support in theme)
|
- [Docsy Hugo Theme](https://www.docsy.dev/docs/adding-content/lookandfeel/#diagrams-with-mermaid) (Native support in theme)
|
||||||
|
@@ -95,7 +95,10 @@ c. The `mermaid.initialize()` call, which dictates the appearance of diagrams an
|
|||||||
<body>
|
<body>
|
||||||
Here is a mermaid diagram:
|
Here is a mermaid diagram:
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
graph TD A[Client] --> B[Load Balancer] B --> C[Server01] B --> D[Server02]
|
graph TD
|
||||||
|
A[Client] --> B[Load Balancer]
|
||||||
|
B --> C[Server01]
|
||||||
|
B --> D[Server02]
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
```
|
```
|
||||||
@@ -137,13 +140,19 @@ Rendering in Mermaid is initalized by `mermaid.initialize()` call. You can place
|
|||||||
|
|
||||||
Here is one mermaid diagram:
|
Here is one mermaid diagram:
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
graph TD A[Client] --> B[Load Balancer] B --> C[Server1] B --> D[Server2]
|
graph TD
|
||||||
|
A[Client] --> B[Load Balancer]
|
||||||
|
B --> C[Server1]
|
||||||
|
B --> D[Server2]
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
And here is another:
|
And here is another:
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
graph TD A[Client] -->|tcp_123| B(Load Balancer) B -->|tcp_456| C[Server1] B
|
graph TD
|
||||||
-->|tcp_456| D[Server2]
|
A[Client] -->|tcp_123|
|
||||||
|
B(Load Balancer)
|
||||||
|
B -->|tcp_456| C[Server1]
|
||||||
|
B -->|tcp_456| D[Server2]
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -159,10 +168,16 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
graph LR A --- B B-->C[fa:fa-ban forbidden] B-->D(fa:fa-spinner);
|
graph LR
|
||||||
|
A --- B
|
||||||
|
B-->C[fa:fa-ban forbidden]
|
||||||
|
B-->D(fa:fa-spinner);
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
graph TD A[Client] --> B[Load Balancer] B --> C[Server1] B --> D[Server2]
|
graph TD
|
||||||
|
A[Client] --> B[Load Balancer]
|
||||||
|
B --> C[Server1]
|
||||||
|
B --> D[Server2]
|
||||||
</div>
|
</div>
|
||||||
<script src="The\Path\In\Your\Package\mermaid.js"></script>
|
<script src="The\Path\In\Your\Package\mermaid.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@@ -46,14 +46,6 @@ sequenceDiagram
|
|||||||
Bob->>Alice: Hi Alice
|
Bob->>Alice: Hi Alice
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid-example
|
|
||||||
sequenceDiagram
|
|
||||||
actor Alice
|
|
||||||
actor Bob
|
|
||||||
Alice->>Bob: Hi Bob
|
|
||||||
Bob->>Alice: Hi Alice
|
|
||||||
```
|
|
||||||
|
|
||||||
### Aliases
|
### Aliases
|
||||||
|
|
||||||
The actor can have a convenient identifier and a descriptive label.
|
The actor can have a convenient identifier and a descriptive label.
|
||||||
|
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mermaid",
|
"name": "mermaid",
|
||||||
"version": "8.13.8",
|
"version": "8.13.10",
|
||||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||||
"main": "dist/mermaid.core.js",
|
"main": "dist/mermaid.core.js",
|
||||||
"module": "dist/mermaid.esm.min.mjs",
|
"module": "dist/mermaid.esm.min.mjs",
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"d3": "^7.0.0",
|
"d3": "^7.0.0",
|
||||||
"dagre": "^0.8.5",
|
"dagre": "^0.8.5",
|
||||||
"dagre-d3": "^0.6.4",
|
"dagre-d3": "^0.6.4",
|
||||||
"dompurify": "2.3.4",
|
"dompurify": "2.3.5",
|
||||||
"graphlib": "^2.1.8",
|
"graphlib": "^2.1.8",
|
||||||
"khroma": "^1.4.1",
|
"khroma": "^1.4.1",
|
||||||
"moment-mini": "^2.24.0",
|
"moment-mini": "^2.24.0",
|
||||||
@@ -72,23 +72,23 @@
|
|||||||
"@babel/eslint-parser": "^7.14.7",
|
"@babel/eslint-parser": "^7.14.7",
|
||||||
"@babel/preset-env": "^7.14.7",
|
"@babel/preset-env": "^7.14.7",
|
||||||
"@babel/register": "^7.14.5",
|
"@babel/register": "^7.14.5",
|
||||||
"@commitlint/cli": "^15.0.0",
|
"@commitlint/cli": "^16.0.0",
|
||||||
"@commitlint/config-conventional": "^15.0.0",
|
"@commitlint/config-conventional": "^16.0.0",
|
||||||
"@percy/cli": "^1.0.0-beta.58",
|
"@percy/cli": "^1.0.0-beta.58",
|
||||||
"@percy/cypress": "^3.1.0",
|
"@percy/cypress": "^3.1.0",
|
||||||
"@percy/migrate": "^0.11.0",
|
"@percy/migrate": "^0.11.0",
|
||||||
"babel-jest": "^27.0.6",
|
"babel-jest": "^27.0.6",
|
||||||
"babel-loader": "^8.2.2",
|
"babel-loader": "^8.2.2",
|
||||||
"concurrently": "^6.2.2",
|
"concurrently": "^7.0.0",
|
||||||
"coveralls": "^3.0.2",
|
"coveralls": "^3.0.2",
|
||||||
"css-to-string-loader": "^0.1.3",
|
"css-to-string-loader": "^0.1.3",
|
||||||
"cypress": "9.1.1",
|
"cypress": "9.4.1",
|
||||||
"documentation": "13.2.0",
|
"documentation": "13.2.0",
|
||||||
"eslint": "^8.2.0",
|
"eslint": "^8.2.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-cypress": "^2.12.1",
|
"eslint-plugin-cypress": "^2.12.1",
|
||||||
"eslint-plugin-html": "^6.2.0",
|
"eslint-plugin-html": "^6.2.0",
|
||||||
"eslint-plugin-jest": "^25.2.4",
|
"eslint-plugin-jest": "^26.0.0",
|
||||||
"eslint-plugin-jsdoc": "^37.0.3",
|
"eslint-plugin-jsdoc": "^37.0.3",
|
||||||
"eslint-plugin-markdown": "^2.2.1",
|
"eslint-plugin-markdown": "^2.2.1",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { log } from '../logger'; // eslint-disable-line
|
import { log } from '../logger'; // eslint-disable-line
|
||||||
import { getConfig } from '../config';
|
import { getConfig } from '../config';
|
||||||
import { evaluate } from '../diagrams/common/common';
|
import { sanitizeText, evaluate } from '../diagrams/common/common';
|
||||||
|
|
||||||
|
const sanitizeTxt = (txt) => sanitizeText(txt, getConfig());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dom
|
* @param dom
|
||||||
|
@@ -35,7 +35,7 @@ const config = {
|
|||||||
theme: 'default',
|
theme: 'default',
|
||||||
themeVariables: theme['default'].getThemeVariables(),
|
themeVariables: theme['default'].getThemeVariables(),
|
||||||
themeCSS: undefined,
|
themeCSS: undefined,
|
||||||
/* **maxTextSize** - The maximum allowed size of the users text diamgram */
|
/* **maxTextSize** - The maximum allowed size of the users text diagram */
|
||||||
maxTextSize: 50000,
|
maxTextSize: 50000,
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
|
|
||||||
|
@@ -13,6 +13,8 @@ let classCounter = 0;
|
|||||||
|
|
||||||
let funs = [];
|
let funs = [];
|
||||||
|
|
||||||
|
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
|
||||||
|
|
||||||
export const parseDirective = function (statement, context, type) {
|
export const parseDirective = function (statement, context, type) {
|
||||||
mermaidAPI.parseDirective(this, statement, context, type);
|
mermaidAPI.parseDirective(this, statement, context, type);
|
||||||
};
|
};
|
||||||
@@ -96,6 +98,16 @@ export const addRelation = function (relation) {
|
|||||||
relation.id1 = splitClassNameAndType(relation.id1).className;
|
relation.id1 = splitClassNameAndType(relation.id1).className;
|
||||||
relation.id2 = splitClassNameAndType(relation.id2).className;
|
relation.id2 = splitClassNameAndType(relation.id2).className;
|
||||||
|
|
||||||
|
relation.relationTitle1 = common.sanitizeText(
|
||||||
|
relation.relationTitle1.trim(),
|
||||||
|
configApi.getConfig()
|
||||||
|
);
|
||||||
|
|
||||||
|
relation.relationTitle2 = common.sanitizeText(
|
||||||
|
relation.relationTitle2.trim(),
|
||||||
|
configApi.getConfig()
|
||||||
|
);
|
||||||
|
|
||||||
relations.push(relation);
|
relations.push(relation);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -131,11 +143,11 @@ export const addMember = function (className, member) {
|
|||||||
|
|
||||||
if (memberString.startsWith('<<') && memberString.endsWith('>>')) {
|
if (memberString.startsWith('<<') && memberString.endsWith('>>')) {
|
||||||
// Remove leading and trailing brackets
|
// Remove leading and trailing brackets
|
||||||
theClass.annotations.push(memberString.substring(2, memberString.length - 2));
|
theClass.annotations.push(sanitizeText(memberString.substring(2, memberString.length - 2)));
|
||||||
} else if (memberString.indexOf(')') > 0) {
|
} else if (memberString.indexOf(')') > 0) {
|
||||||
theClass.methods.push(memberString);
|
theClass.methods.push(sanitizeText(memberString));
|
||||||
} else if (memberString) {
|
} else if (memberString) {
|
||||||
theClass.members.push(memberString);
|
theClass.members.push(sanitizeText(memberString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -151,7 +163,7 @@ export const cleanupLabel = function (label) {
|
|||||||
if (label.substring(0, 1) === ':') {
|
if (label.substring(0, 1) === ':') {
|
||||||
return common.sanitizeText(label.substr(1).trim(), configApi.getConfig());
|
return common.sanitizeText(label.substr(1).trim(), configApi.getConfig());
|
||||||
} else {
|
} else {
|
||||||
return label.trim();
|
return sanitizeText(label.trim());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -17,6 +17,8 @@ parser.yy = classDb;
|
|||||||
let idCache = {};
|
let idCache = {};
|
||||||
const padding = 20;
|
const padding = 20;
|
||||||
|
|
||||||
|
const sanitizeText = (txt) => common.sanitizeText(txt, getConfig());
|
||||||
|
|
||||||
const conf = {
|
const conf = {
|
||||||
dividerMargin: 10,
|
dividerMargin: 10,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
@@ -103,7 +105,7 @@ export const addClasses = function (classes, g) {
|
|||||||
g.setNode(vertex.id, {
|
g.setNode(vertex.id, {
|
||||||
labelStyle: styles.labelStyle,
|
labelStyle: styles.labelStyle,
|
||||||
shape: _shape,
|
shape: _shape,
|
||||||
labelText: vertexText,
|
labelText: sanitizeText(vertexText),
|
||||||
classData: vertex,
|
classData: vertex,
|
||||||
rx: radious,
|
rx: radious,
|
||||||
ry: radious,
|
ry: radious,
|
||||||
|
@@ -18,8 +18,6 @@ export const removeEscapes = (text) => {
|
|||||||
return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
|
return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(newStr);
|
|
||||||
|
|
||||||
newStr = newStr.replace(/\\x([0-9a-f]{2})/gi, (_, c) => String.fromCharCode(parseInt(c, 16)));
|
newStr = newStr.replace(/\\x([0-9a-f]{2})/gi, (_, c) => String.fromCharCode(parseInt(c, 16)));
|
||||||
newStr = newStr.replace(/\\[\d\d\d]{3}/gi, function (match) {
|
newStr = newStr.replace(/\\[\d\d\d]{3}/gi, function (match) {
|
||||||
return String.fromCharCode(parseInt(match.replace(/\\/g, ''), 8));
|
return String.fromCharCode(parseInt(match.replace(/\\/g, ''), 8));
|
||||||
|
@@ -40,7 +40,6 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
const attributeNodes = []; // Intermediate storage for attribute nodes created so that we can do a second pass
|
const attributeNodes = []; // Intermediate storage for attribute nodes created so that we can do a second pass
|
||||||
let hasKeyType = false;
|
let hasKeyType = false;
|
||||||
let hasComment = false;
|
let hasComment = false;
|
||||||
let maxWidth = 0;
|
|
||||||
let maxTypeWidth = 0;
|
let maxTypeWidth = 0;
|
||||||
let maxNameWidth = 0;
|
let maxNameWidth = 0;
|
||||||
let maxKeyWidth = 0;
|
let maxKeyWidth = 0;
|
||||||
@@ -48,9 +47,19 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
let cumulativeHeight = labelBBox.height + heightPadding * 2;
|
let cumulativeHeight = labelBBox.height + heightPadding * 2;
|
||||||
let attrNum = 1;
|
let attrNum = 1;
|
||||||
|
|
||||||
|
// Check to see if any of the attributes has a key or a comment
|
||||||
|
attributes.forEach((item) => {
|
||||||
|
if (item.attributeKeyType !== undefined) {
|
||||||
|
hasKeyType = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.attributeComment !== undefined) {
|
||||||
|
hasComment = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
attributes.forEach((item) => {
|
attributes.forEach((item) => {
|
||||||
const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`;
|
const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`;
|
||||||
let nodeWidth = 0;
|
|
||||||
let nodeHeight = 0;
|
let nodeHeight = 0;
|
||||||
|
|
||||||
// Add a text node for the attribute type
|
// Add a text node for the attribute type
|
||||||
@@ -91,16 +100,14 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
const nameBBox = nameNode.node().getBBox();
|
const nameBBox = nameNode.node().getBBox();
|
||||||
maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width);
|
maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width);
|
||||||
maxNameWidth = Math.max(maxNameWidth, nameBBox.width);
|
maxNameWidth = Math.max(maxNameWidth, nameBBox.width);
|
||||||
nodeWidth += typeBBox.width;
|
|
||||||
nodeWidth += nameBBox.width;
|
|
||||||
|
|
||||||
nodeHeight = Math.max(typeBBox.height, nameBBox.height);
|
nodeHeight = Math.max(typeBBox.height, nameBBox.height);
|
||||||
|
|
||||||
if (hasKeyType || item.attributeKeyType !== undefined) {
|
if (hasKeyType) {
|
||||||
const keyTypeNode = groupNode
|
const keyTypeNode = groupNode
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('class', 'er entityLabel')
|
.attr('class', 'er entityLabel')
|
||||||
.attr('id', `${attrPrefix}-name`)
|
.attr('id', `${attrPrefix}-key`)
|
||||||
.attr('x', 0)
|
.attr('x', 0)
|
||||||
.attr('y', 0)
|
.attr('y', 0)
|
||||||
.attr('dominant-baseline', 'middle')
|
.attr('dominant-baseline', 'middle')
|
||||||
@@ -113,17 +120,15 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
|
|
||||||
attributeNode.kn = keyTypeNode;
|
attributeNode.kn = keyTypeNode;
|
||||||
const keyTypeBBox = keyTypeNode.node().getBBox();
|
const keyTypeBBox = keyTypeNode.node().getBBox();
|
||||||
nodeWidth += keyTypeBBox.width;
|
maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width);
|
||||||
maxKeyWidth = Math.max(maxKeyWidth, nodeWidth);
|
|
||||||
nodeHeight = Math.max(nodeHeight, keyTypeBBox.height);
|
nodeHeight = Math.max(nodeHeight, keyTypeBBox.height);
|
||||||
hasKeyType = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasComment || item.attributeComment !== undefined) {
|
if (hasComment) {
|
||||||
const commentNode = groupNode
|
const commentNode = groupNode
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('class', 'er entityLabel')
|
.attr('class', 'er entityLabel')
|
||||||
.attr('id', `${attrPrefix}-name`)
|
.attr('id', `${attrPrefix}-comment`)
|
||||||
.attr('x', 0)
|
.attr('x', 0)
|
||||||
.attr('y', 0)
|
.attr('y', 0)
|
||||||
.attr('dominant-baseline', 'middle')
|
.attr('dominant-baseline', 'middle')
|
||||||
@@ -136,25 +141,35 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
|
|
||||||
attributeNode.cn = commentNode;
|
attributeNode.cn = commentNode;
|
||||||
const commentNodeBBox = commentNode.node().getBBox();
|
const commentNodeBBox = commentNode.node().getBBox();
|
||||||
nodeWidth += commentNodeBBox.width;
|
maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width);
|
||||||
maxCommentWidth = Math.max(nodeWidth, nameBBox.width);
|
|
||||||
nodeHeight = Math.max(nodeHeight, commentNodeBBox.height);
|
nodeHeight = Math.max(nodeHeight, commentNodeBBox.height);
|
||||||
hasComment = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attributeNode.height = nodeHeight;
|
attributeNode.height = nodeHeight;
|
||||||
// Keep a reference to the nodes so that we can iterate through them later
|
// Keep a reference to the nodes so that we can iterate through them later
|
||||||
attributeNodes.push(attributeNode);
|
attributeNodes.push(attributeNode);
|
||||||
maxWidth = Math.max(maxWidth, nodeWidth);
|
|
||||||
cumulativeHeight += nodeHeight + heightPadding * 2;
|
cumulativeHeight += nodeHeight + heightPadding * 2;
|
||||||
attrNum += 1;
|
attrNum += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let widthPaddingFactor = 4;
|
||||||
|
if (hasKeyType) {
|
||||||
|
widthPaddingFactor += 2;
|
||||||
|
}
|
||||||
|
if (hasComment) {
|
||||||
|
widthPaddingFactor += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth;
|
||||||
|
|
||||||
// Calculate the new bounding box of the overall entity, now that attributes have been added
|
// Calculate the new bounding box of the overall entity, now that attributes have been added
|
||||||
const bBox = {
|
const bBox = {
|
||||||
width: Math.max(
|
width: Math.max(
|
||||||
conf.minEntityWidth,
|
conf.minEntityWidth,
|
||||||
Math.max(labelBBox.width + conf.entityPadding * 2, maxWidth + widthPadding * 4)
|
Math.max(
|
||||||
|
labelBBox.width + conf.entityPadding * 2,
|
||||||
|
maxWidth + widthPadding * widthPaddingFactor
|
||||||
|
)
|
||||||
),
|
),
|
||||||
height:
|
height:
|
||||||
attributes.length > 0
|
attributes.length > 0
|
||||||
@@ -162,10 +177,13 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
: Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2),
|
: Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
// There might be some spare width for padding out attributes if the entity name is very long
|
|
||||||
const spareWidth = Math.max(0, bBox.width - maxWidth - widthPadding * 4);
|
|
||||||
|
|
||||||
if (attributes.length > 0) {
|
if (attributes.length > 0) {
|
||||||
|
// There might be some spare width for padding out attributes if the entity name is very long
|
||||||
|
const spareColumnWidth = Math.max(
|
||||||
|
0,
|
||||||
|
(bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2)
|
||||||
|
);
|
||||||
|
|
||||||
// Position the entity label near the top of the entity bounding box
|
// Position the entity label near the top of the entity bounding box
|
||||||
entityTextNode.attr(
|
entityTextNode.attr(
|
||||||
'transform',
|
'transform',
|
||||||
@@ -180,9 +198,10 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
// Calculate the alignment y co-ordinate for the type/name of the attribute
|
// Calculate the alignment y co-ordinate for the type/name of the attribute
|
||||||
const alignY = heightOffset + heightPadding + attributeNode.height / 2;
|
const alignY = heightOffset + heightPadding + attributeNode.height / 2;
|
||||||
|
|
||||||
// Position the type of the attribute
|
// Position the type attribute
|
||||||
attributeNode.tn.attr('transform', 'translate(' + widthPadding + ',' + alignY + ')');
|
attributeNode.tn.attr('transform', 'translate(' + widthPadding + ',' + alignY + ')');
|
||||||
|
|
||||||
|
// TODO Handle spareWidth in attr('width')
|
||||||
// Insert a rectangle for the type
|
// Insert a rectangle for the type
|
||||||
const typeRect = groupNode
|
const typeRect = groupNode
|
||||||
.insert('rect', '#' + attributeNode.tn.node().id)
|
.insert('rect', '#' + attributeNode.tn.node().id)
|
||||||
@@ -192,65 +211,73 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
|||||||
.attr('stroke', conf.stroke)
|
.attr('stroke', conf.stroke)
|
||||||
.attr('x', 0)
|
.attr('x', 0)
|
||||||
.attr('y', heightOffset)
|
.attr('y', heightOffset)
|
||||||
.attr('width', maxTypeWidth * 2 + spareWidth / 2)
|
.attr('width', maxTypeWidth + widthPadding * 2 + spareColumnWidth)
|
||||||
.attr('height', attributeNode.tn.node().getBBox().height + heightPadding * 2);
|
.attr('height', attributeNode.height + heightPadding * 2);
|
||||||
|
|
||||||
// Position the name of the attribute
|
const nameXOffset = parseFloat(typeRect.attr('x')) + parseFloat(typeRect.attr('width'));
|
||||||
|
|
||||||
|
// Position the name attribute
|
||||||
attributeNode.nn.attr(
|
attributeNode.nn.attr(
|
||||||
'transform',
|
'transform',
|
||||||
'translate(' + (parseFloat(typeRect.attr('width')) + widthPadding) + ',' + alignY + ')'
|
'translate(' + (nameXOffset + widthPadding) + ',' + alignY + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Insert a rectangle for the name
|
// Insert a rectangle for the name
|
||||||
groupNode
|
const nameRect = groupNode
|
||||||
.insert('rect', '#' + attributeNode.nn.node().id)
|
.insert('rect', '#' + attributeNode.nn.node().id)
|
||||||
.attr('class', `er ${attribStyle}`)
|
.attr('class', `er ${attribStyle}`)
|
||||||
.attr('fill', conf.fill)
|
.attr('fill', conf.fill)
|
||||||
.attr('fill-opacity', '100%')
|
.attr('fill-opacity', '100%')
|
||||||
.attr('stroke', conf.stroke)
|
.attr('stroke', conf.stroke)
|
||||||
.attr('x', `${typeRect.attr('x') + typeRect.attr('width')}`)
|
.attr('x', nameXOffset)
|
||||||
.attr('y', heightOffset)
|
.attr('y', heightOffset)
|
||||||
.attr('width', maxNameWidth + widthPadding * 2 + spareWidth / 2)
|
.attr('width', maxNameWidth + widthPadding * 2 + spareColumnWidth)
|
||||||
.attr('height', attributeNode.nn.node().getBBox().height + heightPadding * 2);
|
.attr('height', attributeNode.height + heightPadding * 2);
|
||||||
|
|
||||||
|
let keyTypeAndCommentXOffset =
|
||||||
|
parseFloat(nameRect.attr('x')) + parseFloat(nameRect.attr('width'));
|
||||||
|
|
||||||
if (hasKeyType) {
|
if (hasKeyType) {
|
||||||
// Position the name of the attribute
|
// Position the key type attribute
|
||||||
attributeNode.kn.attr(
|
attributeNode.kn.attr(
|
||||||
'transform',
|
'transform',
|
||||||
'translate(' + (parseFloat(typeRect.attr('width')) + widthPadding) + ',' + alignY + ')'
|
'translate(' + (keyTypeAndCommentXOffset + widthPadding) + ',' + alignY + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Insert a rectangle for the name
|
// Insert a rectangle for the key type
|
||||||
groupNode
|
const keyTypeRect = groupNode
|
||||||
.insert('rect', '#' + attributeNode.kn.node().id)
|
.insert('rect', '#' + attributeNode.kn.node().id)
|
||||||
.attr('class', `er ${attribStyle}`)
|
.attr('class', `er ${attribStyle}`)
|
||||||
.attr('fill', conf.fill)
|
.attr('fill', conf.fill)
|
||||||
.attr('fill-opacity', '100%')
|
.attr('fill-opacity', '100%')
|
||||||
.attr('stroke', conf.stroke)
|
.attr('stroke', conf.stroke)
|
||||||
.attr('x', `${typeRect.attr('x') + typeRect.attr('width')}`)
|
.attr('x', keyTypeAndCommentXOffset)
|
||||||
.attr('y', heightOffset)
|
.attr('y', heightOffset)
|
||||||
.attr('width', maxKeyWidth + widthPadding * 2 + spareWidth / 2)
|
.attr('width', maxKeyWidth + widthPadding * 2 + spareColumnWidth)
|
||||||
.attr('height', attributeNode.kn.node().getBBox().height + heightPadding * 2);
|
.attr('height', attributeNode.height + heightPadding * 2);
|
||||||
|
|
||||||
|
keyTypeAndCommentXOffset =
|
||||||
|
parseFloat(keyTypeRect.attr('x')) + parseFloat(keyTypeRect.attr('width'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasComment) {
|
if (hasComment) {
|
||||||
// Position the name of the attribute
|
// Position the comment attribute
|
||||||
attributeNode.cn.attr(
|
attributeNode.cn.attr(
|
||||||
'transform',
|
'transform',
|
||||||
'translate(' + (parseFloat(typeRect.attr('width')) + widthPadding) + ',' + alignY + ')'
|
'translate(' + (keyTypeAndCommentXOffset + widthPadding) + ',' + alignY + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Insert a rectangle for the name
|
// Insert a rectangle for the comment
|
||||||
groupNode
|
groupNode
|
||||||
.insert('rect', '#' + attributeNode.cn.node().id)
|
.insert('rect', '#' + attributeNode.cn.node().id)
|
||||||
.attr('class', `er ${attribStyle}`)
|
.attr('class', `er ${attribStyle}`)
|
||||||
.attr('fill', conf.fill)
|
.attr('fill', conf.fill)
|
||||||
.attr('fill-opacity', '100%')
|
.attr('fill-opacity', '100%')
|
||||||
.attr('stroke', conf.stroke)
|
.attr('stroke', conf.stroke)
|
||||||
.attr('x', `${typeRect.attr('x') + typeRect.attr('width')}`)
|
.attr('x', keyTypeAndCommentXOffset)
|
||||||
.attr('y', heightOffset)
|
.attr('y', heightOffset)
|
||||||
.attr('width', maxCommentWidth + widthPadding * 2 + spareWidth / 2)
|
.attr('width', maxCommentWidth + widthPadding * 2 + spareColumnWidth)
|
||||||
.attr('height', attributeNode.cn.node().getBBox().height + heightPadding * 2);
|
.attr('height', attributeNode.height + heightPadding * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment the height offset to move to the next row
|
// Increment the height offset to move to the next row
|
||||||
|
@@ -98,8 +98,8 @@ attributes
|
|||||||
attribute
|
attribute
|
||||||
: attributeType attributeName { $$ = { attributeType: $1, attributeName: $2 }; }
|
: attributeType attributeName { $$ = { attributeType: $1, attributeName: $2 }; }
|
||||||
| attributeType attributeName attributeKeyType { $$ = { attributeType: $1, attributeName: $2, attributeKeyType: $3 }; }
|
| attributeType attributeName attributeKeyType { $$ = { attributeType: $1, attributeName: $2, attributeKeyType: $3 }; }
|
||||||
| attributeType attributeName COMMENT { $$ = { attributeType: $1, attributeName: $2, attributeComment: $3 }; }
|
| attributeType attributeName attributeComment { $$ = { attributeType: $1, attributeName: $2, attributeComment: $3 }; }
|
||||||
| attributeType attributeName attributeKeyType COMMENT { $$ = { attributeType: $1, attributeName: $2, attributeKeyType: $3, attributeComment: $4 }; }
|
| attributeType attributeName attributeKeyType attributeComment { $$ = { attributeType: $1, attributeName: $2, attributeKeyType: $3, attributeComment: $4 }; }
|
||||||
;
|
;
|
||||||
|
|
||||||
attributeType
|
attributeType
|
||||||
@@ -114,6 +114,10 @@ attributeKeyType
|
|||||||
: ATTRIBUTE_KEY { $$=$1; }
|
: ATTRIBUTE_KEY { $$=$1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
attributeComment
|
||||||
|
: COMMENT { $$=$1.replace(/"/g, ''); }
|
||||||
|
;
|
||||||
|
|
||||||
relSpec
|
relSpec
|
||||||
: cardinality relType cardinality
|
: cardinality relType cardinality
|
||||||
{
|
{
|
||||||
|
@@ -59,6 +59,7 @@ describe('when parsing ER diagram it...', function () {
|
|||||||
const entities = erDb.getEntities();
|
const entities = erDb.getEntities();
|
||||||
expect(Object.keys(entities).length).toBe(1);
|
expect(Object.keys(entities).length).toBe(1);
|
||||||
expect(entities[entity].attributes.length).toBe(1);
|
expect(entities[entity].attributes.length).toBe(1);
|
||||||
|
expect(entities[entity].attributes[0].attributeComment).toBe('comment');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow an entity with a single attribute to be defined with a key and a comment', function () {
|
it('should allow an entity with a single attribute to be defined with a key and a comment', function () {
|
||||||
|
@@ -17,7 +17,9 @@ function getId() {
|
|||||||
*/
|
*/
|
||||||
function isfastforwardable(currentCommit, otherCommit) {
|
function isfastforwardable(currentCommit, otherCommit) {
|
||||||
log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id);
|
log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id);
|
||||||
while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit) {
|
let cnt = 0;
|
||||||
|
while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit && cnt < 1000) {
|
||||||
|
cnt++;
|
||||||
// only if other branch has more commits
|
// only if other branch has more commits
|
||||||
if (otherCommit.parent == null) break;
|
if (otherCommit.parent == null) break;
|
||||||
if (Array.isArray(otherCommit.parent)) {
|
if (Array.isArray(otherCommit.parent)) {
|
||||||
|
@@ -227,7 +227,9 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
|||||||
let commit;
|
let commit;
|
||||||
const numCommits = Object.keys(allCommitsDict).length;
|
const numCommits = Object.keys(allCommitsDict).length;
|
||||||
if (typeof commitid === 'string') {
|
if (typeof commitid === 'string') {
|
||||||
|
let cnt = 0;
|
||||||
do {
|
do {
|
||||||
|
cnt++;
|
||||||
commit = allCommitsDict[commitid];
|
commit = allCommitsDict[commitid];
|
||||||
log.debug('in renderCommitHistory', commit.id, commit.seq);
|
log.debug('in renderCommitHistory', commit.id, commit.seq);
|
||||||
if (svg.select('#node-' + commitid).size() > 0) {
|
if (svg.select('#node-' + commitid).size() > 0) {
|
||||||
@@ -293,7 +295,7 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
|||||||
.text(', ' + commit.message);
|
.text(', ' + commit.message);
|
||||||
}
|
}
|
||||||
commitid = commit.parent;
|
commitid = commit.parent;
|
||||||
} while (commitid && allCommitsDict[commitid]);
|
} while (commitid && allCommitsDict[commitid] && cnt < 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(commitid)) {
|
if (Array.isArray(commitid)) {
|
||||||
@@ -313,7 +315,9 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
|||||||
*/
|
*/
|
||||||
function renderLines(svg, commit, direction, branchColor) {
|
function renderLines(svg, commit, direction, branchColor) {
|
||||||
branchColor = branchColor || 0;
|
branchColor = branchColor || 0;
|
||||||
while (commit.seq > 0 && !commit.lineDrawn) {
|
let cnt = 0;
|
||||||
|
while (commit.seq > 0 && !commit.lineDrawn && cnt < 1000) {
|
||||||
|
cnt++;
|
||||||
if (typeof commit.parent === 'string') {
|
if (typeof commit.parent === 'string') {
|
||||||
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor);
|
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor);
|
||||||
commit.lineDrawn = true;
|
commit.lineDrawn = true;
|
||||||
|
Reference in New Issue
Block a user