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 }" }}
{{- end }}
<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 } ) );
}
</script>

View file

@ -104,7 +104,7 @@ function initMermaid() {
$(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.contentLoaded();
$(".mermaid svg").svgPanZoom({})