mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.48k stars 234 forks source link

Add support for `lazyLoadedDiagrams` (mermaid v9.2.0) #420

Closed aloisklink closed 1 year ago

aloisklink commented 2 years ago

:bookmark_tabs: Summary

Mermaid v9.2.0 added support for custom diagrams using lazyLoadedDiagrams, such as the new @mermaid-js/mermaid-mindmap plugin diagram.

This PR bumps the minimum required version of mermaid to v9.2.0, adds support for lazyLoadedDiagrams (needed to switch the Mermaid rendering code to async) and adds some test cases/docs.

Resolves #406

:straight_ruler: Design Decisions

mermaid-mindmap is opt-in (disabled by default), since I couldn't get it to work locally, due to puppeteer CORS issues.

Instead, currently it only works when hosted from a CDN like https://www.jsdelivr.com/, so it requires internet connection (and there are some GDPR issues with enabling it by default, since jsdeliver has a privacy policy).

In order to get mermaid-mindmap working locally/offline, I think we need https://github.com/mermaid-js/mermaid/pull/3710 to be merged first, then we can bundle it together into a single index.html file.

Also, to make adding mermaid-mindmap test cases easier, I've moved all of the test cases into a test/__fixtures__/... folder.

:clipboard: Tasks

Make sure you

MindaugasLaganeckas commented 1 year ago

Thank you for your help @aloisklink ! And excellent work!! Approved!

aloisklink commented 1 year ago

I'm closing this, it sounds like lazyLoadedDiagrams will be removed in Mermaid v9.2.2, see https://github.com/mermaid-js/mermaid/pull/3774

I might cherry-pick some commits from this branch and make another PR once the API is locked-down a bit more.