md-editor-v3 4.9.0 → 4.10.0-beta.0

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,304 +1,308 @@
1
- import { inject as P, onMounted as S, watch as C, toRef as Y, nextTick as O, shallowRef as R, ref as U, computed as H, defineComponent as ee, createVNode as A, Fragment as de, reactive as te, provide as F, onBeforeUnmount as me } from "vue";
2
- import { e as I, p, m as fe, k as j, f as G, h as pe, s as D, a as he, i as ge, g as V, j as z, l as ye, b as ve, d as be } from "./config.mjs";
3
- import { u as we, a as ke, b as g, P as $e, C as W, B as M, O as ne, E as Ce, U as Ie, c as oe, d as K, F as q, e as Z, H as J, f as X, R as re, h as Se, T as Ee } from "./index4.mjs";
1
+ import { inject as P, onMounted as S, watch as C, toRef as Y, nextTick as O, shallowRef as R, ref as U, computed as H, defineComponent as ee, createVNode as x, Fragment as de, reactive as te, provide as F, onBeforeUnmount as me } from "vue";
2
+ import { e as I, p as h, m as fe, k as j, f as G, h as pe, s as D, a as he, i as ge, g as V, j as z, l as ye, b as ve, d as be } from "./config.mjs";
3
+ import { u as we, a as ke, b as v, P as $e, C as W, B as A, O as ne, E as Ce, U as Ie, c as oe, d as K, F as q, e as Z, H as J, f as X, R as re, h as Se, T as Ee } from "./index4.mjs";
4
4
  import { a as _, u as Pe } from "./dom.mjs";
5
5
  import Te from "medium-zoom";
6
6
  import { debounce as ae } from "@vavt/util";
7
7
  import _e from "copy-to-clipboard";
8
8
  import Fe from "markdown-it";
9
9
  import He from "markdown-it-image-figures";
