Skip to content

Mermaid ELK layouts not activated #11351

@Feez2403

Description

@Feez2403

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Mermaid uses ELK for alternative layouts, but entering the configuration for elk layouts in docusaurus mermaid blocks does not change the layout.

Reproducible demo

No response

Steps to reproduce

  1. Clone the docusaurus repo
  2. Create 2 mermaid diagrams, for example the following ER Diagrams. One has the config block with elk layout.
```mermaid
erDiagram

  COMPANY ||--o{ DEPARTMENT : has
  COMPANY ||--o{ PROJECT : undertakes
  COMPANY ||--o{ LOCATION : operates_in
  COMPANY ||--o{ CLIENT : serves

  DEPARTMENT ||--o{ EMPLOYEE : employs
  DEPARTMENT ||--o{ PROJECT : manages
  DEPARTMENT ||--o{ BUDGET : allocated

  EMPLOYEE }o--o{ PROJECT : works_on
  EMPLOYEE ||--|| ADDRESS : lives_at
  EMPLOYEE }o--o{ SKILL : has
  EMPLOYEE ||--o{ DEPENDENT : supports

  PROJECT ||--o{ CLIENT : for
  PROJECT ||--o{ TASK : contains
```
```mermaid
---
config:
  layout: elk
---
erDiagram
  COMPANY ||--o{ DEPARTMENT : has
  COMPANY ||--o{ PROJECT : undertakes
  COMPANY ||--o{ LOCATION : operates_in
  COMPANY ||--o{ CLIENT : serves

  DEPARTMENT ||--o{ EMPLOYEE : employs
  DEPARTMENT ||--o{ PROJECT : manages
  DEPARTMENT ||--o{ BUDGET : allocated

  EMPLOYEE }o--o{ PROJECT : works_on
  EMPLOYEE ||--|| ADDRESS : lives_at
  EMPLOYEE }o--o{ SKILL : has
  EMPLOYEE ||--o{ DEPENDENT : supports

  PROJECT ||--o{ CLIENT : for
  PROJECT ||--o{ TASK : contains
```
  1. Start the server (yarn install & yarn start)
  2. The diagrams are the same, ELK layout engine is ignored.

Expected behavior

On the official mermaid.live editor, we can see the expected behavior:

  • Without ELK (using the default Dagre layout engine)
Image
  • With ELK layout engine
Image

Actual behavior

On Daucusaurus, the diagrams are the same. ELK layout config is ignored.

Image

There is a package that web pages frameworks (e.g. Docusaurus) using mermaid should use, as stated in the official Mermaid github page.
Docusaurus is actually missing this import. Therefore, Memaid does not take ELK layout config into account.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions