Compare commits

...

169 Commits

Author SHA1 Message Date
Knut Sveidqvist
20298d243a v10.0.2 2023-03-02 13:45:56 +01:00
Sidharth Vinod
6f3077c856 fix: dayjs import extension 2023-03-01 23:16:24 +05:30
Knut Sveidqvist
4a9d96aaba Setting version to 10.0.1 2023-03-01 14:04:03 +01:00
Knut Sveidqvist
4275aa613c Merge pull request #4169 from mermaid-js/4168_elk_diamon_subgraph
Elk layout for flowcharts: Incorrect placement of edges when using diamonds in subgraphs
2023-03-01 13:44:08 +01:00
Knut Sveidqvist
a65fb3b979 #4168 Adding the correct offset for the edges 2023-03-01 13:38:26 +01:00
Knut Sveidqvist
c0dba713c5 Updated import of cytoscape for consistent behavior 2023-03-01 09:29:59 +01:00
Sidharth Vinod
807e1f303d Use cytoscape esm 2023-02-28 20:40:56 +05:30
Sidharth Vinod
65f5f9dc45 Revert "chore: Defer elk loading"
This reverts commit 037504785c.
2023-02-28 20:39:06 +05:30
Sidharth Vinod
b8b8c4740a Revert "Split cytoscape"
This reverts commit f81f9f7c95.
2023-02-28 20:31:03 +05:30
Sidharth Vinod
f8f7d94d5a fix: Class with members and styles 2023-02-28 19:34:54 +05:30
Knut Sveidqvist
114ab87816 Merge pull request #4160 from mermaid-js/sidv/fix4157
fix #4157: Inject only fontFamily without replacing themeVariables
2023-02-28 13:38:52 +01:00
Sidharth Vinod
4a6056b558 typo 2023-02-28 18:01:46 +05:30
knsv
3a56af9633 Update docs 2023-02-28 12:24:04 +00:00
Knut Sveidqvist
fda0c8d0a9 Merge branch 'develop' into sidv/fix4157 2023-02-28 13:20:37 +01:00
Knut Sveidqvist
b932cd0930 Merge pull request #4128 from kshitijsaksena/bug/3949_erdiagram_attribute_comment
Added grammar to skip comment in attribute block
2023-02-28 13:14:50 +01:00
Knut Sveidqvist
2f06b41f5f Merge pull request #4142 from mermaid-js/sidv/fixRunAsync
Fix(#4140): Async bug in mermaid.run
2023-02-28 13:12:14 +01:00
Sidharth Vinod
1ab3ed1a1a chore: Add vitest imports 2023-02-28 16:58:41 +05:30
Sidharth Vinod
1981f12976 chore: Fix snapshots 2023-02-28 16:58:04 +05:30
Sidharth Vinod
733967f65a fix #4157: Inject only fontFamily without replacing themeVariables 2023-02-28 16:55:25 +05:30
Sidharth Vinod
56d27d555b Merge branch 'sidv/fixRunAsync' of https://github.com/mermaid-js/mermaid into sidv/fixRunAsync
* 'sidv/fixRunAsync' of https://github.com/mermaid-js/mermaid:
  Update packages/mermaid/src/mermaid.ts
2023-02-28 16:49:02 +05:30
Sidharth Vinod
7cee8cb6dc Merge branch 'develop' into sidv/fixRunAsync
* develop: (23 commits)
  Fix test
  refactor(deps): replace `moment` with `dayjs`
  test(gantt): test daylight savings in ganttdb
  Update .lycheeignore
  chore: dagre-d3-es@7.0.9
  chore: Add tsdoc for registerLazyLoadedDiagrams
  feat: Ensure proper detection for flowcharts
  fix: Class label not visible if class is already defined
  Update import
  fix TS errors
  fix TS errors
  feat: Match timeline section width to tasks
  chore: TimelineRenderer in TS
  Fix types
  fix: Detector order
  Lint
  Cleanup nodes.js
  docs: Update classdiagram docs
  classLabel tests
  Formatting
  ...
2023-02-28 16:48:54 +05:30
Knut Sveidqvist
c91fa192aa Update packages/mermaid/src/mermaid.ts
Co-authored-by: Alois Klink <alois@aloisklink.com>
2023-02-28 12:14:35 +01:00
Knut Sveidqvist
3f93edaaf3 Merge pull request #4086 from sidharthv96/sidv/classDiagramLabels
feat: Add support for classDiagram labels
2023-02-28 12:03:22 +01:00
Knut Sveidqvist
0bed5d717b Merge pull request #4126 from mermaid-js/sidv/timelineSectionWidth
💄 section width now covers all tasks - Timeline
2023-02-28 11:59:14 +01:00
Knut Sveidqvist
1b56071eb3 Merge pull request #4124 from mermaid-js/sidv/fixDetectorOrder
fix: Detector order
2023-02-28 11:49:08 +01:00
Sidharth Vinod
e050a5aaa1 Fix test 2023-02-28 15:40:59 +05:30
Sidharth Vinod
9b2f503dc7 Merge branch 'develop' into sidv/classDiagramLabels
* develop:
  refactor(deps): replace `moment` with `dayjs`
  test(gantt): test daylight savings in ganttdb
  Update .lycheeignore
  chore: dagre-d3-es@7.0.9
  Update docs
  Doc (typo): remove duplicate "be"
  💄 section width now covers all tasks
2023-02-28 14:20:11 +05:30
Sidharth Vinod
c7bdc6ad92 Merge pull request #4153 from aloisklink/chore/switch-to-dayjs
Replace `moment-mini`/`moment` date library with `dayjs`
2023-02-28 10:33:21 +05:30
Alois Klink
a5db04b01c refactor(deps): replace moment with dayjs
Replace Mermaid's dependency on `moment` with `dayjs`.

[Moment is now in maintenance mode][1], and they don't recommend
using it.

[Dayjs][2] has almost exactly the same API as moment, and is still
curently being maintained. Unlike moment, dayjs objects are immutable,
which makes our life much easier, but we need to do
`a = a.add(1, "day")` instead of just `a.add(1, "day")`.

We can't use `dayjs.duration`, because unlike `moment.duration`,
[dayjs durations always degrade to ms][3].
This causes issues with daylight savings, since it assumes that each
day is 24 hours, when some days have 23/25 hours with daylight savings.
(it also assumes that each month is 30 days).

However, `dayjs.add(1, "d");` correctly adds 1 days, even when that
day is only 23 hours long, so we can use that instead.

[1]: https://momentjs.com/docs/#/-project-status/
[2]: https://day.js.org/
[3]: https://day.js.org/docs/en/durations/durations
2023-02-26 22:31:12 +00:00
Alois Klink
06640aba06 test(gantt): test daylight savings in ganttdb
Add a quick test that ensures `ganttDb` correctly adds `1d` (1 day),
even on days with 25 hours.

This test only runs if the test PC has the TZ='America/Los_Angeles'
set (California has daylight savings).

I've added a test to the GitHub Actions `test.yml` action too for this.
It should only add about 5 seconds to each test, so it isn't too bad.
2023-02-26 06:43:14 +00:00
Sidharth Vinod
8b5cb75ef7 Update .lycheeignore 2023-02-25 10:02:07 +05:30
Sidharth Vinod
50db9dcf8e Merge pull request #4147 from mermaid-js/sidv/dagre-d3-es
chore: dagre-d3-es@7.0.9
2023-02-25 09:37:09 +05:30
Sidharth Vinod
fa8a887ae1 chore: dagre-d3-es@7.0.9 2023-02-25 08:56:18 +05:30
Sidharth Vinod
275a54a562 core: Fix render tsdoc
Co-authored-by:  Dmitry Stratiychuk  <dmstrati@microsoft.com>
2023-02-24 23:10:01 +05:30
Sidharth Vinod
1bace23cea Merge branch 'develop' into sidv/fixRunAsync
* develop:
  Update docs
  fix: fix exports
  Doc (typo): remove duplicate "be"
  💄 section width now covers all tasks
2023-02-24 20:54:55 +05:30
Sidharth Vinod
f62c4831ad Merge pull request #4074 from l2fprod/feature/user_journey_expand_section
💄 section width now covers all tasks
2023-02-24 20:00:17 +05:30
Sidharth Vinod
7b4ce7c6ea chore: Add tsdoc for registerLazyLoadedDiagrams
Co-authored-by: Alois Klink <alois@aloisklink.com>
2023-02-24 17:32:39 +05:30
Sidharth Vinod
dda0d00fb9 Merge branch 'develop' into sidv/fixDetectorOrder
* develop:
  Update docs
  fix Lint
  Update CHANGELOG.md
  Update CHANGELOG.md
  fix: fix exports
  Doc (typo): remove duplicate "be"
  Fix readme link
  Regenerate mermaid docs
  Add deepdwn to cspell
  Add Deepdwn to native integrations list
2023-02-24 17:27:47 +05:30
Sidharth Vinod
4bf5c9f3d8 feat: Ensure proper detection for flowcharts 2023-02-24 17:27:24 +05:30
sidharthv96
0409c5ac27 Update docs 2023-02-24 08:34:38 +00:00
Sidharth Vinod
19e5ccfdda Merge pull request #4133 from Julez404/patch-1
Doc (typo): remove duplicate "be"
2023-02-24 14:00:20 +05:30
Sidharth Vinod
b13707fa7b fix: Class label not visible if class is already defined 2023-02-24 13:46:56 +05:30
Sidharth Vinod
716a4d2cbc Update import 2023-02-24 13:29:34 +05:30
Sidharth Vinod
3b2d55efec Merge branch 'develop' into sidv/classDiagramLabels
* develop: (85 commits)
  fix Lint
  Update CHANGELOG.md
  Update CHANGELOG.md
  fix: fix exports
  Fix readme link
  Regenerate mermaid docs
  Add deepdwn to cspell
  Add Deepdwn to native integrations list
  docs: Fix changelog
  docs: v10 breaking changes
  Remove `null` from diagrams before render
  fix docs diagram
  Updated version
  Minor cleanup to trigger build.
  Fix spellings
  Wrap option working in test case
  Fix typos
  Minor cleanup
  Removed the deprecated use of mindmap in Demo
  Minor cleanup
  ...
2023-02-24 13:28:28 +05:30
Sidharth Vinod
870550bd7e Merge pull request #4135 from Mister-Hope/develop
fix: fix exports
2023-02-24 12:38:47 +05:30
Sidharth Vinod
89f1ea49ba Merge branch 'develop' into sidv/fixRunAsync
* develop:
  fix Lint
2023-02-24 12:31:48 +05:30
Sidharth Vinod
7372d7d6c5 fix Lint 2023-02-24 12:31:29 +05:30
Sidharth Vinod
0206ff540a fix(#4140): Deprecate mermaidAPI.render 2023-02-24 12:20:31 +05:30
Sidharth Vinod
1e5d9ae1f4 fix(#4140): Remove direct usage of mermaidAPI.render 2023-02-24 12:15:55 +05:30
Sidharth Vinod
378e6b59e6 Merge branch 'master' into develop
* master:
  Update CHANGELOG.md
  Update CHANGELOG.md
2023-02-23 13:19:11 +05:30
Sidharth Vinod
8910ecb463 Update CHANGELOG.md 2023-02-23 13:18:49 +05:30
Sidharth Vinod
ca97210d67 Update CHANGELOG.md 2023-02-23 13:13:36 +05:30
Mr.Hope
f8abc9c6d5 fix: fix exports
"types" import should always be first
2023-02-23 15:20:17 +08:00
Yoshi404
ef20e0b77a Doc (typo): remove duplicate "be" 2023-02-22 22:34:30 +01:00
Sidharth Vinod
f3b313ec1d Merge branch 'master' into develop
* master:
  Fix readme link
2023-02-22 12:34:11 +05:30
Sidharth Vinod
8f830a1698 Fix readme link 2023-02-22 12:33:50 +05:30
Sidharth Vinod
6a6b200a04 Merge pull request #4127 from Billiam/patch-1
Adding app (Deepdwn) to integrations list
2023-02-22 11:41:20 +05:30
Billiam
15231924cd Regenerate mermaid docs 2023-02-21 21:50:02 -06:00
Billiam
7d4692f7b2 Add deepdwn to cspell 2023-02-21 21:24:39 -06:00
Kshitij
285a7448ae Added grammar to skipcomment in attribute block 2023-02-22 08:36:44 +05:30
Billiam
fd6ce89933 Add Deepdwn to native integrations list 2023-02-21 20:56:26 -06:00
Sidharth Vinod
c8e351c2bb fix TS errors 2023-02-22 02:15:15 +05:30
Sidharth Vinod
a59904cf16 fix TS errors 2023-02-22 02:14:16 +05:30
Sidharth Vinod
df36968ec8 feat: Match timeline section width to tasks 2023-02-22 02:10:35 +05:30
Sidharth Vinod
2ab1e15b86 chore: TimelineRenderer in TS 2023-02-22 02:09:14 +05:30
Sidharth Vinod
eca4163363 Fix types 2023-02-21 23:24:11 +05:30
Sidharth Vinod
1ac219282b fix: Detector order 2023-02-21 23:00:03 +05:30
Sidharth Vinod
0df8c149f9 Merge branch 'master' into develop
* master:
  docs: Fix changelog
  docs: v10 breaking changes
  Remove `null` from diagrams before render
  fix docs diagram
2023-02-21 21:40:29 +05:30
Sidharth Vinod
bdf2667389 docs: Fix changelog 2023-02-21 21:40:06 +05:30
Sidharth Vinod
b868777184 docs: v10 breaking changes 2023-02-21 21:35:54 +05:30
Sidharth Vinod
fe2ef5e0c6 Remove null from diagrams before render 2023-02-21 16:33:42 +05:30
Sidharth Vinod
ac21fe2d5c fix docs diagram 2023-02-21 16:25:18 +05:30
Per Brolin
6b251de227 Merge branch 'master' into develop 2023-02-21 10:29:21 +01:00
Per Brolin
bb56492afe Merge remote-tracking branch 'origin/master' 2023-02-21 10:27:50 +01:00
Per Brolin
2a9e846a49 Merge branch 'release/10.0.0' 2023-02-21 10:27:12 +01:00
Per Brolin
3b25cd3238 Updated version 2023-02-21 10:25:02 +01:00
Sidharth Vinod
4bc997cb8f Minor cleanup to trigger build. 2023-02-21 13:29:43 +05:30
Sidharth Vinod
555d4f2cdc Fix spellings 2023-02-21 13:27:37 +05:30
Sidharth Vinod
75633ba125 Merge pull request #4118 from fkohrt/patch-1
Fix typos
2023-02-21 13:24:54 +05:30
Per Brolin
ec5fa31a11 Wrap option working in test case 2023-02-21 07:00:51 +01:00
Florian Kohrt
bfb8a75fca Fix typos 2023-02-20 22:06:38 +01:00
Sidharth Vinod
14c15b221a Minor cleanup
Co-authored-by: Per Brolin <per@mermaidchart.com>
2023-02-20 19:28:31 +05:30
Per Brolin
8743e9e30e Removed the deprecated use of mindmap in Demo 2023-02-20 14:50:04 +01:00
pbrolin47
22b18a4320 Merge pull request #4113 from mermaid-js/3192_invisible_edges
Adding the ability to use invisible edges
2023-02-20 14:40:43 +01:00
pbrolin47
786023ffa6 Merge pull request #4110 from mermaid-js/sidv/splitDiagrams
splitDiagrams
2023-02-20 13:54:27 +01:00
Sidharth Vinod
68cdc759a7 Minor cleanup
Co-authored-by: Per Brolin <per@mermaidchart.com>
2023-02-20 17:53:07 +05:30
knsv
eb04d80df0 Update docs 2023-02-20 10:23:13 +00:00
Knut Sveidqvist
b6cac3a431 #3192 Adding docs and visual test 2023-02-20 11:19:23 +01:00
Knut Sveidqvist
3a71618a49 #3192 Adding the ability to create invisible links in flowcharts(v2) 2023-02-20 11:08:25 +01:00
Per Brolin
dde8330888 Merge remote-tracking branch 'origin/develop' into develop 2023-02-20 09:47:39 +01:00
Sidharth Vinod
38b2cbc3d1 chore: Update RunOptions docs
Co-authored-by: Alois Klink <alois@aloisklink.com>
2023-02-20 13:10:54 +05:30
Sidharth Vinod
2272af38b9 Merge branch 'release/10.0.0' into sidv/splitDiagrams
* release/10.0.0:
  Cleanup
2023-02-20 01:32:12 +05:30
Sidharth Vinod
40b5f868de Cleanup 2023-02-20 01:19:07 +05:30
Sidharth Vinod
3e480612c7 Merge branch 'release/10.0.0' into sidv/splitDiagrams
* release/10.0.0:
  Skip elk
2023-02-20 00:36:33 +05:30
Sidharth Vinod
4c7306d808 Skip elk 2023-02-20 00:36:13 +05:30
Sidharth Vinod
f66b524585 Merge branch 'release/10.0.0' into sidv/splitDiagrams
* release/10.0.0:
  Skip all elk tests as it's flaky
2023-02-20 00:31:13 +05:30
Sidharth Vinod
5de5598069 Skip all elk tests as it's flaky 2023-02-20 00:30:27 +05:30
Sidharth Vinod
c9c4320f89 fix unit tests 2023-02-20 00:14:39 +05:30
Sidharth Vinod
543e4de0c8 chore: Remove lazyLoadedDiagrams from config 2023-02-19 23:55:22 +05:30
Sidharth Vinod
8174c7ca16 Cleanup 2023-02-19 22:42:26 +05:30
Sidharth Vinod
014ab85420 Cleanup 2023-02-19 22:41:44 +05:30
sidharthv96
e51817b735 Update docs 2023-02-19 16:46:20 +00:00
Sidharth Vinod
c7d9103ede Merge pull request #4107 from rodja/develop
add links to NiceGUI integration
2023-02-19 22:12:43 +05:30
sidharthv96
92cd5ed133 Update docs 2023-02-19 15:06:09 +00:00
Sidharth Vinod
6fb17bb405 Merge pull request #4105 from Oliboy50/patch-1
docs(flowchart): duplicated hexagon node example
2023-02-19 20:32:43 +05:30
Sidharth Vinod
638362baea Merge branch 'release/10.0.0' into sidv/splitDiagrams
* release/10.0.0: (333 commits)
  10.0.0-rc.3
  Export more types
  no side effects
  10.0.0-rc.2
  skip failing elk test
  Cleanup
  Update docs
  fix(#3406, #3394): Remove init & initThrowsErrors
  chore: Rename lazy loaded diagram definitions
  Skip flowchart-elk failing test
  Fix docs
  fix Server
  Fix lint
  Remove Readme
  Fix E2E Tests
  Fix tests
  feat: Break render and parse types
  chore: Remove all non async render/parse/init
  Remove CJS builds from docs
  chore: Remove cjs from build
  ...
2023-02-19 20:18:26 +05:30
Sidharth Vinod
e22171c5bc 10.0.0-rc.3 2023-02-19 20:07:07 +05:30
Sidharth Vinod
77207e0452 Export more types 2023-02-19 20:04:46 +05:30
Sidharth Vinod
4a721a2d25 no side effects 2023-02-19 18:59:08 +05:30
Sidharth Vinod
db8a14cdaf 10.0.0-rc.2 2023-02-19 18:36:04 +05:30
Sidharth Vinod
1691d48b2e skip failing elk test 2023-02-19 18:26:13 +05:30
Sidharth Vinod
8469e72709 Cleanup 2023-02-19 17:33:46 +05:30
sidharthv96
83f3ceb7f5 Update docs 2023-02-19 10:43:49 +00:00
Sidharth Vinod
4ea7294eeb fix(#3406, #3394): Remove init & initThrowsErrors
New run function added as replacement.
2023-02-19 16:10:08 +05:30
Sidharth Vinod
57fd3e586a chore: Rename lazy loaded diagram definitions 2023-02-19 14:58:55 +05:30
Sidharth Vinod
8363552c3a Skip flowchart-elk failing test 2023-02-19 14:52:08 +05:30
Sidharth Vinod
8c64a90721 Fix docs 2023-02-19 14:21:15 +05:30
Sidharth Vinod
6e3d96e16d fix Server 2023-02-19 14:18:09 +05:30
Sidharth Vinod
1684faf632 Fix lint 2023-02-19 14:15:50 +05:30
Sidharth Vinod
e6b4e2c084 Remove Readme 2023-02-19 14:13:57 +05:30
Sidharth Vinod
6aa3ea43ae Remove Readme 2023-02-19 14:13:30 +05:30
Sidharth Vinod
735aceb37a Fix E2E Tests 2023-02-19 14:03:11 +05:30
Sidharth Vinod
d2927435ab Fix tests 2023-02-19 13:09:31 +05:30
Sidharth Vinod
eaa84d2d91 feat: Break render and parse types
Both render and parse are async now.
Return type of render contains svg and bindFunctions.
Parse will not throw error if parseOptions.silent is passed.
2023-02-19 13:08:13 +05:30
Rodja Trappe
941b959da3 add links to NiceGUI integration 2023-02-19 05:40:45 +01:00
Oliver THEBAULT
ae36586b58 docs(flowchart): duplicated hexagon node example 2023-02-18 22:29:35 +01:00
Sidharth Vinod
d22e8d92c6 chore: Remove all non async render/parse/init 2023-02-19 01:10:15 +05:30
Sidharth Vinod
45adc5fb6b Remove CJS builds from docs 2023-02-19 00:58:36 +05:30
Sidharth Vinod
c1aad5975c Merge branch 'release/9.4.2' into release/10.0.0
* release/9.4.2:
  RC version
  Revert #4034
  Revert #4034
  fix: Vite, D3, Vitest Types
  fix(api): tree shaking package.json import
2023-02-19 00:55:23 +05:30
Sidharth Vinod
0c18c0309b Enable blank issues 2023-02-19 00:37:41 +05:30
Sidharth Vinod
631ff8fb9e chore: Remove cjs from build 2023-02-19 00:37:11 +05:30
Sidharth Vinod
bb8bd111f8 Merge branch 'develop' into sidv/classDiagramLabels
* develop: (39 commits)
  Add highlight tag info in contributing.md
  chore(deps): update dependency cypress to v12
  docs: fix links
  Skip precommit hooks on CI
  Fix release-publish
  Fix timeline and mindmap
  Updating integration instructions for timeline and mindmap
  Remove node heap
  Revert "chore: Set node heap size"
  Revert "Remove text hint"
  Split cytoscape
  Linear build
  Remove text hint
  Fix elk import
  Dynamic elk import
  Remove heap option
  elk web-worker
  Test publish docs
  chore: Add file extension for dynamic import
  chore: Defer elk loading
  ...
2023-02-16 18:06:41 +05:30
Per Brolin
aad147c219 Merge branch 'master' into develop 2023-02-15 16:21:17 +01:00
Sidharth Vinod
10e6c92766 Lint 2023-02-14 10:56:16 +05:30
Sidharth Vinod
e1710fddd9 Cleanup nodes.js 2023-02-14 10:22:17 +05:30
Sidharth Vinod
bcfefefbd4 docs: Update classdiagram docs 2023-02-14 00:56:40 +05:30
Sidharth Vinod
ef4fbd8bb3 classLabel tests 2023-02-14 00:54:42 +05:30
Sidharth Vinod
17e317385a Formatting 2023-02-14 00:37:17 +05:30
Sidharth Vinod
102900749e Add support for classDiagram labels 2023-02-14 00:36:43 +05:30
Sidharth Vinod
46f2aebabc Cleanup Renderer 2023-02-13 22:48:11 +05:30
Sidharth Vinod
b9c2f62b47 Cleanup classDB 2023-02-13 21:31:43 +05:30
Frederic Lavigne
f791cd2b24 💄 section width now covers all tasks 2023-02-08 22:02:19 -06:00
Sidharth Vinod
15cfa5d40d Merge branch 'develop' into sidv/splitDiagrams
* develop: (79 commits)
  Minor change
  feat: Add @include support to docs
  feat: Add @include example to docs
  feat: Add @include support to docs
  cleanup
  fix lines
  fix Async rendering
  Revert "sync"
  chore(deps): update pnpm to v7.17.1
  chore(deps): remove dependency on `graphlib`
  test(e2e): make gitgraph snapshots consistent
  chore: Fix lint
  test: Update vitest
  Add official vim plugin to list in integrations
  chore: Cleanup package.json
  chore: Cleanup package.json
  chore: Cleanup package.json
  fix lock
  Docs
  Fix: array concat
  ...
2022-11-30 19:15:21 +05:30
Sidharth Vinod
bf53a03c9d fix: Use lodash instead of lodash-es
lodash with specific imports use lesser space than lodash-es
2022-11-20 18:30:01 +05:30
Sidharth Vinod
3b32f44a60 Merge branch 'sidv/viz' into sidv/splitDiagrams
* sidv/viz:
  feat: Add package visualization
  Ignore stats.html
  feat: Add bundle visualization
2022-11-20 14:25:40 +05:30
Sidharth Vinod
a8cd5e675d Ignore stats.html 2022-11-20 12:10:05 +05:30
Sidharth Vinod
bc269a966d Merge branch 'sidv/sizeCheck' into sidv/splitDiagrams
* sidv/sizeCheck:
  feat: Add size inspection plugin
2022-11-20 12:09:42 +05:30
Sidharth Vinod
d39606cb47 fix: Mindmap link 2022-11-20 12:04:28 +05:30
Sidharth Vinod
b04517b146 chore: Cleanup 2022-11-20 12:00:34 +05:30
Sidharth Vinod
024ee4213f Merge branch 'develop' into sidv/splitDiagrams
* develop: (233 commits)
  style(docs): use `github-dark` hightlight theme
  refactor(docs): use default vitepress highlighter
  fix: Move redirection to router
  ci(renovate): disable pinning dependencies
  Revert "chore(deps): pin dependencies"
  change shiki getHighlighter import
  create separate spec for stateRenderer-v2
  diagramStates should not be global; pass it into functions; minor comment fixes
  diagramClasses no longer needs to be cached; mermaidAPI no longer calls it repeatedly
  (minor) import expectTypeOf in spec
  (minor) fix JSdoc tag
  + spec stateRenderer-v2.js getClasses() to verify it returns a {}
  (minor) fix JSdoc types in comments
  (minor) add comments, remove duplicated line
  chore: Add master to link checker
  chore: Add docs to redirect.ts
  stateDB classes must be a {} not []
  feat: Redirect old documentation links.
  add stateDiagram-v2 to list of graphs with classDefs
  fix(docs): ClassDiagram table
  ...
2022-11-20 11:58:55 +05:30
Sidharth Vinod
e861fbb517 feat: unbundle styles 2022-11-20 11:09:08 +05:30
Sidharth Vinod
2e028ce36d chore: Unify registerLazyLoadedDiagrams 2022-11-20 00:38:35 +05:30
Sidharth Vinod
7306b5ac45 feat: Add size inspection plugin 2022-11-18 17:52:55 +05:30
Sidharth Vinod
0854bab124 fix: Remove diagram dependency from mermaidAPI 2022-11-18 16:51:50 +05:30
Sidharth Vinod
fa51121f29 chore(split): Error 2022-11-18 16:30:54 +05:30
Sidharth Vinod
0b4c6f6477 chore(split): Journey 2022-11-18 16:22:38 +05:30
Sidharth Vinod
e5768454f1 chore(split): State Diagram 2022-11-18 16:19:38 +05:30
Sidharth Vinod
89b5eb56f2 chore(split): Orchestration 2022-11-18 16:11:19 +05:30
Sidharth Vinod
616c969a03 chore(split): Flow type 2022-11-18 16:11:03 +05:30
Sidharth Vinod
4fd826ac8c chore(split): Sequence 2022-11-18 16:10:51 +05:30
Sidharth Vinod
6d5a6ad0c8 chore(split): Requirement 2022-11-18 16:10:42 +05:30
Sidharth Vinod
e0cd76e6fd chore(split): Pie 2022-11-18 16:10:25 +05:30
Sidharth Vinod
f03364f328 chore(split): Info 2022-11-18 16:10:15 +05:30
Sidharth Vinod
25bc381361 chore(split): gitGraph 2022-11-18 16:10:06 +05:30
Sidharth Vinod
38e5c3a81e chore(split): Gantt 2022-11-18 16:09:56 +05:30
Sidharth Vinod
43aa831dd2 chore(split): ER 2022-11-18 16:09:45 +05:30
Sidharth Vinod
4492c5ed4e chore(split): classDiagram 2022-11-18 16:09:36 +05:30
Sidharth Vinod
5dec9eb2f5 fix: C4 type 2022-11-18 16:09:10 +05:30
Sidharth Vinod
02903be558 feat: Split C4 & Flow 2022-11-18 14:28:28 +05:30
203 changed files with 3458 additions and 3823 deletions

View File

@@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: GitHub Discussions
url: https://github.com/mermaid-js/mermaid/discussions

View File

@@ -33,6 +33,14 @@ jobs:
run: |
pnpm run ci --coverage
- name: Run ganttDb tests using California timezone
env:
# Makes sure that gantt db works even in a timezone that has daylight savings
# since some days have 25 hours instead of 24.
TZ: America/Los_Angeles
run: |
pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts
- name: Upload Coverage to Coveralls
# it feels a bit weird to use @master, but that's what the docs use
# (coveralls also doesn't publish a @v1 we can use)

View File

@@ -9,8 +9,11 @@ https://mkdocs.org/
https://osawards.com/javascript/#nominees
https://osawards.com/javascript/2019
# Timeout error, maybe Twitter has anti-bot defences against GitHub's CI servers?
# Timeout error, maybe Twitter has anti-bot defenses against GitHub's CI servers?
https://twitter.com/mermaidjs_
# Don't check files that are generated during the build via `pnpm docs:code`
packages/mermaid/src/docs/config/setup/*
# Network error: 502, since few days
https://bundlephobia.com/

View File

@@ -1,6 +0,0 @@
version: 2
snapshot:
widths:
- 1280
discovery:
disable-cache: true

View File

@@ -1,15 +0,0 @@
{
"ecmaVersion": 6,
"libs": ["browser"],
"loadEagerly": [],
"dontLoad": ["node_modules/**"],
"plugins": {
"modules": {},
"es_modules": {},
"node": {},
"doc_comment": {
"fullDocs": true,
"strong": true
}
}
}

View File

@@ -62,12 +62,6 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
sourcemap: true,
entryFileNames: `${name}.esm${minify ? '.min' : ''}.mjs`,
},
{
name,
format: 'umd',
sourcemap: true,
entryFileNames: `${name}${minify ? '.min' : ''}.js`,
},
];
if (core) {

View File

@@ -1,27 +1,20 @@
import express, { NextFunction, Request, Response } from 'express';
import express from 'express';
import cors from 'cors';
import { createServer as createViteServer } from 'vite';
const cors = (req: Request, res: Response, next: NextFunction) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
};
async function createServer() {
const app = express();
// Create Vite server in middleware mode
const vite = await createViteServer({
configFile: './vite.config.ts',
mode: 'production',
server: { middlewareMode: true },
appType: 'custom', // don't include Vite's default HTML handling middlewares
});
app.use(cors);
app.use(cors());
app.use(express.static('./packages/mermaid/dist'));
// app.use(express.static('./packages/mermaid-example-diagram/dist'));
app.use(express.static('./packages/mermaid-example-diagram/dist'));
app.use(vite.middlewares);
app.use(express.static('demos'));

View File

@@ -1,6 +1,105 @@
# Change Log
# Changelog
// TODO: Populate changelog
## [10.0.0](https://github.com/mermaid-js/mermaid/releases/tag/v10.0.0)
### Mermaid is ESM only!
We've dropped CJS support. So, you will have to update your import scripts as follows.
```html
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
```
You can keep using v9 by adding the `@9` in the CDN URL.
```diff
- <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.js"></script>
```
### mermaid.render is async and doesn't accept callbacks
```js
// < v10
mermaid.render('id', 'graph TD;\nA-->B', (svg, bindFunctions) => {
element.innerHTML = svg;
if (bindFunctions) {
bindFunctions(element);
}
});
// Shorter syntax
if (bindFunctions) {
bindFunctions(element);
}
// can be replaced with the `?.` shorthand
bindFunctions?.(element);
// >= v10 with async/await
const { svg, bindFunctions } = await mermaid.render('id', 'graph TD;\nA-->B');
element.innerHTML = svg;
bindFunctions?.(element);
// >= v10 with promise.then
mermaid.render('id', 'graph TD;A-->B').then(({ svg, bindFunctions }) => {
element.innerHTML = svg;
bindFunctions?.(element);
});
```
### mermaid.parse is async and ParseError is removed
```js
// < v10
mermaid.parse(text, parseError);
//>= v10
await mermaid.parse(text).catch(parseError);
// or
try {
await mermaid.parse(text);
} catch (err) {
parseError(err);
}
```
### Init deprecated and InitThrowsErrors removed
The config passed to `init` was not being used eariler.
It will now be used.
The `init` function is deprecated and will be removed in the next major release.
init currently works as a wrapper to `initialize` and `run`.
```js
// < v10
mermaid.init(config, selector, cb);
//>= v10
mermaid.initialize(config);
mermaid.run({
querySelector: selector,
postRenderCallback: cb,
suppressErrors: true,
});
```
```js
// < v10
mermaid.initThrowsErrors(config, selector, cb);
//>= v10
mermaid.initialize(config);
mermaid.run({
querySelector: selector,
postRenderCallback: cb,
suppressErrors: false,
});
```
// TODO: Populate changelog pre v10
- Config has a lot of changes
- globalReset resets to `defaultConfig` instead of current config. Use `reset` instead.

View File

@@ -8,7 +8,7 @@ Mermaid
Generate diagrams from markdown-like text.
<p>
<p align="center">
<a href="https://www.npmjs.com/package/vitest"><img src="https://img.shields.io/npm/v/mermaid?color=ff3670&label="></a>
<a href="https://www.npmjs.com/package/mermaid"><img src="https://img.shields.io/npm/v/mermaid?color=ff3670&label="></a>
<p>
<p align="center">

View File

@@ -8,7 +8,7 @@ Mermaid
通过解析类 Markdown 的文本语法来实现图表的创建和动态修改。
<p>
<p align="center">
<a href="https://www.npmjs.com/package/vitest"><img src="https://img.shields.io/npm/v/mermaid?color=ff3670&label="></a>
<a href="https://www.npmjs.com/package/mermaid"><img src="https://img.shields.io/npm/v/mermaid?color=ff3670&label="></a>
<p>
<p align="center">

View File

@@ -1,5 +0,0 @@
# A collection of updates that change the behaviour
## Lazy loading and asynchronisity
- Invalid dates are rendered as syntax error instead of returning best guess or the current date

View File

@@ -19,6 +19,7 @@
"brkt",
"brolin",
"brotli",
"città",
"classdef",
"codedoc",
"colour",
@@ -27,6 +28,7 @@
"cuzon",
"cytoscape",
"dagre",
"deepdwn",
"descr",
"docsify",
"docsy",

View File

@@ -22,7 +22,7 @@ export const mermaidUrl = (graphStr, options, api) => {
return url;
};
export const imgSnapshotTest = (graphStr, _options, api = false, validation) => {
export const imgSnapshotTest = (graphStr, _options = {}, api = false, validation = undefined) => {
cy.log(_options);
const options = Object.assign(_options);
if (!options.fontFamily) {

View File

@@ -13,7 +13,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('1: should render a simple class diagram', () => {
@@ -47,7 +46,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('2: should render a simple class diagrams with cardinality', () => {
@@ -76,7 +74,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('should render a simple class diagram with different visibilities', () => {
@@ -94,7 +91,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('should render multiple class diagrams', () => {
@@ -147,7 +143,6 @@ describe('Class diagram V2', () => {
],
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('4: should render a simple class diagram with comments', () => {
@@ -177,7 +172,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('5: should render a simple class diagram with abstract method', () => {
@@ -189,7 +183,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('6: should render a simple class diagram with static method', () => {
@@ -201,7 +194,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('7: should render a simple class diagram with Generic class', () => {
@@ -221,7 +213,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('8: should render a simple class diagram with Generic class and relations', () => {
@@ -242,7 +233,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('9: should render a simple class diagram with clickable link', () => {
@@ -264,7 +254,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('10: should render a simple class diagram with clickable callback', () => {
@@ -286,7 +275,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('11: should render a simple class diagram with return type on method', () => {
@@ -301,7 +289,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('12: should render a simple class diagram with generic types', () => {
@@ -317,7 +304,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('13: should render a simple class diagram with css classes applied', () => {
@@ -335,7 +321,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('14: should render a simple class diagram with css classes applied directly', () => {
@@ -351,7 +336,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('15: should render a simple class diagram with css classes applied two multiple classes', () => {
@@ -365,7 +349,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('16a: should render a simple class diagram with static field', () => {
@@ -378,7 +361,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('16b: should handle the direction statement with TB', () => {
@@ -403,7 +385,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('18: should handle the direction statement with LR', () => {
@@ -428,7 +409,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('17a: should handle the direction statement with BT', () => {
imgSnapshotTest(
@@ -452,7 +432,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('17b: should handle the direction statement with RL', () => {
imgSnapshotTest(
@@ -476,7 +455,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('18: should render a simple class diagram with notes', () => {
@@ -493,7 +471,6 @@ describe('Class diagram V2', () => {
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
cy.get('svg');
});
it('1433: should render a simple class with a title', () => {
@@ -503,8 +480,72 @@ title: simple class diagram
---
classDiagram-v2
class Class10
`,
{}
`
);
});
it('should render a class with text label', () => {
imgSnapshotTest(
`classDiagram
class C1["Class 1 with text label"]
C1 --> C2`
);
});
it('should render two classes with text labels', () => {
imgSnapshotTest(
`classDiagram
class C1["Class 1 with text label"]
class C2["Class 2 with chars @?"]
C1 --> C2`
);
});
it('should render a class with a text label, members and annotation', () => {
imgSnapshotTest(
`classDiagram
class C1["Class 1 with text label"] {
&lt;&lt;interface&gt;&gt;
+member1
}
C1 --> C2`
);
});
it('should render multiple classes with same text labels', () => {
imgSnapshotTest(
`classDiagram
class C1["Class with text label"]
class C2["Class with text label"]
class C3["Class with text label"]
C1 --> C2
C3 ..> C2
`
);
});
it('should render classes with different text labels', () => {
imgSnapshotTest(
`classDiagram
class C1["OneWord"]
class C2["With, Comma"]
class C3["With (Brackets)"]
class C4["With [Brackets]"]
class C5["With {Brackets}"]
class C7["With 1 number"]
class C8["With . period..."]
class C9["With - dash"]
class C10["With _ underscore"]
class C11["With ' single quote"]
class C12["With ~!@#$%^&*()_+=-/?"]
class C13["With Città foreign language"]
`
);
});
it('should render classLabel if class has already been defined earlier', () => {
imgSnapshotTest(
`classDiagram
Animal <|-- Duck
class Duck["Duck with text label"]
`
);
});
});

View File

@@ -188,7 +188,7 @@ describe('Entity Relationship Diagram', () => {
erDiagram
CLUSTER {
varchar(99) name
string(255) description
string(255) description
}
`,
{ logLevel: 1 }

View File

@@ -1,6 +1,6 @@
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
describe('Flowchart ELK', () => {
describe.skip('Flowchart ELK', () => {
it('1-elk: should render a simple flowchart', () => {
imgSnapshotTest(
`flowchart-elk TD

View File

@@ -670,6 +670,17 @@ title: Simple flowchart
---
flowchart TD
A --> B
`,
{ titleTopMargin: 0 }
);
});
it('3192: It should be possieble to render flowcharts with invisible edges', () => {
imgSnapshotTest(
`---
title: Simple flowchart with invisible edges
---
flowchart TD
A ~~~ B
`,
{ titleTopMargin: 0 }
);

View File

@@ -116,7 +116,11 @@ context('Sequence diagram', () => {
loop Loopy
Bob->>Alice: Pasten
end `,
{ wrap: true }
{
sequence: {
wrap: true,
},
}
);
});
context('font settings', () => {

View File

@@ -49,13 +49,9 @@ mermaid.initialize({
],
},
});
mermaid.render(
'the-id-of-the-svg',
code,
(svg) => {
console.log(svg);
const elem = document.querySelector('#graph-to-be');
elem.innerHTML = svg;
}
// ,document.querySelector('#tmp')
);
void (async () => {
const { svg } = await mermaid.render('the-id-of-the-svg', code);
console.log(svg);
const elem = document.querySelector('#graph-to-be');
elem.innerHTML = svg;
})();

View File

@@ -12,7 +12,6 @@
<style>
body {
background: rgb(221, 208, 208);
/*background:#333;*/
font-family: 'Arial';
}
h1 {
@@ -113,24 +112,16 @@ classE o-- classF : aggregation
callback Shape "callbackFunction" "This is a tooltip for a callback"
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
theme: 'default',
// arrowMarkerAbsolute: true,
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
logLevel: 0,
flowchart: { curve: 'linear', htmlLabels: true },
// gantt: { axisFormat: '%m/%d/%Y' },
sequence: { actorMargin: 50, showSequenceNumbers: true },
// sequenceDiagram: { actorMargin: 300 } // deprecated
// fontFamily: '"arial", sans-serif',
// themeVariables: {
// fontFamily: '"arial", sans-serif',
// },
curve: 'linear',
securityLevel: 'loose',
});

View File

@@ -125,7 +125,6 @@
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
function clickByFlow(elemName) {
const div = document.createElement('div');
@@ -162,6 +161,9 @@
document.getElementsByTagName('body')[0].appendChild(div);
}
</script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: true, securityLevel: 'loose', logLevel: 1 });
</script>
</body>

View File

@@ -59,8 +59,8 @@
Add another diagram to demo page : 48h
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';

View File

@@ -125,8 +125,8 @@
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';

View File

@@ -61,8 +61,8 @@
Add another diagram to demo page : 48h
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';

View File

@@ -28,8 +28,8 @@
end
A --> B
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function showFullFirstSquad(elemName) {
console.log('show ' + elemName);
}

View File

@@ -107,8 +107,8 @@ Note over Alice,Bob: Looks
Note over Bob,Alice: Looks back
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -1,32 +1,12 @@
<html>
<head>
<meta charset="utf-8" />
<!-- <meta charset="iso-8859-15"/> -->
<script src="./viewer.js" type="module"></script>
<!-- <link href="https://fonts.googleapis.com/css?family=Mansalva&display=swap" rel="stylesheet" /> -->
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
rel="stylesheet"
/>
<style>
body {
/* font-family: 'Mansalva', cursive;*/
/* font-family: 'Mansalva', cursive; */
/* font-family: 'arial'; */
/* font-family: "trebuchet ms", verdana, arial; */
}
/* div {
font-family: 'arial';
} */
/* .mermaid-main-font {
font-family: "trebuchet ms", verdana, arial;
font-family: var(--mermaid-font-family);
} */
/* :root {
--mermaid-font-family: '"trebuchet ms", verdana, arial';
--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive;
--mermaid-font-family: '"Lucida Console", Monaco, monospace';
} */
svg {
border: 2px solid darkred;
}
@@ -36,21 +16,5 @@
}
</style>
</head>
<body>
<!-- <script src="./mermaid.js"></script> -->
<script>
// Notice startOnLoad=false
// This prevents default handling in mermaid from render before the e2e logic is applied
// mermaid.initialize({
// startOnLoad: false,
// useMaxWidth: true,
// // "themeCSS": ":root { --mermaid-font-family: \"trebuchet ms\", verdana, arial;}",
// // fontFamily: '\"trebuchet ms\", verdana, arial;'
// // fontFamily: '"Comic Sans MS", "Comic Sans", cursive'
// // fontFamily: '"Mansalva", cursive',
// // fontFamily: '"Noto Sans SC", sans-serif'
// fontFamily: '"Noto Sans SC", sans-serif'
// });
</script>
</body>
<body></body>
</html>

