mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-27 14:46:26 +01:00
Compare commits
236 Commits
@mermaid-j
...
refactor/s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eb14f09bf | ||
|
|
b7c66a220a | ||
|
|
87e2d819bf | ||
|
|
93aa657578 | ||
|
|
7b167cf331 | ||
|
|
d435ac6fe1 | ||
|
|
ed96d067fc | ||
|
|
09c60be450 | ||
|
|
39d070fdea | ||
|
|
4f6f627e75 | ||
|
|
53570ee815 | ||
|
|
a3a5040d79 | ||
|
|
7ff9bf1a50 | ||
|
|
ffd38716d0 | ||
|
|
4313f233d2 | ||
|
|
56564f3807 | ||
|
|
7e1a1de5e9 | ||
|
|
b4b90417cf | ||
|
|
6bf2b2108c | ||
|
|
614129ca31 | ||
|
|
b115ad3cd7 | ||
|
|
73b8626ab0 | ||
|
|
88e8ad6f5b | ||
|
|
ac5fdb8121 | ||
|
|
a30b3bb3f8 | ||
|
|
87c561615e | ||
|
|
0843a2fa7a | ||
|
|
1aa4cd9847 | ||
|
|
8d1cdc41c2 | ||
|
|
bf50ce5237 | ||
|
|
8bfd47758a | ||
|
|
88fd141276 | ||
|
|
454238867b | ||
|
|
6025ec663c | ||
|
|
2346801c30 | ||
|
|
d7eb94dc89 | ||
|
|
db9c683316 | ||
|
|
c9b5c5fed6 | ||
|
|
324cf05afd | ||
|
|
a357c1079f | ||
|
|
e20b079707 | ||
|
|
b1fe4ffe97 | ||
|
|
61c18b99a0 | ||
|
|
04ac594f5b | ||
|
|
a6c2b1d85e | ||
|
|
96ca7c090f | ||
|
|
3c752421a2 | ||
|
|
bf7c532e43 | ||
|
|
8add133bbe | ||
|
|
8cf0d3373d | ||
|
|
ff3b194925 | ||
|
|
6e869ff8dc | ||
|
|
9df18da01c | ||
|
|
608d623641 | ||
|
|
ecf9ea1134 | ||
|
|
b33ce14932 | ||
|
|
283aef54e4 | ||
|
|
96f87fd597 | ||
|
|
03e8589818 | ||
|
|
6b9f26dac8 | ||
|
|
ea590cdafe | ||
|
|
f3769c70bc | ||
|
|
4cf4d15197 | ||
|
|
c02cf92656 | ||
|
|
3a1266892d | ||
|
|
67e81de557 | ||
|
|
847b3aa24e | ||
|
|
85a13da40f | ||
|
|
43b7db9d6a | ||
|
|
df46b617d4 | ||
|
|
9ec0e8f932 | ||
|
|
9585ee7533 | ||
|
|
1269486124 | ||
|
|
f45ea0c60e | ||
|
|
d20955a56a | ||
|
|
fb66b3fbe3 | ||
|
|
82ea5d63bb | ||
|
|
881e74087a | ||
|
|
09920c0497 | ||
|
|
8065d65cd7 | ||
|
|
6bc6617ca6 | ||
|
|
29ed57ffec | ||
|
|
9fdc4b8005 | ||
|
|
09b841f781 | ||
|
|
d0f9dc0c9b | ||
|
|
15e2824d53 | ||
|
|
7eb582e860 | ||
|
|
6ca928f31f | ||
|
|
983120d945 | ||
|
|
61f74ffc5e | ||
|
|
74318f9337 | ||
|
|
dfd59470dc | ||
|
|
4aac6fa448 | ||
|
|
5f96f80efb | ||
|
|
545801e144 | ||
|
|
0bd74759cc | ||
|
|
e4cf266c1d | ||
|
|
c0e1662e50 | ||
|
|
6546aed482 | ||
|
|
b76ccae065 | ||
|
|
287a9a3fcb | ||
|
|
7f5160fa4d | ||
|
|
7b0763f262 | ||
|
|
38c289818c | ||
|
|
57530076aa | ||
|
|
f2d7877c7a | ||
|
|
62d2c6505e | ||
|
|
974236bbb8 | ||
|
|
cf0d1248a4 | ||
|
|
ebefbd87a8 | ||
|
|
1e7b71a085 | ||
|
|
f28f3c25aa | ||
|
|
58137aa631 | ||
|
|
e7719f14c5 | ||
|
|
35d9cead8a | ||
|
|
13baf51b35 | ||
|
|
9af985ba9b | ||
|
|
c7f8a11ded | ||
|
|
762b44cf33 | ||
|
|
02c0091106 | ||
|
|
16359adc33 | ||
|
|
061632c580 | ||
|
|
cbf89462ac | ||
|
|
700aa100f2 | ||
|
|
49103ea654 | ||
|
|
3f46c94ab2 | ||
|
|
b136acdc67 | ||
|
|
bba5e5938e | ||
|
|
fed8a523a4 | ||
|
|
33b4946e21 | ||
|
|
3d768f3adf | ||
|
|
76e17ffd20 | ||
|
|
835de0012d | ||
|
|
60f633101c | ||
|
|
18f51eb14e | ||
|
|
2bb57bf7d2 | ||
|
|
a6276daffd | ||
|
|
7def6eecbf | ||
|
|
96a766dcdb | ||
|
|
39d7ebd32e | ||
|
|
34f40f0794 | ||
|
|
32ac2c689d | ||
|
|
dbcadc1d0b | ||
|
|
ac411a7d7e | ||
|
|
d80a638e55 | ||
|
|
7a869c08a2 | ||
|
|
44e8cbb1de | ||
|
|
efe38b8425 | ||
|
|
6fecb985e8 | ||
|
|
69b338d8af | ||
|
|
fa15ce8502 | ||
|
|
6d0650918f | ||
|
|
c728d864c8 | ||
|
|
99f17bea3a | ||
|
|
c1c14e401a | ||
|
|
8b3057f27c | ||
|
|
717d3b3bb2 | ||
|
|
2f8d9ba958 | ||
|
|
ace0367afd | ||
|
|
b983626587 | ||
|
|
7effdc147b | ||
|
|
6e67515f41 | ||
|
|
1a9d45abf0 | ||
|
|
09b74f1c29 | ||
|
|
880da21908 | ||
|
|
38191243be | ||
|
|
b75dcb8a82 | ||
|
|
4c1e170f4a | ||
|
|
d5c4eff251 | ||
|
|
5324fd8dfd | ||
|
|
bd25b88a01 | ||
|
|
d3de3ecbbb | ||
|
|
3964ce0a0f | ||
|
|
4dbabba8e8 | ||
|
|
bbb93b263d | ||
|
|
e3ef5e4208 | ||
|
|
daeb85bac2 | ||
|
|
4240340a18 | ||
|
|
ca10a259fa | ||
|
|
0ed9c65572 | ||
|
|
56cc12690f | ||
|
|
2cdaf03ada | ||
|
|
f6fa0260e7 | ||
|
|
29aad6d23c | ||
|
|
82ef7b5fdb | ||
|
|
11cd3f1262 | ||
|
|
ac4aa94e78 | ||
|
|
c40faac80d | ||
|
|
c530baed3f | ||
|
|
045699de10 | ||
|
|
1988d24227 | ||
|
|
39f90debe7 | ||
|
|
73e9849f99 | ||
|
|
5a05540a5f | ||
|
|
2b58df9665 | ||
|
|
e6fb4a84da | ||
|
|
32723b2de1 | ||
|
|
18703782ee | ||
|
|
0b42bdba07 | ||
|
|
74c96db3e2 | ||
|
|
bd47c57eaf | ||
|
|
3e5d2db514 | ||
|
|
40990bb096 | ||
|
|
7ca0665764 | ||
|
|
81a6a361ab | ||
|
|
62faacdeeb | ||
|
|
0e40d8e8a8 | ||
|
|
e8d6daf4f6 | ||
|
|
cb4ed605b2 | ||
|
|
ba9db26bfa | ||
|
|
252b1837f7 | ||
|
|
6b9c15d7f0 | ||
|
|
fda640c90c | ||
|
|
584a789183 | ||
|
|
47297f7c26 | ||
|
|
967aa0629e | ||
|
|
04b20a79b9 | ||
|
|
d60b09cafc | ||
|
|
875827f59b | ||
|
|
c4e08261b5 | ||
|
|
70f679d2fa | ||
|
|
25c43fa439 | ||
|
|
ec1c6325d4 | ||
|
|
309ff6be38 | ||
|
|
02d368df05 | ||
|
|
4ee1fe2ca4 | ||
|
|
4ff2ae9f4e | ||
|
|
7a729e8f16 | ||
|
|
3c7fd95617 | ||
|
|
2dd29bee25 | ||
|
|
259a508d8a | ||
|
|
1963064369 | ||
|
|
a101ce803c | ||
|
|
fc0c7936d1 | ||
|
|
2d2add5b44 | ||
|
|
58fd5ddbaf |
5
.changeset/brave-baths-behave.md
Normal file
5
.changeset/brave-baths-behave.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Prevent HTML tags from being escaped in sandbox label rendering
|
||||||
5
.changeset/brave-memes-flash.md
Normal file
5
.changeset/brave-memes-flash.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Support edge animation in hand drawn look
|
||||||
5
.changeset/busy-mirrors-try.md
Normal file
5
.changeset/busy-mirrors-try.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Resolved parsing error where direction TD was not recognized within subgraphs
|
||||||
5
.changeset/chatty-insects-dream.md
Normal file
5
.changeset/chatty-insects-dream.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(treemap): Fixed treemap classDef style application to properly apply user-defined styles
|
||||||
5
.changeset/chilly-words-march.md
Normal file
5
.changeset/chilly-words-march.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Correct viewBox casing and make SVGs responsive
|
||||||
5
.changeset/curly-apes-prove.md
Normal file
5
.changeset/curly-apes-prove.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Improve participant parsing and prevent recursive loops on invalid syntax
|
||||||
5
.changeset/late-bears-chew.md
Normal file
5
.changeset/late-bears-chew.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
revert: restore original hexagon and roundedRect implementations
|
||||||
5
.changeset/lazy-brooms-battle.md
Normal file
5
.changeset/lazy-brooms-battle.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: add alias support for new participant syntax of sequence diagrams
|
||||||
5
.changeset/loud-results-melt.md
Normal file
5
.changeset/loud-results-melt.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: Add half-arrowheads (solid & stick) and central connection support
|
||||||
5
.changeset/restore-hexagon-roundedrect.md
Normal file
5
.changeset/restore-hexagon-roundedrect.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: restore original hexagon and roundedRect implementations
|
||||||
5
.changeset/short-seals-sort.md
Normal file
5
.changeset/short-seals-sort.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: allow to put notes in namespaces on classDiagram
|
||||||
5
.changeset/slow-lemons-know.md
Normal file
5
.changeset/slow-lemons-know.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Mindmap breaking in ELK layout
|
||||||
5
.changeset/sweet-games-build.md
Normal file
5
.changeset/sweet-games-build.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(er-diagram): prevent syntax error when using 'u', numbers, and decimals in node names
|
||||||
5
.changeset/ten-plums-bet.md
Normal file
5
.changeset/ten-plums-bet.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Support ComponentQueue_Ext to prevent parsing error
|
||||||
5
.changeset/tricky-rivers-stand.md
Normal file
5
.changeset/tricky-rivers-stand.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: validate dates and tick interval to prevent UI freeze/crash in gantt diagramtype
|
||||||
5
.changeset/wide-lines-trade.md
Normal file
5
.changeset/wide-lines-trade.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Mindmap rendering issue when the number of Level 2 nodes exceeds 11
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
!viewbox
|
||||||
|
# It should be viewBox
|
||||||
# This file contains coding related terms
|
# This file contains coding related terms
|
||||||
ALPHANUM
|
ALPHANUM
|
||||||
antiscript
|
antiscript
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ rscratch
|
|||||||
shiki
|
shiki
|
||||||
Slidev
|
Slidev
|
||||||
sparkline
|
sparkline
|
||||||
|
speccharts
|
||||||
sphinxcontrib
|
sphinxcontrib
|
||||||
ssim
|
ssim
|
||||||
stylis
|
stylis
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
|
|||||||
|
|
||||||
const external: string[] = ['require', 'fs', 'path'];
|
const external: string[] = ['require', 'fs', 'path'];
|
||||||
const outFileName = getFileName(name, options);
|
const outFileName = getFileName(name, options);
|
||||||
|
const { dependencies, version } = JSON.parse(
|
||||||
|
readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8')
|
||||||
|
);
|
||||||
const output: BuildOptions = buildOptions({
|
const output: BuildOptions = buildOptions({
|
||||||
...rest,
|
...rest,
|
||||||
absWorkingDir: resolve(__dirname, `../packages/${packageName}`),
|
absWorkingDir: resolve(__dirname, `../packages/${packageName}`),
|
||||||
@@ -82,15 +85,13 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
|
|||||||
chunkNames: `chunks/${outFileName}/[name]-[hash]`,
|
chunkNames: `chunks/${outFileName}/[name]-[hash]`,
|
||||||
define: {
|
define: {
|
||||||
// This needs to be stringified for esbuild
|
// This needs to be stringified for esbuild
|
||||||
includeLargeFeatures: `${includeLargeFeatures}`,
|
'injected.includeLargeFeatures': `${includeLargeFeatures}`,
|
||||||
|
'injected.version': `'${version}'`,
|
||||||
'import.meta.vitest': 'undefined',
|
'import.meta.vitest': 'undefined',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (core) {
|
if (core) {
|
||||||
const { dependencies } = JSON.parse(
|
|
||||||
readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8')
|
|
||||||
);
|
|
||||||
// Core build is used to generate file without bundled dependencies.
|
// Core build is used to generate file without bundled dependencies.
|
||||||
// This is used by downstream projects to bundle dependencies themselves.
|
// This is used by downstream projects to bundle dependencies themselves.
|
||||||
// Ignore dependencies and any dependencies of dependencies
|
// Ignore dependencies and any dependencies of dependencies
|
||||||
|
|||||||
4
.github/workflows/codeql.yml
vendored
4
.github/workflows/codeql.yml
vendored
@@ -26,8 +26,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
language: ['javascript']
|
language: ['javascript', 'actions']
|
||||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
# CodeQL supports [ 'actions', 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
2
.github/workflows/e2e-timings.yml
vendored
2
.github/workflows/e2e-timings.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
|||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Commit and create pull request
|
- name: Commit and create pull request
|
||||||
uses: peter-evans/create-pull-request@915d841dae6a4f191bb78faf61a257411d7be4d2
|
uses: peter-evans/create-pull-request@0979079bc20c05bbbb590a56c21c4e2b1d1f1bbe
|
||||||
with:
|
with:
|
||||||
add-paths: |
|
add-paths: |
|
||||||
cypress/timings.json
|
cypress/timings.json
|
||||||
|
|||||||
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -42,5 +42,4 @@ jobs:
|
|||||||
publish: pnpm changeset:publish
|
publish: pnpm changeset:publish
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
NPM_CONFIG_PROVENANCE: true
|
NPM_CONFIG_PROVENANCE: true
|
||||||
|
|||||||
2
.github/workflows/scorecard.yml
vendored
2
.github/workflows/scorecard.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Run analysis
|
- name: Run analysis
|
||||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||||
with:
|
with:
|
||||||
results_file: results.sarif
|
results_file: results.sarif
|
||||||
results_format: sarif
|
results_format: sarif
|
||||||
|
|||||||
2
.github/workflows/update-browserlist.yml
vendored
2
.github/workflows/update-browserlist.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
message: 'chore: update browsers list'
|
message: 'chore: update browsers list'
|
||||||
push: false
|
push: false
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
|
||||||
with:
|
with:
|
||||||
branch: update-browserslist
|
branch: update-browserslist
|
||||||
title: Update Browserslist
|
title: Update Browserslist
|
||||||
|
|||||||
38
.github/workflows/validate-lockfile.yml
vendored
38
.github/workflows/validate-lockfile.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Validate pnpm-lock.yaml
|
name: Validate pnpm-lock.yaml
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request_target:
|
||||||
paths:
|
paths:
|
||||||
- 'pnpm-lock.yaml'
|
- 'pnpm-lock.yaml'
|
||||||
- '**/package.json'
|
- '**/package.json'
|
||||||
@@ -15,13 +15,8 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Set up Node.js
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
|
|
||||||
|
|
||||||
- name: Validate pnpm-lock.yaml entries
|
- name: Validate pnpm-lock.yaml entries
|
||||||
id: validate # give this step an ID so we can reference its outputs
|
id: validate # give this step an ID so we can reference its outputs
|
||||||
@@ -55,16 +50,41 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Find existing lockfile validation comment
|
||||||
|
if: always()
|
||||||
|
uses: peter-evans/find-comment@v3
|
||||||
|
id: find-comment
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
comment-author: 'github-actions[bot]'
|
||||||
|
body-includes: 'Lockfile Validation Failed'
|
||||||
|
|
||||||
- name: Comment on PR if validation failed
|
- name: Comment on PR if validation failed
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: peter-evans/create-or-update-comment@v4
|
uses: peter-evans/create-or-update-comment@v5
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
||||||
|
edit-mode: replace
|
||||||
body: |
|
body: |
|
||||||
|
❌ **Lockfile Validation Failed**
|
||||||
|
|
||||||
The following issue(s) were detected:
|
The following issue(s) were detected:
|
||||||
${{ steps.validate.outputs.errors }}
|
${{ steps.validate.outputs.errors }}
|
||||||
|
|
||||||
Please address these and push an update.
|
Please address these and push an update.
|
||||||
|
|
||||||
_Posted automatically by GitHub Actions_
|
_Posted automatically by GitHub Actions_
|
||||||
|
|
||||||
|
- name: Delete comment if validation passed
|
||||||
|
if: success() && steps.find-comment.outputs.comment-id != ''
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
await github.rest.issues.deleteComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: ${{ steps.find-comment.outputs.comment-id }},
|
||||||
|
});
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
|
|||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
'import.meta.vitest': 'undefined',
|
'import.meta.vitest': 'undefined',
|
||||||
|
'injected.includeLargeFeatures': 'true',
|
||||||
|
'injected.version': `'0.0.0'`,
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [],
|
extensions: [],
|
||||||
@@ -94,10 +96,6 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
|
|||||||
}),
|
}),
|
||||||
...visualizerOptions(packageName, core),
|
...visualizerOptions(packageName, core),
|
||||||
],
|
],
|
||||||
define: {
|
|
||||||
// Needs to be string
|
|
||||||
includeLargeFeatures: 'true',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (watch && config.build) {
|
if (watch && config.build) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ USER 0:0
|
|||||||
RUN corepack enable \
|
RUN corepack enable \
|
||||||
&& corepack enable pnpm
|
&& corepack enable pnpm
|
||||||
|
|
||||||
RUN apk add --no-cache git~=2.43.4 \
|
RUN apk add --no-cache git~=2.43 \
|
||||||
&& git config --add --system safe.directory /mermaid
|
&& git config --add --system safe.directory /mermaid
|
||||||
|
|
||||||
ENV NODE_OPTIONS="--max_old_space_size=8192"
|
ENV NODE_OPTIONS="--max_old_space_size=8192"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ interface CypressConfig {
|
|||||||
listUrl?: boolean;
|
listUrl?: boolean;
|
||||||
listId?: string;
|
listId?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
screenshot?: boolean;
|
||||||
}
|
}
|
||||||
type CypressMermaidConfig = MermaidConfig & CypressConfig;
|
type CypressMermaidConfig = MermaidConfig & CypressConfig;
|
||||||
|
|
||||||
@@ -90,20 +91,33 @@ export const renderGraph = (
|
|||||||
|
|
||||||
export const openURLAndVerifyRendering = (
|
export const openURLAndVerifyRendering = (
|
||||||
url: string,
|
url: string,
|
||||||
options: CypressMermaidConfig,
|
{ screenshot = true, ...options }: CypressMermaidConfig,
|
||||||
validation?: any
|
validation?: any
|
||||||
): void => {
|
): void => {
|
||||||
const name: string = (options.name ?? cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
const name: string = (options.name ?? cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
|
|
||||||
cy.visit(url);
|
cy.visit(url);
|
||||||
cy.window().should('have.property', 'rendered', true);
|
cy.window().should('have.property', 'rendered', true);
|
||||||
cy.get('svg').should('be.visible');
|
|
||||||
|
|
||||||
if (validation) {
|
// Handle sandbox mode where SVG is inside an iframe
|
||||||
cy.get('svg').should(validation);
|
if (options.securityLevel === 'sandbox') {
|
||||||
|
cy.get('iframe').should('be.visible');
|
||||||
|
if (validation) {
|
||||||
|
cy.get('iframe').should(validation);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cy.get('svg').should('be.visible');
|
||||||
|
// cspell:ignore viewbox
|
||||||
|
cy.get('svg').should('not.have.attr', 'viewbox');
|
||||||
|
|
||||||
|
if (validation) {
|
||||||
|
cy.get('svg').should(validation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyScreenshot(name);
|
if (screenshot) {
|
||||||
|
verifyScreenshot(name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const verifyScreenshot = (name: string): void => {
|
export const verifyScreenshot = (name: string): void => {
|
||||||
|
|||||||
@@ -114,4 +114,28 @@ describe('C4 diagram', () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('C4.6 should render C4Context diagram with ComponentQueue_Ext', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
C4Context
|
||||||
|
title System Context diagram with ComponentQueue_Ext
|
||||||
|
|
||||||
|
Enterprise_Boundary(b0, "BankBoundary0") {
|
||||||
|
Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")
|
||||||
|
|
||||||
|
System(SystemAA, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.")
|
||||||
|
|
||||||
|
Enterprise_Boundary(b1, "BankBoundary") {
|
||||||
|
ComponentQueue_Ext(msgQueue, "Message Queue", "RabbitMQ", "External message queue system for processing banking transactions")
|
||||||
|
System_Ext(SystemC, "E-mail system", "The internal Microsoft Exchange e-mail system.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BiRel(customerA, SystemAA, "Uses")
|
||||||
|
Rel(SystemAA, msgQueue, "Sends messages to")
|
||||||
|
Rel(SystemAA, SystemC, "Sends e-mails", "SMTP")
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -562,6 +562,20 @@ class C13["With Città foreign language"]
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should add notes in namespaces', function () {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
classDiagram
|
||||||
|
note "This is a outer note"
|
||||||
|
note for C1 "This is a outer note for C1"
|
||||||
|
namespace Namespace1 {
|
||||||
|
note "This is a inner note"
|
||||||
|
note for C1 "This is a inner note for C1"
|
||||||
|
class C1
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
it('should render a simple class diagram with no members', () => {
|
it('should render a simple class diagram with no members', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -709,6 +709,20 @@ class C13["With Città foreign language"]
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should add notes in namespaces', function () {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
classDiagram
|
||||||
|
note "This is a outer note"
|
||||||
|
note for C1 "This is a outer note for C1"
|
||||||
|
namespace Namespace1 {
|
||||||
|
note "This is a inner note"
|
||||||
|
note for C1 "This is a inner note for C1"
|
||||||
|
class C1
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
it('should render a simple class diagram with no members', () => {
|
it('should render a simple class diagram with no members', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -369,4 +369,92 @@ ORDER ||--|{ LINE-ITEM : contains
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Special characters and numbers syntax', () => {
|
||||||
|
it('should render ER diagram with numeric entity names', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
1 ||--|| ORDER : places
|
||||||
|
ORDER ||--|{ 2 : contains
|
||||||
|
2 ||--o{ 3.5 : references
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render ER diagram with "u" character in entity names and cardinality', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
CUSTOMER ||--|| u : has
|
||||||
|
u ||--|| ORDER : places
|
||||||
|
PROJECT u--o{ TEAM_MEMBER : "parent"
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render ER diagram with decimal numbers in relationships', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
2.5 ||--|| 1.5 : has
|
||||||
|
CUSTOMER ||--o{ 3.14 : references
|
||||||
|
1.0 ||--|{ ORDER : contains
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render ER diagram with numeric entity names and attributes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
1 {
|
||||||
|
string name
|
||||||
|
int value
|
||||||
|
}
|
||||||
|
1 ||--|| ORDER : places
|
||||||
|
ORDER {
|
||||||
|
float price
|
||||||
|
string description
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render complex ER diagram with mixed special entity names', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
CUSTOMER ||--o{ 1 : places
|
||||||
|
1 ||--|{ u : contains
|
||||||
|
1.5
|
||||||
|
u ||--|| 2.5 : processes
|
||||||
|
2.5 {
|
||||||
|
string id
|
||||||
|
float value
|
||||||
|
}
|
||||||
|
u {
|
||||||
|
varchar(50) name
|
||||||
|
int count
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render ER diagram with standalone numeric entities', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`erDiagram
|
||||||
|
PRODUCT ||--o{ ORDER-ITEM : has
|
||||||
|
1.5
|
||||||
|
u
|
||||||
|
1
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1029,4 +1029,19 @@ graph TD
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('FDH49: should add edge animation', () => {
|
||||||
|
renderGraph(
|
||||||
|
`
|
||||||
|
flowchart TD
|
||||||
|
A(["Start"]) L_A_B_0@--> B{"Decision"}
|
||||||
|
B --> C["Option A"] & D["Option B"]
|
||||||
|
style C stroke-width:4px,stroke-dasharray: 5
|
||||||
|
L_A_B_0@{ animation: slow }
|
||||||
|
L_B_D_0@{ animation: fast }`,
|
||||||
|
{ look: 'handDrawn', screenshot: false }
|
||||||
|
);
|
||||||
|
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
|
||||||
|
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,6 +79,18 @@ describe('Flowchart v2', () => {
|
|||||||
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
|
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('6a: should render complex HTML in labels with sandbox security', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`flowchart TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
B --> C{Let me think}
|
||||||
|
C -->|One| D[Laptop]
|
||||||
|
C -->|Two| E[iPhone]
|
||||||
|
C -->|Three| F[fa:fa-car Car]
|
||||||
|
`,
|
||||||
|
{ securityLevel: 'sandbox', flowchart: { htmlLabels: true } }
|
||||||
|
);
|
||||||
|
});
|
||||||
it('7: should render a flowchart when useMaxWidth is true (default)', () => {
|
it('7: should render a flowchart when useMaxWidth is true (default)', () => {
|
||||||
renderGraph(
|
renderGraph(
|
||||||
`flowchart TD
|
`flowchart TD
|
||||||
|
|||||||
@@ -774,6 +774,21 @@ describe('Graph', () => {
|
|||||||
expect(svg).to.not.have.attr('style');
|
expect(svg).to.not.have.attr('style');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('40: should add edge animation', () => {
|
||||||
|
renderGraph(
|
||||||
|
`
|
||||||
|
flowchart TD
|
||||||
|
A(["Start"]) L_A_B_0@--> B{"Decision"}
|
||||||
|
B --> C["Option A"] & D["Option B"]
|
||||||
|
style C stroke-width:4px,stroke-dasharray: 5
|
||||||
|
L_A_B_0@{ animation: slow }
|
||||||
|
L_B_D_0@{ animation: fast }`,
|
||||||
|
{ screenshot: false }
|
||||||
|
);
|
||||||
|
// Verify animation classes are applied to both edges
|
||||||
|
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
|
||||||
|
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
|
||||||
|
});
|
||||||
it('58: handle styling with style expressions', () => {
|
it('58: handle styling with style expressions', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@@ -973,4 +988,19 @@ graph TD
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('70: should render a subgraph with direction TD', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
flowchart LR
|
||||||
|
subgraph A
|
||||||
|
direction TD
|
||||||
|
a --> b
|
||||||
|
end
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
fontFamily: 'courier',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -833,4 +833,34 @@ describe('Gantt diagram', () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should handle seconds-only format with tickInterval (issue #5496)', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
tickInterval 1second
|
||||||
|
dateFormat ss
|
||||||
|
axisFormat %s
|
||||||
|
|
||||||
|
section Network Request
|
||||||
|
RTT : rtt, 0, 20
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should handle dates with year typo like 202 instead of 2024 (issue #5496)', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
title Schedule
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
tickInterval 1week
|
||||||
|
axisFormat %m-%d
|
||||||
|
|
||||||
|
section Vacation
|
||||||
|
London : 2024-12-01, 7d
|
||||||
|
London : 202-12-01, 7d
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -247,5 +247,31 @@ root
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('Level 2 nodes exceeding 11', () => {
|
||||||
|
it('should render all Level 2 nodes correctly when there are more than 11', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`mindmap
|
||||||
|
root
|
||||||
|
Node1
|
||||||
|
Node2
|
||||||
|
Node3
|
||||||
|
Node4
|
||||||
|
Node5
|
||||||
|
Node6
|
||||||
|
Node7
|
||||||
|
Node8
|
||||||
|
Node9
|
||||||
|
Node10
|
||||||
|
Node11
|
||||||
|
Node12
|
||||||
|
Node13
|
||||||
|
Node14
|
||||||
|
Node15`,
|
||||||
|
{},
|
||||||
|
undefined,
|
||||||
|
shouldHaveRoot
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
/* The end */
|
/* The end */
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -655,5 +655,315 @@ describe('Sequence Diagram Special Cases', () => {
|
|||||||
expect(svg).to.not.have.attr('style');
|
expect(svg).to.not.have.attr('style');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Central Connection Rendering Tests', () => {
|
||||||
|
it('should render central connection circles on actor vertical lines', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
participant Charlie
|
||||||
|
Alice ()->>() Bob: Central connection
|
||||||
|
Bob ()-->> Charlie: Reverse central connection
|
||||||
|
Charlie ()<<-->>() Alice: Dual central connection`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections with different arrow types', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()->>() Bob: Solid open arrow
|
||||||
|
Alice ()-->>() Bob: Dotted open arrow
|
||||||
|
Alice ()-x() Bob: Solid cross
|
||||||
|
Alice ()--x() Bob: Dotted cross
|
||||||
|
Alice ()->() Bob: Solid arrow`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections with bidirectional arrows', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()<<->>() Bob: Bidirectional solid
|
||||||
|
Alice ()<<-->>() Bob: Bidirectional dotted`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections with activations', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
participant Charlie
|
||||||
|
Alice ()->>() Bob: Activate Bob
|
||||||
|
activate Bob
|
||||||
|
Bob ()-->> Charlie: Message to Charlie
|
||||||
|
Bob ()->>() Alice: Response to Alice
|
||||||
|
deactivate Bob`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections mixed with normal messages', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
participant Charlie
|
||||||
|
Alice ->> Bob: Normal message
|
||||||
|
Bob ()->>() Charlie: Central connection
|
||||||
|
Charlie -->> Alice: Normal dotted message
|
||||||
|
Alice ()<<-->>() Bob: Dual central connection
|
||||||
|
Bob -x Charlie: Normal cross message`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections with notes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
participant Charlie
|
||||||
|
Alice ()->>() Bob: Central connection
|
||||||
|
Note over Alice,Bob: Central connection note
|
||||||
|
Bob ()-->> Charlie: Reverse central connection
|
||||||
|
Note right of Charlie: Response note
|
||||||
|
Charlie ()<<-->>() Alice: Dual central connection`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections with loops and alternatives', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
participant Charlie
|
||||||
|
loop Every minute
|
||||||
|
Alice ()->>() Bob: Central heartbeat
|
||||||
|
Bob ()-->> Charlie: Forward heartbeat
|
||||||
|
end
|
||||||
|
alt Success
|
||||||
|
Charlie ()<<-->>() Alice: Success response
|
||||||
|
else Failure
|
||||||
|
Charlie ()-x() Alice: Failure response
|
||||||
|
end`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render central connections with different participant types', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
actor Bob
|
||||||
|
participant Charlie@{"type":"boundary"}
|
||||||
|
participant David@{"type":"control"}
|
||||||
|
participant Eve@{"type":"entity"}
|
||||||
|
Alice ()->>() Bob: To actor
|
||||||
|
Bob ()-->> Charlie: To boundary
|
||||||
|
Charlie ()->>() David: To control
|
||||||
|
David ()<<-->>() Eve: To entity
|
||||||
|
Eve ()-x() Alice: Back to participant`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Participant Stereotypes with Aliases', () => {
|
||||||
|
it('should render participants with stereotypes and aliases', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant API@{ "type" : "boundary" } as Public API
|
||||||
|
participant Auth@{ "type" : "control" } as Auth Controller
|
||||||
|
participant DB@{ "type" : "database" } as User Database
|
||||||
|
participant Cache@{ "type" : "entity" } as Cache Layer
|
||||||
|
API ->> Auth: Authenticate request
|
||||||
|
Auth ->> DB: Query user
|
||||||
|
DB -->> Auth: User data
|
||||||
|
Auth ->> Cache: Store session
|
||||||
|
Cache -->> Auth: Confirmed
|
||||||
|
Auth -->> API: Token`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render actors with stereotypes and aliases', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
actor U@{ "type" : "actor" } as End User
|
||||||
|
actor A@{ "type" : "boundary" } as API Gateway
|
||||||
|
actor S@{ "type" : "control" } as Service Layer
|
||||||
|
actor D@{ "type" : "database" } as Data Store
|
||||||
|
U ->> A: Send request
|
||||||
|
A ->> S: Process
|
||||||
|
S ->> D: Persist
|
||||||
|
D -->> S: Success
|
||||||
|
S -->> A: Response
|
||||||
|
A -->> U: Result`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render mixed participants and actors with stereotypes and aliases', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
actor Client@{ "type" : "actor" } AS Mobile Client
|
||||||
|
participant Gateway@{ "type" : "boundary" } as API Gateway
|
||||||
|
participant OrderSvc@{ "type" : "control" } as Order Service
|
||||||
|
participant Queue@{ "type" : "queue" } as Message Queue
|
||||||
|
participant DB@{ "type" : "database" } as Order Database
|
||||||
|
participant Logs@{ "type" : "collections" } as Audit Logs
|
||||||
|
Client ->> Gateway: Place order
|
||||||
|
Gateway ->> OrderSvc: Validate order
|
||||||
|
OrderSvc ->> Queue: Queue for processing as well
|
||||||
|
OrderSvc ->> DB: Save order
|
||||||
|
OrderSvc ->> Logs: Log transaction
|
||||||
|
Queue -->> OrderSvc: Processing started AS Well
|
||||||
|
DB -->> OrderSvc: Order saved
|
||||||
|
Logs -->> OrderSvc: Logged
|
||||||
|
OrderSvc -->> Gateway: Order confirmed
|
||||||
|
Gateway -->> Client: Confirmation`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render stereotypes with aliases in boxes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
box rgb(200,220,255) Frontend Layer
|
||||||
|
actor User@{ "type" : "actor" } as End User
|
||||||
|
participant UI@{ "type" : "boundary" } as User Interface
|
||||||
|
end
|
||||||
|
box rgb(255,220,200) Backend Layer
|
||||||
|
participant API@{ "type" : "boundary" } as REST API
|
||||||
|
participant Svc@{ "type" : "control" } as Business Logic
|
||||||
|
end
|
||||||
|
box rgb(220,255,200) Data Layer
|
||||||
|
participant DB@{ "type" : "database" } as Primary DB
|
||||||
|
participant Cache@{ "type" : "entity" } as Cache Store
|
||||||
|
end
|
||||||
|
User ->> UI: Click button
|
||||||
|
UI ->> API: HTTP request
|
||||||
|
API ->> Svc: Process
|
||||||
|
Svc ->> Cache: Check cache
|
||||||
|
Cache -->> Svc: Cache miss
|
||||||
|
Svc ->> DB: Query data
|
||||||
|
DB -->> Svc: Data
|
||||||
|
Svc ->> Cache: Update cache
|
||||||
|
Svc -->> API: Response
|
||||||
|
API -->> UI: Data
|
||||||
|
UI -->> User: Display`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render stereotypes with aliases and complex interactions', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant Web@{ "type" : "boundary" } as Web Portal
|
||||||
|
participant Auth@{ "type" : "control" } as Auth Service
|
||||||
|
participant UserDB@{ "type" : "database" } as User DB
|
||||||
|
participant Queue@{ "type" : "queue" } as Event Queue
|
||||||
|
participant Audit@{ "type" : "collections" } as Audit Trail
|
||||||
|
Web ->> Auth: Login request
|
||||||
|
activate Auth
|
||||||
|
Auth ->> UserDB: Verify credentials
|
||||||
|
activate UserDB
|
||||||
|
UserDB -->> Auth: User found
|
||||||
|
deactivate UserDB
|
||||||
|
alt Valid credentials
|
||||||
|
Auth ->> Queue: Publish login event
|
||||||
|
Auth ->> Audit: Log success
|
||||||
|
par Parallel processing
|
||||||
|
Queue -->> Auth: Event queued
|
||||||
|
and
|
||||||
|
Audit -->> Auth: Logged
|
||||||
|
end
|
||||||
|
Auth -->> Web: Success token
|
||||||
|
else Invalid credentials
|
||||||
|
Auth ->> Audit: Log failure
|
||||||
|
Audit -->> Auth: Logged
|
||||||
|
Auth --x Web: Access denied
|
||||||
|
end
|
||||||
|
deactivate Auth
|
||||||
|
Note over Web,Audit: All interactions logged`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Participant Inline Alias in Config', () => {
|
||||||
|
it('should render participants with inline alias in config object', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant API@{ "type" : "boundary", "alias": "Public API" }
|
||||||
|
participant Auth@{ "type" : "control", "alias": "Auth Service" }
|
||||||
|
participant DB@{ "type" : "database", "alias": "User DB" }
|
||||||
|
API ->> Auth: Login request
|
||||||
|
Auth ->> DB: Query user
|
||||||
|
DB -->> Auth: User data
|
||||||
|
Auth -->> API: Token`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render actors with inline alias in config object', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
actor U@{ "type" : "actor", "alias": "End User" }
|
||||||
|
actor G@{ "type" : "boundary", "alias": "Gateway" }
|
||||||
|
actor S@{ "type" : "control", "alias": "Service" }
|
||||||
|
U ->> G: Request
|
||||||
|
G ->> S: Process
|
||||||
|
S -->> G: Response
|
||||||
|
G -->> U: Result`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle mixed inline and external alias syntax', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant A@{ "type" : "boundary", "alias": "Service A" }
|
||||||
|
participant B@{ "type" : "control" } as Service B
|
||||||
|
participant C@{ "type" : "database" }
|
||||||
|
A ->> B: Request
|
||||||
|
B ->> C: Query
|
||||||
|
C -->> B: Data
|
||||||
|
B -->> A: Response`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should prioritize external alias over inline alias', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant API@{ "type" : "boundary", "alias": "Internal Name" } as External Name
|
||||||
|
participant DB@{ "type" : "database", "alias": "Internal DB" } AS External DB
|
||||||
|
API ->> DB: Query
|
||||||
|
DB -->> API: Result`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render inline alias with only alias field (no type)', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
participant API@{ "alias": "Public API" }
|
||||||
|
participant Auth@{ "alias": "Auth Service" }
|
||||||
|
API ->> Auth: Request
|
||||||
|
Auth -->> API: Response`,
|
||||||
|
{ look: 'classic', sequence: { diagramMarginX: 50, diagramMarginY: 10 } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1053,4 +1053,167 @@ describe('Sequence diagram', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('render new arrow type', () => {
|
||||||
|
it('should render Solid half arrow top', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice -|\\ John: Hello John, how are you?
|
||||||
|
Alice-|\\ John: Hi Alice, I can hear you!
|
||||||
|
Alice -|\\ John: Test
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render Solid half arrow bottom', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice-|/John: Hello John, how are you?
|
||||||
|
Alice-|/John: Hi Alice, I can hear you!
|
||||||
|
Alice-|/John: Test
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow top ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice-\\\\John: Hello John, how are you?
|
||||||
|
Alice-\\\\John: Hi Alice, I can hear you!
|
||||||
|
Alice-\\\\John: Test
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render Stick half arrow bottom ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice-//John: Hello John, how are you?
|
||||||
|
Alice-//John: Hi Alice, I can hear you!
|
||||||
|
Alice-//John: Test
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render Solid half arrow top reverse ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice/|-John: Hello Alice, how are you?
|
||||||
|
Alice/|-John: Hi Alice, I can hear you!
|
||||||
|
Alice/|-John: Test
|
||||||
|
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Solid half arrow bottom reverse ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`sequenceDiagram
|
||||||
|
Alice \\|- John: Hello Alice, how are you?
|
||||||
|
Alice \\|- John: Hi Alice, I can hear you!
|
||||||
|
Alice \\|- John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow top reverse ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice //-John: Hello Alice, how are you?
|
||||||
|
Alice //-John: Hi Alice, I can hear you!
|
||||||
|
Alice //-John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow bottom reverse ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice \\\\-John: Hello Alice, how are you?
|
||||||
|
Alice \\\\-John: Hi Alice, I can hear you!
|
||||||
|
Alice \\\\-John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Solid half arrow top dotted', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice --|\\John: Hello John, how are you?
|
||||||
|
Alice --|\\John: Hi Alice, I can hear you!
|
||||||
|
Alice --|\\John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Solid half arrow bottom dotted', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice --|/John: Hello John, how are you?
|
||||||
|
Alice --|/John: Hi Alice, I can hear you!
|
||||||
|
Alice --|/John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow top dotted', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice--\\\\John: Hello John, how are you?
|
||||||
|
Alice--\\\\John: Hi Alice, I can hear you!
|
||||||
|
Alice--\\\\John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow bottom dotted', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice--//John: Hello John, how are you?
|
||||||
|
Alice--//John: Hi Alice, I can hear you!
|
||||||
|
Alice--//John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Solid half arrow top reverse dotted', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice/|--John: Hello Alice, how are you?
|
||||||
|
Alice/|--John: Hi Alice, I can hear you!
|
||||||
|
Alice/|--John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Solid half arrow bottom reverse dotted', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice\\|--John: Hello Alice, how are you?
|
||||||
|
Alice\\|--John: Hi Alice, I can hear you!
|
||||||
|
Alice\\|--John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow top reverse dotted ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice//--John: Hello Alice, how are you?
|
||||||
|
Alice//--John: Hi Alice, I can hear you!
|
||||||
|
Alice//--John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render Stick half arrow bottom reverse dotted ', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice\\\\--John: Hello Alice, how are you?
|
||||||
|
Alice\\\\--John: Hi Alice, I can hear you!
|
||||||
|
Alice\\\\--John: Test`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -327,8 +327,97 @@ classDef sales fill:#c3a66b,stroke:#333;
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('12: should apply classDef fill color to leaf nodes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`treemap-beta
|
||||||
|
"Root"
|
||||||
|
"Item A": 30:::redClass
|
||||||
|
"Item B": 20
|
||||||
|
"Item C": 25:::blueClass
|
||||||
|
|
||||||
|
classDef redClass fill:#ff0000;
|
||||||
|
classDef blueClass fill:#0000ff;
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('13: should apply classDef stroke styles to sections', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`treemap-beta
|
||||||
|
%% This is a comment
|
||||||
|
"Category A":::thickBorder
|
||||||
|
"Item A1": 10
|
||||||
|
"Item A2": 20
|
||||||
|
%% Another comment
|
||||||
|
"Category B":::dashedBorder
|
||||||
|
"Item B1": 15
|
||||||
|
"Item B2": 25
|
||||||
|
|
||||||
|
classDef thickBorder stroke:red,stroke-width:8px;
|
||||||
|
classDef dashedBorder stroke:black,stroke-dasharray:5,stroke-width:8px;
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('14: should apply classDef color to text labels', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`treemap-beta
|
||||||
|
"Products"
|
||||||
|
"Electronics":::whiteText
|
||||||
|
"Phones": 40
|
||||||
|
"Laptops": 30
|
||||||
|
"Furniture":::darkText
|
||||||
|
"Chairs": 25
|
||||||
|
"Tables": 20
|
||||||
|
|
||||||
|
classDef whiteText fill:#2c3e50,color:#ffffff;
|
||||||
|
classDef darkText fill:#ecf0f1,color:#000000;
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('15: should apply multiple classDef properties simultaneously', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`treemap-beta
|
||||||
|
"Budget"
|
||||||
|
"Critical":::critical
|
||||||
|
"Server Costs": 50000
|
||||||
|
"Salaries": 80000
|
||||||
|
"Normal":::normal
|
||||||
|
"Office Supplies": 5000
|
||||||
|
"Marketing": 15000
|
||||||
|
classDef critical fill:#e74c3c,color:#fff,stroke:#c0392b,stroke-width:3px;
|
||||||
|
classDef normal fill:#3498db,color:#fff,stroke:#2980b9,stroke-width:1px;
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('16: should handle classDef on nested sections and leaves', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`treemap-beta
|
||||||
|
"Company"
|
||||||
|
"Engineering":::engSection
|
||||||
|
"Frontend": 30:::highlight
|
||||||
|
"Backend": 40
|
||||||
|
"DevOps": 20:::highlight
|
||||||
|
"Sales"
|
||||||
|
"Direct": 35
|
||||||
|
"Channel": 25:::highlight
|
||||||
|
|
||||||
|
classDef engSection fill:#9b59b6,stroke:#8e44ad,stroke-width:2px;
|
||||||
|
classDef highlight fill:#f39c12,color:#000,stroke:#e67e22,stroke-width:2px;
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
it.skip('12: should render a treemap with title', () => {
|
it.skip('17: should render a treemap with title', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
treemap-beta
|
treemap-beta
|
||||||
|
|||||||
@@ -110,6 +110,48 @@
|
|||||||
config:
|
config:
|
||||||
layout: elk
|
layout: elk
|
||||||
---
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
id)I am a cloud(
|
||||||
|
id))I am a bang((
|
||||||
|
Tools
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
flowchart
|
||||||
|
aid0
|
||||||
|
</pre
|
||||||
|
>
|
||||||
|
<pre id="diagram4" class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
aid0
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: ogdc
|
||||||
|
---
|
||||||
flowchart-elk TB
|
flowchart-elk TB
|
||||||
c1-->a2
|
c1-->a2
|
||||||
subgraph one
|
subgraph one
|
||||||
|
|||||||
@@ -603,6 +603,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="test">
|
<div class="test">
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
theme: dark
|
||||||
|
---
|
||||||
classDiagram
|
classDiagram
|
||||||
test ()--() test2
|
test ()--() test2
|
||||||
</pre>
|
</pre>
|
||||||
|
|||||||
@@ -2,227 +2,227 @@
|
|||||||
"durations": [
|
"durations": [
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/configuration.spec.js",
|
"spec": "cypress/integration/other/configuration.spec.js",
|
||||||
"duration": 5841
|
"duration": 5944
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/external-diagrams.spec.js",
|
"spec": "cypress/integration/other/external-diagrams.spec.js",
|
||||||
"duration": 2138
|
"duration": 2180
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/ghsa.spec.js",
|
"spec": "cypress/integration/other/ghsa.spec.js",
|
||||||
"duration": 3370
|
"duration": 3282
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/iife.spec.js",
|
"spec": "cypress/integration/other/iife.spec.js",
|
||||||
"duration": 2052
|
"duration": 2137
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/interaction.spec.js",
|
"spec": "cypress/integration/other/interaction.spec.js",
|
||||||
"duration": 12243
|
"duration": 11926
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/rerender.spec.js",
|
"spec": "cypress/integration/other/rerender.spec.js",
|
||||||
"duration": 2065
|
"duration": 2021
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/other/xss.spec.js",
|
"spec": "cypress/integration/other/xss.spec.js",
|
||||||
"duration": 31288
|
"duration": 31377
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/appli.spec.js",
|
"spec": "cypress/integration/rendering/appli.spec.js",
|
||||||
"duration": 3421
|
"duration": 3442
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/architecture.spec.ts",
|
"spec": "cypress/integration/rendering/architecture.spec.ts",
|
||||||
"duration": 97
|
"duration": 103
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/block.spec.js",
|
"spec": "cypress/integration/rendering/block.spec.js",
|
||||||
"duration": 18500
|
"duration": 18390
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/c4.spec.js",
|
"spec": "cypress/integration/rendering/c4.spec.js",
|
||||||
"duration": 5793
|
"duration": 6468
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/classDiagram-elk-v3.spec.js",
|
"spec": "cypress/integration/rendering/classDiagram-elk-v3.spec.js",
|
||||||
"duration": 40966
|
"duration": 41282
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/classDiagram-handDrawn-v3.spec.js",
|
"spec": "cypress/integration/rendering/classDiagram-handDrawn-v3.spec.js",
|
||||||
"duration": 39176
|
"duration": 39226
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/classDiagram-v2.spec.js",
|
"spec": "cypress/integration/rendering/classDiagram-v2.spec.js",
|
||||||
"duration": 23468
|
"duration": 25028
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/classDiagram-v3.spec.js",
|
"spec": "cypress/integration/rendering/classDiagram-v3.spec.js",
|
||||||
"duration": 38291
|
"duration": 38458
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/classDiagram.spec.js",
|
"spec": "cypress/integration/rendering/classDiagram.spec.js",
|
||||||
"duration": 16949
|
"duration": 17305
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/conf-and-directives.spec.js",
|
"spec": "cypress/integration/rendering/conf-and-directives.spec.js",
|
||||||
"duration": 9480
|
"duration": 9762
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/current.spec.js",
|
"spec": "cypress/integration/rendering/current.spec.js",
|
||||||
"duration": 2753
|
"duration": 2923
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/erDiagram-unified.spec.js",
|
"spec": "cypress/integration/rendering/erDiagram-unified.spec.js",
|
||||||
"duration": 88028
|
"duration": 89135
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/erDiagram.spec.js",
|
"spec": "cypress/integration/rendering/erDiagram.spec.js",
|
||||||
"duration": 15615
|
"duration": 18976
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/errorDiagram.spec.js",
|
"spec": "cypress/integration/rendering/errorDiagram.spec.js",
|
||||||
"duration": 3706
|
"duration": 3643
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/flowchart-elk.spec.js",
|
"spec": "cypress/integration/rendering/flowchart-elk.spec.js",
|
||||||
"duration": 43905
|
"duration": 43103
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/flowchart-handDrawn.spec.js",
|
"spec": "cypress/integration/rendering/flowchart-handDrawn.spec.js",
|
||||||
"duration": 31217
|
"duration": 31637
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/flowchart-icon.spec.js",
|
"spec": "cypress/integration/rendering/flowchart-icon.spec.js",
|
||||||
"duration": 7531
|
"duration": 7630
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/flowchart-shape-alias.spec.ts",
|
"spec": "cypress/integration/rendering/flowchart-shape-alias.spec.ts",
|
||||||
"duration": 25423
|
"duration": 25642
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/flowchart-v2.spec.js",
|
"spec": "cypress/integration/rendering/flowchart-v2.spec.js",
|
||||||
"duration": 49664
|
"duration": 50365
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/flowchart.spec.js",
|
"spec": "cypress/integration/rendering/flowchart.spec.js",
|
||||||
"duration": 32525
|
"duration": 32790
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/gantt.spec.js",
|
"spec": "cypress/integration/rendering/gantt.spec.js",
|
||||||
"duration": 20915
|
"duration": 23065
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/gitGraph.spec.js",
|
"spec": "cypress/integration/rendering/gitGraph.spec.js",
|
||||||
"duration": 53556
|
"duration": 52238
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/iconShape.spec.ts",
|
"spec": "cypress/integration/rendering/iconShape.spec.ts",
|
||||||
"duration": 283038
|
"duration": 289380
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/imageShape.spec.ts",
|
"spec": "cypress/integration/rendering/imageShape.spec.ts",
|
||||||
"duration": 59434
|
"duration": 59265
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/info.spec.ts",
|
"spec": "cypress/integration/rendering/info.spec.ts",
|
||||||
"duration": 3101
|
"duration": 3269
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/journey.spec.js",
|
"spec": "cypress/integration/rendering/journey.spec.js",
|
||||||
"duration": 7099
|
"duration": 7470
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/kanban.spec.ts",
|
"spec": "cypress/integration/rendering/kanban.spec.ts",
|
||||||
"duration": 7567
|
"duration": 7980
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/katex.spec.js",
|
"spec": "cypress/integration/rendering/katex.spec.js",
|
||||||
"duration": 3817
|
"duration": 3896
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/marker_unique_id.spec.js",
|
"spec": "cypress/integration/rendering/marker_unique_id.spec.js",
|
||||||
"duration": 2624
|
"duration": 2640
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/mindmap-tidy-tree.spec.js",
|
"spec": "cypress/integration/rendering/mindmap-tidy-tree.spec.js",
|
||||||
"duration": 4246
|
"duration": 4327
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/mindmap.spec.ts",
|
"spec": "cypress/integration/rendering/mindmap.spec.ts",
|
||||||
"duration": 11967
|
"duration": 12588
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/newShapes.spec.ts",
|
"spec": "cypress/integration/rendering/newShapes.spec.ts",
|
||||||
"duration": 151914
|
"duration": 153490
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/oldShapes.spec.ts",
|
"spec": "cypress/integration/rendering/oldShapes.spec.ts",
|
||||||
"duration": 116698
|
"duration": 117833
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/packet.spec.ts",
|
"spec": "cypress/integration/rendering/packet.spec.ts",
|
||||||
"duration": 4967
|
"duration": 4975
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/pie.spec.ts",
|
"spec": "cypress/integration/rendering/pie.spec.ts",
|
||||||
"duration": 6700
|
"duration": 6682
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/quadrantChart.spec.js",
|
"spec": "cypress/integration/rendering/quadrantChart.spec.js",
|
||||||
"duration": 8963
|
"duration": 8972
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/radar.spec.js",
|
"spec": "cypress/integration/rendering/radar.spec.js",
|
||||||
"duration": 5540
|
"duration": 5631
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/requirement.spec.js",
|
"spec": "cypress/integration/rendering/requirement.spec.js",
|
||||||
"duration": 2782
|
"duration": 2776
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/requirementDiagram-unified.spec.js",
|
"spec": "cypress/integration/rendering/requirementDiagram-unified.spec.js",
|
||||||
"duration": 54797
|
"duration": 54373
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/sankey.spec.ts",
|
"spec": "cypress/integration/rendering/sankey.spec.ts",
|
||||||
"duration": 6914
|
"duration": 7203
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/sequencediagram-v2.spec.js",
|
"spec": "cypress/integration/rendering/sequencediagram-v2.spec.js",
|
||||||
"duration": 20481
|
"duration": 31707
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/sequencediagram.spec.js",
|
"spec": "cypress/integration/rendering/sequencediagram.spec.js",
|
||||||
"duration": 38490
|
"duration": 48327
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/stateDiagram-v2.spec.js",
|
"spec": "cypress/integration/rendering/stateDiagram-v2.spec.js",
|
||||||
"duration": 30766
|
"duration": 30728
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/stateDiagram.spec.js",
|
"spec": "cypress/integration/rendering/stateDiagram.spec.js",
|
||||||
"duration": 16705
|
"duration": 16881
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/theme.spec.js",
|
"spec": "cypress/integration/rendering/theme.spec.js",
|
||||||
"duration": 30928
|
"duration": 30715
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/timeline.spec.ts",
|
"spec": "cypress/integration/rendering/timeline.spec.ts",
|
||||||
"duration": 8424
|
"duration": 8586
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/treemap.spec.ts",
|
"spec": "cypress/integration/rendering/treemap.spec.ts",
|
||||||
"duration": 12533
|
"duration": 15184
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/xyChart.spec.js",
|
"spec": "cypress/integration/rendering/xyChart.spec.js",
|
||||||
"duration": 21197
|
"duration": 21282
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"spec": "cypress/integration/rendering/zenuml.spec.js",
|
"spec": "cypress/integration/rendering/zenuml.spec.js",
|
||||||
"duration": 3455
|
"duration": 3576
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,7 @@
|
|||||||
}
|
}
|
||||||
Admin --> Report : generates
|
Admin --> Report : generates
|
||||||
</pre>
|
</pre>
|
||||||
|
<hr />
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
classDiagram
|
classDiagram
|
||||||
namespace Company.Project.Module {
|
namespace Company.Project.Module {
|
||||||
@@ -240,6 +241,20 @@
|
|||||||
Bike --> Square : "Logo Shape"
|
Bike --> Square : "Logo Shape"
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
<hr />
|
||||||
|
<pre class="mermaid">
|
||||||
|
classDiagram
|
||||||
|
note "This is a outer note"
|
||||||
|
note for Class1 "This is a outer note for Class1"
|
||||||
|
namespace ns {
|
||||||
|
note "This is a inner note"
|
||||||
|
note for Class1 "This is a inner note for Class1"
|
||||||
|
class Class1
|
||||||
|
class Class2
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
<hr />
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import mermaid from './mermaid.esm.mjs';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: ParseOptions
|
# Interface: ParseOptions
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:88](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L88)
|
Defined in: [packages/mermaid/src/types.ts:89](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L89)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Defined in: [packages/mermaid/src/types.ts:88](https://github.com/mermaid-js/mer
|
|||||||
|
|
||||||
> `optional` **suppressErrors**: `boolean`
|
> `optional` **suppressErrors**: `boolean`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:93](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L93)
|
Defined in: [packages/mermaid/src/types.ts:94](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L94)
|
||||||
|
|
||||||
If `true`, parse will return `false` instead of throwing error when the diagram is invalid.
|
If `true`, parse will return `false` instead of throwing error when the diagram is invalid.
|
||||||
The `parseError` function will not be called.
|
The `parseError` function will not be called.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: ParseResult
|
# Interface: ParseResult
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:96](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L96)
|
Defined in: [packages/mermaid/src/types.ts:97](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L97)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Defined in: [packages/mermaid/src/types.ts:96](https://github.com/mermaid-js/mer
|
|||||||
|
|
||||||
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:104](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L104)
|
Defined in: [packages/mermaid/src/types.ts:105](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L105)
|
||||||
|
|
||||||
The config passed as YAML frontmatter or directives
|
The config passed as YAML frontmatter or directives
|
||||||
|
|
||||||
@@ -28,6 +28,6 @@ The config passed as YAML frontmatter or directives
|
|||||||
|
|
||||||
> **diagramType**: `string`
|
> **diagramType**: `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:100](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L100)
|
Defined in: [packages/mermaid/src/types.ts:101](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L101)
|
||||||
|
|
||||||
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: RenderResult
|
# Interface: RenderResult
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:114](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L114)
|
Defined in: [packages/mermaid/src/types.ts:115](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L115)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Defined in: [packages/mermaid/src/types.ts:114](https://github.com/mermaid-js/me
|
|||||||
|
|
||||||
> `optional` **bindFunctions**: (`element`) => `void`
|
> `optional` **bindFunctions**: (`element`) => `void`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:132](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L132)
|
Defined in: [packages/mermaid/src/types.ts:133](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L133)
|
||||||
|
|
||||||
Bind function to be called after the svg has been inserted into the DOM.
|
Bind function to be called after the svg has been inserted into the DOM.
|
||||||
This is necessary for adding event listeners to the elements in the svg.
|
This is necessary for adding event listeners to the elements in the svg.
|
||||||
@@ -45,7 +45,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present.
|
|||||||
|
|
||||||
> **diagramType**: `string`
|
> **diagramType**: `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:122](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L122)
|
Defined in: [packages/mermaid/src/types.ts:123](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L123)
|
||||||
|
|
||||||
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
||||||
|
|
||||||
@@ -55,6 +55,6 @@ The diagram type, e.g. 'flowchart', 'sequence', etc.
|
|||||||
|
|
||||||
> **svg**: `string`
|
> **svg**: `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:118](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L118)
|
Defined in: [packages/mermaid/src/types.ts:119](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L119)
|
||||||
|
|
||||||
The svg code for the rendered graph.
|
The svg code for the rendered graph.
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ To add an integration to this list, see the [Integrations - create page](./integ
|
|||||||
- [GitHub Writer](https://github.com/ckeditor/github-writer)
|
- [GitHub Writer](https://github.com/ckeditor/github-writer)
|
||||||
- [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
|
- [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
|
||||||
- [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅
|
- [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅
|
||||||
|
- [GNU Octave](https://octave.org/) ✅
|
||||||
|
- [octave_mermaid_js](https://github.com/CNOCTAVE/octave_mermaid_js) ✅
|
||||||
|
- [HackMD](https://hackmd.io/c/tutorials/%2F%40docs%2Fflowchart-en#Create-more-complex-flowcharts) ✅
|
||||||
- [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid)
|
- [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid)
|
||||||
- [MonsterWriter](https://www.monsterwriter.com/) ✅
|
- [MonsterWriter](https://www.monsterwriter.com/) ✅
|
||||||
- [Joplin](https://joplinapp.org) ✅
|
- [Joplin](https://joplinapp.org) ✅
|
||||||
@@ -272,6 +275,7 @@ Communication tools and platforms
|
|||||||
- [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin)
|
- [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin)
|
||||||
- [Reveal CK](https://github.com/jedcn/reveal-ck)
|
- [Reveal CK](https://github.com/jedcn/reveal-ck)
|
||||||
- [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin)
|
- [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin)
|
||||||
|
- [speccharts: Turn your test suites into specification diagrams](https://github.com/arnaudrenaud/speccharts)
|
||||||
- [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer)
|
- [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer)
|
||||||
|
|
||||||
<!--- cspell:ignore Blazorade HueHive --->
|
<!--- cspell:ignore Blazorade HueHive --->
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ block
|
|||||||
blockArrowId4<["Label"]>(down)
|
blockArrowId4<["Label"]>(down)
|
||||||
blockArrowId5<["Label"]>(x)
|
blockArrowId5<["Label"]>(x)
|
||||||
blockArrowId6<["Label"]>(y)
|
blockArrowId6<["Label"]>(y)
|
||||||
blockArrowId6<["Label"]>(x, down)
|
blockArrowId7<["Label"]>(x, down)
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
@@ -413,7 +413,7 @@ block
|
|||||||
blockArrowId4<["Label"]>(down)
|
blockArrowId4<["Label"]>(down)
|
||||||
blockArrowId5<["Label"]>(x)
|
blockArrowId5<["Label"]>(x)
|
||||||
blockArrowId6<["Label"]>(y)
|
blockArrowId6<["Label"]>(y)
|
||||||
blockArrowId6<["Label"]>(x, down)
|
blockArrowId7<["Label"]>(x, down)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example - Space Blocks
|
#### Example - Space Blocks
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ title: Animal example
|
|||||||
classDiagram
|
classDiagram
|
||||||
note "From Duck till Zebra"
|
note "From Duck till Zebra"
|
||||||
Animal <|-- Duck
|
Animal <|-- Duck
|
||||||
note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
|
note for Duck "can fly<br>can swim<br>can dive<br>can help in debugging"
|
||||||
Animal <|-- Fish
|
Animal <|-- Fish
|
||||||
Animal <|-- Zebra
|
Animal <|-- Zebra
|
||||||
Animal : +int age
|
Animal : +int age
|
||||||
@@ -50,7 +50,7 @@ title: Animal example
|
|||||||
classDiagram
|
classDiagram
|
||||||
note "From Duck till Zebra"
|
note "From Duck till Zebra"
|
||||||
Animal <|-- Duck
|
Animal <|-- Duck
|
||||||
note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
|
note for Duck "can fly<br>can swim<br>can dive<br>can help in debugging"
|
||||||
Animal <|-- Fish
|
Animal <|-- Fish
|
||||||
Animal <|-- Zebra
|
Animal <|-- Zebra
|
||||||
Animal : +int age
|
Animal : +int age
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ radar-beta
|
|||||||
radar-beta
|
radar-beta
|
||||||
title Restaurant Comparison
|
title Restaurant Comparison
|
||||||
axis food["Food Quality"], service["Service"], price["Price"]
|
axis food["Food Quality"], service["Service"], price["Price"]
|
||||||
axis ambiance["Ambiance"],
|
axis ambiance["Ambiance"]
|
||||||
|
|
||||||
curve a["Restaurant A"]{4, 3, 2, 4}
|
curve a["Restaurant A"]{4, 3, 2, 4}
|
||||||
curve b["Restaurant B"]{3, 4, 3, 3}
|
curve b["Restaurant B"]{3, 4, 3, 3}
|
||||||
@@ -78,7 +78,7 @@ radar-beta
|
|||||||
radar-beta
|
radar-beta
|
||||||
title Restaurant Comparison
|
title Restaurant Comparison
|
||||||
axis food["Food Quality"], service["Service"], price["Price"]
|
axis food["Food Quality"], service["Service"], price["Price"]
|
||||||
axis ambiance["Ambiance"],
|
axis ambiance["Ambiance"]
|
||||||
|
|
||||||
curve a["Restaurant A"]{4, 3, 2, 4}
|
curve a["Restaurant A"]{4, 3, 2, 4}
|
||||||
curve b["Restaurant B"]{3, 4, 3, 3}
|
curve b["Restaurant B"]{3, 4, 3, 3}
|
||||||
|
|||||||
@@ -196,7 +196,11 @@ sequenceDiagram
|
|||||||
|
|
||||||
### Aliases
|
### Aliases
|
||||||
|
|
||||||
The actor can have a convenient identifier and a descriptive label.
|
The actor can have a convenient identifier and a descriptive label. Aliases can be defined in two ways: using external syntax with the `as` keyword, or inline within the configuration object.
|
||||||
|
|
||||||
|
#### External Alias Syntax
|
||||||
|
|
||||||
|
You can define an alias using the `as` keyword after the participant declaration:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
@@ -214,6 +218,78 @@ sequenceDiagram
|
|||||||
J->>A: Great!
|
J->>A: Great!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The external alias syntax also works with participant stereotype configurations, allowing you to combine type specification with aliases:
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary" } as Public API
|
||||||
|
actor DB@{ "type": "database" } as User Database
|
||||||
|
participant Svc@{ "type": "control" } as Auth Service
|
||||||
|
API->>Svc: Authenticate
|
||||||
|
Svc->>DB: Query user
|
||||||
|
DB-->>Svc: User data
|
||||||
|
Svc-->>API: Token
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary" } as Public API
|
||||||
|
actor DB@{ "type": "database" } as User Database
|
||||||
|
participant Svc@{ "type": "control" } as Auth Service
|
||||||
|
API->>Svc: Authenticate
|
||||||
|
Svc->>DB: Query user
|
||||||
|
DB-->>Svc: User data
|
||||||
|
Svc-->>API: Token
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inline Alias Syntax
|
||||||
|
|
||||||
|
Alternatively, you can define an alias directly inside the configuration object using the `"alias"` field. This works with both `participant` and `actor` keywords:
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary", "alias": "Public API" }
|
||||||
|
participant Auth@{ "type": "control", "alias": "Auth Service" }
|
||||||
|
participant DB@{ "type": "database", "alias": "User Database" }
|
||||||
|
API->>Auth: Login request
|
||||||
|
Auth->>DB: Query user
|
||||||
|
DB-->>Auth: User data
|
||||||
|
Auth-->>API: Access token
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary", "alias": "Public API" }
|
||||||
|
participant Auth@{ "type": "control", "alias": "Auth Service" }
|
||||||
|
participant DB@{ "type": "database", "alias": "User Database" }
|
||||||
|
API->>Auth: Login request
|
||||||
|
Auth->>DB: Query user
|
||||||
|
DB-->>Auth: User data
|
||||||
|
Auth-->>API: Access token
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Alias Precedence
|
||||||
|
|
||||||
|
When both inline alias (in the configuration object) and external alias (using `as` keyword) are provided, the **external alias takes precedence**:
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary", "alias": "Internal Name" } as External Name
|
||||||
|
participant DB@{ "type": "database", "alias": "Internal DB" } as External DB
|
||||||
|
API->>DB: Query
|
||||||
|
DB-->>API: Result
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary", "alias": "Internal Name" } as External Name
|
||||||
|
participant DB@{ "type": "database", "alias": "Internal DB" } as External DB
|
||||||
|
API->>DB: Query
|
||||||
|
DB-->>API: Result
|
||||||
|
```
|
||||||
|
|
||||||
|
In the example above, "External Name" and "External DB" will be displayed, not "Internal Name" and "Internal DB".
|
||||||
|
|
||||||
### Actor Creation and Destruction (v10.3.0+)
|
### Actor Creation and Destruction (v10.3.0+)
|
||||||
|
|
||||||
It is possible to create and destroy actors by messages. To do so, add a create or destroy directive before the message.
|
It is possible to create and destroy actors by messages. To do so, add a create or destroy directive before the message.
|
||||||
@@ -329,7 +405,11 @@ Messages can be of two displayed either solid or with a dotted line.
|
|||||||
[Actor][Arrow][Actor]:Message text
|
[Actor][Arrow][Actor]:Message text
|
||||||
```
|
```
|
||||||
|
|
||||||
There are ten types of arrows currently supported:
|
Lines can be solid or dotted, and can end with various types of arrowheads, crosses, or open arrows.
|
||||||
|
|
||||||
|
#### Supported Arrow Types
|
||||||
|
|
||||||
|
**Standard Arrow Types**
|
||||||
|
|
||||||
| Type | Description |
|
| Type | Description |
|
||||||
| -------- | ---------------------------------------------------- |
|
| -------- | ---------------------------------------------------- |
|
||||||
@@ -344,6 +424,58 @@ There are ten types of arrows currently supported:
|
|||||||
| `-)` | Solid line with an open arrow at the end (async) |
|
| `-)` | Solid line with an open arrow at the end (async) |
|
||||||
| `--)` | Dotted line with a open arrow at the end (async) |
|
| `--)` | Dotted line with a open arrow at the end (async) |
|
||||||
|
|
||||||
|
**Half-Arrows (v\<MERMAID_RELEASE_VERSION>+)**
|
||||||
|
|
||||||
|
The following half-arrow types are supported for more expressive sequence diagrams. Both solid and dotted variants are available by increasing the number of dashes (`-` → `--`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ------- | ---------------------------------------------------- |
|
||||||
|
| `-\|\` | Solid line with top half arrowhead |
|
||||||
|
| `--\|\` | Dotted line with top half arrowhead |
|
||||||
|
| `-\|/` | Solid line with bottom half arrowhead |
|
||||||
|
| `--\|/` | Dotted line with bottom half arrowhead |
|
||||||
|
| `/\|-` | Solid line with reverse top half arrowhead |
|
||||||
|
| `/\|--` | Dotted line with reverse top half arrowhead |
|
||||||
|
| `\\-` | Solid line with reverse bottom half arrowhead |
|
||||||
|
| `\\--` | Dotted line with reverse bottom half arrowhead |
|
||||||
|
| `-\\` | Solid line with top stick half arrowhead |
|
||||||
|
| `--\\` | Dotted line with top stick half arrowhead |
|
||||||
|
| `-//` | Solid line with bottom stick half arrowhead |
|
||||||
|
| `--//` | Dotted line with bottom stick half arrowhead |
|
||||||
|
| `//-` | Solid line with reverse top stick half arrowhead |
|
||||||
|
| `//--` | Dotted line with reverse top stick half arrowhead |
|
||||||
|
| `\\-` | Solid line with reverse bottom stick half arrowhead |
|
||||||
|
| `\\--` | Dotted line with reverse bottom stick half arrowhead |
|
||||||
|
|
||||||
|
## Central Connections (v\<MERMAID_RELEASE_VERSION>+)
|
||||||
|
|
||||||
|
Mermaid sequence diagrams support **central lifeline connections** using a `()`.
|
||||||
|
This is useful to represent messages or signals that connect to a central point, rather than from one actor directly to another.
|
||||||
|
|
||||||
|
To indicate a central connection, append `()` to the arrow syntax.
|
||||||
|
|
||||||
|
#### Basic Syntax
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant John
|
||||||
|
Alice->>()John: Hello John
|
||||||
|
Alice()->>John: How are you?
|
||||||
|
John()->>()Alice: Great!
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant John
|
||||||
|
Alice->>()John: Hello John
|
||||||
|
Alice()->>John: How are you?
|
||||||
|
John()->>()Alice: Great!
|
||||||
|
```
|
||||||
|
|
||||||
## Activations
|
## Activations
|
||||||
|
|
||||||
It is possible to activate and deactivate an actor. (de)activation can be dedicated declarations:
|
It is possible to activate and deactivate an actor. (de)activation can be dedicated declarations:
|
||||||
|
|||||||
60
package.json
60
package.json
@@ -63,73 +63,73 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@applitools/eyes-cypress": "^3.44.9",
|
"@applitools/eyes-cypress": "^3.56.5",
|
||||||
"@argos-ci/cypress": "^6.1.1",
|
"@argos-ci/cypress": "^6.2.2",
|
||||||
"@changesets/changelog-github": "^0.5.1",
|
"@changesets/changelog-github": "^0.5.2",
|
||||||
"@changesets/cli": "^2.27.12",
|
"@changesets/cli": "^2.29.8",
|
||||||
"@cspell/eslint-plugin": "^8.19.4",
|
"@cspell/eslint-plugin": "^9.3.2",
|
||||||
"@cypress/code-coverage": "^3.12.49",
|
"@cypress/code-coverage": "^3.14.7",
|
||||||
"@eslint/js": "^9.26.0",
|
"@eslint/js": "^9.26.0",
|
||||||
"@rollup/plugin-typescript": "^12.1.4",
|
"@rollup/plugin-typescript": "^12.1.4",
|
||||||
"@types/cors": "^2.8.19",
|
"@types/cors": "^2.8.19",
|
||||||
"@types/express": "^5.0.3",
|
"@types/express": "^5.0.6",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/jsdom": "^21.1.7",
|
"@types/jsdom": "^21.1.7",
|
||||||
"@types/lodash": "^4.17.20",
|
"@types/lodash": "^4.17.21",
|
||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"@types/node": "^22.13.17",
|
"@types/node": "^22.19.1",
|
||||||
"@types/rollup-plugin-visualizer": "^5.0.3",
|
"@types/rollup-plugin-visualizer": "^5.0.3",
|
||||||
"@vitest/coverage-v8": "^3.0.9",
|
"@vitest/coverage-v8": "^3.2.4",
|
||||||
"@vitest/spy": "^3.0.9",
|
"@vitest/spy": "^3.2.4",
|
||||||
"@vitest/ui": "^3.0.9",
|
"@vitest/ui": "^3.2.4",
|
||||||
"ajv": "^8.17.1",
|
"ajv": "^8.17.1",
|
||||||
"chokidar": "3.6.0",
|
"chokidar": "3.6.0",
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.2.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cpy-cli": "^5.0.0",
|
"cpy-cli": "^5.0.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"cspell": "^9.1.5",
|
"cspell": "^9.3.2",
|
||||||
"cypress": "^14.5.4",
|
"cypress": "^14.5.4",
|
||||||
"cypress-image-snapshot": "^4.0.1",
|
"cypress-image-snapshot": "^4.0.1",
|
||||||
"cypress-split": "^1.24.21",
|
"cypress-split": "^1.24.25",
|
||||||
"esbuild": "^0.25.9",
|
"esbuild": "^0.25.12",
|
||||||
"eslint": "^9.26.0",
|
"eslint": "^9.26.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-cypress": "^4.3.0",
|
"eslint-plugin-cypress": "^5.2.0",
|
||||||
"eslint-plugin-html": "^8.1.3",
|
"eslint-plugin-html": "^8.1.3",
|
||||||
"eslint-plugin-jest": "^28.14.0",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
"eslint-plugin-jsdoc": "^50.8.0",
|
"eslint-plugin-jsdoc": "^61.1.12",
|
||||||
"eslint-plugin-json": "^4.0.1",
|
"eslint-plugin-json": "^4.0.1",
|
||||||
"eslint-plugin-lodash": "^8.0.0",
|
"eslint-plugin-lodash": "^8.0.0",
|
||||||
"eslint-plugin-markdown": "^5.1.0",
|
"eslint-plugin-markdown": "^5.1.0",
|
||||||
"eslint-plugin-no-only-tests": "^3.3.0",
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
||||||
"eslint-plugin-tsdoc": "^0.4.0",
|
"eslint-plugin-tsdoc": "^0.4.0",
|
||||||
"eslint-plugin-unicorn": "^59.0.1",
|
"eslint-plugin-unicorn": "^62.0.0",
|
||||||
"express": "^5.1.0",
|
"express": "^5.2.1",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.4.0",
|
||||||
"globby": "^14.1.0",
|
"globby": "^14.1.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"jest": "^30.0.5",
|
"jest": "^30.1.3",
|
||||||
"jison": "^0.4.18",
|
"jison": "^0.4.18",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.1",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^26.1.0",
|
||||||
"langium-cli": "3.3.0",
|
"langium-cli": "3.3.0",
|
||||||
"lint-staged": "^16.1.6",
|
"lint-staged": "^16.1.6",
|
||||||
"markdown-table": "^3.0.4",
|
"markdown-table": "^3.0.4",
|
||||||
"nyc": "^17.1.0",
|
"nyc": "^17.1.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.6.2",
|
||||||
"prettier-plugin-jsdoc": "^1.3.3",
|
"prettier-plugin-jsdoc": "^1.3.3",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"rollup-plugin-visualizer": "^6.0.3",
|
"rollup-plugin-visualizer": "^6.0.5",
|
||||||
"start-server-and-test": "^2.0.13",
|
"start-server-and-test": "^2.1.3",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"tsx": "^4.7.3",
|
"tsx": "^4.20.6",
|
||||||
"typescript": "~5.7.3",
|
"typescript": "~5.7.3",
|
||||||
"typescript-eslint": "^8.38.0",
|
"typescript-eslint": "^8.38.0",
|
||||||
"vite": "^7.0.6",
|
"vite": "^7.0.8",
|
||||||
"vite-plugin-istanbul": "^7.0.0",
|
"vite-plugin-istanbul": "^7.0.0",
|
||||||
"vitest": "^3.0.9"
|
"vitest": "^3.2.4"
|
||||||
},
|
},
|
||||||
"nyc": {
|
"nyc": {
|
||||||
"report-dir": "coverage/cypress"
|
"report-dir": "coverage/cypress"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
"khroma": "^2.1.0"
|
"khroma": "^2.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.2.1",
|
||||||
"mermaid": "workspace:*",
|
"mermaid": "workspace:*",
|
||||||
"rimraf": "^6.0.1"
|
"rimraf": "^6.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
"elk",
|
"elk",
|
||||||
"mermaid"
|
"mermaid"
|
||||||
],
|
],
|
||||||
"scripts": {},
|
"scripts": {
|
||||||
|
"clean": "rimraf dist"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/mermaid-js/mermaid"
|
"url": "https://github.com/mermaid-js/mermaid"
|
||||||
|
|||||||
@@ -67,7 +67,22 @@ export const render = async (
|
|||||||
|
|
||||||
// Add the element to the DOM
|
// Add the element to the DOM
|
||||||
if (!node.isGroup) {
|
if (!node.isGroup) {
|
||||||
const child = node as NodeWithVertex;
|
// const child = node as NodeWithVertex;
|
||||||
|
const child: NodeWithVertex = {
|
||||||
|
id: node.id,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
// Store the original node data for later use
|
||||||
|
label: node.label,
|
||||||
|
isGroup: node.isGroup,
|
||||||
|
shape: node.shape,
|
||||||
|
padding: node.padding,
|
||||||
|
cssClasses: node.cssClasses,
|
||||||
|
cssStyles: node.cssStyles,
|
||||||
|
look: node.look,
|
||||||
|
// Include parentId for subgraph processing
|
||||||
|
parentId: node.parentId,
|
||||||
|
};
|
||||||
graph.children.push(child);
|
graph.children.push(child);
|
||||||
nodeDb[node.id] = node;
|
nodeDb[node.id] = node;
|
||||||
|
|
||||||
@@ -150,7 +165,7 @@ export const render = async (
|
|||||||
domId: { node: () => any; attr: (arg0: string, arg1: string) => void };
|
domId: { node: () => any; attr: (arg0: string, arg1: string) => void };
|
||||||
}) {
|
}) {
|
||||||
if (node) {
|
if (node) {
|
||||||
nodeDb[node.id] = node;
|
nodeDb[node.id] ??= {};
|
||||||
nodeDb[node.id].offset = {
|
nodeDb[node.id].offset = {
|
||||||
posX: node.x + relX,
|
posX: node.x + relX,
|
||||||
posY: node.y + relY,
|
posY: node.y + relY,
|
||||||
@@ -860,11 +875,13 @@ export const render = async (
|
|||||||
log.info('APA01 layout result:', JSON.stringify(g, null, 2));
|
log.info('APA01 layout result:', JSON.stringify(g, null, 2));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error('APA01 ELK layout error:', error);
|
log.error('APA01 ELK layout error:', error);
|
||||||
|
log.error('APA01 elkGraph that caused error:', JSON.stringify(elkGraph, null, 2));
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// debugger;
|
// debugger;
|
||||||
await drawNodes(0, 0, g.children, svg, subGraphsEl, 0);
|
await drawNodes(0, 0, g.children, svg, subGraphsEl, 0);
|
||||||
|
|
||||||
g.edges?.map(
|
g.edges?.map(
|
||||||
(edge: {
|
(edge: {
|
||||||
sources: (string | number)[];
|
sources: (string | number)[];
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
"mermaid",
|
"mermaid",
|
||||||
"layout"
|
"layout"
|
||||||
],
|
],
|
||||||
"scripts": {},
|
"scripts": {
|
||||||
|
"clean": "rimraf dist"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/mermaid-js/mermaid"
|
"url": "https://github.com/mermaid-js/mermaid"
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@zenuml/core": "^3.35.2"
|
"@zenuml/core": "^3.41.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mermaid": "workspace:^"
|
"mermaid": "workspace:^"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# mermaid
|
# mermaid
|
||||||
|
|
||||||
|
## 11.12.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#7107](https://github.com/mermaid-js/mermaid/pull/7107) [`cbf8946`](https://github.com/mermaid-js/mermaid/commit/cbf89462acecac7a06f19843e8d48cb137df0753) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - fix: Updated the dependency dagre-d3-es to 7.0.13 to fix GHSA-cc8p-78qf-8p7q
|
||||||
|
|
||||||
## 11.12.0
|
## 11.12.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mermaid",
|
"name": "mermaid",
|
||||||
"version": "11.12.0",
|
"version": "11.12.1",
|
||||||
"description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.",
|
"description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "./dist/mermaid.core.mjs",
|
"module": "./dist/mermaid.core.mjs",
|
||||||
@@ -68,32 +68,32 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^7.1.1",
|
"@braintree/sanitize-url": "^7.1.1",
|
||||||
"@iconify/utils": "^3.0.1",
|
"@iconify/utils": "^3.0.2",
|
||||||
"@mermaid-js/parser": "workspace:^",
|
"@mermaid-js/parser": "workspace:^",
|
||||||
"@types/d3": "^7.4.3",
|
"@types/d3": "^7.4.3",
|
||||||
"cytoscape": "^3.29.3",
|
"cytoscape": "^3.33.1",
|
||||||
"cytoscape-cose-bilkent": "^4.1.0",
|
"cytoscape-cose-bilkent": "^4.1.0",
|
||||||
"cytoscape-fcose": "^2.2.0",
|
"cytoscape-fcose": "^2.2.0",
|
||||||
"d3": "^7.9.0",
|
"d3": "^7.9.0",
|
||||||
"d3-sankey": "^0.12.3",
|
"d3-sankey": "^0.12.3",
|
||||||
"dagre-d3-es": "7.0.11",
|
"dagre-d3-es": "7.0.13",
|
||||||
"dayjs": "^1.11.18",
|
"dayjs": "^1.11.19",
|
||||||
"dompurify": "^3.2.5",
|
"dompurify": "^3.3.1",
|
||||||
"katex": "^0.16.22",
|
"katex": "^0.16.25",
|
||||||
"khroma": "^2.1.0",
|
"khroma": "^2.1.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"marked": "^16.2.1",
|
"marked": "^16.3.0",
|
||||||
"roughjs": "^4.6.6",
|
"roughjs": "^4.6.6",
|
||||||
"stylis": "^4.3.6",
|
"stylis": "^4.3.6",
|
||||||
"ts-dedent": "^2.2.0",
|
"ts-dedent": "^2.2.0",
|
||||||
"uuid": "^11.1.0"
|
"uuid": "^11.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@adobe/jsonschema2md": "^8.0.5",
|
"@adobe/jsonschema2md": "^8.0.8",
|
||||||
"@iconify/types": "^2.0.0",
|
"@iconify/types": "^2.0.0",
|
||||||
"@types/cytoscape": "^3.21.9",
|
"@types/cytoscape": "^3.21.9",
|
||||||
"@types/cytoscape-fcose": "^2.2.4",
|
"@types/cytoscape-fcose": "^2.2.5",
|
||||||
"@types/d3-sankey": "^0.12.4",
|
"@types/d3-sankey": "^0.12.5",
|
||||||
"@types/d3-scale": "^4.0.9",
|
"@types/d3-scale": "^4.0.9",
|
||||||
"@types/d3-scale-chromatic": "^3.1.0",
|
"@types/d3-scale-chromatic": "^3.1.0",
|
||||||
"@types/d3-selection": "^3.0.11",
|
"@types/d3-selection": "^3.0.11",
|
||||||
@@ -101,13 +101,13 @@
|
|||||||
"@types/jsdom": "^21.1.7",
|
"@types/jsdom": "^21.1.7",
|
||||||
"@types/katex": "^0.16.7",
|
"@types/katex": "^0.16.7",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/micromatch": "^4.0.9",
|
"@types/micromatch": "^4.0.10",
|
||||||
"@types/stylis": "^4.2.7",
|
"@types/stylis": "^4.2.7",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"ajv": "^8.17.1",
|
"ajv": "^8.17.1",
|
||||||
"canvas": "^3.1.2",
|
"canvas": "^3.2.0",
|
||||||
"chokidar": "3.6.0",
|
"chokidar": "3.6.0",
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.2.1",
|
||||||
"csstree-validator": "^4.0.1",
|
"csstree-validator": "^4.0.1",
|
||||||
"globby": "^14.1.0",
|
"globby": "^14.1.0",
|
||||||
"jison": "^0.4.18",
|
"jison": "^0.4.18",
|
||||||
@@ -116,14 +116,14 @@
|
|||||||
"json-schema-to-typescript": "^15.0.4",
|
"json-schema-to-typescript": "^15.0.4",
|
||||||
"micromatch": "^4.0.8",
|
"micromatch": "^4.0.8",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.6.2",
|
||||||
"remark": "^15.0.1",
|
"remark": "^15.0.1",
|
||||||
"remark-frontmatter": "^5.0.0",
|
"remark-frontmatter": "^5.0.0",
|
||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"start-server-and-test": "^2.0.13",
|
"start-server-and-test": "^2.1.3",
|
||||||
"type-fest": "^4.35.0",
|
"type-fest": "^4.41.0",
|
||||||
"typedoc": "^0.28.12",
|
"typedoc": "^0.28.15",
|
||||||
"typedoc-plugin-markdown": "^4.8.1",
|
"typedoc-plugin-markdown": "^4.8.1",
|
||||||
"typescript": "~5.7.3",
|
"typescript": "~5.7.3",
|
||||||
"unist-util-flatmap": "^1.0.0",
|
"unist-util-flatmap": "^1.0.0",
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export const addDiagrams = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (includeLargeFeatures) {
|
if (injected.includeLargeFeatures) {
|
||||||
registerLazyLoadedDiagrams(flowchartElk, mindmap, architecture);
|
registerLazyLoadedDiagrams(flowchartElk, mindmap, architecture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
58
packages/mermaid/src/diagrams/c4/parser/c4Component.spec.js
Normal file
58
packages/mermaid/src/diagrams/c4/parser/c4Component.spec.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import c4Db from '../c4Db.js';
|
||||||
|
import c4 from './c4Diagram.jison';
|
||||||
|
import { setConfig } from '../../../config.js';
|
||||||
|
|
||||||
|
setConfig({
|
||||||
|
securityLevel: 'strict',
|
||||||
|
});
|
||||||
|
|
||||||
|
describe.each([
|
||||||
|
['Component', 'component'],
|
||||||
|
['ComponentDb', 'component_db'],
|
||||||
|
['ComponentQueue', 'component_queue'],
|
||||||
|
['Component_Ext', 'external_component'],
|
||||||
|
['ComponentDb_Ext', 'external_component_db'],
|
||||||
|
['ComponentQueue_Ext', 'external_component_queue'],
|
||||||
|
])('parsing a C4 %s', function (macroName, elementName) {
|
||||||
|
beforeEach(function () {
|
||||||
|
c4.parser.yy = c4Db;
|
||||||
|
c4.parser.yy.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse a C4 diagram with one Component correctly', function () {
|
||||||
|
c4.parser.parse(`C4Component
|
||||||
|
title Component diagram for Internet Banking Component
|
||||||
|
${macroName}(ComponentAA, "Internet Banking Component", "Technology", "Allows customers to view information about their bank accounts, and make payments.")`);
|
||||||
|
|
||||||
|
const yy = c4.parser.yy;
|
||||||
|
|
||||||
|
const shapes = yy.getC4ShapeArray();
|
||||||
|
expect(shapes.length).toBe(1);
|
||||||
|
const onlyShape = shapes[0];
|
||||||
|
|
||||||
|
expect(onlyShape).toMatchObject({
|
||||||
|
alias: 'ComponentAA',
|
||||||
|
descr: {
|
||||||
|
text: 'Allows customers to view information about their bank accounts, and make payments.',
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
text: 'Internet Banking Component',
|
||||||
|
},
|
||||||
|
techn: {
|
||||||
|
text: 'Technology',
|
||||||
|
},
|
||||||
|
typeC4Shape: {
|
||||||
|
text: elementName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle a trailing whitespaces after Component', function () {
|
||||||
|
const whitespace = ' ';
|
||||||
|
const rendered = c4.parser.parse(`C4Component${whitespace}
|
||||||
|
title Component diagram for Internet Banking Component${whitespace}
|
||||||
|
${macroName}(ComponentAA, "Internet Banking Component", "Technology", "Allows customers to view information about their bank accounts, and make payments.")${whitespace}`);
|
||||||
|
|
||||||
|
expect(rendered).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -158,10 +158,10 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multiline");}
|
|||||||
"UpdateRelStyle" { this.begin("update_rel_style"); return 'UPDATE_REL_STYLE';}
|
"UpdateRelStyle" { this.begin("update_rel_style"); return 'UPDATE_REL_STYLE';}
|
||||||
"UpdateLayoutConfig" { this.begin("update_layout_config"); return 'UPDATE_LAYOUT_CONFIG';}
|
"UpdateLayoutConfig" { this.begin("update_layout_config"); return 'UPDATE_LAYOUT_CONFIG';}
|
||||||
|
|
||||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config><<EOF>> return "EOF_IN_STRUCT";
|
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext_queue,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config><<EOF>> return "EOF_IN_STRUCT";
|
||||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(][ ]*[,] { this.begin("attribute"); return "ATTRIBUTE_EMPTY";}
|
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext_queue,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(][ ]*[,] { this.begin("attribute"); return "ATTRIBUTE_EMPTY";}
|
||||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(] { this.begin("attribute"); }
|
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext_queue,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config>[(] { this.begin("attribute"); }
|
||||||
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config,attribute>[)] { this.popState();this.popState();}
|
<person,person_ext,system_ext_queue,system_ext_db,system_ext,system_queue,system_db,system,boundary,enterprise_boundary,system_boundary,container_ext_db,container_ext_queue,container_ext,container_queue,container_db,container,container_boundary,component_ext_db,component_ext_queue,component_ext,component_queue,component_db,component,node,node_l,node_r,rel,birel,rel_u,rel_d,rel_l,rel_r,rel_b,rel_index,update_el_style,update_rel_style,update_layout_config,attribute>[)] { this.popState();this.popState();}
|
||||||
|
|
||||||
<attribute>",," { return 'ATTRIBUTE_EMPTY';}
|
<attribute>",," { return 'ATTRIBUTE_EMPTY';}
|
||||||
<attribute>"," { }
|
<attribute>"," { }
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import type {
|
|||||||
ClassRelation,
|
ClassRelation,
|
||||||
ClassNode,
|
ClassNode,
|
||||||
ClassNote,
|
ClassNote,
|
||||||
|
ClassNoteMap,
|
||||||
ClassMap,
|
ClassMap,
|
||||||
NamespaceMap,
|
NamespaceMap,
|
||||||
NamespaceNode,
|
NamespaceNode,
|
||||||
@@ -33,15 +34,16 @@ const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
|
|||||||
|
|
||||||
export class ClassDB implements DiagramDB {
|
export class ClassDB implements DiagramDB {
|
||||||
private relations: ClassRelation[] = [];
|
private relations: ClassRelation[] = [];
|
||||||
private classes = new Map<string, ClassNode>();
|
private classes: ClassMap = new Map<string, ClassNode>();
|
||||||
private readonly styleClasses = new Map<string, StyleClass>();
|
private readonly styleClasses = new Map<string, StyleClass>();
|
||||||
private notes: ClassNote[] = [];
|
private notes: ClassNoteMap = new Map<string, ClassNote>();
|
||||||
private interfaces: Interface[] = [];
|
private interfaces: Interface[] = [];
|
||||||
// private static classCounter = 0;
|
// private static classCounter = 0;
|
||||||
private namespaces = new Map<string, NamespaceNode>();
|
private namespaces = new Map<string, NamespaceNode>();
|
||||||
private namespaceCounter = 0;
|
private namespaceCounter = 0;
|
||||||
|
|
||||||
private functions: any[] = [];
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||||
|
private functions: Function[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.functions.push(this.setupToolTips.bind(this));
|
this.functions.push(this.setupToolTips.bind(this));
|
||||||
@@ -124,7 +126,7 @@ export class ClassDB implements DiagramDB {
|
|||||||
annotations: [],
|
annotations: [],
|
||||||
styles: [],
|
styles: [],
|
||||||
domId: MERMAID_DOM_ID_PREFIX + name + '-' + classCounter,
|
domId: MERMAID_DOM_ID_PREFIX + name + '-' + classCounter,
|
||||||
} as ClassNode);
|
});
|
||||||
|
|
||||||
classCounter++;
|
classCounter++;
|
||||||
}
|
}
|
||||||
@@ -155,12 +157,12 @@ export class ClassDB implements DiagramDB {
|
|||||||
|
|
||||||
public clear() {
|
public clear() {
|
||||||
this.relations = [];
|
this.relations = [];
|
||||||
this.classes = new Map();
|
this.classes = new Map<string, ClassNode>();
|
||||||
this.notes = [];
|
this.notes = new Map<string, ClassNote>();
|
||||||
this.interfaces = [];
|
this.interfaces = [];
|
||||||
this.functions = [];
|
this.functions = [];
|
||||||
this.functions.push(this.setupToolTips.bind(this));
|
this.functions.push(this.setupToolTips.bind(this));
|
||||||
this.namespaces = new Map();
|
this.namespaces = new Map<string, NamespaceNode>();
|
||||||
this.namespaceCounter = 0;
|
this.namespaceCounter = 0;
|
||||||
this.direction = 'TB';
|
this.direction = 'TB';
|
||||||
commonClear();
|
commonClear();
|
||||||
@@ -178,7 +180,12 @@ export class ClassDB implements DiagramDB {
|
|||||||
return this.relations;
|
return this.relations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNotes() {
|
public getNote(id: string | number): ClassNote {
|
||||||
|
const key = typeof id === 'number' ? `note${id}` : id;
|
||||||
|
return this.notes.get(key)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNotes(): ClassNoteMap {
|
||||||
return this.notes;
|
return this.notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,16 +286,19 @@ export class ClassDB implements DiagramDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addNote(text: string, className: string) {
|
public addNote(text: string, className: string): string {
|
||||||
|
const index = this.notes.size;
|
||||||
const note = {
|
const note = {
|
||||||
id: `note${this.notes.length}`,
|
id: `note${index}`,
|
||||||
class: className,
|
class: className,
|
||||||
text: text,
|
text: text,
|
||||||
|
index: index,
|
||||||
};
|
};
|
||||||
this.notes.push(note);
|
this.notes.set(note.id, note);
|
||||||
|
return note.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public cleanupLabel(label: string) {
|
public cleanupLabel(label: string): string {
|
||||||
if (label.startsWith(':')) {
|
if (label.startsWith(':')) {
|
||||||
label = label.substring(1);
|
label = label.substring(1);
|
||||||
}
|
}
|
||||||
@@ -354,7 +364,7 @@ export class ClassDB implements DiagramDB {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTooltip(id: string, namespace?: string) {
|
public getTooltip(id: string, namespace?: string): string | undefined {
|
||||||
if (namespace && this.namespaces.has(namespace)) {
|
if (namespace && this.namespaces.has(namespace)) {
|
||||||
return this.namespaces.get(namespace)!.classes.get(id)!.tooltip;
|
return this.namespaces.get(namespace)!.classes.get(id)!.tooltip;
|
||||||
}
|
}
|
||||||
@@ -534,10 +544,11 @@ export class ClassDB implements DiagramDB {
|
|||||||
|
|
||||||
this.namespaces.set(id, {
|
this.namespaces.set(id, {
|
||||||
id: id,
|
id: id,
|
||||||
classes: new Map(),
|
classes: new Map<string, ClassNode>(),
|
||||||
children: {},
|
notes: new Map<string, ClassNote>(),
|
||||||
|
children: new Map<string, NamespaceNode>(),
|
||||||
domId: MERMAID_DOM_ID_PREFIX + id + '-' + this.namespaceCounter,
|
domId: MERMAID_DOM_ID_PREFIX + id + '-' + this.namespaceCounter,
|
||||||
} as NamespaceNode);
|
});
|
||||||
|
|
||||||
this.namespaceCounter++;
|
this.namespaceCounter++;
|
||||||
}
|
}
|
||||||
@@ -555,16 +566,23 @@ export class ClassDB implements DiagramDB {
|
|||||||
*
|
*
|
||||||
* @param id - ID of the namespace to add
|
* @param id - ID of the namespace to add
|
||||||
* @param classNames - IDs of the class to add
|
* @param classNames - IDs of the class to add
|
||||||
|
* @param noteNames - IDs of the notes to add
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
public addClassesToNamespace(id: string, classNames: string[]) {
|
public addClassesToNamespace(id: string, classNames: string[], noteNames: string[]) {
|
||||||
if (!this.namespaces.has(id)) {
|
if (!this.namespaces.has(id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const name of classNames) {
|
for (const name of classNames) {
|
||||||
const { className } = this.splitClassNameAndType(name);
|
const { className } = this.splitClassNameAndType(name);
|
||||||
this.classes.get(className)!.parent = id;
|
const classNode = this.getClass(className);
|
||||||
this.namespaces.get(id)!.classes.set(className, this.classes.get(className)!);
|
classNode.parent = id;
|
||||||
|
this.namespaces.get(id)!.classes.set(className, classNode);
|
||||||
|
}
|
||||||
|
for (const noteName of noteNames) {
|
||||||
|
const noteNode = this.getNote(noteName);
|
||||||
|
noteNode.parent = id;
|
||||||
|
this.namespaces.get(id)!.notes.set(noteName, noteNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,36 +635,32 @@ export class ClassDB implements DiagramDB {
|
|||||||
const edges: Edge[] = [];
|
const edges: Edge[] = [];
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
|
|
||||||
for (const namespaceKey of this.namespaces.keys()) {
|
for (const namespace of this.namespaces.values()) {
|
||||||
const namespace = this.namespaces.get(namespaceKey);
|
const node: Node = {
|
||||||
if (namespace) {
|
id: namespace.id,
|
||||||
const node: Node = {
|
label: namespace.id,
|
||||||
id: namespace.id,
|
isGroup: true,
|
||||||
label: namespace.id,
|
padding: config.class!.padding ?? 16,
|
||||||
isGroup: true,
|
// parent node must be one of [rect, roundedWithTitle, noteGroup, divider]
|
||||||
padding: config.class!.padding ?? 16,
|
shape: 'rect',
|
||||||
// parent node must be one of [rect, roundedWithTitle, noteGroup, divider]
|
cssStyles: [],
|
||||||
shape: 'rect',
|
look: config.look,
|
||||||
cssStyles: ['fill: none', 'stroke: black'],
|
};
|
||||||
look: config.look,
|
nodes.push(node);
|
||||||
};
|
|
||||||
nodes.push(node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const classKey of this.classes.keys()) {
|
for (const classNode of this.classes.values()) {
|
||||||
const classNode = this.classes.get(classKey);
|
const node: Node = {
|
||||||
if (classNode) {
|
...classNode,
|
||||||
const node = classNode as unknown as Node;
|
type: undefined,
|
||||||
node.parentId = classNode.parent;
|
isGroup: false,
|
||||||
node.look = config.look;
|
parentId: classNode.parent,
|
||||||
nodes.push(node);
|
look: config.look,
|
||||||
}
|
};
|
||||||
|
nodes.push(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
let cnt = 0;
|
for (const note of this.notes.values()) {
|
||||||
for (const note of this.notes) {
|
|
||||||
cnt++;
|
|
||||||
const noteNode: Node = {
|
const noteNode: Node = {
|
||||||
id: note.id,
|
id: note.id,
|
||||||
label: note.text,
|
label: note.text,
|
||||||
@@ -660,14 +674,15 @@ export class ClassDB implements DiagramDB {
|
|||||||
`stroke: ${config.themeVariables.noteBorderColor}`,
|
`stroke: ${config.themeVariables.noteBorderColor}`,
|
||||||
],
|
],
|
||||||
look: config.look,
|
look: config.look,
|
||||||
|
parentId: note.parent,
|
||||||
};
|
};
|
||||||
nodes.push(noteNode);
|
nodes.push(noteNode);
|
||||||
|
|
||||||
const noteClassId = this.classes.get(note.class)?.id ?? '';
|
const noteClassId = this.classes.get(note.class)?.id;
|
||||||
|
|
||||||
if (noteClassId) {
|
if (noteClassId) {
|
||||||
const edge: Edge = {
|
const edge: Edge = {
|
||||||
id: `edgeNote${cnt}`,
|
id: `edgeNote${note.index}`,
|
||||||
start: note.id,
|
start: note.id,
|
||||||
end: noteClassId,
|
end: noteClassId,
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
@@ -697,7 +712,7 @@ export class ClassDB implements DiagramDB {
|
|||||||
nodes.push(interfaceNode);
|
nodes.push(interfaceNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = 0;
|
let cnt = 0;
|
||||||
for (const classRelation of this.relations) {
|
for (const classRelation of this.relations) {
|
||||||
cnt++;
|
cnt++;
|
||||||
const edge: Edge = {
|
const edge: Edge = {
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ class C13["With Città foreign language"]
|
|||||||
note "This is a keyword: ${keyword}. It truly is."
|
note "This is a keyword: ${keyword}. It truly is."
|
||||||
`;
|
`;
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
expect(classDb.getNotes()[0].text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
|
expect(classDb.getNote(0).text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(keywords)(
|
it.each(keywords)(
|
||||||
@@ -427,7 +427,7 @@ class C13["With Città foreign language"]
|
|||||||
note "${keyword}"`;
|
note "${keyword}"`;
|
||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
expect(classDb.getNotes()[0].text).toEqual(`${keyword}`);
|
expect(classDb.getNote(0).text).toEqual(`${keyword}`);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -441,7 +441,7 @@ class C13["With Città foreign language"]
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
expect(classDb.getNotes()[0].text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
|
expect(classDb.getNote(0).text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(keywords)(
|
it.each(keywords)(
|
||||||
@@ -456,7 +456,7 @@ class C13["With Città foreign language"]
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
expect(classDb.getNotes()[0].text).toEqual(`${keyword}`);
|
expect(classDb.getNote(0).text).toEqual(`${keyword}`);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import utils, { getEdgeId } from '../../utils.js';
|
|||||||
import { interpolateToCurve, getStylesFromArray } from '../../utils.js';
|
import { interpolateToCurve, getStylesFromArray } from '../../utils.js';
|
||||||
import { setupGraphViewbox } from '../../setupGraphViewbox.js';
|
import { setupGraphViewbox } from '../../setupGraphViewbox.js';
|
||||||
import common from '../common/common.js';
|
import common from '../common/common.js';
|
||||||
import type { ClassRelation, ClassNote, ClassMap, NamespaceMap } from './classTypes.js';
|
import type { ClassRelation, ClassMap, ClassNoteMap, NamespaceMap } from './classTypes.js';
|
||||||
import type { EdgeData } from '../../types.js';
|
import type { EdgeData } from '../../types.js';
|
||||||
|
|
||||||
const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
|
const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
|
||||||
@@ -65,6 +65,9 @@ export const addNamespaces = function (
|
|||||||
|
|
||||||
g.setNode(vertex.id, node);
|
g.setNode(vertex.id, node);
|
||||||
addClasses(vertex.classes, g, _id, diagObj, vertex.id);
|
addClasses(vertex.classes, g, _id, diagObj, vertex.id);
|
||||||
|
const classes: ClassMap = diagObj.db.getClasses();
|
||||||
|
const relations: ClassRelation[] = diagObj.db.getRelations();
|
||||||
|
addNotes(vertex.notes, g, relations.length + 1, classes, vertex.id);
|
||||||
|
|
||||||
log.info('setNode', node);
|
log.info('setNode', node);
|
||||||
});
|
});
|
||||||
@@ -144,69 +147,74 @@ export const addClasses = function (
|
|||||||
* @param classes - Classes
|
* @param classes - Classes
|
||||||
*/
|
*/
|
||||||
export const addNotes = function (
|
export const addNotes = function (
|
||||||
notes: ClassNote[],
|
notes: ClassNoteMap,
|
||||||
g: graphlib.Graph,
|
g: graphlib.Graph,
|
||||||
startEdgeId: number,
|
startEdgeId: number,
|
||||||
classes: ClassMap
|
classes: ClassMap,
|
||||||
|
parent?: string
|
||||||
) {
|
) {
|
||||||
log.info(notes);
|
log.info(notes);
|
||||||
|
|
||||||
notes.forEach(function (note, i) {
|
[...notes.values()]
|
||||||
const vertex = note;
|
.filter((note) => note.parent === parent)
|
||||||
|
.forEach(function (vertex) {
|
||||||
|
const cssNoteStr = '';
|
||||||
|
|
||||||
const cssNoteStr = '';
|
const styles = { labelStyle: '', style: '' };
|
||||||
|
|
||||||
const styles = { labelStyle: '', style: '' };
|
const vertexText = vertex.text;
|
||||||
|
|
||||||
const vertexText = vertex.text;
|
const radius = 0;
|
||||||
|
const shape = 'note';
|
||||||
|
const node = {
|
||||||
|
labelStyle: styles.labelStyle,
|
||||||
|
shape: shape,
|
||||||
|
labelText: sanitizeText(vertexText),
|
||||||
|
noteData: vertex,
|
||||||
|
rx: radius,
|
||||||
|
ry: radius,
|
||||||
|
class: cssNoteStr,
|
||||||
|
style: styles.style,
|
||||||
|
id: vertex.id,
|
||||||
|
domId: vertex.id,
|
||||||
|
tooltip: '',
|
||||||
|
type: 'note',
|
||||||
|
// TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
|
||||||
|
padding: getConfig().flowchart?.padding ?? getConfig().class?.padding,
|
||||||
|
};
|
||||||
|
g.setNode(vertex.id, node);
|
||||||
|
log.info('setNode', node);
|
||||||
|
|
||||||
const radius = 0;
|
if (parent) {
|
||||||
const shape = 'note';
|
g.setParent(vertex.id, parent);
|
||||||
const node = {
|
}
|
||||||
labelStyle: styles.labelStyle,
|
|
||||||
shape: shape,
|
|
||||||
labelText: sanitizeText(vertexText),
|
|
||||||
noteData: vertex,
|
|
||||||
rx: radius,
|
|
||||||
ry: radius,
|
|
||||||
class: cssNoteStr,
|
|
||||||
style: styles.style,
|
|
||||||
id: vertex.id,
|
|
||||||
domId: vertex.id,
|
|
||||||
tooltip: '',
|
|
||||||
type: 'note',
|
|
||||||
// TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
|
|
||||||
padding: getConfig().flowchart?.padding ?? getConfig().class?.padding,
|
|
||||||
};
|
|
||||||
g.setNode(vertex.id, node);
|
|
||||||
log.info('setNode', node);
|
|
||||||
|
|
||||||
if (!vertex.class || !classes.has(vertex.class)) {
|
if (!vertex.class || !classes.has(vertex.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const edgeId = startEdgeId + i;
|
const edgeId = startEdgeId + vertex.index;
|
||||||
|
|
||||||
const edgeData: EdgeData = {
|
const edgeData: EdgeData = {
|
||||||
id: `edgeNote${edgeId}`,
|
id: `edgeNote${edgeId}`,
|
||||||
//Set relationship style and line type
|
//Set relationship style and line type
|
||||||
classes: 'relation',
|
classes: 'relation',
|
||||||
pattern: 'dotted',
|
pattern: 'dotted',
|
||||||
// Set link type for rendering
|
// Set link type for rendering
|
||||||
arrowhead: 'none',
|
arrowhead: 'none',
|
||||||
//Set edge extra labels
|
//Set edge extra labels
|
||||||
startLabelRight: '',
|
startLabelRight: '',
|
||||||
endLabelLeft: '',
|
endLabelLeft: '',
|
||||||
//Set relation arrow types
|
//Set relation arrow types
|
||||||
arrowTypeStart: 'none',
|
arrowTypeStart: 'none',
|
||||||
arrowTypeEnd: 'none',
|
arrowTypeEnd: 'none',
|
||||||
style: 'fill:none',
|
style: 'fill:none',
|
||||||
labelStyle: '',
|
labelStyle: '',
|
||||||
curve: interpolateToCurve(conf.curve, curveLinear),
|
curve: interpolateToCurve(conf.curve, curveLinear),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add the edge to the graph
|
// Add the edge to the graph
|
||||||
g.setEdge(vertex.id, vertex.class, edgeData, edgeId);
|
g.setEdge(vertex.id, vertex.class, edgeData, edgeId);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -329,7 +337,7 @@ export const draw = async function (text: string, id: string, _version: string,
|
|||||||
const namespaces: NamespaceMap = diagObj.db.getNamespaces();
|
const namespaces: NamespaceMap = diagObj.db.getNamespaces();
|
||||||
const classes: ClassMap = diagObj.db.getClasses();
|
const classes: ClassMap = diagObj.db.getClasses();
|
||||||
const relations: ClassRelation[] = diagObj.db.getRelations();
|
const relations: ClassRelation[] = diagObj.db.getRelations();
|
||||||
const notes: ClassNote[] = diagObj.db.getNotes();
|
const notes: ClassNoteMap = diagObj.db.getNotes();
|
||||||
log.info(relations);
|
log.info(relations);
|
||||||
addNamespaces(namespaces, g, id, diagObj);
|
addNamespaces(namespaces, g, id, diagObj);
|
||||||
addClasses(classes, g, id, diagObj);
|
addClasses(classes, g, id, diagObj);
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ export const draw = function (text, id, _version, diagObj) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const notes = diagObj.db.getNotes();
|
const notes = diagObj.db.getNotes().values();
|
||||||
notes.forEach(function (note) {
|
notes.forEach(function (note) {
|
||||||
log.debug(`Adding note: ${JSON.stringify(note)}`);
|
log.debug(`Adding note: ${JSON.stringify(note)}`);
|
||||||
const node = svgDraw.drawNote(diagram, note, conf, diagObj);
|
const node = svgDraw.drawNote(diagram, note, conf, diagObj);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export interface ClassNode {
|
|||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
label: string;
|
label: string;
|
||||||
shape: string;
|
shape: 'classBox';
|
||||||
text: string;
|
text: string;
|
||||||
cssClasses: string;
|
cssClasses: string;
|
||||||
methods: ClassMember[];
|
methods: ClassMember[];
|
||||||
@@ -149,6 +149,8 @@ export interface ClassNote {
|
|||||||
id: string;
|
id: string;
|
||||||
class: string;
|
class: string;
|
||||||
text: string;
|
text: string;
|
||||||
|
index: number;
|
||||||
|
parent?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClassRelation {
|
export interface ClassRelation {
|
||||||
@@ -177,6 +179,7 @@ export interface NamespaceNode {
|
|||||||
id: string;
|
id: string;
|
||||||
domId: string;
|
domId: string;
|
||||||
classes: ClassMap;
|
classes: ClassMap;
|
||||||
|
notes: ClassNoteMap;
|
||||||
children: NamespaceMap;
|
children: NamespaceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,4 +190,5 @@ export interface StyleClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ClassMap = Map<string, ClassNode>;
|
export type ClassMap = Map<string, ClassNode>;
|
||||||
|
export type ClassNoteMap = Map<string, ClassNote>;
|
||||||
export type NamespaceMap = Map<string, NamespaceNode>;
|
export type NamespaceMap = Map<string, NamespaceNode>;
|
||||||
|
|||||||
@@ -275,8 +275,8 @@ statement
|
|||||||
;
|
;
|
||||||
|
|
||||||
namespaceStatement
|
namespaceStatement
|
||||||
: namespaceIdentifier STRUCT_START classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $3); }
|
: namespaceIdentifier STRUCT_START classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $3[0], $3[1]); }
|
||||||
| namespaceIdentifier STRUCT_START NEWLINE classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $4); }
|
| namespaceIdentifier STRUCT_START NEWLINE classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $4[0], $4[1]); }
|
||||||
;
|
;
|
||||||
|
|
||||||
namespaceIdentifier
|
namespaceIdentifier
|
||||||
@@ -284,9 +284,12 @@ namespaceIdentifier
|
|||||||
;
|
;
|
||||||
|
|
||||||
classStatements
|
classStatements
|
||||||
: classStatement {$$=[$1]}
|
: classStatement {$$=[[$1], []]}
|
||||||
| classStatement NEWLINE {$$=[$1]}
|
| classStatement NEWLINE {$$=[[$1], []]}
|
||||||
| classStatement NEWLINE classStatements {$3.unshift($1); $$=$3}
|
| classStatement NEWLINE classStatements {$3[0].unshift($1); $$=$3}
|
||||||
|
| noteStatement {$$=[[], [$1]]}
|
||||||
|
| noteStatement NEWLINE {$$=[[], [$1]]}
|
||||||
|
| noteStatement NEWLINE classStatements {$3[1].unshift($1); $$=$3}
|
||||||
;
|
;
|
||||||
|
|
||||||
classStatement
|
classStatement
|
||||||
@@ -333,8 +336,8 @@ relationStatement
|
|||||||
;
|
;
|
||||||
|
|
||||||
noteStatement
|
noteStatement
|
||||||
: NOTE_FOR className noteText { yy.addNote($3, $2); }
|
: NOTE_FOR className noteText { $$ = yy.addNote($3, $2); }
|
||||||
| NOTE noteText { yy.addNote($2); }
|
| NOTE noteText { $$ = yy.addNote($2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
classDefStatement
|
classDefStatement
|
||||||
|
|||||||
@@ -13,6 +13,30 @@ const getStyles = (options) =>
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cluster-label text {
|
||||||
|
fill: ${options.titleColor};
|
||||||
|
}
|
||||||
|
.cluster-label span {
|
||||||
|
color: ${options.titleColor};
|
||||||
|
}
|
||||||
|
.cluster-label span p {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cluster rect {
|
||||||
|
fill: ${options.clusterBkg};
|
||||||
|
stroke: ${options.clusterBorder};
|
||||||
|
stroke-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cluster text {
|
||||||
|
fill: ${options.titleColor};
|
||||||
|
}
|
||||||
|
|
||||||
|
.cluster span {
|
||||||
|
color: ${options.titleColor};
|
||||||
|
}
|
||||||
|
|
||||||
.nodeLabel, .edgeLabel {
|
.nodeLabel, .edgeLabel {
|
||||||
color: ${options.classText};
|
color: ${options.classText};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,31 @@ describe('Sanitize text', () => {
|
|||||||
});
|
});
|
||||||
expect(result).not.toContain('javascript:alert(1)');
|
expect(result).not.toContain('javascript:alert(1)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow HTML tags in sandbox mode', () => {
|
||||||
|
const htmlStr = '<p>This is a <strong>bold</strong> text</p>';
|
||||||
|
const result = sanitizeText(htmlStr, {
|
||||||
|
securityLevel: 'sandbox',
|
||||||
|
flowchart: { htmlLabels: true },
|
||||||
|
});
|
||||||
|
expect(result).toContain('<p>');
|
||||||
|
expect(result).toContain('<strong>');
|
||||||
|
expect(result).toContain('</strong>');
|
||||||
|
expect(result).toContain('</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove script tags in sandbox mode', () => {
|
||||||
|
const maliciousStr = '<p>Hello <script>alert(1)</script> world</p>';
|
||||||
|
const result = sanitizeText(maliciousStr, {
|
||||||
|
securityLevel: 'sandbox',
|
||||||
|
flowchart: { htmlLabels: true },
|
||||||
|
});
|
||||||
|
expect(result).not.toContain('<script>');
|
||||||
|
expect(result).not.toContain('alert(1)');
|
||||||
|
expect(result).toContain('<p>');
|
||||||
|
expect(result).toContain('Hello');
|
||||||
|
expect(result).toContain('world');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('generic parser', () => {
|
describe('generic parser', () => {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const removeScript = (txt: string): string => {
|
|||||||
const sanitizeMore = (text: string, config: MermaidConfig) => {
|
const sanitizeMore = (text: string, config: MermaidConfig) => {
|
||||||
if (config.flowchart?.htmlLabels !== false) {
|
if (config.flowchart?.htmlLabels !== false) {
|
||||||
const level = config.securityLevel;
|
const level = config.securityLevel;
|
||||||
if (level === 'antiscript' || level === 'strict') {
|
if (level === 'antiscript' || level === 'strict' || level === 'sandbox') {
|
||||||
text = removeScript(text);
|
text = removeScript(text);
|
||||||
} else if (level !== 'loose') {
|
} else if (level !== 'loose') {
|
||||||
text = breakToPlaceholder(text);
|
text = breakToPlaceholder(text);
|
||||||
@@ -333,7 +333,7 @@ const renderKatexUnsanitized = async (text: string, config: MermaidConfig): Prom
|
|||||||
return text.replace(katexRegex, 'MathML is unsupported in this environment.');
|
return text.replace(katexRegex, 'MathML is unsupported in this environment.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeLargeFeatures) {
|
if (injected.includeLargeFeatures) {
|
||||||
const { default: katex } = await import('katex');
|
const { default: katex } = await import('katex');
|
||||||
const outputMode =
|
const outputMode =
|
||||||
config.forceLegacyMathML || (!isMathMLSupported() && config.legacyMathML)
|
config.forceLegacyMathML || (!isMathMLSupported() && config.legacyMathML)
|
||||||
|
|||||||
@@ -66,12 +66,15 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
|
|||||||
\}\| return 'ONE_OR_MORE';
|
\}\| return 'ONE_OR_MORE';
|
||||||
"one" return 'ONLY_ONE';
|
"one" return 'ONLY_ONE';
|
||||||
"only one" return 'ONLY_ONE';
|
"only one" return 'ONLY_ONE';
|
||||||
"1" return 'ONLY_ONE';
|
[0-9]+\.[0-9]+ return 'DECIMAL_NUM';
|
||||||
|
"1"(?=\s+[A-Za-z_"']) return 'ONLY_ONE';
|
||||||
|
"1" return 'ENTITY_ONE';
|
||||||
|
[0-9]+ return 'NUM';
|
||||||
\|\| return 'ONLY_ONE';
|
\|\| return 'ONLY_ONE';
|
||||||
o\| return 'ZERO_OR_ONE';
|
o\| return 'ZERO_OR_ONE';
|
||||||
o\{ return 'ZERO_OR_MORE';
|
o\{ return 'ZERO_OR_MORE';
|
||||||
\|\{ return 'ONE_OR_MORE';
|
\|\{ return 'ONE_OR_MORE';
|
||||||
\s*u return 'MD_PARENT';
|
u(?=[\.\-\|]) return 'MD_PARENT';
|
||||||
\.\. return 'NON_IDENTIFYING';
|
\.\. return 'NON_IDENTIFYING';
|
||||||
\-\- return 'IDENTIFYING';
|
\-\- return 'IDENTIFYING';
|
||||||
"to" return 'IDENTIFYING';
|
"to" return 'IDENTIFYING';
|
||||||
@@ -80,13 +83,15 @@ o\{ return 'ZERO_OR_MORE';
|
|||||||
\-\. return 'NON_IDENTIFYING';
|
\-\. return 'NON_IDENTIFYING';
|
||||||
<style>([^\x00-\x7F]|\w|\-|\*)+ return 'STYLE_TEXT';
|
<style>([^\x00-\x7F]|\w|\-|\*)+ return 'STYLE_TEXT';
|
||||||
<style>';' return 'SEMI';
|
<style>';' return 'SEMI';
|
||||||
([^\x00-\x7F]|\w|\-|\*)+ return 'UNICODE_TEXT';
|
([^\x00-\x7F]|\w|\-|\*|\.)+ return 'UNICODE_TEXT';
|
||||||
[0-9] return 'NUM';
|
|
||||||
. return yytext[0];
|
. return yytext[0];
|
||||||
<<EOF>> return 'EOF';
|
<<EOF>> return 'EOF';
|
||||||
|
|
||||||
/lex
|
/lex
|
||||||
|
|
||||||
|
%left 'ONLY_ONE'
|
||||||
|
%left 'ZERO_OR_ONE' 'ZERO_OR_MORE' 'ONE_OR_MORE' 'MD_PARENT'
|
||||||
|
|
||||||
%start start
|
%start start
|
||||||
%% /* language grammar */
|
%% /* language grammar */
|
||||||
|
|
||||||
@@ -228,6 +233,9 @@ styleComponent: STYLE_TEXT | NUM | COLON | BRKT;
|
|||||||
entityName
|
entityName
|
||||||
: 'ENTITY_NAME' { $$ = $1.replace(/"/g, ''); }
|
: 'ENTITY_NAME' { $$ = $1.replace(/"/g, ''); }
|
||||||
| 'UNICODE_TEXT' { $$ = $1; }
|
| 'UNICODE_TEXT' { $$ = $1; }
|
||||||
|
| 'NUM' { $$ = $1; }
|
||||||
|
| 'DECIMAL_NUM' { $$ = $1; }
|
||||||
|
| 'ENTITY_ONE' { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
attributes
|
attributes
|
||||||
|
|||||||
@@ -1001,4 +1001,90 @@ describe('when parsing ER diagram it...', function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('syntax fixes for special characters and numbers', function () {
|
||||||
|
describe('standalone entity names', function () {
|
||||||
|
it('should allow number "1" as standalone entity', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER }|..|{ DELIVERY-ADDRESS : has\n1`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow character "u" as standalone entity', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER }|..|{ DELIVERY-ADDRESS : has\nu`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow decimal numbers as standalone entities', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER }|..|{ DELIVERY-ADDRESS : has\n2.5`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER }|..|{ DELIVERY-ADDRESS : has\n1.5`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER }|..|{ DELIVERY-ADDRESS : has\n0.1`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER }|..|{ DELIVERY-ADDRESS : has\n99.99`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('entity names with attributes', function () {
|
||||||
|
it('should allow "u" as entity name with attributes', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nu {\nstring name\nint id\n}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow number "1" as entity name with attributes', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\n1 {\nstring name\nint id\n}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow decimal numbers as entity names with attributes', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\n2.5 {\nstring name\nint id\n}`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\n1.5 {\nstring value\n}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('entity names in relationships', function () {
|
||||||
|
it('should allow "u" in relationships', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER ||--|| u : has`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\nu ||--|| ORDER : places`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\nu ||--|| v : connects`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow numbers in relationships', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER ||--|| 1 : has`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\n1 ||--|| ORDER : places`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\n1 ||--|| 2 : connects`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow decimal numbers in relationships', function () {
|
||||||
|
erDiagram.parser.parse(`erDiagram\nCUSTOMER ||--|| 2.5 : has`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\n1.5 ||--|| ORDER : places`);
|
||||||
|
erDiagram.parser.parse(`erDiagram\n2.5 ||--|| 5.5 : connects`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('mixed scenarios', function () {
|
||||||
|
it('should handle complex diagram with special entity names', function () {
|
||||||
|
erDiagram.parser.parse(
|
||||||
|
`erDiagram
|
||||||
|
CUSTOMER ||--o{ 1 : places
|
||||||
|
1 ||--|{ u : contains
|
||||||
|
u {
|
||||||
|
string name
|
||||||
|
int quantity
|
||||||
|
}
|
||||||
|
"2.5" ||--|| ORDER : processes
|
||||||
|
ORDER {
|
||||||
|
int id
|
||||||
|
date created
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle attributes with numbers in names (but not starting)', function () {
|
||||||
|
erDiagram.parser.parse(
|
||||||
|
`erDiagram
|
||||||
|
ENTITY {
|
||||||
|
string name1
|
||||||
|
int value2
|
||||||
|
float point3_5
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ that id.
|
|||||||
.*direction\s+BT[^\n]* return 'direction_bt';
|
.*direction\s+BT[^\n]* return 'direction_bt';
|
||||||
.*direction\s+RL[^\n]* return 'direction_rl';
|
.*direction\s+RL[^\n]* return 'direction_rl';
|
||||||
.*direction\s+LR[^\n]* return 'direction_lr';
|
.*direction\s+LR[^\n]* return 'direction_lr';
|
||||||
|
.*direction\s+TD[^\n]* return 'direction_td';
|
||||||
|
|
||||||
[^\s\"]+\@(?=[^\{\"]) { return 'LINK_ID'; }
|
[^\s\"]+\@(?=[^\{\"]) { return 'LINK_ID'; }
|
||||||
[0-9]+ return 'NUM';
|
[0-9]+ return 'NUM';
|
||||||
@@ -626,6 +627,8 @@ direction
|
|||||||
{ $$={stmt:'dir', value:'RL'};}
|
{ $$={stmt:'dir', value:'RL'};}
|
||||||
| direction_lr
|
| direction_lr
|
||||||
{ $$={stmt:'dir', value:'LR'};}
|
{ $$={stmt:'dir', value:'LR'};}
|
||||||
|
| direction_td
|
||||||
|
{ $$={stmt:'dir', value:'TD'};}
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|||||||
@@ -309,4 +309,21 @@ describe('when parsing subgraphs', function () {
|
|||||||
expect(subgraphA.nodes).toContain('a');
|
expect(subgraphA.nodes).toContain('a');
|
||||||
expect(subgraphA.nodes).not.toContain('c');
|
expect(subgraphA.nodes).not.toContain('c');
|
||||||
});
|
});
|
||||||
|
it('should correctly parse direction TD inside a subgraph', function () {
|
||||||
|
const res = flow.parser.parse(`
|
||||||
|
graph LR
|
||||||
|
subgraph WithTD
|
||||||
|
direction TD
|
||||||
|
A1 --> A2
|
||||||
|
end
|
||||||
|
`);
|
||||||
|
|
||||||
|
const subgraphs = flow.parser.yy.getSubGraphs();
|
||||||
|
expect(subgraphs.length).toBe(1);
|
||||||
|
const subgraph = subgraphs[0];
|
||||||
|
|
||||||
|
expect(subgraph.dir).toBe('TD');
|
||||||
|
expect(subgraph.nodes).toContain('A1');
|
||||||
|
expect(subgraph.nodes).toContain('A2');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -268,7 +268,15 @@ const fixTaskDates = function (startTime, endTime, dateFormat, excludes, include
|
|||||||
|
|
||||||
const getStartDate = function (prevTime, dateFormat, str) {
|
const getStartDate = function (prevTime, dateFormat, str) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
if ((dateFormat.trim() === 'x' || dateFormat.trim() === 'X') && /^\d+$/.test(str)) {
|
|
||||||
|
// Helper function to check if format is a timestamp format (x or X)
|
||||||
|
const isTimestampFormat = (format) => {
|
||||||
|
const trimmedFormat = format.trim();
|
||||||
|
return trimmedFormat === 'x' || trimmedFormat === 'X';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle timestamp formats (x, X) with numeric strings
|
||||||
|
if (isTimestampFormat(dateFormat) && /^\d+$/.test(str)) {
|
||||||
return new Date(Number(str));
|
return new Date(Number(str));
|
||||||
}
|
}
|
||||||
// Test for after
|
// Test for after
|
||||||
@@ -293,13 +301,15 @@ const getStartDate = function (prevTime, dateFormat, str) {
|
|||||||
return today;
|
return today;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for actual date set
|
// Check for actual date set using dayjs strict parsing
|
||||||
let mDate = dayjs(str, dateFormat.trim(), true);
|
let mDate = dayjs(str, dateFormat.trim(), true);
|
||||||
if (mDate.isValid()) {
|
if (mDate.isValid()) {
|
||||||
return mDate.toDate();
|
return mDate.toDate();
|
||||||
} else {
|
} else {
|
||||||
log.debug('Invalid date:' + str);
|
log.debug('Invalid date:' + str);
|
||||||
log.debug('With date format:' + dateFormat.trim());
|
log.debug('With date format:' + dateFormat.trim());
|
||||||
|
|
||||||
|
// Timestamp formats can fall back to new Date()
|
||||||
const d = new Date(str);
|
const d = new Date(str);
|
||||||
if (
|
if (
|
||||||
d === undefined ||
|
d === undefined ||
|
||||||
|
|||||||
@@ -505,4 +505,27 @@ describe('when using the ganttDb', function () {
|
|||||||
ganttDb.addTask('test1', 'id1,202304,1d');
|
ganttDb.addTask('test1', 'id1,202304,1d');
|
||||||
expect(() => ganttDb.getTasks()).toThrowError('Invalid date:202304');
|
expect(() => ganttDb.getTasks()).toThrowError('Invalid date:202304');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle seconds-only format with valid numeric values (issue #5496)', function () {
|
||||||
|
ganttDb.setDateFormat('ss');
|
||||||
|
ganttDb.addSection('Network Request');
|
||||||
|
ganttDb.addTask('RTT', 'rtt, 0, 20');
|
||||||
|
const tasks = ganttDb.getTasks();
|
||||||
|
expect(tasks).toHaveLength(1);
|
||||||
|
expect(tasks[0].task).toBe('RTT');
|
||||||
|
expect(tasks[0].id).toBe('rtt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle dates with year typo like 202 instead of 2024 (issue #5496)', function () {
|
||||||
|
ganttDb.setDateFormat('YYYY-MM-DD');
|
||||||
|
ganttDb.addSection('Vacation');
|
||||||
|
ganttDb.addTask('London Trip 1', '2024-12-01, 7d');
|
||||||
|
ganttDb.addTask('London Trip 2', '202-12-01, 7d');
|
||||||
|
const tasks = ganttDb.getTasks();
|
||||||
|
expect(tasks).toHaveLength(2);
|
||||||
|
// First task should be in year 2024
|
||||||
|
expect(tasks[0].startTime.getFullYear()).toBe(2024);
|
||||||
|
// Second task will be parsed as year 202 (fallback to new Date())
|
||||||
|
expect(tasks[1].startTime.getFullYear()).toBe(202);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import dayjsDuration from 'dayjs/plugin/duration.js';
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import {
|
import {
|
||||||
select,
|
select,
|
||||||
@@ -28,6 +29,8 @@ import common from '../common/common.js';
|
|||||||
import { getConfig } from '../../diagram-api/diagramAPI.js';
|
import { getConfig } from '../../diagram-api/diagramAPI.js';
|
||||||
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||||
|
|
||||||
|
dayjs.extend(dayjsDuration);
|
||||||
|
|
||||||
export const setConf = function () {
|
export const setConf = function () {
|
||||||
log.debug('Something is calling, setConf, remove the call');
|
log.debug('Something is calling, setConf, remove the call');
|
||||||
};
|
};
|
||||||
@@ -78,6 +81,7 @@ const getMaxIntersections = (tasks, orderOffset) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let w;
|
let w;
|
||||||
|
const MAX_TICK_COUNT = 10000;
|
||||||
export const draw = function (text, id, version, diagObj) {
|
export const draw = function (text, id, version, diagObj) {
|
||||||
const conf = getConfig().gantt;
|
const conf = getConfig().gantt;
|
||||||
|
|
||||||
@@ -602,6 +606,27 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
.attr('class', 'exclude-range');
|
.attr('class', 'exclude-range');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the estimated number of ticks based on the time domain and tick interval.
|
||||||
|
* Returns the estimated number of ticks as a number.
|
||||||
|
* @param {Date} minTime - The minimum time in the domain
|
||||||
|
* @param {Date} maxTime - The maximum time in the domain
|
||||||
|
* @param {number} every - The interval count (e.g., 1 for "1second")
|
||||||
|
* @param {string} interval - The interval unit (e.g., "second", "day")
|
||||||
|
* @returns {number} The estimated number of ticks
|
||||||
|
*/
|
||||||
|
function getEstimatedTickCount(minTime, maxTime, every, interval) {
|
||||||
|
if (every <= 0 || minTime > maxTime) {
|
||||||
|
return Infinity;
|
||||||
|
}
|
||||||
|
const timeDiffMs = maxTime - minTime;
|
||||||
|
const intervalMs = dayjs.duration({ [interval ?? 'day']: every }).asMilliseconds();
|
||||||
|
if (intervalMs <= 0) {
|
||||||
|
return Infinity;
|
||||||
|
}
|
||||||
|
return Math.ceil(timeDiffMs / intervalMs);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param theSidePad
|
* @param theSidePad
|
||||||
* @param theTopPad
|
* @param theTopPad
|
||||||
@@ -630,32 +655,54 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (resultTickInterval !== null) {
|
if (resultTickInterval !== null) {
|
||||||
const every = resultTickInterval[1];
|
const every = parseInt(resultTickInterval[1], 10);
|
||||||
const interval = resultTickInterval[2];
|
if (isNaN(every) || every <= 0) {
|
||||||
const weekday = diagObj.db.getWeekday() || conf.weekday;
|
log.warn(
|
||||||
|
`Invalid tick interval value: "${resultTickInterval[1]}". Skipping custom tick interval.`
|
||||||
|
);
|
||||||
|
// Skip applying custom ticks
|
||||||
|
} else {
|
||||||
|
const interval = resultTickInterval[2];
|
||||||
|
const weekday = diagObj.db.getWeekday() || conf.weekday;
|
||||||
|
|
||||||
switch (interval) {
|
// Get the time domain to check tick count
|
||||||
case 'millisecond':
|
const domain = timeScale.domain();
|
||||||
bottomXAxis.ticks(timeMillisecond.every(every));
|
const minTime = domain[0];
|
||||||
break;
|
const maxTime = domain[1];
|
||||||
case 'second':
|
const estimatedTicks = getEstimatedTickCount(minTime, maxTime, every, interval);
|
||||||
bottomXAxis.ticks(timeSecond.every(every));
|
|
||||||
break;
|
if (estimatedTicks > MAX_TICK_COUNT) {
|
||||||
case 'minute':
|
log.warn(
|
||||||
bottomXAxis.ticks(timeMinute.every(every));
|
`The tick interval "${every}${interval}" would generate ${estimatedTicks} ticks, ` +
|
||||||
break;
|
`which exceeds the maximum allowed (${MAX_TICK_COUNT}). ` +
|
||||||
case 'hour':
|
`This may indicate an invalid date or time range. Skipping custom tick interval.`
|
||||||
bottomXAxis.ticks(timeHour.every(every));
|
);
|
||||||
break;
|
// D3 will use its default automatic tick generation
|
||||||
case 'day':
|
} else {
|
||||||
bottomXAxis.ticks(timeDay.every(every));
|
switch (interval) {
|
||||||
break;
|
case 'millisecond':
|
||||||
case 'week':
|
bottomXAxis.ticks(timeMillisecond.every(every));
|
||||||
bottomXAxis.ticks(mapWeekdayToTimeFunction[weekday].every(every));
|
break;
|
||||||
break;
|
case 'second':
|
||||||
case 'month':
|
bottomXAxis.ticks(timeSecond.every(every));
|
||||||
bottomXAxis.ticks(timeMonth.every(every));
|
break;
|
||||||
break;
|
case 'minute':
|
||||||
|
bottomXAxis.ticks(timeMinute.every(every));
|
||||||
|
break;
|
||||||
|
case 'hour':
|
||||||
|
bottomXAxis.ticks(timeHour.every(every));
|
||||||
|
break;
|
||||||
|
case 'day':
|
||||||
|
bottomXAxis.ticks(timeDay.every(every));
|
||||||
|
break;
|
||||||
|
case 'week':
|
||||||
|
bottomXAxis.ticks(mapWeekdayToTimeFunction[weekday].every(every));
|
||||||
|
break;
|
||||||
|
case 'month':
|
||||||
|
bottomXAxis.ticks(timeMonth.every(every));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,32 +724,48 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
.tickFormat(timeFormat(axisFormat));
|
.tickFormat(timeFormat(axisFormat));
|
||||||
|
|
||||||
if (resultTickInterval !== null) {
|
if (resultTickInterval !== null) {
|
||||||
const every = resultTickInterval[1];
|
const every = parseInt(resultTickInterval[1], 10);
|
||||||
const interval = resultTickInterval[2];
|
if (isNaN(every) || every <= 0) {
|
||||||
const weekday = diagObj.db.getWeekday() || conf.weekday;
|
log.warn(
|
||||||
|
`Invalid tick interval value: "${resultTickInterval[1]}". Skipping custom tick interval.`
|
||||||
|
);
|
||||||
|
// Skip applying custom ticks
|
||||||
|
} else {
|
||||||
|
const interval = resultTickInterval[2];
|
||||||
|
const weekday = diagObj.db.getWeekday() || conf.weekday;
|
||||||
|
|
||||||
switch (interval) {
|
// Get the time domain to check tick count
|
||||||
case 'millisecond':
|
const domain = timeScale.domain();
|
||||||
topXAxis.ticks(timeMillisecond.every(every));
|
const minTime = domain[0];
|
||||||
break;
|
const maxTime = domain[1];
|
||||||
case 'second':
|
const estimatedTicks = getEstimatedTickCount(minTime, maxTime, every, interval);
|
||||||
topXAxis.ticks(timeSecond.every(every));
|
|
||||||
break;
|
// Only apply custom ticks if the count is reasonable
|
||||||
case 'minute':
|
if (estimatedTicks <= MAX_TICK_COUNT) {
|
||||||
topXAxis.ticks(timeMinute.every(every));
|
switch (interval) {
|
||||||
break;
|
case 'millisecond':
|
||||||
case 'hour':
|
topXAxis.ticks(timeMillisecond.every(every));
|
||||||
topXAxis.ticks(timeHour.every(every));
|
break;
|
||||||
break;
|
case 'second':
|
||||||
case 'day':
|
topXAxis.ticks(timeSecond.every(every));
|
||||||
topXAxis.ticks(timeDay.every(every));
|
break;
|
||||||
break;
|
case 'minute':
|
||||||
case 'week':
|
topXAxis.ticks(timeMinute.every(every));
|
||||||
topXAxis.ticks(mapWeekdayToTimeFunction[weekday].every(every));
|
break;
|
||||||
break;
|
case 'hour':
|
||||||
case 'month':
|
topXAxis.ticks(timeHour.every(every));
|
||||||
topXAxis.ticks(timeMonth.every(every));
|
break;
|
||||||
break;
|
case 'day':
|
||||||
|
topXAxis.ticks(timeDay.every(every));
|
||||||
|
break;
|
||||||
|
case 'week':
|
||||||
|
topXAxis.ticks(mapWeekdayToTimeFunction[weekday].every(every));
|
||||||
|
break;
|
||||||
|
case 'month':
|
||||||
|
topXAxis.ticks(timeMonth.every(every));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import type { InfoFields, InfoDB } from './infoTypes.js';
|
import type { InfoFields, InfoDB } from './infoTypes.js';
|
||||||
import packageJson from '../../../package.json' assert { type: 'json' };
|
|
||||||
|
|
||||||
export const DEFAULT_INFO_DB: InfoFields = {
|
export const DEFAULT_INFO_DB: InfoFields = {
|
||||||
version: packageJson.version + (includeLargeFeatures ? '' : '-tiny'),
|
version: injected.version + (injected.includeLargeFeatures ? '' : '-tiny'),
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const getVersion = (): string => DEFAULT_INFO_DB.version;
|
export const getVersion = (): string => DEFAULT_INFO_DB.version;
|
||||||
|
|||||||
@@ -293,5 +293,37 @@ describe('MindmapDb getData function', () => {
|
|||||||
expect(edgeA1_aaa.section).toBe(1);
|
expect(edgeA1_aaa.section).toBe(1);
|
||||||
expect(edgeA_a2.section).toBe(2);
|
expect(edgeA_a2.section).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should wrap section numbers when there are more than 11 level 2 nodes', () => {
|
||||||
|
db.addNode(0, 'root', 'Example', 0);
|
||||||
|
|
||||||
|
for (let i = 1; i <= 15; i++) {
|
||||||
|
db.addNode(1, `child${i}`, `${i}`, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
expect(result.nodes).toHaveLength(16);
|
||||||
|
|
||||||
|
const child1 = result.nodes.find((n) => n.label === '1') as MindmapLayoutNode;
|
||||||
|
const child11 = result.nodes.find((n) => n.label === '11') as MindmapLayoutNode;
|
||||||
|
const child12 = result.nodes.find((n) => n.label === '12') as MindmapLayoutNode;
|
||||||
|
const child13 = result.nodes.find((n) => n.label === '13') as MindmapLayoutNode;
|
||||||
|
const child14 = result.nodes.find((n) => n.label === '14') as MindmapLayoutNode;
|
||||||
|
const child15 = result.nodes.find((n) => n.label === '15') as MindmapLayoutNode;
|
||||||
|
|
||||||
|
expect(child1.section).toBe(0);
|
||||||
|
expect(child11.section).toBe(10);
|
||||||
|
|
||||||
|
expect(child12.section).toBe(0);
|
||||||
|
expect(child13.section).toBe(1);
|
||||||
|
expect(child14.section).toBe(2);
|
||||||
|
expect(child15.section).toBe(3);
|
||||||
|
|
||||||
|
expect(child12.cssClasses).toBe('mindmap-node section-0');
|
||||||
|
expect(child13.cssClasses).toBe('mindmap-node section-1');
|
||||||
|
expect(child14.cssClasses).toBe('mindmap-node section-2');
|
||||||
|
expect(child15.cssClasses).toBe('mindmap-node section-3');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { MindmapNode } from './mindmapTypes.js';
|
|||||||
import defaultConfig from '../../defaultConfig.js';
|
import defaultConfig from '../../defaultConfig.js';
|
||||||
import type { LayoutData, Node, Edge } from '../../rendering-util/types.js';
|
import type { LayoutData, Node, Edge } from '../../rendering-util/types.js';
|
||||||
import { getUserDefinedConfig } from '../../config.js';
|
import { getUserDefinedConfig } from '../../config.js';
|
||||||
|
import { MAX_SECTIONS } from './svgDraw.js';
|
||||||
|
|
||||||
// Extend Node type for mindmap-specific properties
|
// Extend Node type for mindmap-specific properties
|
||||||
export type MindmapLayoutNode = Node & {
|
export type MindmapLayoutNode = Node & {
|
||||||
@@ -203,7 +204,7 @@ export class MindmapDB {
|
|||||||
// For other nodes, inherit parent's section number
|
// For other nodes, inherit parent's section number
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
for (const [index, child] of node.children.entries()) {
|
for (const [index, child] of node.children.entries()) {
|
||||||
const childSectionNumber = node.level === 0 ? index : sectionNumber;
|
const childSectionNumber = node.level === 0 ? index % (MAX_SECTIONS - 1) : sectionNumber;
|
||||||
this.assignSections(child, childSectionNumber);
|
this.assignSections(child, childSectionNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { parseFontSize } from '../../utils.js';
|
|||||||
import type { MermaidConfig } from '../../config.type.js';
|
import type { MermaidConfig } from '../../config.type.js';
|
||||||
import type { MindmapDB } from './mindmapDb.js';
|
import type { MindmapDB } from './mindmapDb.js';
|
||||||
|
|
||||||
const MAX_SECTIONS = 12;
|
export const MAX_SECTIONS = 12;
|
||||||
|
|
||||||
type ShapeFunction = (
|
type ShapeFunction = (
|
||||||
db: MindmapDB,
|
db: MindmapDB,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
|
|||||||
const svgWidth = bitWidth * bitsPerRow + 2;
|
const svgWidth = bitWidth * bitsPerRow + 2;
|
||||||
const svg: SVG = selectSvgElement(id);
|
const svg: SVG = selectSvgElement(id);
|
||||||
|
|
||||||
svg.attr('viewbox', `0 0 ${svgWidth} ${svgHeight}`);
|
svg.attr('viewBox', `0 0 ${svgWidth} ${svgHeight}`);
|
||||||
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
||||||
|
|
||||||
for (const [word, packet] of words.entries()) {
|
for (const [word, packet] of words.entries()) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { Diagram } from '../../Diagram.js';
|
|||||||
import type { RadarDiagramConfig } from '../../config.type.js';
|
import type { RadarDiagramConfig } from '../../config.type.js';
|
||||||
import type { DiagramRenderer, DrawDefinition, SVG, SVGGroup } from '../../diagram-api/types.js';
|
import type { DiagramRenderer, DrawDefinition, SVG, SVGGroup } from '../../diagram-api/types.js';
|
||||||
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
||||||
|
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||||
import type { RadarDB, RadarAxis, RadarCurve } from './types.js';
|
import type { RadarDB, RadarAxis, RadarCurve } from './types.js';
|
||||||
|
|
||||||
const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
|
const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
|
||||||
@@ -53,11 +54,9 @@ const drawFrame = (svg: SVG, config: Required<RadarDiagramConfig>): SVGGroup =>
|
|||||||
x: config.marginLeft + config.width / 2,
|
x: config.marginLeft + config.width / 2,
|
||||||
y: config.marginTop + config.height / 2,
|
y: config.marginTop + config.height / 2,
|
||||||
};
|
};
|
||||||
// Initialize the SVG
|
configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth ?? true);
|
||||||
svg
|
|
||||||
.attr('viewbox', `0 0 ${totalWidth} ${totalHeight}`)
|
svg.attr('viewBox', `0 0 ${totalWidth} ${totalHeight}`);
|
||||||
.attr('width', totalWidth)
|
|
||||||
.attr('height', totalHeight);
|
|
||||||
// g element to center the radar chart
|
// g element to center the radar chart
|
||||||
return svg.append('g').attr('transform', `translate(${center.x}, ${center.y})`);
|
return svg.append('g').attr('transform', `translate(${center.x}, ${center.y})`);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,15 +30,17 @@
|
|||||||
[0-9]+(?=[ \n]+) return 'NUM';
|
[0-9]+(?=[ \n]+) return 'NUM';
|
||||||
<ID>\@\{ { this.begin('CONFIG'); return 'CONFIG_START'; }
|
<ID>\@\{ { this.begin('CONFIG'); return 'CONFIG_START'; }
|
||||||
<CONFIG>[^\}]+ { return 'CONFIG_CONTENT'; }
|
<CONFIG>[^\}]+ { return 'CONFIG_CONTENT'; }
|
||||||
|
<CONFIG>\}(?=\s+as\s) { this.popState(); this.begin('ALIAS'); return 'CONFIG_END'; }
|
||||||
<CONFIG>\} { this.popState(); this.popState(); return 'CONFIG_END'; }
|
<CONFIG>\} { this.popState(); this.popState(); return 'CONFIG_END'; }
|
||||||
<ID>[^\<->\->:\n,;@\s]+(?=\@\{) { yytext = yytext.trim(); return 'ACTOR'; }
|
<ID>[^\<->\->:\n,;@\s]+(?=\@\{) { yytext = yytext.trim(); return 'ACTOR'; }
|
||||||
<ID>[^\<->\->:\n,;@]+?([\-]*[^\<->\->:\n,;@]+?)*?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
<ID>[^<>:\n,;@\s]+(?=\s+as\s) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
||||||
|
<ID>[^<>:\n,;@]+(?=\s*[\n;#]|$) { yytext = yytext.trim(); this.popState(); return 'ACTOR'; }
|
||||||
|
<ID>[^<>:\n,;@]*\<[^\n]* { this.popState(); return 'INVALID'; }
|
||||||
"box" { this.begin('LINE'); return 'box'; }
|
"box" { this.begin('LINE'); return 'box'; }
|
||||||
"participant" { this.begin('ID'); return 'participant'; }
|
"participant" { this.begin('ID'); return 'participant'; }
|
||||||
"actor" { this.begin('ID'); return 'participant_actor'; }
|
"actor" { this.begin('ID'); return 'participant_actor'; }
|
||||||
"create" return 'create';
|
"create" return 'create';
|
||||||
"destroy" { this.begin('ID'); return 'destroy'; }
|
"destroy" { this.begin('ID'); return 'destroy'; }
|
||||||
<ID>[^<\->\->:\n,;]+?([\-]*[^<\->\->:\n,;]+?)*?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
|
||||||
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
|
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
|
||||||
<ALIAS>(?:) { this.popState(); this.popState(); return 'NEWLINE'; }
|
<ALIAS>(?:) { this.popState(); this.popState(); return 'NEWLINE'; }
|
||||||
"loop" { this.begin('LINE'); return 'loop'; }
|
"loop" { this.begin('LINE'); return 'loop'; }
|
||||||
@@ -78,7 +80,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
|
|||||||
"off" return 'off';
|
"off" return 'off';
|
||||||
"," return ',';
|
"," return ',';
|
||||||
";" return 'NEWLINE';
|
";" return 'NEWLINE';
|
||||||
[^+<\->\->:\n,;]+((?!(\-x|\-\-x|\-\)|\-\-\)))[\-]*[^\+<\->\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; }
|
[^\/\\\+\()\+<\->\->:\n,;]+((?!(\-x|\-\-x|\-\)|\-\-\)|\-\|\\|\-\\|\-\/|\-\/\/|\-\|\/|\/\|\-|\\\|\-|\/\/\-|\\\\\-|\/\|\-|\-\-\|\\|\-\-|\(\)))[\-]*[^\+<\->\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; } //final_4.11
|
||||||
"->>" return 'SOLID_ARROW';
|
"->>" return 'SOLID_ARROW';
|
||||||
"<<->>" return 'BIDIRECTIONAL_SOLID_ARROW';
|
"<<->>" return 'BIDIRECTIONAL_SOLID_ARROW';
|
||||||
"-->>" return 'DOTTED_ARROW';
|
"-->>" return 'DOTTED_ARROW';
|
||||||
@@ -89,10 +91,36 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
|
|||||||
\-\-[x] return 'DOTTED_CROSS';
|
\-\-[x] return 'DOTTED_CROSS';
|
||||||
\-[\)] return 'SOLID_POINT';
|
\-[\)] return 'SOLID_POINT';
|
||||||
\-\-[\)] return 'DOTTED_POINT';
|
\-\-[\)] return 'DOTTED_POINT';
|
||||||
|
|
||||||
|
//normal-dotted
|
||||||
|
\-\-\|\\ return 'SOLID_ARROW_TOP_DOTTED';
|
||||||
|
\-\-\|\/ return 'SOLID_ARROW_BOTTOM_DOTTED';
|
||||||
|
\-\-\\\\ return 'STICK_ARROW_TOP_DOTTED';
|
||||||
|
\-\-\/\/ return 'STICK_ARROW_BOTTOM_DOTTED';
|
||||||
|
|
||||||
|
//reverse-dotted
|
||||||
|
\/\|\-\- return 'SOLID_ARROW_TOP_REVERSE_DOTTED';
|
||||||
|
\\\|\-\- return 'SOLID_ARROW_BOTTOM_REVERSE_DOTTED';
|
||||||
|
\/\/\-\- return 'STICK_ARROW_TOP_REVERSE_DOTTED';
|
||||||
|
\\\\\-\- return 'STICK_ARROW_BOTTOM_REVERSE_DOTTED';
|
||||||
|
|
||||||
|
//normal
|
||||||
|
\-\|\\ return 'SOLID_ARROW_TOP';
|
||||||
|
\-\|\/ return 'SOLID_ARROW_BOTTOM';
|
||||||
|
\-\\\\ return 'STICK_ARROW_TOP';
|
||||||
|
\-\/\/ return 'STICK_ARROW_BOTTOM';
|
||||||
|
|
||||||
|
//reverse
|
||||||
|
\/\|\- return 'SOLID_ARROW_TOP_REVERSE';
|
||||||
|
\\\|\- return 'SOLID_ARROW_BOTTOM_REVERSE';
|
||||||
|
\/\/\- return 'STICK_ARROW_TOP_REVERSE';
|
||||||
|
\\\\\- return 'STICK_ARROW_BOTTOM_REVERSE';
|
||||||
|
|
||||||
":"(?:(?:no)?wrap:)?[^#\n;]* return 'TXT';
|
":"(?:(?:no)?wrap:)?[^#\n;]* return 'TXT';
|
||||||
":" return 'TXT';
|
":" return 'TXT';
|
||||||
"+" return '+';
|
"+" return '+';
|
||||||
"-" return '-';
|
"-" return '-';
|
||||||
|
"()" return '()';
|
||||||
<<EOF>> return 'NEWLINE';
|
<<EOF>> return 'NEWLINE';
|
||||||
. return 'INVALID';
|
. return 'INVALID';
|
||||||
|
|
||||||
@@ -119,6 +147,7 @@ line
|
|||||||
: SPACE statement { $$ = $2 }
|
: SPACE statement { $$ = $2 }
|
||||||
| statement { $$ = $1 }
|
| statement { $$ = $1 }
|
||||||
| NEWLINE { $$=[]; }
|
| NEWLINE { $$=[]; }
|
||||||
|
| INVALID { $$=[]; }
|
||||||
;
|
;
|
||||||
|
|
||||||
box_section
|
box_section
|
||||||
@@ -236,7 +265,10 @@ participant_statement
|
|||||||
| 'participant_actor' actor 'AS' restOfLine 'NEWLINE' {$2.draw='actor'; $2.type='addParticipant';$2.description=yy.parseMessage($4); $$=$2;}
|
| 'participant_actor' actor 'AS' restOfLine 'NEWLINE' {$2.draw='actor'; $2.type='addParticipant';$2.description=yy.parseMessage($4); $$=$2;}
|
||||||
| 'participant_actor' actor 'NEWLINE' {$2.draw='actor'; $2.type='addParticipant'; $$=$2;}
|
| 'participant_actor' actor 'NEWLINE' {$2.draw='actor'; $2.type='addParticipant'; $$=$2;}
|
||||||
| 'destroy' actor 'NEWLINE' {$2.type='destroyParticipant'; $$=$2;}
|
| 'destroy' actor 'NEWLINE' {$2.type='destroyParticipant'; $$=$2;}
|
||||||
|
| 'participant' actor_with_config 'AS' restOfLine 'NEWLINE' {$2.draw='participant'; $2.type='addParticipant'; $2.description=yy.parseMessage($4); $$=$2;}
|
||||||
| 'participant' actor_with_config 'NEWLINE' {$2.draw='participant'; $2.type='addParticipant'; $$=$2;}
|
| 'participant' actor_with_config 'NEWLINE' {$2.draw='participant'; $2.type='addParticipant'; $$=$2;}
|
||||||
|
| 'participant_actor' actor_with_config 'AS' restOfLine 'NEWLINE' {$2.draw='actor'; $2.type='addParticipant'; $2.description=yy.parseMessage($4); $$=$2;}
|
||||||
|
| 'participant_actor' actor_with_config 'NEWLINE' {$2.draw='actor'; $2.type='addParticipant'; $$=$2;}
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -304,6 +336,20 @@ signal
|
|||||||
{ $$ = [$1,$4,{type: 'addMessage', from:$1.actor, to:$4.actor, signalType:$2, msg:$5},
|
{ $$ = [$1,$4,{type: 'addMessage', from:$1.actor, to:$4.actor, signalType:$2, msg:$5},
|
||||||
{type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $1.actor}
|
{type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $1.actor}
|
||||||
]}
|
]}
|
||||||
|
| actor signaltype '()' actor text2
|
||||||
|
{ $$ = [$1,$4,{type: 'addMessage', from:$1.actor, to:$4.actor, signalType:$2, msg:$5, activate: true, centralConnection: yy.LINETYPE.CENTRAL_CONNECTION},
|
||||||
|
{type: 'centralConnection', signalType: yy.LINETYPE.CENTRAL_CONNECTION, actor: $4.actor, }
|
||||||
|
]}
|
||||||
|
|
||||||
|
| actor '()' signaltype actor text2
|
||||||
|
{ $$ = [$1,$4,{type: 'addMessage', from:$1.actor, to:$4.actor, signalType:$3, msg:$5, activate: false, centralConnection: yy.LINETYPE.CENTRAL_CONNECTION_REVERSE},
|
||||||
|
{type: 'centralConnectionReverse', signalType: yy.LINETYPE.CENTRAL_CONNECTION_REVERSE, actor: $1.actor}
|
||||||
|
]}
|
||||||
|
| actor '()' signaltype '()' actor text2
|
||||||
|
{ $$ = [$1,$5,{type: 'addMessage', from:$1.actor, to:$5.actor, signalType:$3, msg:$6, activate: true, centralConnection: yy.LINETYPE.CENTRAL_CONNECTION_DUAL},
|
||||||
|
{type: 'centralConnection', signalType: yy.LINETYPE.CENTRAL_CONNECTION, actor: $5.actor, },
|
||||||
|
{type: 'centralConnectionReverse', signalType: yy.LINETYPE.CENTRAL_CONNECTION_REVERSE, actor: $1.actor}
|
||||||
|
]}
|
||||||
| actor signaltype actor text2
|
| actor signaltype actor text2
|
||||||
{ $$ = [$1,$3,{type: 'addMessage', from:$1.actor, to:$3.actor, signalType:$2, msg:$4}]}
|
{ $$ = [$1,$3,{type: 'addMessage', from:$1.actor, to:$3.actor, signalType:$2, msg:$4}]}
|
||||||
;
|
;
|
||||||
@@ -337,7 +383,28 @@ signaltype
|
|||||||
: SOLID_OPEN_ARROW { $$ = yy.LINETYPE.SOLID_OPEN; }
|
: SOLID_OPEN_ARROW { $$ = yy.LINETYPE.SOLID_OPEN; }
|
||||||
| DOTTED_OPEN_ARROW { $$ = yy.LINETYPE.DOTTED_OPEN; }
|
| DOTTED_OPEN_ARROW { $$ = yy.LINETYPE.DOTTED_OPEN; }
|
||||||
| SOLID_ARROW { $$ = yy.LINETYPE.SOLID; }
|
| SOLID_ARROW { $$ = yy.LINETYPE.SOLID; }
|
||||||
| BIDIRECTIONAL_SOLID_ARROW { $$ = yy.LINETYPE.BIDIRECTIONAL_SOLID; }
|
|
||||||
|
| SOLID_ARROW_TOP { $$ = yy.LINETYPE.SOLID_TOP; }
|
||||||
|
| SOLID_ARROW_BOTTOM { $$ = yy.LINETYPE.SOLID_BOTTOM; }
|
||||||
|
| STICK_ARROW_TOP { $$ = yy.LINETYPE.STICK_TOP; }
|
||||||
|
| STICK_ARROW_BOTTOM { $$ = yy.LINETYPE.STICK_BOTTOM; }
|
||||||
|
|
||||||
|
| SOLID_ARROW_TOP_DOTTED { $$ = yy.LINETYPE.SOLID_TOP_DOTTED; }
|
||||||
|
| SOLID_ARROW_BOTTOM_DOTTED { $$ = yy.LINETYPE.SOLID_BOTTOM_DOTTED; }
|
||||||
|
| STICK_ARROW_TOP_DOTTED { $$ = yy.LINETYPE.STICK_TOP_DOTTED; }
|
||||||
|
| STICK_ARROW_BOTTOM_DOTTED { $$ = yy.LINETYPE.STICK_BOTTOM_DOTTED; }
|
||||||
|
|
||||||
|
| SOLID_ARROW_TOP_REVERSE { $$ = yy.LINETYPE.SOLID_ARROW_TOP_REVERSE; }
|
||||||
|
| SOLID_ARROW_BOTTOM_REVERSE { $$ = yy.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE; }
|
||||||
|
| STICK_ARROW_TOP_REVERSE { $$ = yy.LINETYPE.STICK_ARROW_TOP_REVERSE; }
|
||||||
|
| STICK_ARROW_BOTTOM_REVERSE { $$ = yy.LINETYPE.STICK_ARROW_BOTTOM_REVERSE; }
|
||||||
|
|
||||||
|
| SOLID_ARROW_TOP_REVERSE_DOTTED { $$ = yy.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED; }
|
||||||
|
| SOLID_ARROW_BOTTOM_REVERSE_DOTTED { $$ = yy.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED; }
|
||||||
|
| STICK_ARROW_TOP_REVERSE_DOTTED { $$ = yy.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED; }
|
||||||
|
| STICK_ARROW_BOTTOM_REVERSE_DOTTED { $$ = yy.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED; }
|
||||||
|
|
||||||
|
| BIDIRECTIONAL_SOLID_ARROW { $$ = yy.LINETYPE.BIDIRECTIONAL_SOLID; }
|
||||||
| DOTTED_ARROW { $$ = yy.LINETYPE.DOTTED; }
|
| DOTTED_ARROW { $$ = yy.LINETYPE.DOTTED; }
|
||||||
| BIDIRECTIONAL_DOTTED_ARROW { $$ = yy.LINETYPE.BIDIRECTIONAL_DOTTED; }
|
| BIDIRECTIONAL_DOTTED_ARROW { $$ = yy.LINETYPE.BIDIRECTIONAL_DOTTED; }
|
||||||
| SOLID_CROSS { $$ = yy.LINETYPE.SOLID_CROSS; }
|
| SOLID_CROSS { $$ = yy.LINETYPE.SOLID_CROSS; }
|
||||||
@@ -350,4 +417,4 @@ text2
|
|||||||
: TXT {$$ = yy.parseMessage($1.trim().substring(1)) }
|
: TXT {$$ = yy.parseMessage($1.trim().substring(1)) }
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -64,6 +64,30 @@ const LINETYPE = {
|
|||||||
PAR_OVER_START: 32,
|
PAR_OVER_START: 32,
|
||||||
BIDIRECTIONAL_SOLID: 33,
|
BIDIRECTIONAL_SOLID: 33,
|
||||||
BIDIRECTIONAL_DOTTED: 34,
|
BIDIRECTIONAL_DOTTED: 34,
|
||||||
|
|
||||||
|
SOLID_TOP: 41,
|
||||||
|
SOLID_BOTTOM: 42,
|
||||||
|
STICK_TOP: 43,
|
||||||
|
STICK_BOTTOM: 44,
|
||||||
|
|
||||||
|
SOLID_ARROW_TOP_REVERSE: 45,
|
||||||
|
SOLID_ARROW_BOTTOM_REVERSE: 46,
|
||||||
|
STICK_ARROW_TOP_REVERSE: 47,
|
||||||
|
STICK_ARROW_BOTTOM_REVERSE: 48,
|
||||||
|
|
||||||
|
SOLID_TOP_DOTTED: 51,
|
||||||
|
SOLID_BOTTOM_DOTTED: 52,
|
||||||
|
STICK_TOP_DOTTED: 53,
|
||||||
|
STICK_BOTTOM_DOTTED: 54,
|
||||||
|
|
||||||
|
SOLID_ARROW_TOP_REVERSE_DOTTED: 55,
|
||||||
|
SOLID_ARROW_BOTTOM_REVERSE_DOTTED: 56,
|
||||||
|
STICK_ARROW_TOP_REVERSE_DOTTED: 57,
|
||||||
|
STICK_ARROW_BOTTOM_REVERSE_DOTTED: 58,
|
||||||
|
|
||||||
|
CENTRAL_CONNECTION: 59,
|
||||||
|
CENTRAL_CONNECTION_REVERSE: 60,
|
||||||
|
CENTRAL_CONNECTION_DUAL: 61,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const ARROWTYPE = {
|
const ARROWTYPE = {
|
||||||
@@ -148,6 +172,12 @@ export class SequenceDB implements DiagramDB {
|
|||||||
doc = yaml.load(yamlData, { schema: yaml.JSON_SCHEMA }) as ParticipantMetaData;
|
doc = yaml.load(yamlData, { schema: yaml.JSON_SCHEMA }) as ParticipantMetaData;
|
||||||
}
|
}
|
||||||
type = doc?.type ?? type;
|
type = doc?.type ?? type;
|
||||||
|
|
||||||
|
// If alias is provided in metadata and description is not already set, use the alias
|
||||||
|
if (doc?.alias && (!description || description.text === name)) {
|
||||||
|
description = { text: doc.alias, wrap: description?.wrap, type };
|
||||||
|
}
|
||||||
|
|
||||||
const old = this.state.records.actors.get(id);
|
const old = this.state.records.actors.get(id);
|
||||||
if (old) {
|
if (old) {
|
||||||
// If already set and trying to set to a new one throw error
|
// If already set and trying to set to a new one throw error
|
||||||
@@ -244,7 +274,8 @@ export class SequenceDB implements DiagramDB {
|
|||||||
idTo?: Message['to'],
|
idTo?: Message['to'],
|
||||||
message?: { text: string; wrap: boolean },
|
message?: { text: string; wrap: boolean },
|
||||||
messageType?: number,
|
messageType?: number,
|
||||||
activate = false
|
activate = false,
|
||||||
|
centralConnection?: number
|
||||||
) {
|
) {
|
||||||
if (messageType === this.LINETYPE.ACTIVE_END) {
|
if (messageType === this.LINETYPE.ACTIVE_END) {
|
||||||
const cnt = this.activationCount(idFrom ?? '');
|
const cnt = this.activationCount(idFrom ?? '');
|
||||||
@@ -271,6 +302,7 @@ export class SequenceDB implements DiagramDB {
|
|||||||
wrap: message?.wrap ?? this.autoWrap(),
|
wrap: message?.wrap ?? this.autoWrap(),
|
||||||
type: messageType,
|
type: messageType,
|
||||||
activate,
|
activate,
|
||||||
|
centralConnection: centralConnection ?? 0,
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -563,6 +595,12 @@ export class SequenceDB implements DiagramDB {
|
|||||||
case 'activeStart':
|
case 'activeStart':
|
||||||
this.addSignal(param.actor, undefined, undefined, param.signalType);
|
this.addSignal(param.actor, undefined, undefined, param.signalType);
|
||||||
break;
|
break;
|
||||||
|
case 'centralConnection':
|
||||||
|
this.addSignal(param.actor, undefined, undefined, param.signalType);
|
||||||
|
break;
|
||||||
|
case 'centralConnectionReverse':
|
||||||
|
this.addSignal(param.actor, undefined, undefined, param.signalType);
|
||||||
|
break;
|
||||||
case 'activeEnd':
|
case 'activeEnd':
|
||||||
this.addSignal(param.actor, undefined, undefined, param.signalType);
|
this.addSignal(param.actor, undefined, undefined, param.signalType);
|
||||||
break;
|
break;
|
||||||
@@ -606,7 +644,14 @@ export class SequenceDB implements DiagramDB {
|
|||||||
this.state.records.lastDestroyed = undefined;
|
this.state.records.lastDestroyed = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.addSignal(param.from, param.to, param.msg, param.signalType, param.activate);
|
this.addSignal(
|
||||||
|
param.from,
|
||||||
|
param.to,
|
||||||
|
param.msg,
|
||||||
|
param.signalType,
|
||||||
|
param.activate,
|
||||||
|
param.centralConnection
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'boxStart':
|
case 'boxStart':
|
||||||
this.addBox(param.boxData);
|
this.addBox(param.boxData);
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ describe('more than one sequence diagram', () => {
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"activate": false,
|
"activate": false,
|
||||||
|
"centralConnection": 0,
|
||||||
"from": "Alice",
|
"from": "Alice",
|
||||||
"id": "0",
|
"id": "0",
|
||||||
"message": "Hello Bob, how are you?",
|
"message": "Hello Bob, how are you?",
|
||||||
@@ -113,6 +114,7 @@ describe('more than one sequence diagram', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"activate": false,
|
"activate": false,
|
||||||
|
"centralConnection": 0,
|
||||||
"from": "Bob",
|
"from": "Bob",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"message": "I am good thanks!",
|
"message": "I am good thanks!",
|
||||||
@@ -131,6 +133,7 @@ describe('more than one sequence diagram', () => {
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"activate": false,
|
"activate": false,
|
||||||
|
"centralConnection": 0,
|
||||||
"from": "Alice",
|
"from": "Alice",
|
||||||
"id": "0",
|
"id": "0",
|
||||||
"message": "Hello Bob, how are you?",
|
"message": "Hello Bob, how are you?",
|
||||||
@@ -140,6 +143,7 @@ describe('more than one sequence diagram', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"activate": false,
|
"activate": false,
|
||||||
|
"centralConnection": 0,
|
||||||
"from": "Bob",
|
"from": "Bob",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"message": "I am good thanks!",
|
"message": "I am good thanks!",
|
||||||
@@ -160,6 +164,7 @@ describe('more than one sequence diagram', () => {
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"activate": false,
|
"activate": false,
|
||||||
|
"centralConnection": 0,
|
||||||
"from": "Alice",
|
"from": "Alice",
|
||||||
"id": "0",
|
"id": "0",
|
||||||
"message": "Hello John, how are you?",
|
"message": "Hello John, how are you?",
|
||||||
@@ -169,6 +174,7 @@ describe('more than one sequence diagram', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"activate": false,
|
"activate": false,
|
||||||
|
"centralConnection": 0,
|
||||||
"from": "John",
|
"from": "John",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"message": "I am good thanks!",
|
"message": "I am good thanks!",
|
||||||
@@ -181,6 +187,254 @@ describe('more than one sequence diagram', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Central Connection Parsing', () => {
|
||||||
|
describe('when parsing central connection syntax', () => {
|
||||||
|
it('should parse actor ()->>() actor syntax as CENTRAL_CONNECTION_DUAL', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()->>() Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(3); // addMessage + centralConnection + centralConnectionReverse
|
||||||
|
|
||||||
|
// Find the actual message (type: 'addMessage')
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL
|
||||||
|
activate: true,
|
||||||
|
type: 0, // SOLID (based on test output)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor ()-->>() actor syntax as CENTRAL_CONNECTION_DUAL', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()-->>() Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(3); // addMessage + centralConnection + centralConnectionReverse
|
||||||
|
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL
|
||||||
|
activate: true,
|
||||||
|
type: 1, // DOTTED (based on test output)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor ->>() actor syntax as CENTRAL_CONNECTION', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ->>() Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(2); // addMessage + centralConnection (no activation for this pattern)
|
||||||
|
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 59, // CENTRAL_CONNECTION
|
||||||
|
activate: true,
|
||||||
|
type: 0, // SOLID (based on actual parsing)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor ()-->> actor syntax as CENTRAL_CONNECTION_REVERSE', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()-->> Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(2); // addMessage + centralConnectionReverse
|
||||||
|
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 60, // CENTRAL_CONNECTION_REVERSE
|
||||||
|
activate: false,
|
||||||
|
type: 1, // DOTTED (based on test output)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor ()->> actor syntax as CENTRAL_CONNECTION_REVERSE', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()->> Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(2); // addMessage + centralConnectionReverse
|
||||||
|
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 60, // CENTRAL_CONNECTION_REVERSE
|
||||||
|
activate: false,
|
||||||
|
type: 0, // SOLID (based on test output)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor ()<<-->>() actor syntax as CENTRAL_CONNECTION_DUAL', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()<<-->>() Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(3); // addMessage + centralConnection + centralConnectionReverse
|
||||||
|
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL
|
||||||
|
activate: true,
|
||||||
|
type: 34, // BIDIRECTIONAL_DOTTED
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor ()<<->>() actor syntax as CENTRAL_CONNECTION_DUAL', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()<<->>() Bob: Hello Bob, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(3); // addMessage + centralConnection + centralConnectionReverse
|
||||||
|
|
||||||
|
const actualMessage = messages.find((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessage).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
message: 'Hello Bob, how are you?',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL
|
||||||
|
activate: true,
|
||||||
|
type: 33, // BIDIRECTIONAL_SOLID
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle multiple central connection types in one diagram', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
participant Charlie
|
||||||
|
Alice ()->>() Bob: Message 1
|
||||||
|
Bob ()-->> Charlie: Message 2
|
||||||
|
Charlie ()<<-->>() Alice: Message 3
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(8); // 3 addMessages + 5 central connection markers
|
||||||
|
|
||||||
|
// Filter to get only the actual messages
|
||||||
|
const actualMessages = messages.filter((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessages).toHaveLength(3);
|
||||||
|
|
||||||
|
expect(actualMessages[0]).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL (()->>())
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(actualMessages[1]).toMatchObject({
|
||||||
|
from: 'Bob',
|
||||||
|
to: 'Charlie',
|
||||||
|
centralConnection: 60, // CENTRAL_CONNECTION_REVERSE (()-->>)
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(actualMessages[2]).toMatchObject({
|
||||||
|
from: 'Charlie',
|
||||||
|
to: 'Alice',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL (()<<-->>())
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle central connections with different arrow types', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ()-x() Bob: Cross message
|
||||||
|
Alice ()--x() Bob: Dotted cross message
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(6); // 2 addMessages + 4 central connection markers
|
||||||
|
|
||||||
|
const actualMessages = messages.filter((msg) => msg.type !== undefined && msg.from && msg.to);
|
||||||
|
expect(actualMessages).toHaveLength(2);
|
||||||
|
|
||||||
|
expect(actualMessages[0]).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL (()-x())
|
||||||
|
type: 3, // SOLID_CROSS
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(actualMessages[1]).toMatchObject({
|
||||||
|
from: 'Alice',
|
||||||
|
to: 'Bob',
|
||||||
|
centralConnection: 61, // CENTRAL_CONNECTION_DUAL (()--x())
|
||||||
|
type: 4, // DOTTED_CROSS
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not break existing parsing without central connections', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant Bob
|
||||||
|
Alice ->> Bob: Normal message
|
||||||
|
Bob -->> Alice: Normal dotted message
|
||||||
|
Alice -x Bob: Normal cross message
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
expect(messages).toHaveLength(3);
|
||||||
|
|
||||||
|
messages.forEach((msg) => {
|
||||||
|
expect(msg.centralConnection).toBe(0); // No central connection
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(messages[0].type).toBe(0); // SOLID (based on actual parsing)
|
||||||
|
expect(messages[1].type).toBe(1); // DOTTED (based on actual parsing)
|
||||||
|
expect(messages[2].type).toBe(3); // SOLID_CROSS
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when parsing a sequenceDiagram', function () {
|
describe('when parsing a sequenceDiagram', function () {
|
||||||
let diagram;
|
let diagram;
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
@@ -2058,6 +2312,36 @@ Bob->>Alice:Got it!
|
|||||||
expect(messages[0].from).toBe('Alice');
|
expect(messages[0].from).toBe('Alice');
|
||||||
expect(messages[0].to).toBe('Bob');
|
expect(messages[0].to).toBe('Bob');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('1 should parse ', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
actor Bob
|
||||||
|
actor Alice
|
||||||
|
Bob -|\\ Alice: Hello Alice, how are you?
|
||||||
|
Bob -|/ Alice: Hello Alice, how are you?
|
||||||
|
Bob -// Alice: Hello Alice, how are you?
|
||||||
|
Bob -\\\\ Alice: Hello Alice, how are you?
|
||||||
|
|
||||||
|
Bob \\|- Alice: Hello Alice, how are you?
|
||||||
|
Bob /|- Alice: Hello Alice, how are you?
|
||||||
|
Bob //- Alice: Hello Alice, how are you?
|
||||||
|
Bob \\\\- Alice: Hello Alice, how are you?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2 should parse ', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
actor Bob
|
||||||
|
actor Alice
|
||||||
|
Alice ()<<->>() Bob: hey?
|
||||||
|
`);
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
});
|
||||||
describe('when parsing extended participant syntax', () => {
|
describe('when parsing extended participant syntax', () => {
|
||||||
it('should parse participants with different quote styles and whitespace', async () => {
|
it('should parse participants with different quote styles and whitespace', async () => {
|
||||||
const diagram = await Diagram.fromText(`
|
const diagram = await Diagram.fromText(`
|
||||||
@@ -2325,5 +2609,126 @@ Bob->>Alice:Got it!
|
|||||||
expect(actors.get('E').type).toBe('entity');
|
expect(actors.get('E').type).toBe('entity');
|
||||||
expect(actors.get('E').description).toBe('E');
|
expect(actors.get('E').description).toBe('E');
|
||||||
});
|
});
|
||||||
|
it('should handle fail parsing when alias token causes conflicts in participant definition', async () => {
|
||||||
|
let error = false;
|
||||||
|
try {
|
||||||
|
await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant SAS MyServiceWithMoreThan20Chars <br> service decription
|
||||||
|
`);
|
||||||
|
} catch (e) {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
expect(error).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse participant with stereotype and alias', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice@{ "type" : "boundary" } as Public API
|
||||||
|
participant Bob@{ "type" : "control" } as Controller
|
||||||
|
Alice->>Bob: Request
|
||||||
|
Bob-->>Alice: Response
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('Alice').type).toBe('boundary');
|
||||||
|
expect(actors.get('Alice').description).toBe('Public API');
|
||||||
|
expect(actors.get('Bob').type).toBe('control');
|
||||||
|
expect(actors.get('Bob').description).toBe('Controller');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor with stereotype and alias', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
actor A@{ "type" : "database" } AS Database Server
|
||||||
|
actor B@{ "type" : "queue" } as Message Queue
|
||||||
|
A->>B: Send message
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('A').type).toBe('database');
|
||||||
|
expect(actors.get('A').description).toBe('Database Server');
|
||||||
|
expect(actors.get('B').type).toBe('queue');
|
||||||
|
expect(actors.get('B').description).toBe('Message Queue');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse participant with stereotype and simple alias', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type" : "boundary" } AS Public API
|
||||||
|
API->>API: test
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('API').type).toBe('boundary');
|
||||||
|
expect(actors.get('API').description).toBe('Public API');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse participant with inline alias in config object', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type" : "boundary", "alias": "Public API" }
|
||||||
|
participant Auth@{ "type" : "control", "alias": "Auth Controller" }
|
||||||
|
API->>Auth: Request
|
||||||
|
Auth-->>API: Response
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('API').type).toBe('boundary');
|
||||||
|
expect(actors.get('API').description).toBe('Public API');
|
||||||
|
expect(actors.get('Auth').type).toBe('control');
|
||||||
|
expect(actors.get('Auth').description).toBe('Auth Controller');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse actor with inline alias in config object', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
actor U@{ "type" : "actor", "alias": "End User" }
|
||||||
|
actor DB@{ "type" : "database", "alias": "User Database" }
|
||||||
|
U->>DB: Query
|
||||||
|
DB-->>U: Result
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('U').type).toBe('actor');
|
||||||
|
expect(actors.get('U').description).toBe('End User');
|
||||||
|
expect(actors.get('DB').type).toBe('database');
|
||||||
|
expect(actors.get('DB').description).toBe('User Database');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should prioritize external alias over inline alias', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type" : "boundary", "alias": "Internal Name" } as External Name
|
||||||
|
API->>API: test
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('API').type).toBe('boundary');
|
||||||
|
expect(actors.get('API').description).toBe('External Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle participant with only inline alias (no type)', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "alias": "Public API" }
|
||||||
|
API->>API: test
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('API').description).toBe('Public API');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle mixed inline and external alias syntax', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant A@{ "type" : "boundary", "alias": "Service A" }
|
||||||
|
participant B@{ "type" : "control" } as Service B
|
||||||
|
participant C@{ "type" : "database" }
|
||||||
|
A->>B: Request
|
||||||
|
B->>C: Query
|
||||||
|
`);
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect(actors.get('A').type).toBe('boundary');
|
||||||
|
expect(actors.get('A').description).toBe('Service A');
|
||||||
|
expect(actors.get('B').type).toBe('control');
|
||||||
|
expect(actors.get('B').description).toBe('Service B');
|
||||||
|
expect(actors.get('C').type).toBe('database');
|
||||||
|
expect(actors.get('C').description).toBe('C');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -282,6 +282,49 @@ const drawNote = async function (elem: any, noteModel: NoteModel) {
|
|||||||
bounds.models.addNote(noteModel);
|
bounds.models.addNote(noteModel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const drawCentralConnection = function (
|
||||||
|
elem: any,
|
||||||
|
msg: any,
|
||||||
|
msgModel: any,
|
||||||
|
diagObj: Diagram,
|
||||||
|
startx: number,
|
||||||
|
stopx: number,
|
||||||
|
lineStartY: number
|
||||||
|
) {
|
||||||
|
const actors = diagObj.db.getActors();
|
||||||
|
const fromActor = actors.get(msg.from);
|
||||||
|
const toActor = actors.get(msg.to);
|
||||||
|
const fromCenter = fromActor.x + fromActor.width / 2;
|
||||||
|
const toCenter = toActor.x + toActor.width / 2;
|
||||||
|
|
||||||
|
const g = elem.append('g');
|
||||||
|
|
||||||
|
const drawCircle = (cx: number) => {
|
||||||
|
g.append('circle')
|
||||||
|
.attr('cx', cx)
|
||||||
|
.attr('cy', lineStartY)
|
||||||
|
.attr('r', 5)
|
||||||
|
.attr('width', 10)
|
||||||
|
.attr('height', 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
const { CENTRAL_CONNECTION, CENTRAL_CONNECTION_REVERSE, CENTRAL_CONNECTION_DUAL } =
|
||||||
|
diagObj.db.LINETYPE;
|
||||||
|
|
||||||
|
switch (msg.centralConnection) {
|
||||||
|
case CENTRAL_CONNECTION:
|
||||||
|
drawCircle(toCenter);
|
||||||
|
break;
|
||||||
|
case CENTRAL_CONNECTION_REVERSE:
|
||||||
|
drawCircle(fromCenter);
|
||||||
|
break;
|
||||||
|
case CENTRAL_CONNECTION_DUAL:
|
||||||
|
drawCircle(fromCenter);
|
||||||
|
drawCircle(toCenter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const messageFont = (cnf) => {
|
const messageFont = (cnf) => {
|
||||||
return {
|
return {
|
||||||
fontFamily: cnf.messageFontFamily,
|
fontFamily: cnf.messageFontFamily,
|
||||||
@@ -367,7 +410,7 @@ async function boundMessage(_diagram, msgModel): Promise<number> {
|
|||||||
* @param lineStartY - The Y coordinate at which the message line starts
|
* @param lineStartY - The Y coordinate at which the message line starts
|
||||||
* @param diagObj - The diagram object.
|
* @param diagObj - The diagram object.
|
||||||
*/
|
*/
|
||||||
const drawMessage = async function (diagram, msgModel, lineStartY: number, diagObj: Diagram) {
|
const drawMessage = async function (diagram, msgModel, lineStartY: number, diagObj: Diagram, msg) {
|
||||||
const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel;
|
const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel;
|
||||||
const textDims = utils.calculateTextDimensions(message, messageFont(conf));
|
const textDims = utils.calculateTextDimensions(message, messageFont(conf));
|
||||||
const textObj = svgDrawCommon.getTextObj();
|
const textObj = svgDrawCommon.getTextObj();
|
||||||
@@ -433,6 +476,9 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
line.attr('y1', lineStartY);
|
line.attr('y1', lineStartY);
|
||||||
line.attr('x2', stopx);
|
line.attr('x2', stopx);
|
||||||
line.attr('y2', lineStartY);
|
line.attr('y2', lineStartY);
|
||||||
|
if (hasCentralConnection(msg, diagObj)) {
|
||||||
|
drawCentralConnection(diagram, msg, msgModel, diagObj, startx, stopx, lineStartY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Make an SVG Container
|
// Make an SVG Container
|
||||||
// Draw the line
|
// Draw the line
|
||||||
@@ -441,7 +487,15 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
type === diagObj.db.LINETYPE.DOTTED_CROSS ||
|
type === diagObj.db.LINETYPE.DOTTED_CROSS ||
|
||||||
type === diagObj.db.LINETYPE.DOTTED_POINT ||
|
type === diagObj.db.LINETYPE.DOTTED_POINT ||
|
||||||
type === diagObj.db.LINETYPE.DOTTED_OPEN ||
|
type === diagObj.db.LINETYPE.DOTTED_OPEN ||
|
||||||
type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED
|
type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_TOP_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_BOTTOM_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_TOP_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_BOTTOM_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED
|
||||||
) {
|
) {
|
||||||
line.style('stroke-dasharray', '3, 3');
|
line.style('stroke-dasharray', '3, 3');
|
||||||
line.attr('class', 'messageLine1');
|
line.attr('class', 'messageLine1');
|
||||||
@@ -457,6 +511,51 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
line.attr('stroke-width', 2);
|
line.attr('stroke-width', 2);
|
||||||
line.attr('stroke', 'none'); // handled by theme/css anyway
|
line.attr('stroke', 'none'); // handled by theme/css anyway
|
||||||
line.style('fill', 'none'); // remove any fill colour
|
line.style('fill', 'none'); // remove any fill colour
|
||||||
|
|
||||||
|
if (type === diagObj.db.LINETYPE.SOLID_TOP || type === diagObj.db.LINETYPE.SOLID_TOP_DOTTED) {
|
||||||
|
line.attr('marker-end', 'url(' + url + '#solidTopArrowHead)');
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_BOTTOM ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_BOTTOM_DOTTED
|
||||||
|
) {
|
||||||
|
line.attr('marker-end', 'url(' + url + '#solidBottomArrowHead)');
|
||||||
|
}
|
||||||
|
if (type === diagObj.db.LINETYPE.STICK_TOP || type === diagObj.db.LINETYPE.STICK_TOP_DOTTED) {
|
||||||
|
line.attr('marker-end', 'url(' + url + '#stickTopArrowHead)');
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
type === diagObj.db.LINETYPE.STICK_BOTTOM ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_BOTTOM_DOTTED
|
||||||
|
) {
|
||||||
|
line.attr('marker-end', 'url(' + url + '#stickBottomArrowHead)');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED
|
||||||
|
) {
|
||||||
|
line.attr('marker-start', 'url(' + url + '#solidBottomArrowHead)');
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED
|
||||||
|
) {
|
||||||
|
line.attr('marker-start', 'url(' + url + '#solidTopArrowHead)');
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED
|
||||||
|
) {
|
||||||
|
line.attr('marker-start', 'url(' + url + '#stickBottomArrowHead)');
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED
|
||||||
|
) {
|
||||||
|
line.attr('marker-start', 'url(' + url + '#stickTopArrowHead)');
|
||||||
|
}
|
||||||
|
|
||||||
if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) {
|
if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) {
|
||||||
line.attr('marker-end', 'url(' + url + '#arrowhead)');
|
line.attr('marker-end', 'url(' + url + '#arrowhead)');
|
||||||
}
|
}
|
||||||
@@ -481,7 +580,18 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
type === diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID ||
|
type === diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID ||
|
||||||
type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED;
|
type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED;
|
||||||
|
|
||||||
if (isBidirectional) {
|
const isReverseArrowType =
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE ||
|
||||||
|
type === diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED;
|
||||||
|
|
||||||
|
let x = 0;
|
||||||
|
if (isBidirectional || isReverseArrowType) {
|
||||||
const SEQUENCE_NUMBER_RADIUS = 6;
|
const SEQUENCE_NUMBER_RADIUS = 6;
|
||||||
|
|
||||||
if (startx < stopx) {
|
if (startx < stopx) {
|
||||||
@@ -489,6 +599,7 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
} else {
|
} else {
|
||||||
line.attr('x1', startx + SEQUENCE_NUMBER_RADIUS);
|
line.attr('x1', startx + SEQUENCE_NUMBER_RADIUS);
|
||||||
}
|
}
|
||||||
|
x = 3.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
diagram
|
diagram
|
||||||
@@ -498,7 +609,8 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
.attr('x2', startx)
|
.attr('x2', startx)
|
||||||
.attr('y2', lineStartY)
|
.attr('y2', lineStartY)
|
||||||
.attr('stroke-width', 0)
|
.attr('stroke-width', 0)
|
||||||
.attr('marker-start', 'url(' + url + '#sequencenumber)');
|
.attr('marker-start', 'url(' + url + '#sequencenumber)')
|
||||||
|
.attr('transform', `translate(-${x}, 0)`);
|
||||||
|
|
||||||
diagram
|
diagram
|
||||||
.append('text')
|
.append('text')
|
||||||
@@ -508,7 +620,8 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
|
|||||||
.attr('font-size', '12px')
|
.attr('font-size', '12px')
|
||||||
.attr('text-anchor', 'middle')
|
.attr('text-anchor', 'middle')
|
||||||
.attr('class', 'sequenceNumber')
|
.attr('class', 'sequenceNumber')
|
||||||
.text(sequenceIndex);
|
.text(sequenceIndex)
|
||||||
|
.attr('transform', `translate(-${x}, 0)`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -857,6 +970,10 @@ export const draw = async function (_text: string, id: string, _version: string,
|
|||||||
svgDraw.insertArrowCrossHead(diagram);
|
svgDraw.insertArrowCrossHead(diagram);
|
||||||
svgDraw.insertArrowFilledHead(diagram);
|
svgDraw.insertArrowFilledHead(diagram);
|
||||||
svgDraw.insertSequenceNumber(diagram);
|
svgDraw.insertSequenceNumber(diagram);
|
||||||
|
svgDraw.insertSolidTopArrowHead(diagram);
|
||||||
|
svgDraw.insertSolidBottomArrowHead(diagram);
|
||||||
|
svgDraw.insertStickTopArrowHead(diagram);
|
||||||
|
svgDraw.insertStickBottomArrowHead(diagram);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param msg - The message to draw.
|
* @param msg - The message to draw.
|
||||||
@@ -897,6 +1014,12 @@ export const draw = async function (_text: string, id: string, _version: string,
|
|||||||
case diagObj.db.LINETYPE.ACTIVE_START:
|
case diagObj.db.LINETYPE.ACTIVE_START:
|
||||||
bounds.newActivation(msg, diagram, actors);
|
bounds.newActivation(msg, diagram, actors);
|
||||||
break;
|
break;
|
||||||
|
case diagObj.db.LINETYPE.CENTRAL_CONNECTION:
|
||||||
|
bounds.newActivation(msg, diagram, actors);
|
||||||
|
break;
|
||||||
|
case diagObj.db.LINETYPE.CENTRAL_CONNECTION_REVERSE:
|
||||||
|
bounds.newActivation(msg, diagram, actors);
|
||||||
|
break;
|
||||||
case diagObj.db.LINETYPE.ACTIVE_END:
|
case diagObj.db.LINETYPE.ACTIVE_END:
|
||||||
activeEnd(msg, bounds.getVerticalPos());
|
activeEnd(msg, bounds.getVerticalPos());
|
||||||
break;
|
break;
|
||||||
@@ -1055,7 +1178,7 @@ export const draw = async function (_text: string, id: string, _version: string,
|
|||||||
createdActors,
|
createdActors,
|
||||||
destroyedActors
|
destroyedActors
|
||||||
);
|
);
|
||||||
messagesToDraw.push({ messageModel: msgModel, lineStartY: lineStartY });
|
messagesToDraw.push({ messageModel: msgModel, lineStartY: lineStartY, msg });
|
||||||
bounds.models.addMessage(msgModel);
|
bounds.models.addMessage(msgModel);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('error while drawing message', e);
|
log.error('error while drawing message', e);
|
||||||
@@ -1068,6 +1191,27 @@ export const draw = async function (_text: string, id: string, _version: string,
|
|||||||
diagObj.db.LINETYPE.SOLID_OPEN,
|
diagObj.db.LINETYPE.SOLID_OPEN,
|
||||||
diagObj.db.LINETYPE.DOTTED_OPEN,
|
diagObj.db.LINETYPE.DOTTED_OPEN,
|
||||||
diagObj.db.LINETYPE.SOLID,
|
diagObj.db.LINETYPE.SOLID,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_TOP,
|
||||||
|
diagObj.db.LINETYPE.SOLID_BOTTOM,
|
||||||
|
diagObj.db.LINETYPE.STICK_TOP,
|
||||||
|
diagObj.db.LINETYPE.STICK_BOTTOM,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_TOP_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_BOTTOM_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_TOP_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_BOTTOM_DOTTED,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
|
||||||
diagObj.db.LINETYPE.DOTTED,
|
diagObj.db.LINETYPE.DOTTED,
|
||||||
diagObj.db.LINETYPE.SOLID_CROSS,
|
diagObj.db.LINETYPE.SOLID_CROSS,
|
||||||
diagObj.db.LINETYPE.DOTTED_CROSS,
|
diagObj.db.LINETYPE.DOTTED_CROSS,
|
||||||
@@ -1087,7 +1231,7 @@ export const draw = async function (_text: string, id: string, _version: string,
|
|||||||
await drawActors(diagram, actors, actorKeys, false);
|
await drawActors(diagram, actors, actorKeys, false);
|
||||||
|
|
||||||
for (const e of messagesToDraw) {
|
for (const e of messagesToDraw) {
|
||||||
await drawMessage(diagram, e.messageModel, e.lineStartY, diagObj);
|
await drawMessage(diagram, e.messageModel, e.lineStartY, diagObj, e.msg);
|
||||||
}
|
}
|
||||||
if (conf.mirrorActors) {
|
if (conf.mirrorActors) {
|
||||||
await drawActors(diagram, actors, actorKeys, true);
|
await drawActors(diagram, actors, actorKeys, true);
|
||||||
@@ -1461,12 +1605,85 @@ const buildNoteModel = async function (msg, actors, diagObj) {
|
|||||||
return noteModel;
|
return noteModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Central connection positioning constants
|
||||||
|
const CENTRAL_CONNECTION_BASE_OFFSET = 4;
|
||||||
|
const CENTRAL_CONNECTION_BIDIRECTIONAL_OFFSET = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a message has central connection
|
||||||
|
* @param msg - The message object
|
||||||
|
* @param diagObj - The diagram object containing LINETYPE constants
|
||||||
|
* @returns True if the message has any type of central connection
|
||||||
|
*/
|
||||||
|
const hasCentralConnection = function (msg, diagObj) {
|
||||||
|
const { CENTRAL_CONNECTION, CENTRAL_CONNECTION_REVERSE, CENTRAL_CONNECTION_DUAL } =
|
||||||
|
diagObj.db.LINETYPE;
|
||||||
|
return [CENTRAL_CONNECTION, CENTRAL_CONNECTION_REVERSE, CENTRAL_CONNECTION_DUAL].includes(
|
||||||
|
msg.centralConnection
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the positioning offset for central connection arrows
|
||||||
|
* @param msg - The message object
|
||||||
|
* @param diagObj - The diagram object containing LINETYPE constants
|
||||||
|
* @param isArrowToRight - Whether the arrow is pointing to the right
|
||||||
|
* @returns The offset to apply to startx position
|
||||||
|
*/
|
||||||
|
const calculateCentralConnectionOffset = function (msg, diagObj, isArrowToRight) {
|
||||||
|
const {
|
||||||
|
CENTRAL_CONNECTION_REVERSE,
|
||||||
|
CENTRAL_CONNECTION_DUAL,
|
||||||
|
BIDIRECTIONAL_SOLID,
|
||||||
|
BIDIRECTIONAL_DOTTED,
|
||||||
|
} = diagObj.db.LINETYPE;
|
||||||
|
|
||||||
|
let offset = 0;
|
||||||
|
|
||||||
|
if (
|
||||||
|
msg.centralConnection === CENTRAL_CONNECTION_REVERSE ||
|
||||||
|
msg.centralConnection === CENTRAL_CONNECTION_DUAL
|
||||||
|
) {
|
||||||
|
offset += CENTRAL_CONNECTION_BASE_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
msg.centralConnection === CENTRAL_CONNECTION_DUAL &&
|
||||||
|
(msg.type === BIDIRECTIONAL_SOLID || msg.type === BIDIRECTIONAL_DOTTED)
|
||||||
|
) {
|
||||||
|
offset += isArrowToRight ? 0 : -CENTRAL_CONNECTION_BIDIRECTIONAL_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
};
|
||||||
|
|
||||||
const buildMessageModel = function (msg, actors, diagObj) {
|
const buildMessageModel = function (msg, actors, diagObj) {
|
||||||
if (
|
if (
|
||||||
![
|
![
|
||||||
diagObj.db.LINETYPE.SOLID_OPEN,
|
diagObj.db.LINETYPE.SOLID_OPEN,
|
||||||
diagObj.db.LINETYPE.DOTTED_OPEN,
|
diagObj.db.LINETYPE.DOTTED_OPEN,
|
||||||
diagObj.db.LINETYPE.SOLID,
|
diagObj.db.LINETYPE.SOLID,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_TOP,
|
||||||
|
diagObj.db.LINETYPE.SOLID_BOTTOM,
|
||||||
|
diagObj.db.LINETYPE.STICK_TOP,
|
||||||
|
diagObj.db.LINETYPE.STICK_BOTTOM,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_TOP_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_BOTTOM_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_TOP_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_BOTTOM_DOTTED,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
|
||||||
diagObj.db.LINETYPE.DOTTED,
|
diagObj.db.LINETYPE.DOTTED,
|
||||||
diagObj.db.LINETYPE.SOLID_CROSS,
|
diagObj.db.LINETYPE.SOLID_CROSS,
|
||||||
diagObj.db.LINETYPE.DOTTED_CROSS,
|
diagObj.db.LINETYPE.DOTTED_CROSS,
|
||||||
@@ -1484,6 +1701,8 @@ const buildMessageModel = function (msg, actors, diagObj) {
|
|||||||
let startx = isArrowToRight ? fromRight : fromLeft;
|
let startx = isArrowToRight ? fromRight : fromLeft;
|
||||||
let stopx = isArrowToRight ? toLeft : toRight;
|
let stopx = isArrowToRight ? toLeft : toRight;
|
||||||
|
|
||||||
|
// Apply central connection positioning adjustments
|
||||||
|
startx += calculateCentralConnectionOffset(msg, diagObj, isArrowToRight);
|
||||||
// As the line width is considered, the left and right values will be off by 2.
|
// As the line width is considered, the left and right values will be off by 2.
|
||||||
const isArrowToActivation = Math.abs(toLeft - toRight) > 2;
|
const isArrowToActivation = Math.abs(toLeft - toRight) > 2;
|
||||||
|
|
||||||
@@ -1517,7 +1736,30 @@ const buildMessageModel = function (msg, actors, diagObj) {
|
|||||||
* Shorten the length of arrow at the end and move the marker forward (using refX) to have a clean arrowhead
|
* Shorten the length of arrow at the end and move the marker forward (using refX) to have a clean arrowhead
|
||||||
* This is not required for open arrows that don't have arrowheads
|
* This is not required for open arrows that don't have arrowheads
|
||||||
*/
|
*/
|
||||||
if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) {
|
if (
|
||||||
|
![
|
||||||
|
diagObj.db.LINETYPE.SOLID_OPEN,
|
||||||
|
diagObj.db.LINETYPE.DOTTED_OPEN,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.STICK_TOP,
|
||||||
|
diagObj.db.LINETYPE.STICK_BOTTOM,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.STICK_TOP_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_BOTTOM_DOTTED,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.STICK_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE,
|
||||||
|
].includes(msg.type)
|
||||||
|
) {
|
||||||
stopx += adjustValue(3);
|
stopx += adjustValue(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1525,9 +1767,14 @@ const buildMessageModel = function (msg, actors, diagObj) {
|
|||||||
* Shorten start position of bidirectional arrow to accommodate for second arrowhead
|
* Shorten start position of bidirectional arrow to accommodate for second arrowhead
|
||||||
*/
|
*/
|
||||||
if (
|
if (
|
||||||
[diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID, diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED].includes(
|
[
|
||||||
msg.type
|
diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID,
|
||||||
)
|
diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE_DOTTED,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_TOP_REVERSE,
|
||||||
|
diagObj.db.LINETYPE.SOLID_ARROW_BOTTOM_REVERSE,
|
||||||
|
].includes(msg.type)
|
||||||
) {
|
) {
|
||||||
startx -= adjustValue(3);
|
startx -= adjustValue(3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1709,6 +1709,77 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||||
|
*
|
||||||
|
* @param elem
|
||||||
|
*/
|
||||||
|
export const insertSolidTopArrowHead = function (elem) {
|
||||||
|
elem
|
||||||
|
.append('defs')
|
||||||
|
.append('marker')
|
||||||
|
.attr('id', 'solidTopArrowHead')
|
||||||
|
.attr('refX', 7.9)
|
||||||
|
.attr('refY', 7.25)
|
||||||
|
.attr('markerUnits', 'userSpaceOnUse')
|
||||||
|
.attr('markerWidth', 12)
|
||||||
|
.attr('markerHeight', 12)
|
||||||
|
.attr('orient', 'auto-start-reverse')
|
||||||
|
.append('path')
|
||||||
|
.attr('d', 'M 0 0 L 10 8 L 0 8 z'); // this is actual shape for arrowhead
|
||||||
|
};
|
||||||
|
|
||||||
|
export const insertSolidBottomArrowHead = function (elem) {
|
||||||
|
elem
|
||||||
|
.append('defs')
|
||||||
|
.append('marker')
|
||||||
|
.attr('id', 'solidBottomArrowHead')
|
||||||
|
.attr('refX', 7.9)
|
||||||
|
.attr('refY', 0.75)
|
||||||
|
.attr('markerUnits', 'userSpaceOnUse')
|
||||||
|
.attr('markerWidth', 12)
|
||||||
|
.attr('markerHeight', 12)
|
||||||
|
.attr('orient', 'auto-start-reverse')
|
||||||
|
.append('path')
|
||||||
|
.attr('d', 'M 0 0 L 10 0 L 0 8 z');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const insertStickTopArrowHead = function (elem) {
|
||||||
|
elem
|
||||||
|
.append('defs')
|
||||||
|
.append('marker')
|
||||||
|
.attr('id', 'stickTopArrowHead')
|
||||||
|
.attr('refX', 7.5)
|
||||||
|
.attr('refY', 7)
|
||||||
|
.attr('markerUnits', 'userSpaceOnUse')
|
||||||
|
.attr('markerWidth', 12)
|
||||||
|
.attr('markerHeight', 12)
|
||||||
|
.attr('orient', 'auto-start-reverse')
|
||||||
|
.append('path')
|
||||||
|
.attr('d', 'M 0 0 L 7 7')
|
||||||
|
.attr('stroke', 'black')
|
||||||
|
.attr('stroke-width', 1.5)
|
||||||
|
.attr('fill', 'none');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const insertStickBottomArrowHead = function (elem) {
|
||||||
|
elem
|
||||||
|
.append('defs')
|
||||||
|
.append('marker')
|
||||||
|
.attr('id', 'stickBottomArrowHead')
|
||||||
|
.attr('refX', 7.5)
|
||||||
|
.attr('refY', 0)
|
||||||
|
.attr('markerUnits', 'userSpaceOnUse')
|
||||||
|
.attr('markerWidth', 12)
|
||||||
|
.attr('markerHeight', 12)
|
||||||
|
.attr('orient', 'auto-start-reverse')
|
||||||
|
.append('path')
|
||||||
|
.attr('d', 'M 0 7 L 7 0')
|
||||||
|
.attr('stroke', 'black')
|
||||||
|
.attr('stroke-width', 1.5)
|
||||||
|
.attr('fill', 'none');
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
drawRect,
|
drawRect,
|
||||||
drawText,
|
drawText,
|
||||||
@@ -1731,4 +1802,8 @@ export default {
|
|||||||
getNoteRect,
|
getNoteRect,
|
||||||
fixLifeLineHeights,
|
fixLifeLineHeights,
|
||||||
sanitizeUrl,
|
sanitizeUrl,
|
||||||
|
insertSolidTopArrowHead,
|
||||||
|
insertSolidBottomArrowHead,
|
||||||
|
insertStickTopArrowHead,
|
||||||
|
insertStickBottomArrowHead,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export interface Message {
|
|||||||
type?: number;
|
type?: number;
|
||||||
activate?: boolean;
|
activate?: boolean;
|
||||||
placement?: string;
|
placement?: string;
|
||||||
|
centralConnection?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddMessageParams {
|
export interface AddMessageParams {
|
||||||
@@ -50,6 +51,8 @@ export interface AddMessageParams {
|
|||||||
| 'destroyParticipant'
|
| 'destroyParticipant'
|
||||||
| 'activeStart'
|
| 'activeStart'
|
||||||
| 'activeEnd'
|
| 'activeEnd'
|
||||||
|
| 'centralConnection'
|
||||||
|
| 'centralConnectionReverse'
|
||||||
| 'addNote'
|
| 'addNote'
|
||||||
| 'addLinks'
|
| 'addLinks'
|
||||||
| 'addALink'
|
| 'addALink'
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const populate = (ast: TreemapAst, db: TreemapDB) => {
|
|||||||
type: string;
|
type: string;
|
||||||
value?: number;
|
value?: number;
|
||||||
classSelector?: string;
|
classSelector?: string;
|
||||||
cssCompiledStyles?: string;
|
cssCompiledStyles?: string[];
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
// Extract classes and styles from the treemap
|
// Extract classes and styles from the treemap
|
||||||
@@ -44,7 +44,7 @@ const populate = (ast: TreemapAst, db: TreemapDB) => {
|
|||||||
|
|
||||||
// Get styles as a string if they exist
|
// Get styles as a string if they exist
|
||||||
const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
|
const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
|
||||||
const cssCompiledStyles = styles.length > 0 ? styles.join(';') : undefined;
|
const cssCompiledStyles = styles.length > 0 ? styles : undefined;
|
||||||
|
|
||||||
const itemData = {
|
const itemData = {
|
||||||
level,
|
level,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export function buildHierarchy(
|
|||||||
type: string;
|
type: string;
|
||||||
value?: number;
|
value?: number;
|
||||||
classSelector?: string;
|
classSelector?: string;
|
||||||
cssCompiledStyles?: string;
|
cssCompiledStyles?: string[];
|
||||||
}[]
|
}[]
|
||||||
): TreemapNode[] {
|
): TreemapNode[] {
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
@@ -29,7 +29,7 @@ export function buildHierarchy(
|
|||||||
};
|
};
|
||||||
node.classSelector = item?.classSelector;
|
node.classSelector = item?.classSelector;
|
||||||
if (item?.cssCompiledStyles) {
|
if (item?.cssCompiledStyles) {
|
||||||
node.cssCompiledStyles = [item.cssCompiledStyles];
|
node.cssCompiledStyles = item.cssCompiledStyles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.type === 'Leaf' && item.value !== undefined) {
|
if (item.type === 'Leaf' && item.value !== undefined) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { MarkdownOptions } from 'vitepress';
|
import type { MarkdownOptions } from 'vitepress';
|
||||||
import { defineConfig } from 'vitepress';
|
import { defineConfig } from 'vitepress';
|
||||||
import packageJson from '../../../package.json' assert { type: 'json' };
|
import packageJson from '../../../package.json' with { type: 'json' };
|
||||||
import { addCanonicalUrls } from './canonical-urls.js';
|
import { addCanonicalUrls } from './canonical-urls.js';
|
||||||
import MermaidExample from './mermaid-markdown-all.js';
|
import MermaidExample from './mermaid-markdown-all.js';
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ To add an integration to this list, see the [Integrations - create page](./integ
|
|||||||
- [GitHub Writer](https://github.com/ckeditor/github-writer)
|
- [GitHub Writer](https://github.com/ckeditor/github-writer)
|
||||||
- [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
|
- [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
|
||||||
- [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅
|
- [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅
|
||||||
|
- [GNU Octave](https://octave.org/) ✅
|
||||||
|
- [octave_mermaid_js](https://github.com/CNOCTAVE/octave_mermaid_js) ✅
|
||||||
|
- [HackMD](https://hackmd.io/c/tutorials/%2F%40docs%2Fflowchart-en#Create-more-complex-flowcharts) ✅
|
||||||
- [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid)
|
- [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid)
|
||||||
- [MonsterWriter](https://www.monsterwriter.com/) ✅
|
- [MonsterWriter](https://www.monsterwriter.com/) ✅
|
||||||
- [Joplin](https://joplinapp.org) ✅
|
- [Joplin](https://joplinapp.org) ✅
|
||||||
@@ -267,6 +270,7 @@ Communication tools and platforms
|
|||||||
- [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin)
|
- [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin)
|
||||||
- [Reveal CK](https://github.com/jedcn/reveal-ck)
|
- [Reveal CK](https://github.com/jedcn/reveal-ck)
|
||||||
- [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin)
|
- [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin)
|
||||||
|
- [speccharts: Turn your test suites into specification diagrams](https://github.com/arnaudrenaud/speccharts)
|
||||||
- [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer)
|
- [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer)
|
||||||
|
|
||||||
<!--- cspell:ignore Blazorade HueHive --->
|
<!--- cspell:ignore Blazorade HueHive --->
|
||||||
|
|||||||
@@ -17,25 +17,25 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "^7.4.47",
|
"@mdi/font": "^7.4.47",
|
||||||
"@vueuse/core": "^13.1.0",
|
"@vueuse/core": "^13.9.0",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"jiti": "^2.4.2",
|
"jiti": "^2.4.2",
|
||||||
"mermaid": "workspace:^",
|
"mermaid": "workspace:^",
|
||||||
"vue": "^3.5.21"
|
"vue": "^3.5.25"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify-json/carbon": "^1.2.13",
|
"@iconify-json/carbon": "^1.2.14",
|
||||||
"@unocss/reset": "^66.0.0",
|
"@unocss/reset": "^66.5.9",
|
||||||
"@vite-pwa/vitepress": "^1.0.0",
|
"@vite-pwa/vitepress": "^1.0.1",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.2",
|
||||||
"fast-glob": "^3.3.3",
|
"fast-glob": "^3.3.3",
|
||||||
"https-localhost": "^4.7.1",
|
"https-localhost": "^4.7.1",
|
||||||
"pathe": "^2.0.3",
|
"pathe": "^2.0.3",
|
||||||
"unocss": "^66.4.2",
|
"unocss": "^66.5.9",
|
||||||
"unplugin-vue-components": "^28.4.0",
|
"unplugin-vue-components": "^28.8.0",
|
||||||
"vite": "^7.0.0",
|
"vite": "^7.0.8",
|
||||||
"vite-plugin-pwa": "^1.0.0",
|
"vite-plugin-pwa": "^1.0.3",
|
||||||
"vitepress": "1.6.3",
|
"vitepress": "1.6.4",
|
||||||
"workbox-window": "^7.3.0"
|
"workbox-window": "^7.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ block
|
|||||||
blockArrowId4<["Label"]>(down)
|
blockArrowId4<["Label"]>(down)
|
||||||
blockArrowId5<["Label"]>(x)
|
blockArrowId5<["Label"]>(x)
|
||||||
blockArrowId6<["Label"]>(y)
|
blockArrowId6<["Label"]>(y)
|
||||||
blockArrowId6<["Label"]>(x, down)
|
blockArrowId7<["Label"]>(x, down)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example - Space Blocks
|
#### Example - Space Blocks
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ title: Animal example
|
|||||||
classDiagram
|
classDiagram
|
||||||
note "From Duck till Zebra"
|
note "From Duck till Zebra"
|
||||||
Animal <|-- Duck
|
Animal <|-- Duck
|
||||||
note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
|
note for Duck "can fly<br>can swim<br>can dive<br>can help in debugging"
|
||||||
Animal <|-- Fish
|
Animal <|-- Fish
|
||||||
Animal <|-- Zebra
|
Animal <|-- Zebra
|
||||||
Animal : +int age
|
Animal : +int age
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ radar-beta
|
|||||||
radar-beta
|
radar-beta
|
||||||
title Restaurant Comparison
|
title Restaurant Comparison
|
||||||
axis food["Food Quality"], service["Service"], price["Price"]
|
axis food["Food Quality"], service["Service"], price["Price"]
|
||||||
axis ambiance["Ambiance"],
|
axis ambiance["Ambiance"]
|
||||||
|
|
||||||
curve a["Restaurant A"]{4, 3, 2, 4}
|
curve a["Restaurant A"]{4, 3, 2, 4}
|
||||||
curve b["Restaurant B"]{3, 4, 3, 3}
|
curve b["Restaurant B"]{3, 4, 3, 3}
|
||||||
|
|||||||
@@ -120,7 +120,11 @@ sequenceDiagram
|
|||||||
|
|
||||||
### Aliases
|
### Aliases
|
||||||
|
|
||||||
The actor can have a convenient identifier and a descriptive label.
|
The actor can have a convenient identifier and a descriptive label. Aliases can be defined in two ways: using external syntax with the `as` keyword, or inline within the configuration object.
|
||||||
|
|
||||||
|
#### External Alias Syntax
|
||||||
|
|
||||||
|
You can define an alias using the `as` keyword after the participant declaration:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
@@ -130,6 +134,48 @@ sequenceDiagram
|
|||||||
J->>A: Great!
|
J->>A: Great!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The external alias syntax also works with participant stereotype configurations, allowing you to combine type specification with aliases:
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary" } as Public API
|
||||||
|
actor DB@{ "type": "database" } as User Database
|
||||||
|
participant Svc@{ "type": "control" } as Auth Service
|
||||||
|
API->>Svc: Authenticate
|
||||||
|
Svc->>DB: Query user
|
||||||
|
DB-->>Svc: User data
|
||||||
|
Svc-->>API: Token
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inline Alias Syntax
|
||||||
|
|
||||||
|
Alternatively, you can define an alias directly inside the configuration object using the `"alias"` field. This works with both `participant` and `actor` keywords:
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary", "alias": "Public API" }
|
||||||
|
participant Auth@{ "type": "control", "alias": "Auth Service" }
|
||||||
|
participant DB@{ "type": "database", "alias": "User Database" }
|
||||||
|
API->>Auth: Login request
|
||||||
|
Auth->>DB: Query user
|
||||||
|
DB-->>Auth: User data
|
||||||
|
Auth-->>API: Access token
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Alias Precedence
|
||||||
|
|
||||||
|
When both inline alias (in the configuration object) and external alias (using `as` keyword) are provided, the **external alias takes precedence**:
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant API@{ "type": "boundary", "alias": "Internal Name" } as External Name
|
||||||
|
participant DB@{ "type": "database", "alias": "Internal DB" } as External DB
|
||||||
|
API->>DB: Query
|
||||||
|
DB-->>API: Result
|
||||||
|
```
|
||||||
|
|
||||||
|
In the example above, "External Name" and "External DB" will be displayed, not "Internal Name" and "Internal DB".
|
||||||
|
|
||||||
### Actor Creation and Destruction (v10.3.0+)
|
### Actor Creation and Destruction (v10.3.0+)
|
||||||
|
|
||||||
It is possible to create and destroy actors by messages. To do so, add a create or destroy directive before the message.
|
It is possible to create and destroy actors by messages. To do so, add a create or destroy directive before the message.
|
||||||
@@ -216,7 +262,11 @@ Messages can be of two displayed either solid or with a dotted line.
|
|||||||
[Actor][Arrow][Actor]:Message text
|
[Actor][Arrow][Actor]:Message text
|
||||||
```
|
```
|
||||||
|
|
||||||
There are ten types of arrows currently supported:
|
Lines can be solid or dotted, and can end with various types of arrowheads, crosses, or open arrows.
|
||||||
|
|
||||||
|
#### Supported Arrow Types
|
||||||
|
|
||||||
|
**Standard Arrow Types**
|
||||||
|
|
||||||
| Type | Description |
|
| Type | Description |
|
||||||
| -------- | ---------------------------------------------------- |
|
| -------- | ---------------------------------------------------- |
|
||||||
@@ -231,6 +281,49 @@ There are ten types of arrows currently supported:
|
|||||||
| `-)` | Solid line with an open arrow at the end (async) |
|
| `-)` | Solid line with an open arrow at the end (async) |
|
||||||
| `--)` | Dotted line with a open arrow at the end (async) |
|
| `--)` | Dotted line with a open arrow at the end (async) |
|
||||||
|
|
||||||
|
**Half-Arrows (v<MERMAID_RELEASE_VERSION>+)**
|
||||||
|
|
||||||
|
The following half-arrow types are supported for more expressive sequence diagrams. Both solid and dotted variants are available by increasing the number of dashes (`-` → `--`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ------- | ---------------------------------------------------- |
|
||||||
|
| `-\|\` | Solid line with top half arrowhead |
|
||||||
|
| `--\|\` | Dotted line with top half arrowhead |
|
||||||
|
| `-\|/` | Solid line with bottom half arrowhead |
|
||||||
|
| `--\|/` | Dotted line with bottom half arrowhead |
|
||||||
|
| `/\|-` | Solid line with reverse top half arrowhead |
|
||||||
|
| `/\|--` | Dotted line with reverse top half arrowhead |
|
||||||
|
| `\\-` | Solid line with reverse bottom half arrowhead |
|
||||||
|
| `\\--` | Dotted line with reverse bottom half arrowhead |
|
||||||
|
| `-\\` | Solid line with top stick half arrowhead |
|
||||||
|
| `--\\` | Dotted line with top stick half arrowhead |
|
||||||
|
| `-//` | Solid line with bottom stick half arrowhead |
|
||||||
|
| `--//` | Dotted line with bottom stick half arrowhead |
|
||||||
|
| `//-` | Solid line with reverse top stick half arrowhead |
|
||||||
|
| `//--` | Dotted line with reverse top stick half arrowhead |
|
||||||
|
| `\\-` | Solid line with reverse bottom stick half arrowhead |
|
||||||
|
| `\\--` | Dotted line with reverse bottom stick half arrowhead |
|
||||||
|
|
||||||
|
## Central Connections (v<MERMAID_RELEASE_VERSION>+)
|
||||||
|
|
||||||
|
Mermaid sequence diagrams support **central lifeline connections** using a `()`.
|
||||||
|
This is useful to represent messages or signals that connect to a central point, rather than from one actor directly to another.
|
||||||
|
|
||||||
|
To indicate a central connection, append `()` to the arrow syntax.
|
||||||
|
|
||||||
|
#### Basic Syntax
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice
|
||||||
|
participant John
|
||||||
|
Alice->>()John: Hello John
|
||||||
|
Alice()->>John: How are you?
|
||||||
|
John()->>()Alice: Great!
|
||||||
|
```
|
||||||
|
|
||||||
## Activations
|
## Activations
|
||||||
|
|
||||||
It is possible to activate and deactivate an actor. (de)activation can be dedicated declarations:
|
It is possible to activate and deactivate an actor. (de)activation can be dedicated declarations:
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user