-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
feat(mermaid): support elk layout #11357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mermaid): support elk layout #11357
Conversation
…luding @mermaid-js/layout-elk dependency
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
| "@docusaurus/types": "3.8.1", | ||
| "@docusaurus/utils-validation": "3.8.1", | ||
| "mermaid": ">=11.6.0", | ||
| "@mermaid-js/layout-elk": "^0.1.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this dependency optional?
This package is large, and there are also license concerns: mermaid-js/mermaid#5654
We don't want existing Docusaurus sites under MIT license to implicitly change their license while upgrading to the next minor version
| import type {ThemeConfig} from '@docusaurus/theme-mermaid'; | ||
|
|
||
| // mermaid does not support ELK layouts in external websites (e.g. Docusaurus) by default, as explained in https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid-layout-elk | ||
| mermaid.registerLayoutLoaders(elkLayouts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could do something like:
try {
mermaid.registerLayoutLoaders(require("@mermaid-js/layout-elk"));
} catch (e) {
// Ignore
}|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Pre-flight checklist
Motivation
When using mermaid, we can change the layout of the diagram using ELK (Eclipse Layout Kernel). This layout becomes handy when working with large or intricate diagrams.
However, for rendering using ELK on web pages, we need to import an additional package, as stated in the official Mermaid github documentation.
Test Plan
We create additional diagrams on dogfood (/tests/pages/diagrams)
Diagram using Dagre (default Mermaid layout manager)

Diagram using ELK

The ELK layout is applied successfully.
Test links
We added diagrams to the dogfooding page :
website_dogfooding_pages tests\diagrams.mdx
access on : https://deploy-preview-11357--docusaurus-2.netlify.app/tests/pages/diagrams#elk-er-diagram-layout
Related issues/PRs
Mermaid ELK layouts not activated #11351