Skip to content

Commit

Permalink
Merge e28a766 into ce6f62e
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Jan 11, 2023
2 parents ce6f62e + e28a766 commit da78344
Show file tree
Hide file tree
Showing 29 changed files with 2,275 additions and 33 deletions.
7 changes: 7 additions & 0 deletions .vite/build.ts
Expand Up @@ -41,6 +41,11 @@ const packageOptions = {
packageName: 'mermaid-mindmap',
file: 'detector.ts',
},
'mermaid-flowchart-v3': {
name: 'mermaid-flowchart-v3',
packageName: 'mermaid-flowchart-v3',
file: 'detector.ts',
},
// 'mermaid-example-diagram-detector': {
// name: 'mermaid-example-diagram-detector',
// packageName: 'mermaid-example-diagram',
Expand Down Expand Up @@ -120,6 +125,7 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
if (watch && config.build) {
config.build.watch = {
include: [
'packages/mermaid-flowchart-v3/src/**',
'packages/mermaid-mindmap/src/**',
'packages/mermaid/src/**',
// 'packages/mermaid-example-diagram/src/**',
Expand Down Expand Up @@ -148,6 +154,7 @@ const main = async () => {
if (watch) {
build(getBuildConfig({ minify: false, watch, core: false, entryName: 'mermaid' }));
if (!mermaidOnly) {
build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-flowchart-v3' }));
build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-mindmap' }));
// build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' }));
}
Expand Down
4 changes: 4 additions & 0 deletions cSpell.json
Expand Up @@ -31,6 +31,7 @@
"doku",
"dompurify",
"edgechromium",
"elkjs",
"faber",
"flatmap",
"ftplugin",
Expand All @@ -39,6 +40,7 @@
"gitgraph",
"globby",
"graphlib",
"graphviz",
"grav",
"greywolf",
"inkdrop",
Expand Down Expand Up @@ -69,6 +71,7 @@
"pnpm",
"podlite",
"quence",
"radious",
"ranksep",
"rect",
"rects",
Expand All @@ -90,6 +93,7 @@
"treemap",
"ts-nocheck",
"tuleap",
"ugge",
"unist",
"verdana",
"viewports",
Expand Down
181 changes: 162 additions & 19 deletions cypress/platform/knsv2.html
Expand Up @@ -54,31 +54,172 @@
</style>
</head>
<body>
<div>Security check</div>
<pre id="diagram" class="mermaid">
flowchart LR
%% Actors
A
subgraph Sub
B --> C
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
graph TB
a --> b
a --> c
b --> d
c --> d
</pre>
<pre id="diagram" class="mermaid">
%%{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

%% Accusations
A --L --> Sub
radeon[AMD Radeon R7xx GX2]

%% Offense
B --> A
mem --- gx
mem --- radeon

</pre>
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}}
</pre
>
<br />
<pre id="diagram" class="mermaid">
stateDiagram-v2
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]

[*] --> S1
S1 --> S2: long line using<br/>should work
S1 --> S3: long line using <br>should work
S1 --> S4: long line using \\nshould work
rom[16 KB ROM]

</pre>
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}}
</pre
>
<br />
&nbsp;
<pre id="diagram" class="mermaid2">
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
</pre
>
<pre id="diagram" class="mermaid2">
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
</pre
>
<pre id="diagram" class="mermaid2">
gantt
title Style today marker (vertical line should be 5px wide and half-transparent blue)
Expand All @@ -97,17 +238,19 @@

<script type="module">
import mindmap from '../../packages/mermaid-mindmap/src/detector';
import flowV3 from '../../packages/mermaid-flowchart-v3/src/detector';
// import example from '../../packages/mermaid-example-diagram/src/detector';
import mermaid from '../../packages/mermaid/src/mermaid';
await mermaid.registerExternalDiagrams([mindmap]);
await mermaid.registerExternalDiagrams([mindmap, flowV3]);
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
theme: 'default',
// theme: 'forest',
startOnLoad: true,
logLevel: 0,
flowchart: {
// defaultRenderer: 'elk',
useMaxWidth: false,
htmlLabels: true,
},
Expand Down
2 changes: 1 addition & 1 deletion docs/config/setup/modules/defaultConfig.md
Expand Up @@ -14,7 +14,7 @@

#### Defined in

[defaultConfig.ts:1933](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L1933)
[defaultConfig.ts:1934](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L1934)

---

Expand Down
17 changes: 16 additions & 1 deletion docs/syntax/flowchart.md
Expand Up @@ -990,7 +990,22 @@ flowchart LR
C -->|Two| E[Result two]
```

## Configuration...
## Configuration

### Renderer

The layout of the diagram is done with the renderer. The default renderer is dagre.

Starting with Mermaid version 9.4, you can use an alternate renderer named elk. The elk renderer is better for larger and/or more complex diagrams.

The _elk_ renderer is an experimenal feature.
You can change the renderer to elk by adding this directive:

%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%

Note that the site needs to use mermaid version 9.4+ for this to work and have this featured enabled in the lazy-loading configuration.

### Width

It is possible to adjust the width of the rendered flowchart.

Expand Down
65 changes: 65 additions & 0 deletions packages/mermaid-flowchart-v3/package.json
@@ -0,0 +1,65 @@
{
"name": "@mermaid-js/mermaid-flowchart-v3",
"version": "9.4.0",
"description": "An extension for the Mermaid diagramming library that utilizes elkjs for layout, enabling the creation of visually appealing and easy-to-understand flowcharts.",
"module": "dist/mermaid-flowchart-v3.core.mjs",
"types": "dist/detector.d.ts",
"type": "module",
"exports": {
".": {
"import": "./dist/mermaid-flowchart-v3.core.mjs",
"types": "./dist/detector.d.ts"
},
"./*": "./*"
},
"keywords": [
"diagram",
"markdown",
"flowchart",
"mermaid",
"elkjs"
],
"scripts": {
"prepublishOnly": "pnpm -w run build"
},
"repository": {
"type": "git",
"url": "https://github.com/mermaid-js/mermaid"
},
"author": "Knut Sveidqvist",
"license": "MIT",
"standard": {
"ignore": [
"**/parser/*.js",
"dist/**/*.js",
"cypress/**/*.js"
],
"globals": [
"page"
]
},
"dependencies": {
"@braintree/sanitize-url": "^6.0.0",
"graphlib": "^2.1.0",
"dagre-d3-es": "7.0.4",
"elkjs": "^0.8.2",
"d3": "^7.0.0",
"khroma": "^2.0.0",
"non-layered-tidy-tree-layout": "^2.0.2"
},
"devDependencies": {
"concurrently": "^7.5.0",
"mermaid": "workspace:*",
"rimraf": "^3.0.2"
},
"resolutions": {
"d3": "^7.0.0"
},
"files": [
"dist"
],
"sideEffects": [
"**/*.css",
"**/*.scss"
]
}

0 comments on commit da78344

Please sign in to comment.