mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
18 lines
505 B
TypeScript
18 lines
505 B
TypeScript
|
|
import mermaid from "mermaid";
|
||
|
|
|
||
|
|
export default function setupMermaid() {
|
||
|
|
for (const codeBlock of document.querySelectorAll("#content pre code.language-mermaid")) {
|
||
|
|
const parentPre = codeBlock.parentElement;
|
||
|
|
if (!parentPre) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
const mermaidDiv = document.createElement("div");
|
||
|
|
mermaidDiv.classList.add("mermaid");
|
||
|
|
mermaidDiv.innerHTML = codeBlock.innerHTML;
|
||
|
|
parentPre.replaceWith(mermaidDiv);
|
||
|
|
}
|
||
|
|
|
||
|
|
mermaid.init();
|
||
|
|
}
|