From d023a1142b99ac01f15278abc18625680bab4a71 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 28 Aug 2024 17:43:37 +0530 Subject: [PATCH] feat: Add layout-elk --- package.json | 1 + src/lib/util/mermaid.ts | 6 ++++-- yarn.lock | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 135c1fa23..15061e843 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "vitest-dom": "^0.1.1" }, "dependencies": { + "@mermaid-js/layout-elk": "^0.1.2", "@mermaid-js/mermaid-zenuml": "^0.2.0", "daisyui": "2.52.0", "dayjs": "^1.11.7", diff --git a/src/lib/util/mermaid.ts b/src/lib/util/mermaid.ts index 728325e56..c4a5c6c5f 100644 --- a/src/lib/util/mermaid.ts +++ b/src/lib/util/mermaid.ts @@ -1,7 +1,9 @@ -import mermaid from 'mermaid'; -import type { MermaidConfig, RenderResult } from 'mermaid'; +import elkLayouts from '@mermaid-js/layout-elk'; import zenuml from '@mermaid-js/mermaid-zenuml'; +import type { MermaidConfig, RenderResult } from 'mermaid'; +import mermaid from 'mermaid'; +mermaid.registerLayoutLoaders(elkLayouts); const init = mermaid.registerExternalDiagrams([zenuml]); export const render = async ( diff --git a/yarn.lock b/yarn.lock index 4fd313924..211653e32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -462,6 +462,14 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@mermaid-js/layout-elk@^0.1.2": + version "0.1.2" + resolved "https://registry.yarnpkg.com/@mermaid-js/layout-elk/-/layout-elk-0.1.2.tgz#0255dfcf3c88cc84e2bead48d06b36b7ea0a0058" + integrity sha512-a5WbVHAXv+lMAeccex3zPwmJYmnuH8z7cdJkuunwzdhvmFKYwGPx7ggr2gIIxUR2lMMLALiEorwFx8/OAkrdUQ== + dependencies: + d3 "^7.9.0" + elkjs "^0.9.3" + "@mermaid-js/mermaid-zenuml@^0.2.0": version "0.2.0" resolved "https://registry.yarnpkg.com/@mermaid-js/mermaid-zenuml/-/mermaid-zenuml-0.2.0.tgz#6a418409804e25039d2a5c3ec7df0679cf53ed30" @@ -2753,6 +2761,11 @@ electron-to-chromium@^1.4.668, electron-to-chromium@^1.5.4: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.5.tgz#03bfdf422bdd2c05ee2657efedde21264a1a566b" integrity sha512-QR7/A7ZkMS8tZuoftC/jfqNkZLQO779SSW3YuZHP4eXpj3EffGLFcB/Xu9AAZQzLccTiCV+EmUo3ha4mQ9wnlA== +elkjs@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/elkjs/-/elkjs-0.9.3.tgz#16711f8ceb09f1b12b99e971b138a8384a529161" + integrity sha512-f/ZeWvW/BCXbhGEf1Ujp29EASo/lk1FDnETgNKwJrsVvGZhUWCZyg3xLJjAsxfOmt8KjswHmI5EwCQcPMpOYhQ== + emoji-regex@^10.3.0: version "10.3.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-10.3.0.tgz#76998b9268409eb3dae3de989254d456e70cfe23"