hyperbook 0.47.1 → 0.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,19 @@
1
1
  hyperbook.mermaid = (function () {
2
2
  const elementCode = ".directive-mermaid";
3
3
 
4
- const loadMermaid = function (theme) {
5
- window.mermaid.initialize({ theme });
6
- window.mermaid.init({ theme }, document.querySelectorAll(elementCode));
4
+ const loadMermaid = async function (theme) {
5
+ window.mermaid.initialize({ theme, startOnLoad: false });
6
+ let i = 0;
7
+ for (const el of document.querySelectorAll(elementCode)) {
8
+ if (el.getAttribute("data-processed")) return;
9
+
10
+ el.setAttribute("data-processed", true);
11
+ let id = `graph-` + Date.now() + i++;
12
+
13
+ mermaid.render(id, el.innerText).then(({ svg }) => {
14
+ el.innerHTML = svg;
15
+ });
16
+ }
7
17
  };
8
18
 
9
19
  const resetProcessed = function () {