mirror of
https://github.com/imfing/hextra.git
synced 2025-07-14 16:11:46 -04:00
Compare commits
1 Commits
48d82dffbd
...
aa60cf3580
Author | SHA1 | Date | |
---|---|---|---|
aa60cf3580 |
@ -37,32 +37,9 @@
|
|||||||
{{- $mermaidJS := resources.Get "lib/mermaid/mermaid.min.js" | fingerprint -}}
|
{{- $mermaidJS := resources.Get "lib/mermaid/mermaid.min.js" | fingerprint -}}
|
||||||
<script defer src="{{ $mermaidJS.RelPermalink }}" integrity="{{ $mermaidJS.Data.Integrity }}"></script>
|
<script defer src="{{ $mermaidJS.RelPermalink }}" integrity="{{ $mermaidJS.Data.Integrity }}"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
// Store original mermaid code for each diagram
|
|
||||||
document.querySelectorAll(".mermaid").forEach(el => {
|
|
||||||
el.dataset.original = el.innerHTML;
|
|
||||||
});
|
|
||||||
|
|
||||||
const theme = document.documentElement.classList.contains("dark") ? "dark" : "default";
|
const theme = document.documentElement.classList.contains("dark") ? "dark" : "default";
|
||||||
mermaid.initialize({ startOnLoad: true, theme: theme });
|
mermaid.initialize({ startOnLoad: true, theme: theme });
|
||||||
|
|
||||||
let timeout;
|
|
||||||
new MutationObserver(() => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = setTimeout(() => {
|
|
||||||
const theme = document.documentElement.classList.contains("dark") ? "dark" : "default";
|
|
||||||
document.querySelectorAll(".mermaid").forEach(el => {
|
|
||||||
// Reset to original content, preserving HTML
|
|
||||||
el.innerHTML = el.dataset.original;
|
|
||||||
el.removeAttribute("data-processed");
|
|
||||||
});
|
|
||||||
mermaid.initialize({ startOnLoad: true, theme: theme });
|
|
||||||
mermaid.init();
|
|
||||||
}, 150);
|
|
||||||
}).observe(document.documentElement, {
|
|
||||||
attributes: true,
|
|
||||||
attributeFilter: ["class"]
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
Reference in New Issue
Block a user