diff --git a/.build/common.ts b/.build/common.ts index 274977fa2..e2190974f 100644 --- a/.build/common.ts +++ b/.build/common.ts @@ -22,9 +22,9 @@ export const packageOptions = { packageName: 'mermaid-zenuml', file: 'detector.ts', }, - 'mermaid-flowchart-elk': { - name: 'mermaid-flowchart-elk', - packageName: 'mermaid-flowchart-elk', - file: 'detector.ts', + 'mermaid-layout-elk': { + name: 'mermaid-layout-elk', + packageName: 'mermaid-layout-elk', + file: 'layouts.ts', }, } as const; diff --git a/.build/jisonTransformer.ts b/.build/jisonTransformer.ts index 314df8a33..b60350230 100644 --- a/.build/jisonTransformer.ts +++ b/.build/jisonTransformer.ts @@ -1,6 +1,7 @@ import jison from 'jison'; export const transformJison = (src: string): string => { + // @ts-ignore - Jison is not typed properly const parser = new jison.Generator(src, { moduleType: 'js', 'token-stack': true, diff --git a/.cspell/code-terms.txt b/.cspell/code-terms.txt index fa063616a..f2b37dcaf 100644 --- a/.cspell/code-terms.txt +++ b/.cspell/code-terms.txt @@ -27,6 +27,7 @@ controly CSSCLASS CYLINDEREND CYLINDERSTART +DAGA datakey DEND descr @@ -89,6 +90,7 @@ reqs rewritelinks rgba RIGHTOF +roughjs sankey sequencenumber shrc diff --git a/.cspell/libraries.txt b/.cspell/libraries.txt index 9d2926186..ed01e539a 100644 --- a/.cspell/libraries.txt +++ b/.cspell/libraries.txt @@ -54,6 +54,7 @@ presetAttributify pyplot redmine rehype +roughjs rscratch sparkline sphinxcontrib diff --git a/.cspell/mermaid-terms.txt b/.cspell/mermaid-terms.txt index 3fa5eff26..6937c8fb5 100644 --- a/.cspell/mermaid-terms.txt +++ b/.cspell/mermaid-terms.txt @@ -9,6 +9,7 @@ elems gantt gitgraph gzipped +handdrawn knsv Knut marginx @@ -17,6 +18,7 @@ Markdownish mermaidjs mindmap mindmaps +mrtree multigraph nodesep NOTEGROUP diff --git a/.cspell/misc-terms.txt b/.cspell/misc-terms.txt index 467e48891..d0516532d 100644 --- a/.cspell/misc-terms.txt +++ b/.cspell/misc-terms.txt @@ -1 +1,4 @@ +circo +handdrawnSeed +neato newbranch diff --git a/.esbuild/build.ts b/.esbuild/build.ts index 3c87f9d62..471fb5c66 100644 --- a/.esbuild/build.ts +++ b/.esbuild/build.ts @@ -7,8 +7,8 @@ import { MermaidBuildOptions, defaultOptions, getBuildConfig } from './util.js'; const shouldVisualize = process.argv.includes('--visualize'); const buildPackage = async (entryName: keyof typeof packageOptions) => { - const commonOptions = { ...defaultOptions, entryName } as const; - const buildConfigs = [ + const commonOptions: MermaidBuildOptions = { ...defaultOptions, entryName } as const; + const buildConfigs: MermaidBuildOptions[] = [ // package.mjs { ...commonOptions }, // package.min.mjs diff --git a/.esbuild/util.ts b/.esbuild/util.ts index 5c21cbf45..7e0fd27ea 100644 --- a/.esbuild/util.ts +++ b/.esbuild/util.ts @@ -8,7 +8,7 @@ import { jisonPlugin } from './jisonPlugin.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); -export interface MermaidBuildOptions { +export interface MermaidBuildOptions extends BuildOptions { minify: boolean; core: boolean; metafile: boolean; diff --git a/.gitignore b/.gitignore index 7948faee4..7448f2a81 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ cypress/snapshots/ .tsbuildinfo tsconfig.tsbuildinfo -knsv*.html +#knsv*.html local*.html stats/ diff --git a/.prettierignore b/.prettierignore index 7da0646e3..c70080426 100644 --- a/.prettierignore +++ b/.prettierignore @@ -16,3 +16,5 @@ generated/ # Ignore the files creates in /demos/dev except for example.html demos/dev/** !/demos/dev/example.html +# TODO: Lots of errors to fix +cypress/platform/state-refactor.html diff --git a/cypress/platform/knsv-4442.html b/cypress/platform/knsv-4442.html new file mode 100644 index 000000000..fc15a1685 --- /dev/null +++ b/cypress/platform/knsv-4442.html @@ -0,0 +1,433 @@ + +
+ + + + + + + + ++stateDiagram-v2 + [*] --> Still + Still --> [*] + Still --> Moving + Moving --> Still + Moving --> Crash + Crash --> [*]+
+flowchart RL + subgraph "`one`" + a1 -- l1 --> a2 + a1 -- l2 --> a2 + end ++
+flowchart RL + subgraph "`one`" + a1 -- l1 --> a2 + a1 -- l2 --> a2 + end ++
+flowchart +id["`A root with a long text that wraps to keep the node size in check. A root with a long text that wraps to keep the node size in check`"]+
+flowchart LR + A[A text that needs to be wrapped wraps to another line] + B[A text that needs to be+
wrapped wraps to another line] + C["`A text that needs to be wrapped to another line`"]
+flowchart LR + C["`A text + that needs + to be wrapped + in another + way`"] ++
+ classDiagram-v2 + note "I love this diagram!\nDo you love it?" ++
+ stateDiagram-v2 + State1: The state with a note with minus - and plus + in it + note left of State1 + Important information! You can write + notes with . and in them. + end note+
+mindmap +root + Child3(A node with an icon and with a long text that wraps to keep the node size in check) ++
+ %%{init: {"theme": "forest"} }%% +mindmap + id1[**Start2**+
end] + id2[**Start2**
end] + %% Another comment + id3[**Start2**
end] %% Comment + id4[**Start2**
end
the very end] +
+mindmap + id1["`**Start2** + second line 😎 with long text that is wrapping to the next line`"] + id2["`Child **with bold** text`"] + id3["`Children of which some + is using *italic type of* text`"] + id4[Child] + id5["`Child + Row + and another + `"] ++
+mindmap + id1("`**Root**`"] + id2["`A formatted text... with **bold** and *italics*`"] + id3[Regular labels works as usual] + id4["`Emojis and unicode works too: 🤓 + शान्तिः سلام 和平 `"] + ++
+%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% +flowchart TB + %% I could not figure out how to use double quotes in labels in Mermaid + subgraph ibm[IBM Espresso CPU] + core0[IBM PowerPC Broadway Core 0] + core1[IBM PowerPC Broadway Core 1] + core2[IBM PowerPC Broadway Core 2] + + rom[16 KB ROM] + + core0 --- core2 + + rom --> core2 + end + + subgraph amd["`**AMD** Latte GPU`"] + mem[Memory & I/O Bridge] + dram[DRAM Controller] + edram[32 MB EDRAM MEM1] + rom[512 B SEEPROM] + + sata[SATA IF] + exi[EXI] + + subgraph gx[GX] + sram[3 MB 1T-SRAM] + end + + radeon[AMD Radeon R7xx GX2] + + mem --- gx + mem --- radeon + + rom --- mem + + mem --- sata + mem --- exi + + dram --- sata + dram --- exi + end + + ddr3[2 GB DDR3 RAM MEM2] + + mem --- ddr3 + dram --- ddr3 + edram --- ddr3 + + core1 --- mem + + exi --- rtc + rtc{{rtc}} ++
+%%{init: {"flowchart": {"defaultRenderer": "elk", "htmlLabels": false}} }%% +flowchart TB + %% I could not figure out how to use double quotes in labels in Mermaid + subgraph ibm[IBM Espresso CPU] + core0[IBM PowerPC Broadway Core 0] + core1[IBM PowerPC Broadway Core 1] + core2[IBM PowerPC Broadway Core 2] + + rom[16 KB ROM] + + core0 --- core2 + + rom --> core2 + end + + subgraph amd["`**AMD** Latte GPU`"] + mem[Memory & I/O Bridge] + dram[DRAM Controller] + edram[32 MB EDRAM MEM1] + rom[512 B SEEPROM] + + sata[SATA IF] + exi[EXI] + + subgraph gx[GX] + sram[3 MB 1T-SRAM] + end + + radeon[AMD Radeon R7xx GX2] + + mem --- gx + mem --- radeon + + rom --- mem + + mem --- sata + mem --- exi + + dram --- sata + dram --- exi + end + + ddr3[2 GB DDR3 RAM MEM2] + + mem --- ddr3 + dram --- ddr3 + edram --- ddr3 + + core1 --- mem + + exi --- rtc + rtc{{rtc}} ++ +
+flowchart TB + %% I could not figure out how to use double quotes in labels in Mermaid + subgraph ibm[IBM Espresso CPU] + core0[IBM PowerPC Broadway Core 0] + core1[IBM PowerPC Broadway Core 1] + core2[IBM PowerPC Broadway Core 2] + + rom[16 KB ROM] + + core0 --- core2 + + rom --> core2 + end + + subgraph amd[AMD Latte GPU] + mem[Memory & I/O Bridge] + dram[DRAM Controller] + edram[32 MB EDRAM MEM1] + rom[512 B SEEPROM] + + sata[SATA IF] + exi[EXI] + + subgraph gx[GX] + sram[3 MB 1T-SRAM] + end + + radeon[AMD Radeon R7xx GX2] + + mem --- gx + mem --- radeon + + rom --- mem + + mem --- sata + mem --- exi + + dram --- sata + dram --- exi + end + + ddr3[2 GB DDR3 RAM MEM2] + + mem --- ddr3 + dram --- ddr3 + edram --- ddr3 + + core1 --- mem + + exi --- rtc + rtc{{rtc}} ++
+ flowchart LR + B1 --be be--x B2 + B1 --bo bo--o B3 + subgraph Ugge + B2 + B3 + subgraph inner + B4 + B5 + end + subgraph inner2 + subgraph deeper + C4 + C5 + end + C6 + end + + B4 --> C4 + + B3 -- X --> B4 + B2 --> inner + + C4 --> C5 + end + + subgraph outer + B6 + end + B6 --> B5 ++
+sequenceDiagram + Customer->>+Stripe: Makes a payment request + Stripe->>+Bank: Forwards the payment request to the bank + Bank->>+Customer: Asks for authorization + Customer->>+Bank: Provides authorization + Bank->>+Stripe: Sends a response with payment details + Stripe->>+Merchant: Sends a notification of payment receipt + Merchant->>+Stripe: Confirms the payment + Stripe->>+Customer: Sends a confirmation of payment + Customer->>+Merchant: Receives goods or services ++
+mindmap + root((mindmap)) + Origins + Long history + ::icon(fa fa-book) + Popularisation + British popular psychology author Tony Buzan + Research + On effectiveness+
and features + On Automatic creation + Uses + Creative techniques + Strategic planning + Argument mapping + Tools + Pen and paper + Mermaid +
+ example-diagram ++ + + + + + + +
++%%{ + init: { + "theme":"base", + "fontFamily": "Kalam", + "themeVariables": { + "background": "#FFFFFF", + "primaryColor": "#7bdfa7", + "primaryTextColor": "#3c3c3b", + "secondaryColor": "#642470", + "secondaryTextColor": "#3c3c3b", + "tertiaryColor": "#1c736D", + "tertiaryTextColor": "#3c3c3b", + "noteBkgColor": "#9fd8ef", + "loopTextColor": "#636362", + "labelBoxBkgColor": "#642470", + "labelBoxBorderColor": "#642470", + "labelTextColor": "#d4d4d4", + "signalTextColor": "#636362", + "signalColor": "#642470" + } + } +}%% sequenceDiagram - alt apa Alice->>+John: Hello John, how are you? Alice->>+John: John, can you hear me? - note right of Alice: John thinks\nabout it John-->>-Alice: Hi Alice, I can hear you! John-->>-Alice: I feel great! - end - - -+
-%%{ init: {}}%% - +%%{ + init: { + "theme":"base", + "fontFamily": "Forth Bold", + "themeVariables": { + "background": "#FFFFFF", + "primaryColor": "#7bdfa7", + "primaryTextColor": "#3c3c3b", + "secondaryColor": "#642470", + "secondaryTextColor": "#3c3c3b", + "tertiaryColor": "#1c736D", + "tertiaryTextColor": "#3c3c3b", + "noteBkgColor": "#9fd8ef", + "loopTextColor": "#636362", + "labelBoxBkgColor": "#642470", + "labelBoxBorderColor": "#642470", + "labelTextColor": "#d4d4d4", + "signalTextColor": "#636362", + "signalColor": "#642470" + } + } +}%% sequenceDiagram - participant H as H - participant Alice as Alice - participant Bob as Bob + Alice->>+John: Hello John, how are you? + Alice->>+John: John, can you hear me? + John-->>-Alice: Hi Alice, I can hear you! + John-->>-Alice: I feel great! +- Alice ->> Bob: Hello Bob, how are you ? - Bob ->> Alice: Fine, thank you. And you? - create participant Carl as Carl - Alice ->> Carl: Hi Carl! - create actor D as Donald - Carl ->> D: Hi! - D ->> H: sss - destroy Carl - Alice -x Carl: We are too many - destroy Bob - Bob ->> Alice: I agree - - -
-flowchart - A --> B - --
- block-beta - blockArrowId<["Label"]>(right) - blockArrowId2<["Label"]>(left) - blockArrowId3<["Label"]>(up) - blockArrowId4<["Label"]>(down) - blockArrowId5<["Label"]>(x) - blockArrowId6<["Label"]>(y) - blockArrowId6<["Label"]>(x, down) --
-block-beta - block:e:4 - columns 2 - f - g - end - --
-block-beta - block:e:4 - columns 2 - f - g - h - end - --
-block-beta - columns 4 - a b c d - block:e:4 - columns 2 - f - g - h - end - i:4 - --
-flowchart LR - X-- "y" -->z --
-block-beta -columns 5 - A space B - A --x B --
-block-beta -columns 3 - a["A wide one"] b:2 c:2 d --
-block-beta - block:e - f - end --
-block-beta - columns 3 - a:3 - block:e:3 - f - end - g --
-block-beta - columns 3 - a:3 - block:e:3 - f - g - end - h - i - j - --
-block-beta -columns 3 - a b:2 - block:e:3 - f - end - g h i --
-block-beta -columns 3 - a b c - e:3 - f g h --
-block-beta -columns 1 - db(("DB")) - blockArrowId6<[" "]>(down) - block:ID - A - B["A wide one in the middle"] - C - end - space - D - ID --> D - C --> D - style B fill:#f9F,stroke:#333,stroke-width:4px --
-block-beta - columns 5 - A1:3 - A2:1 - A3 - B1 B2 B3:3 --
-block-beta - block - D - E - end - db("This is the text in the box") --
-block-beta - - block - D - end - A["A: I am a wide one"] --
-block-beta - A["square"] - B("rounded") - C(("circle")) --
-block-beta - A>"rect_left_inv_arrow"] - B{"diamond"} - C{{"hexagon"}} --
-block-beta - A(["stadium"]) --
-block-beta - %% A[["subroutine"]] - %% B[("cylinder")] - C>"surprise"] --
-block-beta - A[/"lean right"/] - B[\"lean left"\] - C[/"trapezoid"\] - D[\"trapezoid"/] -- -
-flowchart - B - style B fill:#f9F,stroke:#333,stroke-width:4px -- -
- flowchart LR - a1 -- apa --> b1 -- -
-flowchart RL - subgraph "`one`" - id - end --
-flowchart RL - subgraph "`one`" - a1 -- l1 --> a2 - a1 -- l2 --> a2 - end --
-flowchart -id["`A root with a long text that wraps to keep the node size in check. A root with a long text that wraps to keep the node size in check`"]+ %%{init: {"layout": "elk", "mergeEdges": true} }%% +stateDiagram + direction TB + T00 --> T0 + T00 --> T1 + +
+ %%{init: {"layout": "elk", "mergeEdges": false, "elk.nodePlacement.strategy": "NETWORK_SIMPLEX"} }%% +stateDiagram + State T0 { + direction LR + A --> B + } + State T1 { + [*] --> NumLockOff + NumLockOff --> NumLockOn : EvNumLockPressed + NumLockOn --> NumLockOff : EvNumLockPressed + } +
-flowchart LR - A[A text that needs to be wrapped wraps to another line] - B[A text that needs to be-
wrapped wraps to another line] - C["`A text that needs to be wrapped to another line`"]
-flowchart LR - C["`A text - that needs - to be wrapped - in another - way`"] -
- classDiagram-v2 - note "I love this diagram!\nDo you love it?" -+ %%{init: {"layout": "dagre", "mergeEdges": true} }%% +stateDiagram +State T1 { + T21 + -- + T22 + } +
- stateDiagram-v2 - State1: The state with a note with minus - and plus + in it - note left of State1 + %%{init: {"layout": "elk", "mergeEdges": true} }%% +stateDiagram + direction TB + State T1 { + T11 + } ++
+ %%{init: {"layout": "elk", "mergeEdges": true} }%% +stateDiagram +State T1 { + T21 + -- + T22 + } ++
+ %%{init: {"layout": "elk", "mergeEdges": true} }%% +stateDiagram + [*] --> T1 + T1 --> T2 + T1 --> T3 + T1 --> T4 ++
+ %%{init: {"layout": "elk"} }%% +stateDiagram + [*] --> T1 + T1 --> T2 + T2 --> T3 + T3 --> T1 + T1 --> T3 ++
+stateDiagram + State1: The state with a note + note right of State1 Important information! You can write - notes with . and in them. - end note
-mindmap -root - Child3(A node with an icon and with a long text that wraps to keep the node size in check) -Active + + state Active { + direction BT + [*] --> Inner + Inner --> NumLockOn : EvNumLockPressed + } + %% Outer --> Inner + -
- %%{init: {"theme": "forest"} }%% -mindmap - id1[**Start2**-
end] - id2[**Start2**
end] - %% Another comment - id3[**Start2**
end] %% Comment - id4[**Start2**
end
the very end] -
-mindmap - id1["`**Start2** - second line 😎 with long text that is wrapping to the next line`"] - id2["`Child **with bold** text`"] - id3["`Children of which some - is using *italic type of* text`"] - id4[Child] - id5["`Child - Row - and another - `"] --
-mindmap - id1("`**Root**`"] - id2["`A formatted text... with **bold** and *italics*`"] - id3[Regular labels works as usual] - id4["`Emojis and unicode works too: 🤓 - शान्तिः سلام 和平 `"] - --
-%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% -flowchart TB - %% I could not figure out how to use double quotes in labels in Mermaid - subgraph ibm[IBM Espresso CPU] - core0[IBM PowerPC Broadway Core 0] - core1[IBM PowerPC Broadway Core 1] - core2[IBM PowerPC Broadway Core 2] - - rom[16 KB ROM] - - core0 --- core2 - - rom --> core2 - end - - subgraph amd["`**AMD** Latte GPU`"] - mem[Memory & I/O Bridge] - dram[DRAM Controller] - edram[32 MB EDRAM MEM1] - rom[512 B SEEPROM] - - sata[SATA IF] - exi[EXI] - - subgraph gx[GX] - sram[3 MB 1T-SRAM] - end - - radeon[AMD Radeon R7xx GX2] - - mem --- gx - mem --- radeon - - rom --- mem - - mem --- sata - mem --- exi - - dram --- sata - dram --- exi - end - - ddr3[2 GB DDR3 RAM MEM2] - - mem --- ddr3 - dram --- ddr3 - edram --- ddr3 - - core1 --- mem - - exi --- rtc - rtc{{rtc}} --
-%%{init: {"flowchart": {"defaultRenderer": "elk", "htmlLabels": false}} }%% -flowchart TB - %% I could not figure out how to use double quotes in labels in Mermaid - subgraph ibm[IBM Espresso CPU] - core0[IBM PowerPC Broadway Core 0] - core1[IBM PowerPC Broadway Core 1] - core2[IBM PowerPC Broadway Core 2] - - rom[16 KB ROM] - - core0 --- core2 - - rom --> core2 - end - - subgraph amd["`**AMD** Latte GPU`"] - mem[Memory & I/O Bridge] - dram[DRAM Controller] - edram[32 MB EDRAM MEM1] - rom[512 B SEEPROM] - - sata[SATA IF] - exi[EXI] - - subgraph gx[GX] - sram[3 MB 1T-SRAM] - end - - radeon[AMD Radeon R7xx GX2] - - mem --- gx - mem --- radeon - - rom --- mem - - mem --- sata - mem --- exi - - dram --- sata - dram --- exi - end - - ddr3[2 GB DDR3 RAM MEM2] - - mem --- ddr3 - dram --- ddr3 - edram --- ddr3 - - core1 --- mem - - exi --- rtc - rtc{{rtc}} -- -
-flowchart TB - %% I could not figure out how to use double quotes in labels in Mermaid - subgraph ibm[IBM Espresso CPU] - core0[IBM PowerPC Broadway Core 0] - core1[IBM PowerPC Broadway Core 1] - core2[IBM PowerPC Broadway Core 2] - - rom[16 KB ROM] - - core0 --- core2 - - rom --> core2 - end - - subgraph amd[AMD Latte GPU] - mem[Memory & I/O Bridge] - dram[DRAM Controller] - edram[32 MB EDRAM MEM1] - rom[512 B SEEPROM] - - sata[SATA IF] - exi[EXI] - - subgraph gx[GX] - sram[3 MB 1T-SRAM] - end - - radeon[AMD Radeon R7xx GX2] - - mem --- gx - mem --- radeon - - rom --- mem - - mem --- sata - mem --- exi - - dram --- sata - dram --- exi - end - - ddr3[2 GB DDR3 RAM MEM2] - - mem --- ddr3 - dram --- ddr3 - edram --- ddr3 - - core1 --- mem - - exi --- rtc - rtc{{rtc}} --
- flowchart LR - B1 --be be--x B2 - B1 --bo bo--o B3 - subgraph Ugge - B2 - B3 - subgraph inner - B4 - B5 - end - subgraph inner2 - subgraph deeper - C4 - C5 - end - C6 - end - - B4 --> C4 - - B3 -- X --> B4 - B2 --> inner - - C4 --> C5 - end - - subgraph outer - B6 - end - B6 --> B5 --
-sequenceDiagram - Customer->>+Stripe: Makes a payment request - Stripe->>+Bank: Forwards the payment request to the bank - Bank->>+Customer: Asks for authorization - Customer->>+Bank: Provides authorization - Bank->>+Stripe: Sends a response with payment details - Stripe->>+Merchant: Sends a notification of payment receipt - Merchant->>+Stripe: Confirms the payment - Stripe->>+Customer: Sends a confirmation of payment - Customer->>+Merchant: Receives goods or services --
-mindmap - root((mindmap)) - Origins - Long history - ::icon(fa fa-book) - Popularisation - British popular psychology author Tony Buzan - Research - On effectiveness-
and features - On Automatic creation - Uses - Creative techniques - Strategic planning - Argument mapping - Tools - Pen and paper - Mermaid -
- example-diagram -- - - - - - + + +