Skip to content

Commit

Permalink
[Fix] mermaid is not defined (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
bumbummen99 authored Jun 22, 2024
1 parent 062bda2 commit 8611bf3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public static function html(ClassDiagram|ERDiagram|Graph|Timeline $graph, array
' <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>',
'<script type="module">',
" import mermaid from '{$scriptUrl}';",
' window.mermaid = mermaid;',
" document.dispatchEvent(new Event('MermaidLoaded'));",
'</script>',
'</head>',
'<body>',
Expand All @@ -92,13 +94,15 @@ public static function html(ClassDiagram|ERDiagram|Graph|Timeline $graph, array
$showZoom ?
"<input type=\"button\" class=\"btn btn-primary\" id=\"zoom\" value=\"Zoom In\">
<script>
mermaid.initialize({$mermaidParams});
$(function () {
document.addEventListener('MermaidLoaded', function () {
mermaid.initialize({$mermaidParams});
}, {once: true});
$(function () {
$('#zoom').click(() => {
$('.mermaid').removeAttr('data-processed');
$('.mermaid').width($('.mermaid svg').css('max-width'));
});
});
});
</script>"
: '',
'<script>
Expand Down

0 comments on commit 8611bf3

Please sign in to comment.