This commit is contained in:
Mateusz Gruszczyński committed 2026-10-29 13:07:22 +01:00
1 parent b15a6c54ce
commit d36a4b2451
22 files changed
+926 -114

No files matched your search

+3
View File
@@ -37,6 +37,7 @@ async function renderMermaid() {
const renderVersion = ++mermaidRenderVersion;
const nodes = [...content.querySelectorAll(".mermaid")];
if (!nodes.length) return;
content.querySelectorAll(".mermaid-error").forEach(error => error.remove());
try {
nodes.forEach(node => {
if (!node.dataset.mermaidSource) node.dataset.mermaidSource = node.textContent || "";
@@ -44,10 +45,12 @@ async function renderMermaid() {
const mermaid = await loadMermaid();
mermaid.initialize({ startOnLoad: false, theme: getTheme() === "dark" ? "dark" : "default", securityLevel: "strict" });
await mermaid.run({ nodes });
if (renderVersion === mermaidRenderVersion) content.querySelectorAll(".mermaid-error").forEach(error => error.remove());
} catch {
if (renderVersion !== mermaidRenderVersion) return;
nodes.forEach(node => {
if (!node.isConnected || !content.contains(node) || !node.parentNode) return;
if (node.previousElementSibling?.classList.contains("mermaid-error")) return;
const message = document.createElement("p");
message.className = "error mermaid-error";
message.textContent = t("public.mermaidFailed", {}, "Failed to load Mermaid.");