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.
@@ -7942,18 +7942,9 @@ async function render_pumlText(text2, div) {
7942
7942
  return div;
7943
7943
  }
7944
7944
  let mermaid = null;
7945
- (async () => {
7946
- if (ABCSetting.env !== "obsidian" || true) return;
7947
- const { default: mermaid_ } = await import("mermaid");
7948
- const { default: mindmap } = await import("@mermaid-js/mermaid-mindmap");
7949
- mermaid = mermaid_;
7950
- mermaid.registerExternalDiagrams([mindmap]);
7951
- const isDarkTheme = document.body.classList.contains("theme-dark");
7952
- const theme = isDarkTheme ? "dark" : "light";
7953
- mermaid.initialize({
7954
- theme
7955
- });
7956
- })();
7945
+ function getID(length = 16) {
7946
+ return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36);
7947
+ }
7957
7948
  ABConvert.factory({
7958
7949
  id: "title2mindmap",
7959
7950
  name: "标题到脑图",
@@ -8124,7 +8115,9 @@ async function data2mindmap(list_itemInfo, div) {
8124
8115
  }
8125
8116
  async function render_mermaidText(mermaidText, div) {
8126
8117
  if (ABCSetting.env == "obsidian") {
8127
- console.error("缺少 mermaid 环境");
8118
+ await init_mermaid();
8119
+ const { svg } = await mermaid?.render("ab-mermaid-" + getID(), mermaidText);
8120
+ div.innerHTML = svg;
8128
8121
  } else if (ABCSetting.env == "obsidian-min") {
8129
8122
  ABConvertManager.getInstance().m_renderMarkdownFn("```mermaid\n" + mermaidText + "\n```", div);
8130
8123
  } else {
@@ -8133,6 +8126,19 @@ async function render_mermaidText(mermaidText, div) {
8133
8126
  }
8134
8127
  return div;
8135
8128
  }
8129
+ async function init_mermaid() {
8130
+ if (mermaid != null) return;
8131
+ if (ABCSetting.env !== "obsidian" || true) return;
8132
+ const { default: mermaid_ } = await import("mermaid");
8133
+ const { default: mindmap } = await import("@mermaid-js/mermaid-mindmap");
8134
+ mermaid = mermaid_;
8135
+ mermaid.registerExternalDiagrams([mindmap]);
8136
+ const isDarkTheme = document.body.classList.contains("theme-dark");
8137
+ const theme = isDarkTheme ? "dark" : "light";
8138
+ mermaid.initialize({
8139
+ theme
8140
+ });
8141
+ }
8136
8142
  function abConvertEvent(d, isCycle = false) {
8137
8143
  if (d.querySelector(".ab-super-width")) {
8138
8144
  const els_note = d.querySelectorAll(".ab-note");