10
- import xe from "markdown-it-task-lists";
11
- import Ae from "lru-cache";
12
- const Me = (e, a) => {
10
+ import Me from "markdown-it-task-lists";
11
+ import xe from "lru-cache";
12
+ const Ae = (e, r) => {
13
13
  const l = P("editorId"), { noImgZoomIn: t } = e, n = ae(() => {
14
- const r = document.querySelectorAll(`#${l}-preview img`);
15
- r.length !== 0 && Te(r, {
14
+ const o = document.querySelectorAll(`#${l}-preview img`);
15
+ o.length !== 0 && Te(o, {
16
16
  background: "#00000073"
17
17
  });
18
18
  });
19
19
  S(() => {
20
20
  !t && n();
21
- }), C([a, Y(e.setting, "preview")], () => {
21
+ }), C([r, Y(e.setting, "preview")], () => {
22
22
  !t && n();
23
23
  });
24
- }, Re = Me, Be = (e, a) => {
25
- if (typeof a[e] == "string")
26
- return a[e];
27
- const l = `<i class="${p}-iconfont ${p}-icon-${e}"></i>`;
24
+ }, Re = Ae, Be = (e, r) => {
25
+ if (typeof r[e] == "string")
26
+ return r[e];
27
+ const l = `<i class="${h}-iconfont ${h}-icon-${e}"></i>`;
28
28
  switch (I.iconfontType) {
29
29
  case "svg":
30
- return `<svg class="${p}-icon" aria-hidden="true"><use xlink:href="#${p}-icon-${e}"></use></svg>`;
30
+ return `<svg class="${h}-icon" aria-hidden="true"><use xlink:href="#${h}-icon-${e}"></use></svg>`;
31
31
  default:
32
32
  return l;
33
33
  }
34
- }, Le = (e, a) => {
35
- const l = P("editorId"), t = P("usedLanguageText"), n = P("customIcon"), r = () => {
36
- document.querySelectorAll(`#${l}-preview pre`).forEach((u) => {
34
+ }, Le = (e, r) => {
35
+ const l = P("editorId"), t = P("usedLanguageText"), n = P("customIcon"), o = () => {
36
+ document.querySelectorAll(`#${l}-preview pre`).forEach((d) => {
37
37
  var b, y;
38
38
  let s = -1;
39
- (b = u.querySelector(".copy-button")) == null || b.remove();
40
- const o = ((y = t.value.copyCode) == null ? void 0 : y.text) || "复制代码", d = document.createElement("span");
41
- d.setAttribute("class", "copy-button"), d.dataset.tips = o, d.innerHTML = Be("copy", n.value), d.addEventListener("click", () => {
42
- var v, k;
39
+ (b = d.querySelector(".copy-button")) == null || b.remove();
40
+ const a = ((y = t.value.copyCode) == null ? void 0 : y.text) || "复制代码", u = document.createElement("span");
41
+ u.setAttribute("class", "copy-button"), u.dataset.tips = a, u.innerHTML = Be("copy", n.value), u.addEventListener("click", () => {
42
+ var g, w;
43
43
  clearTimeout(s);
44
- const m = u.querySelector("code").innerText, h = _e(e.formatCopiedText(m)), f = ((v = t.value.copyCode) == null ? void 0 : v.successTips) || "已复制!", w = ((k = t.value.copyCode) == null ? void 0 : k.failTips) || "已复制!";
45
- d.dataset.tips = h ? f : w, s = window.setTimeout(() => {
46
- d.dataset.tips = o;
44
+ const m = d.querySelector("code").innerText, p = _e(e.formatCopiedText(m)), f = ((g = t.value.copyCode) == null ? void 0 : g.successTips) || "已复制!", $ = ((w = t.value.copyCode) == null ? void 0 : w.failTips) || "已复制!";
45
+ u.dataset.tips = p ? f : $, s = window.setTimeout(() => {
46
+ u.dataset.tips = a;
47
47
  }, 1500);
48
- }), u.appendChild(d);
48
+ }), d.appendChild(u);
49
49
  });
50
50
  }, i = () => {
51
- O(r);
52
- }, c = (u) => {
53
- u && O(r);
51
+ O(o);
52
+ }, c = (d) => {
53
+ d && O(o);
54
54
  };
55
- C(() => a.value, i), C(() => e.setting.preview, c), C(() => e.setting.htmlPreview, c), C(() => t.value, r), S(r);
55
+ C(() => r.value, i), C(() => e.setting.preview, c), C(() => e.setting.htmlPreview, c), C(() => t.value, o), S(o);
56
56
  }, Ne = Le, Oe = (e) => {
57
- var r;
58
- const a = (r = I.editorExtensions) == null ? void 0 : r.highlight, l = a == null ? void 0 : a.instance, t = P("highlight"), n = R(l);
57
+ var o;
58
+ const r = (o = I.editorExtensions) == null ? void 0 : o.highlight, l = r == null ? void 0 : r.instance, t = P("highlight"), n = R(l);
59
59
  return S(() => {
60
60
  if (!e.noHighlight && !n.value) {
61
61
  const i = document.createElement("script");
62
62
  i.src = t.value.js, i.onload = () => {
63
63
  n.value = window.hljs;
64
- }, i.id = `${p}-hljs`, _(i, "hljs");
64
+ }, i.id = `${h}-hljs`, _(i, "hljs");
65
65
  const c = document.createElement("link");
66
- c.rel = "stylesheet", c.href = t.value.css, c.id = `${p}-hlCss`, _(c);
66
+ c.rel = "stylesheet", c.href = t.value.css, c.id = `${h}-hlCss`, _(c);
67
67
  }
68
68
  }), C(
69
69
  () => t.value.css,
70
70
  (i) => {
71
- Pe(`${p}-hlCss`, "href", i);
71
+ Pe(`${h}-hlCss`, "href", i);
72
72
  }
73
73
  ), n;
74
74
  }, Ue = Oe, je = (e) => {
75
- const a = P("theme"), { editorExtensions: l } = I, t = l == null ? void 0 : l.mermaid, n = R(t == null ? void 0 : t.instance), r = R(-1), i = new Ae({
75
+ const r = P("theme"), { editorExtensions: l, mermaidConfig: t } = I, n = l == null ? void 0 : l.mermaid, o = R(n == null ? void 0 : n.instance), i = R(-1), c = new xe({
76
76
  max: 1e3,
77
77
  // 缓存10分钟
78
78
  ttl: 6e5
79
- }), c = () => {
80
- const s = n.value;
81
- !e.noMermaid && s && (s.initialize({
82
- startOnLoad: !1,
83
- theme: a.value === "dark" ? "dark" : "default"
84
- }), r.value = r.value + 1);
79
+ }), d = () => {
80
+ const a = o.value;
81
+ !e.noMermaid && a && (a.initialize(
82
+ t({
83
+ startOnLoad: !1,
84
+ theme: r.value === "dark" ? "dark" : "default"
85
+ })
86
+ ), i.value = i.value + 1);
85
87
  };
86
88
  return C(
87
- () => a.value,
89
+ () => r.value,
88
90
  () => {
89
- i.clear(), c();
91
+ c.clear(), d();
90
92
  }
91
93
  ), S(() => {
92
- if (!e.noMermaid && !(t != null && t.instance)) {
93
- const s = (t == null ? void 0 : t.js) || fe;
94
- if (/\.mjs/.test(s))
94
+ if (!e.noMermaid && !(n != null && n.instance)) {
95
+ const a = (n == null ? void 0 : n.js) || fe;
96
+ if (/\.mjs/.test(a))
95
97
  import(
96
98
  /* @vite-ignore */
97
99
  /* webpackIgnore: true */
98
- s
99
- ).then((o) => {
100
- n.value = o.default, c();
100
+ a
101
+ ).then((u) => {
102
+ o.value = u.default, d();
101
103
  });
102
104
  else {
103
- const o = document.createElement("script");
104
- o.id = `${p}-mermaid`, o.src = s, o.onload = () => {
105
- n.value = window.mermaid, c();
106
- }, _(o, "mermaid");
105
+ const u = document.createElement("script");
106
+ u.id = `${h}-mermaid`, u.src = a, u.onload = () => {
107
+ o.value = window.mermaid, d();
108
+ }, _(u, "mermaid");
107
109
  }
108
110
  }
109
- }), { mermaidRef: n, reRenderRef: r, replaceMermaid: () => {
111
+ }), { mermaidRef: o, reRenderRef: i, replaceMermaid: () => {
110
112
  O(() => {
111
- if (!e.noMermaid && n.value) {
112
- const s = document.querySelectorAll(
113
- `div.${p}-mermaid`
114
- ), o = document.createElement("div");
115
- o.style.width = document.body.offsetWidth + "px", o.style.height = document.body.offsetHeight + "px", o.style.position = "fixed", o.style.zIndex = "-10000", o.style.top = "-10000";
116
- let d = s.length;
117
- d > 0 && document.body.appendChild(o), s.forEach(async (b) => {
118
- let y = i.get(b.innerText);
119
- if (!y) {
120
- const h = we(), f = n.value.renderAsync || n.value.render;
121
- let w = "";
113
+ if (!e.noMermaid && o.value) {
114
+ const a = document.querySelectorAll(
115
+ `div.${h}-mermaid`
116
+ ), u = document.createElement("div");
117
+ u.style.width = document.body.offsetWidth + "px", u.style.height = document.body.offsetHeight + "px", u.style.position = "fixed", u.style.zIndex = "-10000", u.style.top = "-10000";
118
+ let b = a.length;
119
+ b > 0 && document.body.appendChild(u), a.forEach(async (y) => {
120
+ let m = c.get(y.innerText);
121
+ if (!m) {
122
+ const f = we(), $ = o.value.renderAsync || o.value.render;
123
+ let g = "";
122
124
  try {
123
- w = await f(h, b.innerText, o);
125
+ g = await $(f, y.innerText, u);
124
126
  } catch {
125
127
  }
126
- y = typeof w == "string" ? w : w.svg, i.set(b.innerText, y);
128
+ m = await e.sanitizeMermaid(
129
+ typeof g == "string" ? g : g.svg
130
+ ), c.set(y.innerText, m);
127
131
  }
128
- const m = document.createElement("p");
129
- m.className = `${p}-mermaid`, m.setAttribute("data-processed", ""), m.innerHTML = y, b.dataset.line !== void 0 && (m.dataset.line = b.dataset.line), b.replaceWith(m), --d === 0 && o.remove();
132
+ const p = document.createElement("p");
133
+ p.className = `${h}-mermaid`, p.setAttribute("data-processed", ""), p.innerHTML = m, y.dataset.line !== void 0 && (p.dataset.line = y.dataset.line), y.replaceWith(p), --b === 0 && u.remove();
130
134
  });
131
135
  }
132
136
  });
133
137
  } };
134
138
  }, Ge = je, De = (e) => {
135
139
  var n;
136
- const a = (n = I.editorExtensions) == null ? void 0 : n.katex, l = a == null ? void 0 : a.instance, t = R(l);
140
+ const r = (n = I.editorExtensions) == null ? void 0 : n.katex, l = r == null ? void 0 : r.instance, t = R(l);
137
141
  return S(() => {
138
142
  if (!e.noKatex && !t.value) {
139
- const r = document.createElement("script");
140
- r.src = (a == null ? void 0 : a.js) || j.js, r.onload = () => {
143
+ const o = document.createElement("script");
144
+ o.src = (r == null ? void 0 : r.js) || j.js, o.onload = () => {
141
145
  t.value = window.katex;
142
- }, r.id = `${p}-katex`;
146
+ }, o.id = `${h}-katex`;
143
147
  const i = document.createElement("link");
144
- i.rel = "stylesheet", i.href = (a == null ? void 0 : a.css) || j.css, i.id = `${p}-katexCss`, _(r, "katex"), _(i);
148
+ i.rel = "stylesheet", i.href = (r == null ? void 0 : r.css) || j.css, i.id = `${h}-katexCss`, _(o, "katex"), _(i);
145
149
  }
146
150
  }), t;
147
- }, Ve = De, ze = (e, a) => {
151
+ }, Ve = De, ze = (e, r) => {
148
152
  const l = e.renderer.rules.fence.bind(e.renderer.rules);
149
- e.renderer.rules.fence = (t, n, r, i, c) => {
150
- const u = t[n], s = u.content.trim();
151
- if (u.info === "mermaid") {
152
- let o;
153
- return t[n].map && t[n].level === 0 && (o = t[n].map[0], t[n].attrSet("data-line", String(o))), `<div class="${p}-mermaid" ${o !== void 0 ? "data-line=" + o : ""} data-mermaid-theme=${a.themeRef.value}>${s}</div>`;
153
+ e.renderer.rules.fence = (t, n, o, i, c) => {
154
+ const d = t[n], s = d.content.trim();
155
+ if (d.info === "mermaid") {
156
+ let a;
157
+ return t[n].map && t[n].level === 0 && (a = t[n].map[0], t[n].attrSet("data-line", String(a))), `<div class="${h}-mermaid" ${a !== void 0 ? "data-line=" + a : ""} data-mermaid-theme=${r.themeRef.value}>${s}</div>`;
154
158
  }
155
- return l(t, n, r, i, c);
159
+ return l(t, n, o, i, c);
156
160
  };
157
- }, We = ze, Q = (e, a) => {
161
+ }, We = ze, Q = (e, r) => {
158
162
  let l = !0, t = !0;
159
- const n = e.posMax, r = a > 0 ? e.src.charCodeAt(a - 1) : -1, i = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
160
- return (r === 32 || r === 9 || i >= 48 && i <= 57) && (t = !1), (i === 32 || i === 9) && (l = !1), {
163
+ const n = e.posMax, o = r > 0 ? e.src.charCodeAt(r - 1) : -1, i = r + 1 <= n ? e.src.charCodeAt(r + 1) : -1;
164
+ return (o === 32 || o === 9 || i >= 48 && i <= 57) && (t = !1), (i === 32 || i === 9) && (l = !1), {
161
165
  can_open: l,
162
166
  can_close: t
163
167
  };
164
- }, Ke = (e, a) => {
165
- let l, t, n, r;
168
+ }, Ke = (e, r) => {
169
+ let l, t, n, o;
166
170
  if (e.src[e.pos] !== "$")
167
171
  return !1;
168
172
  if (n = Q(e, e.pos), !n.can_open)
169
- return a || (e.pending += "$"), e.pos += 1, !0;
173
+ return r || (e.pending += "$"), e.pos += 1, !0;
170
174
  const i = e.pos + 1;
171
175
  for (l = i; (l = e.src.indexOf("$", l)) !== -1; ) {
172
- for (r = l - 1; e.src[r] === "\\"; )
173
- r -= 1;
174
- if ((l - r) % 2 == 1)
176
+ for (o = l - 1; e.src[o] === "\\"; )
177
+ o -= 1;
178
+ if ((l - o) % 2 == 1)
175
179
  break;
176
180
  l += 1;
177
181
  }
178
- return l === -1 ? (a || (e.pending += "$"), e.pos = i, !0) : l - i === 0 ? (a || (e.pending += "$$"), e.pos = i + 1, !0) : (n = Q(e, l), n.can_close ? (a || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(i, l)), e.pos = l + 1, !0) : (a || (e.pending += "$"), e.pos = i, !0));
179
- }, qe = (e, a, l, t) => {
180
- let n, r, i, c, u = !1, s = e.bMarks[a] + e.tShift[a], o = e.eMarks[a];
181
- if (s + 2 > o || e.src.slice(s, s + 2) !== "$$")
182
+ return l === -1 ? (r || (e.pending += "$"), e.pos = i, !0) : l - i === 0 ? (r || (e.pending += "$$"), e.pos = i + 1, !0) : (n = Q(e, l), n.can_close ? (r || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(i, l)), e.pos = l + 1, !0) : (r || (e.pending += "$"), e.pos = i, !0));
183
+ }, qe = (e, r, l, t) => {
184
+ let n, o, i, c, d = !1, s = e.bMarks[r] + e.tShift[r], a = e.eMarks[r];
185
+ if (s + 2 > a || e.src.slice(s, s + 2) !== "$$")
182
186
  return !1;
183
- if (s += 2, n = e.src.slice(s, o), t)
187
+ if (s += 2, n = e.src.slice(s, a), t)
184
188
  return !0;
185
- for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), u = !0), i = a; !u && (i++, !(i >= l || (s = e.bMarks[i] + e.tShift[i], o = e.eMarks[i], s < o && e.tShift[i] < e.blkIndent))); )
186
- e.src.slice(s, o).trim().slice(-2) === "$$" && (c = e.src.slice(0, o).lastIndexOf("$$"), r = e.src.slice(s, c), u = !0);
189
+ for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), d = !0), i = r; !d && (i++, !(i >= l || (s = e.bMarks[i] + e.tShift[i], a = e.eMarks[i], s < a && e.tShift[i] < e.blkIndent))); )
190
+ e.src.slice(s, a).trim().slice(-2) === "$$" && (c = e.src.slice(0, a).lastIndexOf("$$"), o = e.src.slice(s, c), d = !0);
187
191
  e.line = i + 1;
188
- const d = e.push("math_block", "math", 0);
189
- return d.block = !0, d.content = (n && n.trim() ? n + `
190
- ` : "") + e.getLines(a + 1, i, e.tShift[a], !0) + (r && r.trim() ? r : ""), d.map = [a, e.line], d.markup = "$$", !0;
191
- }, Ze = (e, a) => {
192
+ const u = e.push("math_block", "math", 0);
193
+ return u.block = !0, u.content = (n && n.trim() ? n + `
194
+ ` : "") + e.getLines(r + 1, i, e.tShift[r], !0) + (o && o.trim() ? o : ""), u.map = [r, e.line], u.markup = "$$", !0;
195
+ }, Ze = (e, r) => {
192
196
  const l = (n) => {
193
- if (a.katexRef.value) {
194
- const r = a.katexRef.value.renderToString(n, {
197
+ if (r.katexRef.value) {
198
+ const o = r.katexRef.value.renderToString(n, {
195
199
  throwOnError: !1
196
200
  });
197
- return `<span class="${p}-katex-inline" data-processed>${r}</span>`;
201
+ return `<span class="${h}-katex-inline" data-processed>${o}</span>`;
198
202
  } else
199
- return `<span class="${p}-katex-inline">${n}</span>`;
200
- }, t = (n, r) => {
201
- if (a.katexRef.value) {
202
- const i = a.katexRef.value.renderToString(n, {
203
+ return `<span class="${h}-katex-inline">${n}</span>`;
204
+ }, t = (n, o) => {
205
+ if (r.katexRef.value) {
206
+ const i = r.katexRef.value.renderToString(n, {
203
207
  throwOnError: !1,
204
208
  displayMode: !0
205
209
  });
206
- return `<p class="${p}-katex-block" data-line=${r} data-processed>${i}</p>`;
210
+ return `<p class="${h}-katex-block" data-line=${o} data-processed>${i}</p>`;
207
211
  } else
208
- return `<p class="${p}-katex-block" data-line=${r}>${n}</p>`;
212
+ return `<p class="${h}-katex-block" data-line=${o}>${n}</p>`;
209
213
  };
210
214
  e.inline.ruler.after("escape", "math_inline", Ke), e.block.ruler.after("blockquote", "math_block", qe, {
211
215
  alt: ["paragraph", "reference", "blockquote", "list"]
212
- }), e.renderer.rules.math_inline = (n, r) => l(n[r].content), e.renderer.rules.math_block = (n, r) => t(n[r].content, n[r].map[0]) + `
216
+ }), e.renderer.rules.math_inline = (n, o) => l(n[o].content), e.renderer.rules.math_block = (n, o) => t(n[o].content, n[o].map[0]) + `
213
217
  `;
214
- }, Je = Ze, Xe = (e, a) => {
215
- a = a || {};
216
- const l = 3, t = a.marker || "!", n = t.charCodeAt(0), r = t.length;
218
+ }, Je = Ze, Xe = (e, r) => {
219
+ r = r || {};
220
+ const l = 3, t = r.marker || "!", n = t.charCodeAt(0), o = t.length;
217
221
  let i = "", c = "";
218
- const u = (o, d, b, y, m) => {
219
- const h = o[d];
220
- return h.type === "admonition_open" ? (o[d].attrPush([
222
+ const d = (a, u, b, y, m) => {
223
+ const p = a[u];
224
+ return p.type === "admonition_open" ? (a[u].attrPush([
221
225
  "class",
222
- `${p}-admonition ${p}-admonition-${h.info}`
223
- ]), o[d].attrSet("data-line", String(o[d].map[0]))) : h.type === "admonition_title_open" && o[d].attrPush(["class", `${p}-admonition-title`]), m.renderToken(o, d, b);
224
- }, s = (o) => {
225
- const d = o.trim().split(" ", 2);
226
- c = "", i = d[0], d.length > 1 && (c = o.substring(i.length + 2)), (c === "" || !c) && (c = i);
226
+ `${h}-admonition ${h}-admonition-${p.info}`
227
+ ]), a[u].attrSet("data-line", String(a[u].map[0]))) : p.type === "admonition_title_open" && a[u].attrPush(["class", `${h}-admonition-title`]), m.renderToken(a, u, b);
228
+ }, s = (a) => {
229
+ const u = a.trim().split(" ", 2);
230
+ c = "", i = u[0], u.length > 1 && (c = a.substring(i.length + 2)), (c === "" || !c) && (c = i);
227
231
  };
228
232
  e.block.ruler.before(
229
233
  "code",
230
234
  "admonition",
231
- (o, d, b, y) => {
232
- let m, h, f, w = !1, v = o.bMarks[d] + o.tShift[d], k = o.eMarks[d];
233
- if (n !== o.src.charCodeAt(v))
235
+ (a, u, b, y) => {
236
+ let m, p, f, $ = !1, g = a.bMarks[u] + a.tShift[u], w = a.eMarks[u];
237
+ if (n !== a.src.charCodeAt(g))
234
238
  return !1;
235
- for (m = v + 1; m <= k && t[(m - v) % r] === o.src[m]; m++)
239
+ for (m = g + 1; m <= w && t[(m - g) % o] === a.src[m]; m++)
236
240
  ;
237
- const $ = Math.floor((m - v) / r);
238
- if ($ !== l)
241
+ const k = Math.floor((m - g) / o);
242
+ if (k !== l)
239
243
  return !1;
240
- m -= (m - v) % r;
241
- const E = o.src.slice(v, m), T = o.src.slice(m, k);
244
+ m -= (m - g) % o;
245
+ const E = a.src.slice(g, m), T = a.src.slice(m, w);
242
246
  if (s(T), y)
243
247
  return !0;
244
- for (h = d; h++, !(h >= b || (v = o.bMarks[h] + o.tShift[h], k = o.eMarks[h], v < k && o.sCount[h] < o.blkIndent)); )
245
- if (n === o.src.charCodeAt(v) && !(o.sCount[h] - o.blkIndent >= 4)) {
246
- for (m = v + 1; m <= k && t[(m - v) % r] === o.src[m]; m++)
248
+ for (p = u; p++, !(p >= b || (g = a.bMarks[p] + a.tShift[p], w = a.eMarks[p], g < w && a.sCount[p] < a.blkIndent)); )
249
+ if (n === a.src.charCodeAt(g) && !(a.sCount[p] - a.blkIndent >= 4)) {
250
+ for (m = g + 1; m <= w && t[(m - g) % o] === a.src[m]; m++)
247
251
  ;
248
- if (!(Math.floor((m - v) / r) < $) && (m -= (m - v) % r, m = o.skipSpaces(m), !(m < k))) {
249
- w = !0;
252
+ if (!(Math.floor((m - g) / o) < k) && (m -= (m - g) % o, m = a.skipSpaces(m), !(m < w))) {
253
+ $ = !0;
250
254
  break;
251
255
  }
252
256
  }
253
- const x = o.parentType, B = o.lineMax;
254
- return o.parentType = "root", o.lineMax = h, f = o.push("admonition_open", "div", 1), f.markup = E, f.block = !0, f.info = i, f.map = [d, h], f = o.push("admonition_title_open", "p", 1), f.markup = E + " " + i, f.map = [d, h], f = o.push("inline", "", 0), f.content = c, f.map = [d, o.line - 1], f.children = [], f = o.push("admonition_title_close", "p", -1), f.markup = E + " " + i, o.md.block.tokenize(o, d + 1, h), f = o.push("admonition_close", "div", -1), f.markup = o.src.slice(v, m), f.block = !0, o.parentType = x, o.lineMax = B, o.line = h + (w ? 1 : 0), !0;
257
+ const M = a.parentType, B = a.lineMax;
258
+ return a.parentType = "root", a.lineMax = p, f = a.push("admonition_open", "div", 1), f.markup = E, f.block = !0, f.info = i, f.map = [u, p], f = a.push("admonition_title_open", "p", 1), f.markup = E + " " + i, f.map = [u, p], f = a.push("inline", "", 0), f.content = c, f.map = [u, a.line - 1], f.children = [], f = a.push("admonition_title_close", "p", -1), f.markup = E + " " + i, a.md.block.tokenize(a, u + 1, p), f = a.push("admonition_close", "div", -1), f.markup = a.src.slice(g, m), f.block = !0, a.parentType = M, a.lineMax = B, a.line = p + ($ ? 1 : 0), !0;
255
259
  },
256
260
  {
257
261
  alt: ["paragraph", "reference", "blockquote", "list"]
258
262
  }
259
- ), e.renderer.rules.admonition_open = u, e.renderer.rules.admonition_title_open = u, e.renderer.rules.admonition_title_close = u, e.renderer.rules.admonition_close = u;
260
- }, Qe = Xe, Ye = (e, a) => {
263
+ ), e.renderer.rules.admonition_open = d, e.renderer.rules.admonition_title_open = d, e.renderer.rules.admonition_title_close = d, e.renderer.rules.admonition_close = d;
264
+ }, Qe = Xe, Ye = (e, r) => {
261
265
  e.renderer.rules.heading_open = (l, t) => {
262
266
  var c;
263
- const n = l[t], r = ((c = l[t + 1].children) == null ? void 0 : c.reduce((u, s) => u + (s.content || ""), "")) || "", i = n.markup.length;
264
- return a.headsRef.value.push({
265
- text: r,
267
+ const n = l[t], o = ((c = l[t + 1].children) == null ? void 0 : c.reduce((d, s) => d + (s.content || ""), "")) || "", i = n.markup.length;
268
+ return r.headsRef.value.push({
269
+ text: o,
266
270
  level: i
267
271
  }), n.map && n.level === 0 && (n.attrSet("data-line", String(n.map[0])), n.attrSet(
268
272
  "id",
269
- a.mdHeadingId(r, i, a.headsRef.value.length)
270
- )), e.renderer.renderToken(l, t, a);
271
- }, e.renderer.rules.heading_close = (l, t, n, r, i) => i.renderToken(l, t, n);
272
- }, et = Ye, tt = (e, a) => {
273
+ r.mdHeadingId(o, i, r.headsRef.value.length)
274
+ )), e.renderer.renderToken(l, t, r);
275
+ }, e.renderer.rules.heading_close = (l, t, n, o, i) => i.renderToken(l, t, n);
276
+ }, et = Ye, tt = (e, r) => {
273
277
  const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
274
- function r(s) {
278
+ function o(s) {
275
279
  return s.info ? t(s.info).trim() : "";
276
280
  }
277
281
  function i(s) {
278
- const o = r(s), [d = null, b = ""] = (n.exec(o) || []).slice(1);
279
- return [d, b];
282
+ const a = o(s), [u = null, b = ""] = (n.exec(a) || []).slice(1);
283
+ return [u, b];
280
284
  }
281
285
  function c(s) {
282
- const o = r(s);
283
- return o ? o.split(/(\s+)/g)[0] : "";
286
+ const a = o(s);
287
+ return a ? a.split(/(\s+)/g)[0] : "";
284
288
  }
285
- const u = (s, o, d, b, y) => {
286
- if (s[o].hidden)
289
+ const d = (s, a, u, b, y) => {
290
+ if (s[a].hidden)
287
291
  return "";
288
- const [m, h] = i(s[o]);
292
+ const [m, p] = i(s[a]);
289
293
  if (m === null)
290
- return l(s, o, d, b, y);
291
- let f, w, v, k, $ = "", E = "";
292
- for (let T = o; T < s.length && (f = s[T], [w, v] = i(f), w === m); T++)
293
- f.info = f.info.replace(n, ""), f.hidden = !0, k = T - o > 0 ? "" : " checked", $ += `<li><input type="radio" name="label-group-${a.editorId}-${o}"${k}><label for="group-${a.editorId}-${o}-tab-${T - o}" onclick="this.previousElementSibling.click()">${v || c(f)}</label></li>
294
- `, E += `<input type="radio" id="group-${a.editorId}-${o}-tab-${T - o}" name="group-${a.editorId}-${o}"${k}>
295
- ` + l(s, T, d, b, y);
294
+ return l(s, a, u, b, y);
295
+ let f, $, g, w, k = "", E = "";
296
+ for (let T = a; T < s.length && (f = s[T], [$, g] = i(f), $ === m); T++)
297
+ f.info = f.info.replace(n, ""), f.hidden = !0, w = T - a > 0 ? "" : " checked", k += `<li><input type="radio" name="label-group-${r.editorId}-${a}"${w}><label for="group-${r.editorId}-${a}-tab-${T - a}" onclick="this.previousElementSibling.click()">${g || c(f)}</label></li>
298
+ `, E += `<input type="radio" id="group-${r.editorId}-${a}-tab-${T - a}" name="group-${r.editorId}-${a}"${w}>
299
+ ` + l(s, T, u, b, y);
296
300
  return `<div class="code-tabs">
297
301
  <ul>
298
- ` + $ + `</ul>
302
+ ` + k + `</ul>
299
303
  ` + E + "</div>";
300
304
  };
301
- e.renderer.rules.fence = u;
305
+ e.renderer.rules.fence = d;
302
306
  }, nt = tt, ot = (e) => {
303
307
  [
304
308
  "paragraph_open",
@@ -309,28 +313,30 @@ const Me = (e, a) => {
309
313
  "hr",
310
314
  "html_block",
311
315
  "fence"
312
- ].forEach((a) => {
313
- const l = e.renderer.rules[a];
314
- l ? e.renderer.rules[a] = (t, n, r, i, c) => {
315
- let u;
316
- const s = l(t, n, r, i, c);
317
- return t[n].map && t[n].level === 0 && !/^<!--/.test(s) ? (u = t[n].map[0], s.replace(/^(<[^>]*)/, `$1 data-line="${u}"`)) : s;
318
- } : e.renderer.rules[a] = (t, n, r, i, c) => {
319
- let u;
320
- return t[n].map && t[n].level === 0 && (u = t[n].map[0], t[n].attrSet("data-line", String(u))), c.renderToken(t, n, r);
316
+ ].forEach((r) => {
317
+ const l = e.renderer.rules[r];
318
+ l ? e.renderer.rules[r] = (t, n, o, i, c) => {
319
+ let d;
320
+ const s = l(t, n, o, i, c);
321
+ return t[n].map && t[n].level === 0 && !/^<!--/.test(s) ? (d = t[n].map[0], s.replace(/^(<[^>]*)/, `$1 data-line="${d}"`)) : s;
322
+ } : e.renderer.rules[r] = (t, n, o, i, c) => {
323
+ let d;
324
+ return t[n].map && t[n].level === 0 && (d = t[n].map[0], t[n].attrSet("data-line", String(d))), c.renderToken(t, n, o);
321
325
  };
322
326
  });
323
- }, rt = (e, a) => {
324
- const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = I, r = P("editorId"), i = P("showCodeRowNumber"), c = P("theme"), u = U([]), s = Ue(e), o = Ve(e), { reRenderRef: d, replaceMermaid: b } = Ge(e), y = Fe({
327
+ }, rt = (e, r) => {
328
+ const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = I, o = P("editorId"), i = P("showCodeRowNumber"), c = P("theme"), d = U([]), s = Ue(e), a = Ve(e), { reRenderRef: u, replaceMermaid: b } = Ge(e), y = Fe({
325
329
  html: !0,
326
330
  breaks: !0
327
331
  });
328
- t(y);
332
+ t(y, {
333
+ editorId: o
334
+ });
329
335
  const m = [
330
336
  {
331
337
  type: "katex",
332
338
  plugin: Je,
333
- options: { katexRef: o }
339
+ options: { katexRef: a }
334
340
  },
335
341
  {
336
342
  type: "image",
@@ -344,59 +350,61 @@ const Me = (e, a) => {
344
350
  },
345
351
  {
346
352
  type: "taskList",
347
- plugin: xe,
353
+ plugin: Me,
348
354
  options: {}
349
355
  },
350
356
  {
351
357
  type: "heading",
352
358
  plugin: et,
353
- options: { mdHeadingId: e.mdHeadingId, headsRef: u }
359
+ options: { mdHeadingId: e.mdHeadingId, headsRef: d }
354
360
  },
355
361
  {
356
362
  type: "codeTabs",
357
363
  plugin: nt,
358
- options: { editorId: r }
364
+ options: { editorId: o }
359
365
  }
360
366
  ];
361
367
  e.noMermaid || m.push({
362
368
  type: "mermaid",
363
369
  plugin: We,
364
370
  options: { themeRef: c }
365
- }), n(m).forEach(($) => {
366
- y.use($.plugin, $.options);
371
+ }), n(m, {
372
+ editorId: o
373
+ }).forEach((k) => {
374
+ y.use(k.plugin, k.options);
367
375
  });
368
- const h = y.options.highlight;
376
+ const p = y.options.highlight;
369
377
  y.set({
370
- highlight: ($, E, T) => {
371
- if (h) {
372
- const L = h($, E, T);
378
+ highlight: (k, E, T) => {
379
+ if (p) {
380
+ const L = p(k, E, T);
373
381
  if (L)
374
382
  return L;
375
383
  }
376
- let x;
377
- !e.noHighlight && s.value ? s.value.getLanguage(E) ? x = s.value.highlight($, {
384
+ let M;
385
+ !e.noHighlight && s.value ? s.value.getLanguage(E) ? M = s.value.highlight(k, {
378
386
  language: E,
379
387
  ignoreIllegals: !0
380
- }).value : x = s.value.highlightAuto($).value : x = y.utils.escapeHtml($);
381
- const B = i ? ke(x.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${x.replace(/^\n+|\n+$/g, "")}</span>`;
388
+ }).value : M = s.value.highlightAuto(k).value : M = y.utils.escapeHtml(k);
389
+ const B = i ? ke(M.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${M.replace(/^\n+|\n+$/g, "")}</span>`;
382
390
  return `<pre><code class="language-${E}" language=${E}>${B}</code></pre>`;
383
391
  }
384
392
  }), ot(y);
385
- const f = U(e.sanitize(y.render(e.modelValue))), w = () => {
386
- g.emit(r, M, f.value), e.onHtmlChanged(f.value), e.onGetCatalog(u.value), g.emit(r, W, u.value), b();
393
+ const f = U(e.sanitize(y.render(e.modelValue))), $ = () => {
394
+ v.emit(o, A, f.value), e.onHtmlChanged(f.value), e.onGetCatalog(d.value), v.emit(o, W, d.value), b();
387
395
  };
388
- S(w);
389
- const v = ae(
396
+ S($);
397
+ const g = ae(
390
398
  async () => {
391
- u.value = [], f.value = e.sanitize(y.render(e.modelValue)), w();
399
+ d.value = [], f.value = e.sanitize(y.render(e.modelValue)), $();
392
400
  },
393
- (l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
394
- ), k = H(() => (e.noKatex || o.value) && (e.noHighlight || s.value));
395
- return C([Y(e, "modelValue"), k, d], v), S(() => {
396
- g.on(r, {
401
+ (l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : r ? 0 : 500
402
+ ), w = H(() => (e.noKatex || a.value) && (e.noHighlight || s.value));
403
+ return C([Y(e, "modelValue"), w, u], g), S(() => {
404
+ v.on(o, {
397
405
  name: $e,
398
406
  callback() {
399
- g.emit(r, W, u.value);
407
+ v.emit(o, W, d.value);
400
408
  }
401
409
  });
402
410
  }), { html: f };
@@ -450,6 +458,9 @@ const Me = (e, a) => {
450
458
  },
451
459
  noImgZoomIn: {
452
460
  type: Boolean
461
+ },
462
+ sanitizeMermaid: {
463
+ type: Function
453
464
  }
454
465
  }, wt = {
455
466
  ...le,
@@ -527,28 +538,28 @@ const Me = (e, a) => {
527
538
  name: "ContentPreview",
528
539
  props: le,
529
540
  setup(e) {
530
- const a = P("editorId"), l = P("previewTheme"), t = P("showCodeRowNumber"), {
541
+ const r = P("editorId"), l = P("previewTheme"), t = P("showCodeRowNumber"), {
531
542
  html: n
532
543
  } = at(e, e.previewOnly);
533
- return Ne(e, n), Re(e, n), () => A(de, null, [A("div", {
534
- id: `${a}-preview-wrapper`,
535
- class: `${p}-preview-wrapper`,
544
+ return Ne(e, n), Re(e, n), () => x(de, null, [x("div", {
545
+ id: `${r}-preview-wrapper`,
546
+ class: `${h}-preview-wrapper`,
536
547
  "data-show": e.setting.preview,
537
548
  key: "content-preview-wrapper"
538
- }, [A("article", {
539
- id: `${a}-preview`,
540
- class: [`${p}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${p}-scrn`],
549
+ }, [x("article", {
550
+ id: `${r}-preview`,
551
+ class: [`${h}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${h}-scrn`],
541
552
  innerHTML: n.value
542
- }, null)]), !e.previewOnly && A("div", {
543
- id: `${a}-html-wrapper`,
544
- class: `${p}-preview-wrapper`,
553
+ }, null)]), !e.previewOnly && x("div", {
554
+ id: `${r}-html-wrapper`,
555
+ class: `${h}-preview-wrapper`,
545
556
  "data-show": e.setting.htmlPreview,
546
557
  key: "html-preview-wrapper"
547
- }, [A("div", {
548
- class: `${p}-html`
558
+ }, [x("div", {
559
+ class: `${h}-html`
549
560
  }, [n.value])])]);
550
561
  }
551
- }), kt = (e, a) => {
562
+ }), kt = (e, r) => {
552
563
  const { editorId: l } = e, t = te({
553
564
  // 是否已编译成html
554
565
  buildFinished: !1,
@@ -561,35 +572,35 @@ const Me = (e, a) => {
561
572
  t.buildFinished = !1;
562
573
  }
563
574
  ), S(() => {
564
- g.on(l, {
565
- name: M,
575
+ v.on(l, {
576
+ name: A,
566
577
  callback(n) {
567
578
  t.buildFinished = !0, t.html = n;
568
579
  }
569
- }), g.on(l, {
580
+ }), v.on(l, {
570
581
  name: ne,
571
582
  callback() {
572
- const n = new Promise((r) => {
583
+ const n = new Promise((o) => {
573
584
  if (t.buildFinished)
574
- r(t.html);
585
+ o(t.html);
575
586
  else {
576
587
  const i = (c) => {
577
- r(c), g.remove(l, M, i);
588
+ o(c), v.remove(l, A, i);
578
589
  };
579
- g.on(l, {
580
- name: M,
590
+ v.on(l, {
591
+ name: A,
581
592
  callback: i
582
593
  });
583
594
  }
584
595
  });
585
- e.onSave ? e.onSave(e.modelValue, n) : a.emit("onSave", e.modelValue, n);
596
+ e.onSave ? e.onSave(e.modelValue, n) : r.emit("onSave", e.modelValue, n);
586
597
  }
587
598
  });
588
599
  });
589
600
  }, ie = (e) => {
590
- var n, r;
591
- const { editorId: a } = e, l = (r = (n = I) == null ? void 0 : n.editorExtensions) == null ? void 0 : r.highlight;
592
- F("editorId", a), F(
601
+ var n, o;
602
+ const { editorId: r } = e, l = (o = (n = I) == null ? void 0 : n.editorExtensions) == null ? void 0 : o.highlight;
603
+ F("editorId", r), F(
593
604
  "theme",
594
605
  H(() => e.theme)
595
606
  ), F(
@@ -609,10 +620,10 @@ const Me = (e, a) => {
609
620
  })
610
621
  ), F("showCodeRowNumber", e.showCodeRowNumber);
611
622
  const t = H(() => {
612
- var c, u;
623
+ var c, d;
613
624
  const i = {
614
625
  ...D,
615
- ...(u = (c = I) == null ? void 0 : c.editorConfig) == null ? void 0 : u.languageUserDefined
626
+ ...(d = (c = I) == null ? void 0 : c.editorConfig) == null ? void 0 : d.languageUserDefined
616
627
  };
617
628
  return i[e.language] ? i[e.language] : D["zh-CN"];
618
629
  });
@@ -627,144 +638,144 @@ const Me = (e, a) => {
627
638
  ie(e), F("tabWidth", e.tabWidth);
628
639
  }, ce = (e) => {
629
640
  S(() => {
630
- var a, l;
641
+ var r, l;
631
642
  if (!e.noIconfont)
632
643
  if (I.iconfontType === "svg") {
633
644
  const t = document.createElement("script");
634
- t.src = ((a = I.editorExtensions) == null ? void 0 : a.iconfont) || he, t.id = `${p}-icon`, _(t);
645
+ t.src = ((r = I.editorExtensions) == null ? void 0 : r.iconfont) || he, t.id = `${h}-icon`, _(t);
635
646
  } else {
636
647
  const t = document.createElement("link");
637
- t.rel = "stylesheet", t.href = ((l = I.editorExtensions) == null ? void 0 : l.iconfontClass) || ge, t.id = `${p}-icon-class`, _(t);
648
+ t.rel = "stylesheet", t.href = ((l = I.editorExtensions) == null ? void 0 : l.iconfontClass) || ge, t.id = `${h}-icon-class`, _(t);
638
649
  }
639
650
  });
640
651
  }, Ct = (e) => {
641
- var c, u, s, o, d, b;
642
- const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = I, n = a || !!((u = (c = I.editorExtensions) == null ? void 0 : c.prettier) != null && u.prettierInstance), r = a || !!((o = (s = I.editorExtensions) == null ? void 0 : s.prettier) != null && o.parserMarkdownInstance), i = l || !!((b = (d = I.editorExtensions) == null ? void 0 : d.cropper) != null && b.instance);
652
+ var c, d, s, a, u, b;
653
+ const { noPrettier: r, noUploadImg: l } = e, { editorExtensions: t } = I, n = r || !!((d = (c = I.editorExtensions) == null ? void 0 : c.prettier) != null && d.prettierInstance), o = r || !!((a = (s = I.editorExtensions) == null ? void 0 : s.prettier) != null && a.parserMarkdownInstance), i = l || !!((b = (u = I.editorExtensions) == null ? void 0 : u.cropper) != null && b.instance);
643
654
  S(() => {
644
- var w, v, k, $;
655
+ var $, g, w, k;
645
656
  const y = document.createElement("script"), m = document.createElement("script");
646
- y.src = ((w = t == null ? void 0 : t.prettier) == null ? void 0 : w.standaloneJs) || V.main, y.id = `${p}-prettier`, m.src = ((v = t == null ? void 0 : t.prettier) == null ? void 0 : v.parserMarkdownJs) || V.markdown, m.id = `${p}-prettierMD`;
647
- const h = document.createElement("link");
648
- h.rel = "stylesheet", h.href = ((k = t == null ? void 0 : t.cropper) == null ? void 0 : k.css) || z.css, h.id = `${p}-cropperCss`;
657
+ y.src = (($ = t == null ? void 0 : t.prettier) == null ? void 0 : $.standaloneJs) || V.main, y.id = `${h}-prettier`, m.src = ((g = t == null ? void 0 : t.prettier) == null ? void 0 : g.parserMarkdownJs) || V.markdown, m.id = `${h}-prettierMD`;
658
+ const p = document.createElement("link");
659
+ p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || z.css, p.id = `${h}-cropperCss`;
649
660
  const f = document.createElement("script");
650
- f.src = (($ = t == null ? void 0 : t.cropper) == null ? void 0 : $.js) || z.js, f.id = `${p}-cropper`, i || (_(h), _(f)), n || _(y), r || _(m);
661
+ f.src = ((k = t == null ? void 0 : t.cropper) == null ? void 0 : k.js) || z.js, f.id = `${h}-cropper`, i || (_(p), _(f)), n || _(y), o || _(m);
651
662
  }), ce(e);
652
- }, It = (e, a) => {
663
+ }, It = (e, r) => {
653
664
  const { editorId: l } = e;
654
665
  S(() => {
655
- g.on(l, {
666
+ v.on(l, {
656
667
  name: Ce,
657
668
  callback: (t) => {
658
- e.onError instanceof Function ? e.onError(t) : a.emit("onError", t);
669
+ e.onError instanceof Function ? e.onError(t) : r.emit("onError", t);
659
670
  }
660
671
  });
661
672
  });
662
- }, St = (e, a) => {
673
+ }, St = (e, r) => {
663
674
  const { editorId: l } = e, t = te({
664
675
  pageFullscreen: e.pageFullscreen,
665
676
  fullscreen: !1,
666
677
  preview: e.preview,
667
678
  htmlPreview: e.preview ? !1 : e.htmlPreview
668
- }), n = (c, u) => {
669
- t[c] = u === void 0 ? !t[c] : u, c === "preview" && t.preview ? t.htmlPreview = !1 : c === "htmlPreview" && t.htmlPreview && (t.preview = !1);
679
+ }), n = (c, d) => {
680
+ t[c] = d === void 0 ? !t[c] : d, c === "preview" && t.preview ? t.htmlPreview = !1 : c === "htmlPreview" && t.htmlPreview && (t.preview = !1);
670
681
  };
671
- let r = "";
682
+ let o = "";
672
683
  const i = () => {
673
- t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = r;
684
+ t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = o;
674
685
  };
675
686
  return C(() => [t.pageFullscreen, t.fullscreen], i), S(() => {
676
- g.on(l, {
687
+ v.on(l, {
677
688
  name: Ie,
678
- callback(c, u) {
679
- const s = (o) => {
680
- g.emit(l, re, "image", {
689
+ callback(c, d) {
690
+ const s = (a) => {
691
+ v.emit(l, re, "image", {
681
692
  desc: "",
682
- urls: o
683
- }), u && u();
693
+ urls: a
694
+ }), d && d();
684
695
  };
685
- e.onUploadImg ? e.onUploadImg(c, s) : a.emit("onUploadImg", c, s);
696
+ e.onUploadImg ? e.onUploadImg(c, s) : r.emit("onUploadImg", c, s);
686
697
  }
687
- }), r = document.body.style.overflow, i();
698
+ }), o = document.body.style.overflow, i();
688
699
  }), [t, n];
689
700
  }, Et = (e) => {
690
- const { editorId: a } = e, l = U(!1);
701
+ const { editorId: r } = e, l = U(!1);
691
702
  return S(() => {
692
- g.on(a, {
703
+ v.on(r, {
693
704
  name: oe,
694
705
  callback: (n) => {
695
706
  n === void 0 ? l.value = !l.value : l.value = n;
696
707
  }
697
708
  });
698
709
  }), H(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
699
- }, Pt = (e, a, l, t, n) => {
700
- const { editorId: r } = e;
710
+ }, Pt = (e, r, l, t, n) => {
711
+ const { editorId: o } = e;
701
712
  C(
702
713
  () => t.pageFullscreen,
703
714
  (c) => {
704
- g.emit(r, K, c);
715
+ v.emit(o, K, c);
705
716
  }
706
717
  ), C(
707
718
  () => t.fullscreen,
708
719
  (c) => {
709
- g.emit(r, q, c);
720
+ v.emit(o, q, c);
710
721
  }
711
722
  ), C(
712
723
  () => t.preview,
713
724
  (c) => {
714
- g.emit(r, Z, c);
725
+ v.emit(o, Z, c);
715
726
  }
716
727
  ), C(
717
728
  () => t.htmlPreview,
718
729
  (c) => {
719
- g.emit(r, J, c);
730
+ v.emit(o, J, c);
720
731
  }
721
732
  ), C(l, (c) => {
722
- g.emit(r, X, c);
733
+ v.emit(o, X, c);
723
734
  });
724
735
  const i = {
725
- on(c, u) {
736
+ on(c, d) {
726
737
  switch (c) {
727
738
  case "pageFullscreen": {
728
- g.on(r, {
739
+ v.on(o, {
729
740
  name: K,
730
741
  callback(s) {
731
- u(s);
742
+ d(s);
732
743
  }
733
744
  });
734
745
  break;
735
746
  }
736
747
  case "fullscreen": {
737
- g.on(r, {
748
+ v.on(o, {
738
749
  name: q,
739
750
  callback(s) {
740
- u(s);
751
+ d(s);
741
752
  }
742
753
  });
743
754
  break;
744
755
  }
745
756
  case "preview": {
746
- g.on(r, {
757
+ v.on(o, {
747
758
  name: Z,
748
759
  callback(s) {
749
- u(s);
760
+ d(s);
750
761
  }
751
762
  });
752
763
  break;
753
764
  }
754
765
  case "htmlPreview": {
755
- g.on(r, {
766
+ v.on(o, {
756
767
  name: J,
757
768
  callback(s) {
758
- u(s);
769
+ d(s);
759
770
  }
760
771
  });
761
772
  break;
762
773
  }
763
774
  case "catalog": {
764
- g.on(r, {
775
+ v.on(o, {
765
776
  name: X,
766
777
  callback(s) {
767
- u(s);
778
+ d(s);
768
779
  }
769
780
  });
770
781
  break;
@@ -775,7 +786,7 @@ const Me = (e, a) => {
775
786
  n("pageFullscreen", c);
776
787
  },
777
788
  toggleFullscreen(c) {
778
- g.emit(r, Se, c);
789
+ v.emit(o, Se, c);
779
790
  },
780
791
  togglePreview(c) {
781
792
  n("preview", c);
@@ -784,19 +795,19 @@ const Me = (e, a) => {
784
795
  n("htmlPreview", c);
785
796
  },
786
797
  toggleCatalog(c) {
787
- g.emit(r, oe, c);
798
+ v.emit(o, oe, c);
788
799
  },
789
800
  triggerSave() {
790
- g.emit(r, ne);
801
+ v.emit(o, ne);
791
802
  },
792
803
  insert(c) {
793
- g.emit(r, re, "universal", { generate: c });
804
+ v.emit(o, re, "universal", { generate: c });
794
805
  },
795
806
  focus(c) {
796
- g.emit(r, Ee, c);
807
+ v.emit(o, Ee, c);
797
808
  }
798
809
  };
799
- a.expose(i);
810
+ r.expose(i);
800
811
  }, it = (e) => e, se = {
801
812
  /**
802
813
  * markdown content.
@@ -980,6 +991,10 @@ const Me = (e, a) => {
980
991
  customIcon: {
981
992
  type: Object,
982
993
  default: {}
994
+ },
995
+ sanitizeMermaid: {
996
+ type: Function,
997
+ default: (e) => Promise.resolve(e)
983
998
  }
984
999
  }, Tt = {
985
1000
  ...se,
@@ -1249,35 +1264,36 @@ const Me = (e, a) => {
1249
1264
  name: "MdPreview",
1250
1265
  props: se,
1251
1266
  emits: ue,
1252
- setup(e, a) {
1267
+ setup(e, r) {
1253
1268
  const {
1254
1269
  editorId: l,
1255
1270
  noKatex: t,
1256
1271
  noMermaid: n,
1257
- noHighlight: r
1272
+ noHighlight: o
1258
1273
  } = e;
1259
1274
  return ie(e), ce(e), me(() => {
1260
- g.clear(l);
1261
- }), () => A("div", {
1275
+ v.clear(l);
1276
+ }), () => x("div", {
1262
1277
  id: l,
1263
- class: [p, e.class, e.theme === "dark" && `${p}-dark`, `${p}-previewOnly`],
1278
+ class: [h, e.class, e.theme === "dark" && `${h}-dark`, `${h}-previewOnly`],
1264
1279
  style: e.style
1265
- }, [A(lt, {
1280
+ }, [x(lt, {
1266
1281
  modelValue: e.modelValue,
1267
1282
  onHtmlChanged: (i) => {
1268
- e.onHtmlChanged ? e.onHtmlChanged(i) : a.emit("onHtmlChanged", i);
1283
+ e.onHtmlChanged ? e.onHtmlChanged(i) : r.emit("onHtmlChanged", i);
1269
1284
  },
1270
1285
  onGetCatalog: (i) => {
1271
- e.onGetCatalog ? e.onGetCatalog(i) : a.emit("onGetCatalog", i);
1286
+ e.onGetCatalog ? e.onGetCatalog(i) : r.emit("onGetCatalog", i);
1272
1287
  },
1273
1288
  mdHeadingId: e.mdHeadingId,
1274
1289
  noMermaid: n,
1275
1290
  sanitize: e.sanitize,
1276
1291
  noKatex: t,
1277
1292
  formatCopiedText: e.formatCopiedText,
1278
- noHighlight: r,
1293
+ noHighlight: o,
1279
1294
  noImgZoomIn: e.noImgZoomIn,
1280
- previewOnly: !0
1295
+ previewOnly: !0,
1296
+ sanitizeMermaid: e.sanitizeMermaid
1281
1297
  }, null)]);
1282
1298
  }
1283
1299
  }), N = ct;