View File

@@ -17,7 +17,7 @@ example-diagram
await mermaid.registerExternalDiagrams([exampleDiagram]);
await mermaid.initialize({ logLevel: 0 });
await mermaid.initThrowsErrorsAsync();
await mermaid.run();
if (window.Cypress) {
window.rendered = true;
}

View File

@@ -29,8 +29,8 @@
click a_a "http://www.aftonbladet.se" "apa"
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -0,0 +1,46 @@
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" />
<style>
body {
font-family: 'trebuchet ms', verdana, arial;
}
</style>
</head>
<body>
<pre class="mermaid">
graph TB
subgraph One
a1-->a2-->a3
end
</pre>
<pre class="mermaid">
graph TB
a_a --> b_b:::apa --> c_c:::apa
classDef apa fill:#f9f,stroke:#333,stroke-width:4px;
class a_a apa;
</pre>
<pre class="mermaid">
graph TB
a_a(Aftonbladet) --> b_b[gorilla]:::apa --> c_c{chimp}:::apa -->a_a
a_a --> c --> d_d --> c_c
classDef apa fill:#f9f,stroke:#333,stroke-width:4px;
class a_a apa;
click a_a "http://www.aftonbladet.se" "apa"
</pre>
<script type="module">
import mermaid from '../../packages/mermaid/src/mermaid';
mermaid.initialize({
theme: 'forest',
// themeCSS: '.node rect { fill: red; }',
logLevel: 3,
flowchart: { curve: 'linear' },
gantt: { axisFormat: '%m/%d/%Y' },
sequence: { actorMargin: 50 },
// sequenceDiagram: { actorMargin: 300 } // deprecated
});
</script>
</body>
</html>

