markdown-it-any-block 3.2.10-beta3 → 3.2.10-beta4

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.
@@ -7966,18 +7966,9 @@ async function render_pumlText(text2, div) {
7966
7966
  return div;
7967
7967
  }
7968
7968
  let mermaid = null;
7969
- (async () => {
7970
- if (ABCSetting.env !== "obsidian" || true) return;
7971
- const { default: mermaid_ } = await import("mermaid");
7972
- const { default: mindmap } = await import("@mermaid-js/mermaid-mindmap");
7973
- mermaid = mermaid_;
7974
- mermaid.registerExternalDiagrams([mindmap]);
7975
- const isDarkTheme = document.body.classList.contains("theme-dark");
7976
- const theme = isDarkTheme ? "dark" : "light";
7977
- mermaid.initialize({
7978
- theme
7979
- });
7980
- })();
7969
+ function getID(length = 16) {
7970
+ return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36);
7971
+ }
7981
7972
  ABConvert.factory({
7982
7973
  id: "title2mindmap",
7983
7974
  name: "标题到脑图",
@@ -8148,7 +8139,9 @@ async function data2mindmap(list_itemInfo, div) {
8148
8139
  }
8149
8140
  async function render_mermaidText(mermaidText, div) {
8150
8141
  if (ABCSetting.env == "obsidian") {
8151
- console.error("缺少 mermaid 环境");
8142
+ await init_mermaid();
8143
+ const { svg } = await mermaid?.render("ab-mermaid-" + getID(), mermaidText);
8144
+ div.innerHTML = svg;
8152
8145
  } else if (ABCSetting.env == "obsidian-min") {
8153
8146
  ABConvertManager.getInstance().m_renderMarkdownFn("```mermaid\n" + mermaidText + "\n```", div);
8154
8147
  } else {
@@ -8157,6 +8150,19 @@ async function render_mermaidText(mermaidText, div) {
8157
8150
  }
8158
8151
  return div;
8159
8152
  }
8153
+ async function init_mermaid() {
8154
+ if (mermaid != null) return;
8155
+ if (ABCSetting.env !== "obsidian" || true) return;
8156
+ const { default: mermaid_ } = await import("mermaid");
8157
+ const { default: mindmap } = await import("@mermaid-js/mermaid-mindmap");
8158
+ mermaid = mermaid_;
8159
+ mermaid.registerExternalDiagrams([mindmap]);
8160
+ const isDarkTheme = document.body.classList.contains("theme-dark");
8161
+ const theme = isDarkTheme ? "dark" : "light";
8162
+ mermaid.initialize({
8163
+ theme
8164
+ });
8165
+ }
8160
8166
  function abConvertEvent(d, isCycle = false) {
8161
8167
  if (d.querySelector(".ab-super-width")) {
8162
8168
  const els_note = d.querySelectorAll(".ab-note");