-
Notifications
You must be signed in to change notification settings - Fork 352
Closed
Description
Opening Task.html documentation and then navigating to the Supervisor.html docs via the sidebar does not trigger mermaid and therefore the mermaid graph is not visible - refreshing the page will trigger mermaid and render the graph:
To display the graph when navigating from the sidebar mermaid would have to be triggered. Example code that achieves this:
<script>
function mermaidLoaded() {
mermaid.initialize({
startOnLoad: false,
theme: document.body.className.includes("dark") ? "dark" : "default"
});
const runMermaid = () => {
let id = 0;
for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
const preEl = codeEl.parentElement;
const graphDefinition = codeEl.textContent;
const graphEl = document.createElement("div");
const graphId = "mermaid-graph-" + id++;
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
graphEl.innerHTML = svg;
bindFunctions?.(graphEl);
preEl.insertAdjacentElement("afterend", graphEl);
preEl.remove();
});
}
}
const observer = new MutationObserver(runMermaid);
// re run mermaid each time we navigate via sidebar
observer.observe(document.querySelector("#sidebar"), {
attributes: true,
subtree: true,
childList: true,
});
runMermaid();
}
</script>
<script async src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" onload="mermaidLoaded();"></script>Metadata
Metadata
Assignees
Labels
No labels