View File

@@ -8,18 +8,18 @@
</div>
<svg id="diagram"></svg>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: false, logLevel: 0 });
const graph = `
%%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }", "mainBkg": "#fff000" } } }%%
graph TD
A[Goose]
`;
%%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }", "mainBkg": "#fff000" } } }%%
graph TD
A[Goose]
`;
const diagram = document.getElementById('diagram');
const svg = mermaid.render('diagram-svg', graph);
const { svg } = await mermaid.render('diagram-svg', graph);
diagram.innerHTML = svg;
if (window.Cypress) {
window.rendered = true;

View File

@@ -8,8 +8,8 @@
</div>
<svg id="diagram"></svg>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: false, logLevel: 0 });
const graph = `
@@ -19,7 +19,7 @@
`;
const diagram = document.getElementById('diagram');
const svg = mermaid.render('diagram-svg', graph);
const { svg } = await mermaid.render('diagram-svg', graph);
diagram.innerHTML = svg;
if (window.Cypress) {
window.rendered = true;

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -91,13 +91,11 @@
diagram += 'le> * { background : red}</style>test</p>"]';
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
document.querySelector('#res').innerHTML = res;
if (window.Cypress) {
window.rendered = true;
}
});
const { svg } = await mermaid.render('diagram', diagram);
document.querySelector('#res').innerHTML = svg;
if (window.Cypress) {
window.rendered = true;
}
</script>
</body>
</html>

View File

@@ -43,8 +43,8 @@
cssClass "BankAccount" customCss
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -130,8 +130,8 @@
commit
merge main
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -98,8 +98,8 @@
commit
merge main
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

File diff suppressed because one or more lines are too long

View File

@@ -7,8 +7,8 @@
<pre class="mermaid">
info
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -87,8 +87,8 @@
Add another diagram to demo page : 48h
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';

View File

@@ -59,7 +59,7 @@ A-->B
>
<script src="./packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script>
<script src="./packages/mermaid-mindmap/dist/mermaid-example-diagram-detector.js"></script>
<script src="./packages/mermaid/dist/mermaid.js"></script>
<script src="./packages/mermaid/dist/mermaid.esm.mjs"></script>
<script>
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);

View File

@@ -1,14 +1,4 @@
<html>
<head>
<script src="http://localhost:9000/mermaid.js"></script>
<script>
mermaid.initialize({
theme: 'base',
themeVariables: {},
startOnLoad: true,
});
</script>
</head>
<body>
<h1>Example</h1>
<pre class="mermaid">
@@ -26,4 +16,12 @@ sequenceDiagram
Note left of Ernie: Cookies are good
</pre>
</body>
<script type="module">
import mermaid from '/mermaid.esm.mjs';
mermaid.initialize({
theme: 'base',
themeVariables: {},
startOnLoad: true,
});
</script>
</html>

View File

@@ -9,19 +9,19 @@
<body>
<div id="graph"></div>
<script src="./mermaid.js"></script>
<script>
mermaid.init({ startOnLoad: false });
<script type="module">
import mermaid from './mermaid.esm.mjs';
await mermaid.initialize({ startOnLoad: false });
await mermaid.run();
mermaid.mermaidAPI.initialize({ securityLevel: 'strict' });
await mermaid.mermaidAPI.initialize({ securityLevel: 'strict' });
try {
console.log('rendering');
mermaid.mermaidAPI.render('graphDiv', `>`);
await mermaid.mermaidAPI.render('graphDiv', `>`);
} catch (e) {}
mermaid.mermaidAPI.render('graphDiv', `graph LR\n a --> b`, (html) => {
document.getElementById('graph').innerHTML = html;
});
const { svg } = await mermaid.mermaidAPI.render('graphDiv', `graph LR\n a --> b`);
document.getElementById('graph').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -9,20 +9,20 @@
<body>
<div id="graph"></div>
<script src="./mermaid.js"></script>
<script>
mermaid.init({ startOnLoad: false });
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: false });
mermaid.mermaidAPI.initialize();
rerender('XMas');
function rerender(text) {
async function rerender(text) {
const graphText = `graph TD
A[${text}] -->|Get money| B(Go shopping)`;
const graph = mermaid.mermaidAPI.render('id', graphText);
console.log('\x1b[35m%s\x1b[0m', '>> graph', graph);
document.getElementById('graph').innerHTML = graph;
const { svg } = await mermaid.mermaidAPI.render('id', graphText);
console.log('\x1b[35m%s\x1b[0m', '>> graph', svg);
document.getElementById('graph').innerHTML = svg;
}
window.rerender = rerender;
await rerender('XMas');
</script>
<button id="rerender" onclick="rerender('Saturday')">Rerender</button>
</body>

View File

@@ -313,8 +313,8 @@ requirementDiagram
merge release
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -308,8 +308,8 @@ gitGraph
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -308,8 +308,8 @@ gitGraph
merge release
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -301,8 +301,8 @@ requirementDiagram
merge release
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -305,8 +305,8 @@ requirementDiagram
merge release
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -305,8 +305,8 @@ requirementDiagram
merge release
</pre>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -1,252 +1,17 @@
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" />
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<link
href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
rel="stylesheet"
/>
<style>
body {
/* background: rgb(221, 208, 208); */
/* background:#333; */
font-family: 'Arial';
/* font-size: 18px !important; */
}
h1 {
color: grey;
}
.mermaid2 {
display: none;
}
.mermaid svg {
/* font-size: 18px !important; */
background-color: #eee;
background-image: radial-gradient(#fff 1%, transparent 11%),
radial-gradient(#fff 1%, transparent 11%);
background-size: 20px 20px;
background-position: 0 0, 10px 10px;
background-repeat: repeat;
}
.malware {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 150px;
background: red;
color: black;
display: flex;
display: flex;
justify-content: center;
align-items: center;
font-family: monospace;
font-size: 72px;
}
</style>
</head>
<body>
<pre id="diagram" class="mermaid">
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
graph TB
a --> b
a --> c
b --> d
c --> d
</pre>
<pre id="diagram" class="mermaid">
flowchart-elk LR
subgraph A
a --> b
end
subgraph B
b
end
</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
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 />
<pre id="diagram" class="mermaid">
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}}
</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)
dateFormat YYYY-MM-DD
axisFormat %d
todayMarker stroke-width:5px,stroke:#00f,opacity:0.5
section Section1
Today: 1, -1h
</pre>
<!-- <div id="cy"></div> -->
<!-- <script src="http://localhost:9000/packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> -->
<!-- <script src="./mermaid-example-diagram-detector.js"></script> -->
<!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> -->
<!-- <script src="./mermaid.js"></script> -->
<div id="d2"></div>
<script type="module">
import mermaid from '../../packages/mermaid/src/mermaid';
import mermaid from '/mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -271,6 +36,11 @@ sequenceDiagram
console.error('In parse error:');
console.error(err);
};
const value = `graph TD\nHello --> World`;
const el = document.getElementById('d2');
const { svg } = await mermaid.render('d22', value);
console.log(svg);
el.innerHTML = svg;
// mermaid.test1('first_slow', 1200).then((r) => console.info(r));
// mermaid.test1('second_fast', 200).then((r) => console.info(r));
// mermaid.test1('third_fast', 200).then((r) => console.info(r));

View File

@@ -34,8 +34,8 @@
9e122290-->82072290_1ec3_e711_8c5a_005056ad0002
style 9e122290 fill:#F99,stroke-width:2px,stroke:#F0F
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function showFullFirstSquad(elemName) {
console.log('show ' + elemName);
}

View File

@@ -120,8 +120,8 @@
</div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};

View File

@@ -25,8 +25,8 @@
Get into car:4: Dad, Mum, Child 1, Child 2
Drive home:3: Dad
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
logLevel: 3,

View File

@@ -26,8 +26,8 @@
A --> B --> C
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function showFullFirstSquad(elemName) {
console.log('show ' + elemName);
}

View File

@@ -46,7 +46,7 @@ const contentLoaded = async function () {
await mermaid2.registerExternalDiagrams([externalExample]);
mermaid2.initialize(graphObj.mermaid);
await mermaid2.init();
await mermaid2.run();
markRendered();
}
};
@@ -75,7 +75,7 @@ function merge(current, update) {
return current;
}
const contentLoadedApi = function () {
const contentLoadedApi = async function () {
let pos = document.location.href.indexOf('?graph=');
if (pos > 0) {
pos = pos + 7;
@@ -102,38 +102,25 @@ const contentLoadedApi = function () {
mermaid2.initialize(cnf);
for (let i = 0; i < numCodes; i++) {
mermaid2.render(
const { svg, bindFunctions } = await mermaid2.render(
'newid' + i,
graphObj.code[i],
(svgCode, bindFunctions) => {
div.innerHTML = svgCode;
bindFunctions(div);
},
divs[i]
);
div.innerHTML = svg;
bindFunctions(div);
}
} else {
const div = document.createElement('div');
div.id = 'block';
div.className = 'mermaid';
// div.innerHTML = graphObj.code
console.warn('graphObj.mermaid', graphObj.mermaid);
document.getElementsByTagName('body')[0].appendChild(div);
mermaid2.initialize(graphObj.mermaid);
mermaid2.render(
'newid',
graphObj.code,
(svgCode, bindFunctions) => {
div.innerHTML = svgCode;
if (bindFunctions) {
bindFunctions(div);
}
},
div
);
const { svg, bindFunctions } = await mermaid2.render('newid', graphObj.code, div);
div.innerHTML = svg;
bindFunctions(div);
}
}
markRendered();
@@ -148,7 +135,7 @@ if (typeof document !== 'undefined') {
function () {
if (this.location.href.match('xss.html')) {
this.console.log('Using api');
contentLoadedApi();
void contentLoadedApi();
} else {
this.console.log('Not using api');
void contentLoaded();

View File

@@ -33,8 +33,8 @@
</script>
</head>
<body>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
startOnLoad: false,
useMaxWidth: true,

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -104,10 +104,9 @@
// diagram += "=xssAttack()> --> B";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -102,10 +102,9 @@
// diagram += "=xssAttack()> --> B";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -102,10 +102,9 @@
// diagram += "=xssAttack()> --> B";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -102,10 +102,9 @@
// diagram += "=xssAttack()> --> B";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -104,10 +104,9 @@
// diagram += "=xssAttack()> --> B";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -103,10 +103,9 @@
// diagram += "=xssAttack()> --> B";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -102,10 +102,9 @@
// diagram += '//via.placeholder.com/64\' width=64 />"]';
// console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -102,10 +102,9 @@
// diagram += '//via.placeholder.com/64\' width=64 />"]';
// console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -101,10 +101,9 @@
// diagram += '//via.placeholder.com/64\' width=64 />"]';
// console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -103,10 +103,9 @@ class Shape{
// diagram += '//via.placeholder.com/64\' width=64 />"]';
// console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -48,8 +48,8 @@
Alice->>Bob: Hi Bob
Bob->>Alice: Hi Alice
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
startOnLoad: true,
useMaxWidth: true,
@@ -59,7 +59,7 @@
const handler = setInterval(() => {
cnt++;
a = {};
if (typeof a.polluted !== 'undefined') {
if (a.polluted !== undefined) {
clearInterval(handler);
xssAttack();
}

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -101,10 +101,8 @@ A --> B["<a href='javasc`;
diagram += `ript#colon;xssAttack()'>AAA</a>"]`;
// diagram += '//via.placeholder.com/64\' width=64 />"]';
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
// console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -97,14 +97,12 @@
// A --> B["&lt;a href='javascript`;
// diagram += `ript#colon;xssAttack()'&gt;AAA&lt;/a&gt;"]`;
let diagram = ` graph TD
A --> B["<a href='javasc`;
A --> B["<a href='javasc`;
diagram += `ript#9;t#colon;xssAttack()'>AAA</a>"]`;
// diagram += '//via.placeholder.com/64\' width=64 />"]';
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -8,8 +8,8 @@
graph TD
A --&gt; B["&lt;a href='javascript#9;t#colon;alert(document.location)'&gt;AAA&lt;/a&gt;"]
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
</body>

View File

@@ -36,8 +36,8 @@
graph LR
A --> B
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
startOnLoad: true,
useMaxWidth: true,

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -95,9 +95,8 @@
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -99,10 +99,9 @@
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -97,10 +97,9 @@
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -99,10 +99,9 @@
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -98,10 +98,9 @@
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -49,8 +49,8 @@
<div id="diagram" class="mermaid"></div>
<div id="res" class=""></div>
</div>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
@@ -98,10 +98,9 @@
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram);
// document.querySelector('#diagram').innerHTML = diagram;
mermaid.render('diagram', diagram, (res) => {
console.log(res);
document.querySelector('#res').innerHTML = res;
});
const { svg } = await mermaid.render('diagram', diagram);
console.log(res);
document.querySelector('#res').innerHTML = svg;
</script>
</body>
</html>

