feat(mermaid): support elk layout#11357
Merged
slorber merged 7 commits intofacebook:mainfrom Aug 24, 2025
Merged
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
|
slorber
requested changes
Aug 1, 2025
| "@docusaurus/types": "3.8.1", | ||
| "@docusaurus/utils-validation": "3.8.1", | ||
| "mermaid": ">=11.6.0", | ||
| "@mermaid-js/layout-elk": "^0.1.8", |
Collaborator
There was a problem hiding this comment.
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
slorber
reviewed
Aug 1, 2025
| 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); |
Collaborator
There was a problem hiding this comment.
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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