mermaid: assert that window.mermaid is actually mermaid #136

This commit is contained in:
Sören Weber 2021-11-03 21:42:38 +01:00
parent 139c587757
commit f3c067bf9b
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 2 additions and 2 deletions

View file

@ -42,7 +42,7 @@
{{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }} {{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }}
{{- end }} {{- end }}
<script> <script>
if (typeof mermaid != 'undefined') { if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') {
mermaid.mermaidAPI.initialize( Object.assign( { "securityLevel": "antiscript" }, JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}), { startOnLoad: false } ) ); mermaid.mermaidAPI.initialize( Object.assign( { "securityLevel": "antiscript" }, JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}), { startOnLoad: false } ) );
} }
</script> </script>

View file

@ -104,7 +104,7 @@ function initMermaid() {
$(element).parent().replaceWith('<div class="mermaid" align="center">' + content + '</div>'); $(element).parent().replaceWith('<div class="mermaid" align="center">' + content + '</div>');
}); });
if (typeof mermaid != 'undefined') { if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') {
mermaid.mermaidAPI.initialize( Object.assign( {}, mermaid.mermaidAPI.getSiteConfig(), { startOnLoad: true } ) ); mermaid.mermaidAPI.initialize( Object.assign( {}, mermaid.mermaidAPI.getSiteConfig(), { startOnLoad: true } ) );
mermaid.contentLoaded(); mermaid.contentLoaded();
$(".mermaid svg").svgPanZoom({}) $(".mermaid svg").svgPanZoom({})