View File

@@ -217,8 +217,8 @@
</pre>
<hr />
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
const ALLOWED_TAGS = [
'a',
'b',
@@ -273,8 +273,7 @@
},
// sequenceDiagram: { actorMargin: 300 } // deprecated
});
</script>
<script>
function testClick(nodeId) {
console.log('clicked', nodeId);
let originalBgColor = document.querySelector('body').style.backgroundColor;
@@ -283,21 +282,18 @@
document.querySelector('body').style.backgroundColor = originalBgColor;
}, 100);
}
</script>
<script>
const testLineEndings = (test, input) => {
const testLineEndings = async (test, input) => {
try {
mermaid.render(test, input, () => {
//no-op
});
await mermaid.render(test, input);
} catch (err) {
console.error('Error in %s:\n\n%s', test, err);
}
};
testLineEndings('CR', 'graph LR\rsubgraph CR\rA --> B\rend');
testLineEndings('LF', 'graph LR\nsubgraph LF\nA --> B\nend');
testLineEndings('CRLF', 'graph LR\r\nsubgraph CRLF\r\nA --> B\r\nend');
await testLineEndings('CR', 'graph LR\rsubgraph CR\rA --> B\rend');
await testLineEndings('LF', 'graph LR\nsubgraph LF\nA --> B\nend');
await testLineEndings('CRLF', 'graph LR\r\nsubgraph CRLF\r\nA --> B\r\nend');
</script>
</body>
</html>

View File

@@ -154,8 +154,8 @@
</pre>
<hr />
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'default',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -34,8 +34,8 @@
noSide[|borders:no| stroke no side ];
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
logLevel: 3,

View File

@@ -109,8 +109,8 @@
MANUFACTURER only one to zero or more CAR : makes
</pre>
<script src="./mermaid.js"></script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'default',

View File

@@ -1507,8 +1507,8 @@
<h1 id="link-clicked">Anchor for "link-clicked" test</h1>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
logLevel: 3,

View File

@@ -182,8 +182,8 @@
}
</script>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
logLevel: 3,
securityLevel: 'loose',

