Skip to content

Commit bddebd8

Browse files
authored
Support ZenUML diagrams in Mermaid (#903)
1 parent a3b4646 commit bddebd8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/honest-spiders-feel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-mermaid': minor
3+
---
4+
5+
Support ZenUML diagrams in Mermaid

integrations/mermaid/src/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export default createIntegration({
7676
<body>
7777
<script type="module">
7878
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
79+
import zenuml from 'https://cdn.jsdelivr.net/npm/@mermaid-js/[email protected]/dist/mermaid-zenuml.esm.min.mjs';
80+
await mermaid.registerExternalDiagrams([zenuml]);
7981
mermaid.initialize({ startOnLoad: false });
8082
8183
const queue = [];
@@ -113,7 +115,9 @@ export default createIntegration({
113115
114116
document.getElementById('content').innerHTML = svgGraph;
115117
const svg = document.getElementById('content').querySelector('svg');
116-
const size = { width: svg.viewBox.baseVal.width, height: svg.viewBox.baseVal.height };
118+
const size = svg.viewBox.baseVal.width && svg.viewBox.baseVal.height
119+
? { width: svg.viewBox.baseVal.width, height: svg.viewBox.baseVal.height }
120+
: { width: parseInt(svg.style.width, 10), height: parseInt(svg.style.height, 10) };
117121
118122
console.log('mermaid: resize', size);
119123
sendAction({

0 commit comments

Comments
 (0)