View File

@@ -38,8 +38,8 @@
merge newbranch
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
const ALLOWED_TAGS = [
'a',
'b',

View File

@@ -17,7 +17,7 @@
<h1>Journey diagram demo</h1>
<pre class="mermaid">
---
title: My working day
title: My working day
---
journey
accTitle: Very simple journey demo
@@ -32,8 +32,8 @@
Sit down: 3: Me
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
logLevel: 3,

View File

@@ -40,7 +40,6 @@
<script type="module">
import mermaid from './mermaid.esm.mjs';
import mermaidMindmap from './mermaid-mindmap.esm.mjs';
const ALLOWED_TAGS = [
'a',

View File

@@ -37,7 +37,7 @@
</pre>
<script type="module">
import mermaid from '../packages/mermaid';
import mermaid from '../packages/mermaid/src/mermaid';
mermaid.initialize({
theme: 'forest',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -159,8 +159,8 @@
An Example <- copies - test_entity2
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'neutral',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -144,8 +144,8 @@
>
<hr />
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'base',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -218,8 +218,8 @@
</pre>
<hr />
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'default',
// themeCSS: '.node rect { fill: red; }',

View File

@@ -23,8 +23,8 @@
1940 : fourth step : fifth step
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
logLevel: 1,

View File

@@ -0,0 +1,19 @@
> **Warning**
>
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
>
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md](../../../../packages/mermaid/src/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md).
# Interface: ParseOptions
[mermaidAPI](../modules/mermaidAPI.md).ParseOptions
## Properties
### suppressErrors
`Optional` **suppressErrors**: `boolean`
#### Defined in
[mermaidAPI.ts:70](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L70)

View File

@@ -0,0 +1,54 @@
> **Warning**
>
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
>
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/interfaces/mermaidAPI.RenderResult.md](../../../../packages/mermaid/src/docs/config/setup/interfaces/mermaidAPI.RenderResult.md).
# Interface: RenderResult
[mermaidAPI](../modules/mermaidAPI.md).RenderResult
## Properties
### bindFunctions
`Optional` **bindFunctions**: (`element`: `Element`) => `void`
#### Type declaration
▸ (`element`): `void`
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.
```js
const { svg, bindFunctions } = mermaidAPI.render('id1', 'graph TD;A-->B');
div.innerHTML = svg;
bindFunctions?.(div); // To call bindFunctions only if it's present.
```
##### Parameters
| Name | Type |
| :-------- | :-------- |
| `element` | `Element` |
##### Returns
`void`
#### Defined in
[mermaidAPI.ts:91](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L91)
---
### svg
**svg**: `string`
The svg code for the rendered graph.
#### Defined in
[mermaidAPI.ts:81](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L81)

View File

@@ -6,6 +6,11 @@
# Module: mermaidAPI
## Interfaces
- [ParseOptions](../interfaces/mermaidAPI.ParseOptions.md)
- [RenderResult](../interfaces/mermaidAPI.RenderResult.md)
## References
### default
@@ -26,7 +31,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
### mermaidAPI
`Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `MermaidConfig` = configApi.getConfig; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseError?`: `ParseErrorFunction`) => `boolean` ; `parseAsync`: (`text`: `string`, `parseError?`: `ParseErrorFunction`) => `Promise`<`boolean`> ; `parseDirective`: (`p`: `any`, `statement`: `string`, `context`: `string`, `type`: `string`) => `void` ; `render`: (`id`: `string`, `text`: `string`, `cb?`: (`svgCode`: `string`, `bindFunctions?`: (`element`: `Element`) => `void`) => `void`, `svgContainingElement?`: `Element`) => `string` ; `renderAsync`: (`id`: `string`, `text`: `string`, `cb?`: (`svgCode`: `string`, `bindFunctions?`: (`element`: `Element`) => `void`) => `void`, `svgContainingElement?`: `Element`) => `Promise`<`string`> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }>
`Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `MermaidConfig` = configApi.getConfig; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<`boolean` | `void`> ; `parseDirective`: (`p`: `any`, `statement`: `string`, `context`: `string`, `type`: `string`) => `void` ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }>
## mermaidAPI configuration defaults
@@ -90,7 +95,7 @@ mermaid.initialize(config);
#### Defined in
[mermaidAPI.ts:887](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L887)
[mermaidAPI.ts:662](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L662)
## Functions
@@ -121,7 +126,7 @@ Return the last node appended
#### Defined in
[mermaidAPI.ts:288](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L288)
[mermaidAPI.ts:308](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L308)
---
@@ -147,7 +152,7 @@ the cleaned up svgCode
#### Defined in
[mermaidAPI.ts:239](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L239)
[mermaidAPI.ts:259](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L259)
---
@@ -173,7 +178,7 @@ the string with all the user styles
#### Defined in
[mermaidAPI.ts:168](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L168)
[mermaidAPI.ts:188](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L188)
---
@@ -196,7 +201,7 @@ the string with all the user styles
#### Defined in
[mermaidAPI.ts:216](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L216)
[mermaidAPI.ts:236](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L236)
---
@@ -223,7 +228,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
#### Defined in
[mermaidAPI.ts:152](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L152)
[mermaidAPI.ts:172](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L172)
---
@@ -243,7 +248,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
#### Defined in
[mermaidAPI.ts:132](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L132)
[mermaidAPI.ts:152](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L152)
---
@@ -263,7 +268,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
#### Defined in
[mermaidAPI.ts:103](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L103)
[mermaidAPI.ts:123](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L123)
---
@@ -289,7 +294,7 @@ Put the svgCode into an iFrame. Return the iFrame code
#### Defined in
[mermaidAPI.ts:267](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L267)
[mermaidAPI.ts:287](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L287)
---
@@ -314,4 +319,4 @@ Remove any existing elements from the given document
#### Defined in
[mermaidAPI.ts:338](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L338)
[mermaidAPI.ts:358](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L358)

View File

@@ -20,21 +20,24 @@ Please note that you can switch versions through the dropdown box at the top rig
For the majority of users, Using the [Live Editor](https://mermaid.live/) would be sufficient, however you may also opt to deploy mermaid as a dependency or using the [Mermaid API](./setup/README.md).
We have compiled some Video [Tutorials](./Tutorials.md) on how to use the mermaid Live Editor.
We have compiled some Video [Tutorials](./Tutorials.md) on how to use the Mermaid Live Editor.
### Installing and Hosting Mermaid on a Webpage
**Using the npm package:**
1. You will need to install `node v16`, which would have npm.
Requirements:
2. Download `yarn` using npm.
- Node >= 16
3. Enter the following command: `yarn add mermaid`.
4. At this point, you can add mermaid as a dev dependency using this command: `yarn add --dev mermaid`.
5. Alternatively, you can also deploy mermaid using the script tag in an HTML file with mermaid diagram descriptions as is shown in the example below.
```bash
# NPM
npm install mermaid
# Yarn
yarn add mermaid
# PNPM
pnpm add mermaid
```
**Hosting mermaid on a web page:**
@@ -42,7 +45,9 @@ We have compiled some Video [Tutorials](./Tutorials.md) on how to use the mermai
The easiest way to integrate mermaid on a web page requires two elements:
- A graph definition, inside `<pre>` tags labeled `class=mermaid`. Example:
- A graph definition, inside `<pre>` tags labeled `class=mermaid`.
Example:
```html
<pre class="mermaid">
@@ -53,14 +58,13 @@ The easiest way to integrate mermaid on a web page requires two elements:
</pre>
```
- Inclusion of the mermaid address in the html page body using a `script` tag as an ESM import, and the `mermaidAPI` call.
- The mermaid js script. Added using a `script` tag as an ESM import.
Example:
```html
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
</script>
```
@@ -71,9 +75,6 @@ Example:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<pre class="mermaid">
graph LR
@@ -82,8 +83,7 @@ Example:
B-->D(fa:fa-spinner);
</pre>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
</script>
</body>
</html>
@@ -95,11 +95,12 @@ An id attribute is also added to mermaid tags without one.
Mermaid can load multiple diagrams, in the same page.
> Try it out, save this code as HTML and load it using any browser.(Except Internet Explorer, please don't use Internet Explorer.)
> Try it out, save this code as HTML and load it using any browser.
> (Except Internet Explorer, please don't use Internet Explorer.)
## Enabling Click Event and Tags in Nodes
A `securityLevel` configuration has to first be cleared, `securityLevel` sets the level of trust for the parsed diagrams and limits click functionality. This was introduce in version 8.2 as a security improvement, aimed at preventing malicious use.
A `securityLevel` configuration has to first be cleared. `securityLevel` sets the level of trust for the parsed diagrams and limits click functionality. This was introduce in version 8.2 as a security improvement, aimed at preventing malicious use.
**It is the site owner's responsibility to discriminate between trustworthy and untrustworthy user-bases and we encourage the use of discretion.**
@@ -107,7 +108,7 @@ A `securityLevel` configuration has to first be cleared, `securityLevel` sets th
| Parameter | Description | Type | Required | Values |
| ------------- | --------------------------------- | ------ | -------- | ------------------------------------------ |
| securityLevel | Level of trust for parsed diagram | String | Required | 'sandbox', 'strict', 'loose', 'antiscript' |
| securityLevel | Level of trust for parsed diagram | String | Optional | 'sandbox', 'strict', 'loose', 'antiscript' |
Values:
@@ -122,26 +123,17 @@ Values:
**If you are taking responsibility for the diagram source security you can set the `securityLevel` to a value of your choosing . This allows clicks and tags are allowed.**
**To change `securityLevel`, you have to call `mermaidAPI.initialize`:**
**To change `securityLevel`, you have to call `mermaid.initialize`:**
```javascript
mermaidAPI.initialize({
mermaid.initialize({
securityLevel: 'loose',
});
```
### Labels out of bounds
If you use dynamically loaded fonts that are loaded through CSS, such as Google fonts, mermaid should wait for the
whole page to load (dom + assets, particularly the fonts file).
```javascript
$(document).load(function () {
mermaid.initialize();
});
```
or
If you use dynamically loaded fonts that are loaded through CSS, such as fonts, mermaid should wait for the whole page to load (dom + assets, particularly the fonts file).
```javascript
$(document).ready(function () {
@@ -154,12 +146,54 @@ Not doing so will most likely result in mermaid rendering graphs that have label
If your page has other fonts in its body those might be used instead of the mermaid font. Specifying the font in your styling is a workaround for this.
```css
div.mermaid {
pre.mermaid {
font-family: 'trebuchet ms', verdana, arial;
}
```
### Calling `mermaid.init`
### Using `mermaid.run`
mermaid.run was added in v10 and is the preferred way of handling more complex integration.
By default, `mermaid.run` will be called when the document is ready, rendering all elements with `class="mermaid"`.
You can customize that behavior by calling `await mermaid.run(<config>)`.
`mermaid.initialize({startOnLoad: false})` will prevent `mermaid.run` from being called automatically after load.
Render all elements with querySelector ".someOtherClass"
```js
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
querySelector: '.someOtherClass',
});
```
Render all elements passed as an array
```js
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
nodes: [document.getElementById('someId'), document.getElementById('anotherId')],
});
await mermaid.run({
nodes: document.querySelectorAll('.yetAnotherClass'),
});
```
Render all `.mermaid` elements while suppressing any error
```js
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
suppressErrors: true,
});
```
### Calling `mermaid.init` - Deprecated
> **Warning**
> mermaid.init is deprecated in v10 and will be removed in v11. Please use mermaid.run instead.
By default, `mermaid.init` will be called when the document is ready, finding all elements with
`class="mermaid"`. If you are adding content after mermaid is loaded, or otherwise need
@@ -192,25 +226,24 @@ mermaid fully supports webpack. Here is a [working demo](https://github.com/merm
## API usage
The main idea of the API is to be able to call a render function with the graph definition as a string. The render function
will render the graph and call a callback with the resulting SVG code. With this approach it is up to the site creator to
fetch the graph definition from the site (perhaps from a textarea), render it and place the graph somewhere in the site.
The main idea of the API is to be able to call a render function with the graph definition as a string. The render function will render the graph and call a callback with the resulting SVG code. With this approach it is up to the site creator to fetch the graph definition from the site (perhaps from a textarea), render it and place the graph somewhere in the site.
The example below show an outline of how this could be used. The example just logs the resulting SVG to the JavaScript console.
```html
<script type="module">
import mermaid from './mermaid.mjs';
mermaid.mermaidAPI.initialize({ startOnLoad: false });
$(async function () {
// Example of using the API var
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: false });
// Example of using the render function
const drawDiagram = async function () {
element = document.querySelector('#graphDiv');
const insertSvg = function (svgCode, bindFunctions) {
element.innerHTML = svgCode;
};
const graphDefinition = 'graph TB\na-->b';
const graph = await mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg);
});
const { svg } = await mermaid.render('graphDiv', graphDefinition);
element.innerHTML = svg;
};
await drawDiagram();
</script>
```
@@ -223,17 +256,17 @@ The example code below is an extract of what mermaid does when using the API. Th
bind events to an SVG when using the API for rendering.
```javascript
const insertSvg = function (svgCode, bindFunctions) {
element.innerHTML = svgCode;
if (typeof callback !== 'undefined') {
callback(id);
// Example of using the bindFunctions
const drawDiagram = async function () {
element = document.querySelector('#graphDiv');
const graphDefinition = 'graph TB\na-->b';
const { svg, bindFunctions } = await mermaid.render('graphDiv', graphDefinition);
element.innerHTML = svg;
// This can also be written as `bindFunctions?.(element);` using the `?` shorthand.
if (bindFunctions) {
bindFunctions(element);
}
bindFunctions(element);
};
const id = 'theGraph';
mermaidAPI.render(id, txt, insertSvg, element);
```
1. The graph is generated using the render call.
@@ -331,8 +364,8 @@ The future proof way of setting the configuration is by using the initialization
on what kind of integration you use.
```html
<script src="../dist/mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
let config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } };
mermaid.initialize(config);
</script>

View File

@@ -20,6 +20,7 @@ They also serve as proof of concept, for the variety of things that can be built
- [Gitea](https://gitea.io) (**Native support**)
- [Azure Devops](https://docs.microsoft.com/en-us/azure/devops/project/wiki/wiki-markdown-guidance?view=azure-devops#add-mermaid-diagrams-to-a-wiki-page) (**Native support**)
- [Tuleap](https://docs.tuleap.org/user-guide/writing-in-tuleap.html#graphs) (**Native support**)
- [Deepdwn](https://billiam.itch.io/deepdwn) (**Native support**)
- [Joplin](https://joplinapp.org) (**Native support**)
- [Swimm](https://swimm.io) (**Native support**)
- [Notion](https://notion.so) (**Native support**)
@@ -188,3 +189,6 @@ They also serve as proof of concept, for the variety of things that can be built
- [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server)
- [ExDoc](https://github.com/elixir-lang/ex_doc)
- [Rendering Mermaid graphs](https://github.com/elixir-lang/ex_doc#rendering-mermaid-graphs)
- [NiceGUI: Let any browser be the frontend of your Python code](https://nicegui.io)
- [ui.mermaid(...)](https://nicegui.io/reference#mermaid_diagrams)
- [ui.markdown(..., extras=\['mermaid'\])](https://nicegui.io/reference#markdown_element)

View File

@@ -249,7 +249,7 @@ To select a version:
Replace `<version>` with the desired version number.
Latest Version: <https://cdn.jsdelivr.net/npm/mermaid@9>
Latest Version: <https://cdn.jsdelivr.net/npm/mermaid@10>
## Deploying Mermaid
@@ -267,7 +267,7 @@ To Deploy Mermaid:
```html
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
```

View File

@@ -103,7 +103,7 @@ When writing the .html file, we give two instructions inside the html code to th
a. The mermaid code for the diagram we want to create.
b. The importing of mermaid library through the `mermaid.esm.js` or `mermaid.esm.min.mjs` and the `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
b. The importing of mermaid library through the `mermaid.esm.mjs` or `mermaid.esm.min.mjs` and the `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
**a. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
@@ -128,14 +128,14 @@ b. The importing of mermaid library through the `mermaid.esm.js` or `mermaid.esm
```html
<body>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
</body>
```
**Notes**:
Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can place `mermaid.initialize()` inside `mermaid.min.js` for brevity. However, doing the opposite lets you control when it starts looking for `<div>`tags inside the web page with `mermaid.initialize()`. This is useful when you think that not all `<div>` tags may have loaded on the execution of `mermaid.min.js` file.
Rendering in Mermaid is initialized by `mermaid.initialize()` call. However, doing the opposite lets you control when it starts looking for `<pre>` tags inside the web page with `mermaid.initialize()`. This is useful when you think that not all `<pre>` tags may have loaded on the execution of `mermaid.esm.min.mjs` file.
`startOnLoad` is one of the parameters that can be defined by `mermaid.initialize()`
@@ -143,10 +143,6 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
| ----------- | --------------------------------- | ------- | ----------- |
| startOnLoad | Toggle for Rendering upon loading | Boolean | true, false |
### Adding external diagrams to mermaid
Please refer to the [Mindmap](../syntax/mindmap.md?id=integrating-with-your-librarywebsite) section for more information.
### Working Examples
**Here is a full working example of the mermaidAPI being called through the CDN:**
@@ -172,7 +168,7 @@ Please refer to the [Mindmap](../syntax/mindmap.md?id=integrating-with-your-libr
</pre>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
</body>

View File

@@ -130,6 +130,40 @@ classDiagram
Naming convention: a class name should be composed only of alphanumeric characters (including unicode), and underscores.
### Class labels
In case you need to provide a label for a class, you can use the following syntax:
```mermaid-example
classDiagram
class Animal["Animal with a label"]
class Car["Car with *! symbols"]
Animal --> Car
```
```mermaid
classDiagram
class Animal["Animal with a label"]
class Car["Car with *! symbols"]
Animal --> Car
```
You can also use backticks to escape special characters in the label:
```mermaid-example
classDiagram
class `Animal Class!`
class `Car Class`
`Animal Class!` --> `Car Class`
```
```mermaid
classDiagram
class `Animal Class!`
class `Car Class`
`Animal Class!` --> `Car Class`
```
## Defining Members of a class
UML provides mechanisms to represent class members such as attributes and methods, as well as additional information about them.
@@ -692,11 +726,11 @@ Beginner's tip—a full example using interactive links in an HTML page:
### Styling a node
It is possible to apply specific styles such as a thicker border or a different background color to individual nodes. This is done by predefining classes in css styles that can be applied from the graph definition:
It is possible to apply specific styles such as a thicker border or a different background color to individual nodes. This is done by predefining classes in css styles that can be applied from the graph definition using the `cssClass` statement or the `:::` short hand.
```html
<style>
.cssClass > rect {
.styleClass > rect {
fill: #ff0000;
stroke: #ffff00;
stroke-width: 4px;
@@ -706,29 +740,29 @@ It is possible to apply specific styles such as a thicker border or a different
Then attaching that class to a specific node:
cssClass "nodeId1" cssClass;
cssClass "nodeId1" styleClass;
It is also possible to attach a class to a list of nodes in one statement:
cssClass "nodeId1,nodeId2" cssClass;
cssClass "nodeId1,nodeId2" styleClass;
A shorter form of adding a class is to attach the classname to the node using the `:::` operator:
```mermaid-example
classDiagram
class Animal:::cssClass
class Animal:::styleClass
```
```mermaid
classDiagram
class Animal:::cssClass
class Animal:::styleClass
```
Or:
```mermaid-example
classDiagram
class Animal:::cssClass {
class Animal:::styleClass {
-int sizeInFeet
-canEat()
}
@@ -736,7 +770,7 @@ classDiagram
```mermaid
classDiagram
class Animal:::cssClass {
class Animal:::styleClass {
-int sizeInFeet
-canEat()
}

View File

@@ -391,6 +391,20 @@ flowchart LR
A == text ==> B
```
### An invisible link
This can be a useful tool in some instances where you want to alter the default positioning of a node.
```mermaid-example
flowchart LR
A ~~~ B
```
```mermaid
flowchart LR
A ~~~ B
```
### Chaining of links
It is possible declare many links in the same line as per below:

Some files were not shown because too many files have changed in this diff Show More