md-editor-v3 4.11.2 → 4.12.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.
Files changed (51) hide show
  1. package/README.md +11 -1
  2. package/lib/cjs/DropdownToolbar.cjs +1 -1
  3. package/lib/cjs/MdCatalog.cjs +1 -1
  4. package/lib/cjs/MdEditor.cjs +7 -7
  5. package/lib/cjs/MdModal.cjs +1 -1
  6. package/lib/cjs/MdPreview.cjs +1 -1
  7. package/lib/cjs/ModalToolbar.cjs +1 -1
  8. package/lib/cjs/chunks/config.cjs +1 -1
  9. package/lib/cjs/chunks/index.cjs +7 -7
  10. package/lib/cjs/chunks/index4.cjs +2 -2
  11. package/lib/cjs/index.cjs +1 -1
  12. package/lib/es/DropdownToolbar.mjs +2 -5
  13. package/lib/es/MdCatalog.mjs +18 -18
  14. package/lib/es/MdEditor.mjs +173 -172
  15. package/lib/es/MdModal.mjs +2 -7
  16. package/lib/es/MdPreview.mjs +2 -13
  17. package/lib/es/ModalToolbar.mjs +8 -10
  18. package/lib/es/chunks/config.mjs +23 -24
  19. package/lib/es/chunks/index.mjs +178 -147
  20. package/lib/es/chunks/index4.mjs +22 -18
  21. package/lib/es/index.mjs +23 -43
  22. package/lib/preview.css +1 -1
  23. package/lib/style.css +1 -1
  24. package/lib/types/DropdownToolbar/index.d.ts +8 -8
  25. package/lib/types/MdCatalog/CatalogLink.d.ts +1 -1
  26. package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
  27. package/lib/types/MdCatalog/index.d.ts +5 -5
  28. package/lib/types/MdEditor/Editor.d.ts +15 -15
  29. package/lib/types/MdEditor/components/Dropdown/index.d.ts +1 -1
  30. package/lib/types/MdEditor/components/Modal/Modal.d.ts +2 -2
  31. package/lib/types/MdEditor/components/Modal/index.d.ts +8 -8
  32. package/lib/types/MdEditor/components/Popper/index.d.ts +15 -0
  33. package/lib/types/MdEditor/config.d.ts +3 -3
  34. package/lib/types/MdEditor/index.d.ts +68 -68
  35. package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +8 -4
  36. package/lib/types/MdEditor/layouts/Content/composition/useAttach.d.ts +9 -0
  37. package/lib/types/MdEditor/layouts/Content/index.d.ts +12 -8
  38. package/lib/types/MdEditor/layouts/Content/props.d.ts +6 -2
  39. package/lib/types/MdEditor/layouts/Modals/Link.d.ts +1 -1
  40. package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +1 -1
  41. package/lib/types/MdEditor/props.d.ts +2 -2
  42. package/lib/types/MdEditor/static/env.d.ts +1 -0
  43. package/lib/types/MdEditor/type.d.ts +7 -1
  44. package/lib/types/MdEditor/utils/index.d.ts +4 -0
  45. package/lib/types/MdPreview/MdPreview.d.ts +13 -13
  46. package/lib/types/MdPreview/index.d.ts +45 -45
  47. package/lib/types/ModalToolbar/ModalToolbar.d.ts +3 -3
  48. package/lib/types/ModalToolbar/index.d.ts +16 -16
  49. package/lib/types/NormalToolbar/index.d.ts +5 -5
  50. package/lib/umd/index.js +46 -46
  51. package/package.json +32 -31
@@ -1,27 +1,32 @@
1
- import { inject as _, onMounted as P, watch as C, toRef as te, nextTick as U, shallowRef as B, ref as R, computed as F, defineComponent as ne, createVNode as M, Fragment as pe, reactive as oe, provide as H, onBeforeUnmount as he } from "vue";
2
- import { e as S, p as h, m as ge, k as D, f as V, h as ye, s as z, a as ve, i as be, g as W, j as K, l as we, b as ke, d as $e } from "./config.mjs";
3
- import { a as Ce, b as y, P as Ie, C as q, R as G, B as A, O as re, E as Se, U as Ee, c as ae, d as Z, F as J, e as Q, H as X, f as Y, h as le, i as Pe } from "./index4.mjs";
1
+ import { inject as P, watch as I, toRef as te, onMounted as _, nextTick as j, shallowRef as B, ref as R, computed as F, defineComponent as ne, createVNode as M, Fragment as pe, reactive as oe, provide as x, onBeforeUnmount as he } from "vue";
2
+ import { e as S, p as h, m as ge, k as D, f as V, h as ye, s as z, a as ve, i as be, g as W, j as q, b as we, d as ke } from "./config.mjs";
3
+ import { a as $e, b as y, P as Ce, C as K, R as G, B as A, O as re, E as Ie, U as Se, c as ae, d as Z, F as J, e as X, H as Q, f as Y, h as le, i as Ee, j as Pe } from "./index4.mjs";
4
4
  import { a as T, u as _e } from "./dom.mjs";
5
5
  import Te from "medium-zoom";
6
- import { debounce as ie, uuid as j } from "@vavt/util";
7
- import He from "copy-to-clipboard";
6
+ import { debounce as ie, uuid as U } from "@vavt/util";
7
+ import xe from "copy-to-clipboard";
8
8
  import Fe from "markdown-it";
9
- import xe from "markdown-it-image-figures";
9
+ import He from "markdown-it-image-figures";
10
10
  import Me from "markdown-it-task-lists";
11
- import Re from "lru-cache";
12
- const Ae = (e, a) => {
13
- const l = _("editorId"), { noImgZoomIn: t } = e, n = ie(() => {
11
+ import Re from "markdown-it-xss";
12
+ import { LRUCache as Ae } from "lru-cache";
13
+ const Be = (e, a) => {
14
+ const l = P("editorId"), { noImgZoomIn: t } = e, n = ie(() => {
14
15
  const i = document.querySelectorAll(`#${l}-preview img`);
15
16
  i.length !== 0 && Te(i, {
16
17
  background: "#00000073"
17
18
  });
18
19
  });
19
- P(() => {
20
- !t && e.setting.preview && n();
21
- }), C([a, te(e.setting, "preview")], () => {
22
- !t && n();
23
- });
24
- }, Be = Ae, Le = (e, a) => {
20
+ I(
21
+ [a, te(e.setting, "preview")],
22
+ () => {
23
+ !t && e.setting.preview && n();
24
+ },
25
+ {
26
+ immediate: !0
27
+ }
28
+ );
29
+ }, Le = (e, a) => {
25
30
  if (typeof a[e] == "string")
26
31
  return a[e];
27
32
  const l = `<i class="${h}-iconfont ${h}-icon-${e}"></i>`;
@@ -32,7 +37,7 @@ const Ae = (e, a) => {
32
37
  return l;
33
38
  }
34
39
  }, Ne = (e, a, l) => {
35
- const t = _("editorId"), n = _("usedLanguageText"), i = _("customIcon"), r = () => {
40
+ const t = P("editorId"), n = P("usedLanguageText"), i = P("customIcon"), r = () => {
36
41
  document.querySelectorAll(`#${t}-preview pre`).forEach((s) => {
37
42
  var v, m;
38
43
  let o = -1;
@@ -41,22 +46,22 @@ const Ae = (e, a) => {
41
46
  b.setAttribute("class", "copy-button"), b.dataset.tips = d, b.innerHTML = Le("copy", i.value), b.addEventListener("click", () => {
42
47
  var w, E;
43
48
  clearTimeout(o);
44
- const p = s.querySelector("code").innerText, f = He(e.formatCopiedText(p)), k = ((w = n.value.copyCode) == null ? void 0 : w.successTips) || "已复制!", g = ((E = n.value.copyCode) == null ? void 0 : E.failTips) || "已复制!";
49
+ const p = s.querySelector("code").innerText, f = xe(e.formatCopiedText(p)), k = ((w = n.value.copyCode) == null ? void 0 : w.successTips) || "已复制!", g = ((E = n.value.copyCode) == null ? void 0 : E.failTips) || "已复制!";
45
50
  b.dataset.tips = f ? k : g, o = window.setTimeout(() => {
46
51
  b.dataset.tips = d;
47
52
  }, 1500);
48
53
  }), s.appendChild(b);
49
54
  });
50
55
  }, u = () => {
51
- U(r);
56
+ j(r);
52
57
  }, c = (s) => {
53
- s && U(r);
58
+ s && j(r);
54
59
  };
55
- C([a, l], u), C(() => e.setting.preview, c), C(() => e.setting.htmlPreview, c), C(() => n.value, r), P(r);
56
- }, Oe = Ne, Ue = (e) => {
60
+ I([a, l], u), I(() => e.setting.preview, c), I(() => e.setting.htmlPreview, c), I(() => n.value, r), _(r);
61
+ }, Oe = (e) => {
57
62
  var i;
58
- const a = (i = S.editorExtensions) == null ? void 0 : i.highlight, l = a == null ? void 0 : a.instance, t = _("highlight"), n = B(l);
59
- return P(() => {
63
+ const a = (i = S.editorExtensions) == null ? void 0 : i.highlight, l = a == null ? void 0 : a.instance, t = P("highlight"), n = B(l);
64
+ return _(() => {
60
65
  if (!e.noHighlight && !n.value) {
61
66
  const r = document.createElement("script");
62
67
  r.src = t.value.js, r.onload = () => {
@@ -65,14 +70,14 @@ const Ae = (e, a) => {
65
70
  const u = document.createElement("link");
66
71
  u.rel = "stylesheet", u.href = t.value.css, u.id = `${h}-hlCss`, T(u);
67
72
  }
68
- }), C(
73
+ }), I(
69
74
  () => t.value.css,
70
75
  (r) => {
71
76
  _e(`${h}-hlCss`, "href", r);
72
77
  }
73
78
  ), n;
74
- }, je = Ue, Ge = (e) => {
75
- const a = _("theme"), { editorExtensions: l, mermaidConfig: t } = S, n = l == null ? void 0 : l.mermaid, i = B(n == null ? void 0 : n.instance), r = B(-1), u = new Re({
79
+ }, je = (e) => {
80
+ const a = P("theme"), { editorExtensions: l, mermaidConfig: t } = S, n = l == null ? void 0 : l.mermaid, i = B(n == null ? void 0 : n.instance), r = B(-1), u = new Ae({
76
81
  max: 1e3,
77
82
  // 缓存10分钟
78
83
  ttl: 6e5
@@ -85,12 +90,12 @@ const Ae = (e, a) => {
85
90
  })
86
91
  ), r.value = r.value + 1);
87
92
  };
88
- return C(
93
+ return I(
89
94
  () => a.value,
90
95
  () => {
91
96
  u.clear(), c();
92
97
  }
93
- ), P(() => {
98
+ ), _(() => {
94
99
  if (!e.noMermaid && !(n != null && n.instance)) {
95
100
  const o = (n == null ? void 0 : n.js) || ge;
96
101
  if (/\.mjs/.test(o))
@@ -109,7 +114,7 @@ const Ae = (e, a) => {
109
114
  }
110
115
  }
111
116
  }), { mermaidRef: i, reRenderRef: r, replaceMermaid: () => {
112
- U(() => {
117
+ j(() => {
113
118
  if (!e.noMermaid && i.value) {
114
119
  const o = document.querySelectorAll(
115
120
  `div.${h}-mermaid`
@@ -119,7 +124,7 @@ const Ae = (e, a) => {
119
124
  b > 0 && document.body.appendChild(d), o.forEach(async (v) => {
120
125
  let m = u.get(v.innerText);
121
126
  if (!m) {
122
- const f = j(), k = i.value.renderAsync || i.value.render;
127
+ const f = U(), k = i.value.renderAsync || i.value.render;
123
128
  let g = "";
124
129
  try {
125
130
  g = await k(f, v.innerText, d);
@@ -135,10 +140,10 @@ const Ae = (e, a) => {
135
140
  }
136
141
  });
137
142
  } };
138
- }, De = Ge, Ve = (e) => {
143
+ }, Ue = (e) => {
139
144
  var n;
140
145
  const a = (n = S.editorExtensions) == null ? void 0 : n.katex, l = a == null ? void 0 : a.instance, t = B(l);
141
- return P(() => {
146
+ return _(() => {
142
147
  if (!e.noKatex && !t.value) {
143
148
  const i = document.createElement("script");
144
149
  i.src = (a == null ? void 0 : a.js) || D.js, i.onload = () => {
@@ -148,7 +153,7 @@ const Ae = (e, a) => {
148
153
  r.rel = "stylesheet", r.href = (a == null ? void 0 : a.css) || D.css, r.id = `${h}-katexCss`, T(i, "katex"), T(r);
149
154
  }
150
155
  }), t;
151
- }, ze = Ve, We = (e, a) => {
156
+ }, Ge = (e, a) => {
152
157
  const l = e.renderer.rules.fence.bind(e.renderer.rules);
153
158
  e.renderer.rules.fence = (t, n, i, r, u) => {
154
159
  const c = t[n], s = c.content.trim();
@@ -158,14 +163,14 @@ const Ae = (e, a) => {
158
163
  }
159
164
  return l(t, n, i, r, u);
160
165
  };
161
- }, Ke = We, ee = (e, a) => {
166
+ }, De = Ge, ee = (e, a) => {
162
167
  let l = !0, t = !0;
163
168
  const n = e.posMax, i = a > 0 ? e.src.charCodeAt(a - 1) : -1, r = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
164
169
  return (i === 32 || i === 9 || r >= 48 && r <= 57) && (t = !1), (r === 32 || r === 9) && (l = !1), {
165
170
  can_open: l,
166
171
  can_close: t
167
172
  };
168
- }, qe = (e, a) => {
173
+ }, Ve = (e, a) => {
169
174
  let l, t, n, i;
170
175
  if (e.src[e.pos] !== "$")
171
176
  return !1;
@@ -180,7 +185,7 @@ const Ae = (e, a) => {
180
185
  l += 1;
181
186
  }
182
187
  return l === -1 ? (a || (e.pending += "$"), e.pos = r, !0) : l - r === 0 ? (a || (e.pending += "$$"), e.pos = r + 1, !0) : (n = ee(e, l), n.can_close ? (a || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(r, l)), e.pos = l + 1, !0) : (a || (e.pending += "$"), e.pos = r, !0));
183
- }, Ze = (e, a, l, t) => {
188
+ }, ze = (e, a, l, t) => {
184
189
  let n, i, r, u, c = !1, s = e.bMarks[a] + e.tShift[a], o = e.eMarks[a];
185
190
  if (s + 2 > o || e.src.slice(s, s + 2) !== "$$")
186
191
  return !1;
@@ -192,7 +197,7 @@ const Ae = (e, a) => {
192
197
  const d = e.push("math_block", "math", 0);
193
198
  return d.block = !0, d.content = (n && n.trim() ? n + `
194
199
  ` : "") + e.getLines(a + 1, r, e.tShift[a], !0) + (i && i.trim() ? i : ""), d.map = [a, e.line], d.markup = "$$", !0;
195
- }, Je = (e, a) => {
200
+ }, We = (e, a) => {
196
201
  const l = (n) => {
197
202
  if (a.katexRef.value) {
198
203
  const i = a.katexRef.value.renderToString(n, {
@@ -211,11 +216,11 @@ const Ae = (e, a) => {
211
216
  } else
212
217
  return `<p class="${h}-katex-block" data-line=${i}>${n}</p>`;
213
218
  };
214
- e.inline.ruler.after("escape", "math_inline", qe), e.block.ruler.after("blockquote", "math_block", Ze, {
219
+ e.inline.ruler.after("escape", "math_inline", Ve), e.block.ruler.after("blockquote", "math_block", ze, {
215
220
  alt: ["paragraph", "reference", "blockquote", "list"]
216
221
  }), e.renderer.rules.math_inline = (n, i) => l(n[i].content), e.renderer.rules.math_block = (n, i) => t(n[i].content, n[i].map[0]) + `
217
222
  `;
218
- }, Qe = Je, Xe = (e, a) => {
223
+ }, qe = We, Ke = (e, a) => {
219
224
  a = a || {};
220
225
  const l = 3, t = a.marker || "!", n = t.charCodeAt(0), i = t.length;
221
226
  let r = "", u = "";
@@ -242,8 +247,8 @@ const Ae = (e, a) => {
242
247
  if (E !== l)
243
248
  return !1;
244
249
  m -= (m - g) % i;
245
- const I = o.src.slice(g, m), $ = o.src.slice(m, w);
246
- if (s($), v)
250
+ const $ = o.src.slice(g, m), C = o.src.slice(m, w);
251
+ if (s(C), v)
247
252
  return !0;
248
253
  for (p = d; p++, !(p >= b || (g = o.bMarks[p] + o.tShift[p], w = o.eMarks[p], g < w && o.sCount[p] < o.blkIndent)); )
249
254
  if (n === o.src.charCodeAt(g) && !(o.sCount[p] - o.blkIndent >= 4)) {
@@ -254,14 +259,14 @@ const Ae = (e, a) => {
254
259
  break;
255
260
  }
256
261
  }
257
- const L = o.parentType, x = o.lineMax;
258
- return o.parentType = "root", o.lineMax = p, f = o.push("admonition_open", "div", 1), f.markup = I, f.block = !0, f.info = r, f.map = [d, p], f = o.push("admonition_title_open", "p", 1), f.markup = I + " " + r, f.map = [d, p], f = o.push("inline", "", 0), f.content = u, f.map = [d, o.line - 1], f.children = [], f = o.push("admonition_title_close", "p", -1), f.markup = I + " " + r, o.md.block.tokenize(o, d + 1, p), f = o.push("admonition_close", "div", -1), f.markup = o.src.slice(g, m), f.block = !0, o.parentType = L, o.lineMax = x, o.line = p + (k ? 1 : 0), !0;
262
+ const L = o.parentType, H = o.lineMax;
263
+ return o.parentType = "root", o.lineMax = p, f = o.push("admonition_open", "div", 1), f.markup = $, f.block = !0, f.info = r, f.map = [d, p], f = o.push("admonition_title_open", "p", 1), f.markup = $ + " " + r, f.map = [d, p], f = o.push("inline", "", 0), f.content = u, f.map = [d, o.line - 1], f.children = [], f = o.push("admonition_title_close", "p", -1), f.markup = $ + " " + r, o.md.block.tokenize(o, d + 1, p), f = o.push("admonition_close", "div", -1), f.markup = o.src.slice(g, m), f.block = !0, o.parentType = L, o.lineMax = H, o.line = p + (k ? 1 : 0), !0;
259
264
  },
260
265
  {
261
266
  alt: ["paragraph", "reference", "blockquote", "list"]
262
267
  }
263
268
  ), e.renderer.rules.admonition_open = c, e.renderer.rules.admonition_title_open = c, e.renderer.rules.admonition_title_close = c, e.renderer.rules.admonition_close = c;
264
- }, Ye = Xe, et = (e, a) => {
269
+ }, Ze = Ke, Je = (e, a) => {
265
270
  e.renderer.rules.heading_open = (l, t) => {
266
271
  var u;
267
272
  const n = l[t], i = ((u = l[t + 1].children) == null ? void 0 : u.reduce((c, s) => c + (s.content || ""), "")) || "", r = n.markup.length;
@@ -273,7 +278,7 @@ const Ae = (e, a) => {
273
278
  a.mdHeadingId(i, r, a.headsRef.value.length)
274
279
  )), e.renderer.renderToken(l, t, a);
275
280
  }, e.renderer.rules.heading_close = (l, t, n, i, r) => r.renderToken(l, t, n);
276
- }, tt = et, nt = (e, a) => {
281
+ }, Xe = Je, Qe = (e, a) => {
277
282
  const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
278
283
  function i(s) {
279
284
  return s.info ? t(s.info).trim() : "";
@@ -292,18 +297,18 @@ const Ae = (e, a) => {
292
297
  const [m, p] = r(s[o]);
293
298
  if (m === null)
294
299
  return l(s, o, d, b, v);
295
- let f, k, g, w, E = "", I = "";
296
- for (let $ = o; $ < s.length && (f = s[$], [k, g] = r(f), k === m); $++)
297
- f.info = f.info.replace(n, ""), f.hidden = !0, w = $ - o > 0 ? "" : " checked", E += `<li><input type="radio" name="label-group-${a.editorId}-${o}"${w}><label for="group-${a.editorId}-${o}-tab-${$ - o}" onclick="this.previousElementSibling.click()">${g || u(f)}</label></li>
298
- `, I += `<input type="radio" id="group-${a.editorId}-${o}-tab-${$ - o}" name="group-${a.editorId}-${o}"${w}>
299
- ` + l(s, $, d, b, v);
300
+ let f, k, g, w, E = "", $ = "";
301
+ for (let C = o; C < s.length && (f = s[C], [k, g] = r(f), k === m); C++)
302
+ f.info = f.info.replace(n, ""), f.hidden = !0, w = C - o > 0 ? "" : " checked", E += `<li><input type="radio" name="label-group-${a.editorId}-${o}"${w}><label for="group-${a.editorId}-${o}-tab-${C - o}" onclick="this.previousElementSibling.click()">${g || u(f)}</label></li>
303
+ `, $ += `<input type="radio" id="group-${a.editorId}-${o}-tab-${C - o}" name="group-${a.editorId}-${o}"${w}>
304
+ ` + l(s, C, d, b, v);
300
305
  return `<div class="code-tabs">
301
306
  <ul>
302
307
  ` + E + `</ul>
303
- ` + I + "</div>";
308
+ ` + $ + "</div>";
304
309
  };
305
310
  e.renderer.rules.fence = c;
306
- }, ot = nt, rt = (e) => {
311
+ }, Ye = Qe, et = (e) => {
307
312
  [
308
313
  "paragraph_open",
309
314
  "table_open",
@@ -324,8 +329,8 @@ const Ae = (e, a) => {
324
329
  return t[n].map && t[n].level === 0 && (c = t[n].map[0], t[n].attrSet("data-line", String(c))), u.renderToken(t, n, i);
325
330
  };
326
331
  });
327
- }, at = (e, a) => {
328
- const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = S, i = _("editorId"), r = _("showCodeRowNumber"), u = _("theme"), c = R([]), s = je(e), o = ze(e), { reRenderRef: d, replaceMermaid: b } = De(e), v = Fe({
332
+ }, tt = (e, a) => {
333
+ const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = S, i = P("editorId"), r = P("showCodeRowNumber"), u = P("theme"), c = R([]), s = Oe(e), o = Ue(e), { reRenderRef: d, replaceMermaid: b } = je(e), v = Fe({
329
334
  html: !0,
330
335
  breaks: !0
331
336
  });
@@ -335,17 +340,17 @@ const Ae = (e, a) => {
335
340
  const m = [
336
341
  {
337
342
  type: "katex",
338
- plugin: Qe,
343
+ plugin: qe,
339
344
  options: { katexRef: o }
340
345
  },
341
346
  {
342
347
  type: "image",
343
- plugin: xe,
348
+ plugin: He,
344
349
  options: { figcaption: !0, classes: "md-zoom" }
345
350
  },
346
351
  {
347
352
  type: "admonition",
348
- plugin: Ye,
353
+ plugin: Ze,
349
354
  options: {}
350
355
  },
351
356
  {
@@ -355,75 +360,103 @@ const Ae = (e, a) => {
355
360
  },
356
361
  {
357
362
  type: "heading",
358
- plugin: tt,
363
+ plugin: Xe,
359
364
  options: { mdHeadingId: e.mdHeadingId, headsRef: c }
360
365
  },
361
366
  {
362
367
  type: "codeTabs",
363
- plugin: ot,
368
+ plugin: Ye,
364
369
  options: { editorId: i }
370
+ },
371
+ {
372
+ type: "xss",
373
+ plugin: Re,
374
+ options: {
375
+ // https://github.com/leizongmin/js-xss/blob/master/README.zh.md
376
+ xss($) {
377
+ return {
378
+ whiteList: Object.assign({}, $.getDefaultWhiteList(), {
379
+ // 支持任务列表
380
+ input: ["class", "disabled", "type", "checked"],
381
+ // 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
382
+ iframe: [
383
+ "class",
384
+ "width",
385
+ "height",
386
+ "src",
387
+ "title",
388
+ "border",
389
+ "frameborder",
390
+ "framespacing",
391
+ "allow",
392
+ "allowfullscreen"
393
+ ]
394
+ })
395
+ };
396
+ }
397
+ }
365
398
  }
366
399
  ];
367
400
  e.noMermaid || m.push({
368
401
  type: "mermaid",
369
- plugin: Ke,
402
+ plugin: De,
370
403
  options: { themeRef: u }
371
404
  }), n(m, {
372
405
  editorId: i
373
- }).forEach((I) => {
374
- v.use(I.plugin, I.options);
406
+ }).forEach(($) => {
407
+ v.use($.plugin, $.options);
375
408
  });
376
409
  const p = v.options.highlight;
377
410
  v.set({
378
- highlight: (I, $, L) => {
411
+ highlight: ($, C, L) => {
379
412
  if (p) {
380
- const N = p(I, $, L);
413
+ const N = p($, C, L);
381
414
  if (N)
382
415
  return N;
383
416
  }
384
- let x;
385
- !e.noHighlight && s.value ? s.value.getLanguage($) ? x = s.value.highlight(I, {
386
- language: $,
417
+ let H;
418
+ !e.noHighlight && s.value ? s.value.getLanguage(C) ? H = s.value.highlight($, {
419
+ language: C,
387
420
  ignoreIllegals: !0
388
- }).value : x = s.value.highlightAuto(I).value : x = v.utils.escapeHtml(I);
389
- const fe = r ? Ce(x.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${x.replace(/^\n+|\n+$/g, "")}</span>`;
390
- return `<pre><code class="language-${$}" language=${$}>${fe}</code></pre>`;
421
+ }).value : H = s.value.highlightAuto($).value : H = v.utils.escapeHtml($);
422
+ const fe = r ? $e(H.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${H.replace(/^\n+|\n+$/g, "")}</span>`;
423
+ return `<pre><code class="language-${C}" language=${C}>${fe}</code></pre>`;
391
424
  }
392
- }), rt(v);
393
- const f = R(`_article-key_${j()}`), k = R(e.sanitize(v.render(e.modelValue))), g = () => {
394
- y.emit(i, A, k.value), e.onHtmlChanged(k.value), e.onGetCatalog(c.value), y.emit(i, q, c.value), b();
425
+ }), et(v);
426
+ const f = R(`_article-key_${U()}`), k = R(e.sanitize(v.render(e.modelValue))), g = () => {
427
+ y.emit(i, A, k.value), e.onHtmlChanged(k.value), e.onGetCatalog(c.value), y.emit(i, K, c.value), b();
395
428
  };
396
- P(g);
429
+ _(g);
397
430
  const w = () => {
398
431
  c.value = [], k.value = e.sanitize(v.render(e.modelValue)), g();
399
432
  }, E = F(() => (e.noKatex || o.value) && (e.noHighlight || s.value));
400
- return C(
433
+ return I(
401
434
  [te(e, "modelValue"), E, d],
402
435
  ie(
403
436
  w,
404
437
  (l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
405
438
  )
406
- ), P(() => {
439
+ ), _(() => {
407
440
  y.on(i, {
408
- name: Ie,
441
+ name: Ce,
409
442
  callback() {
410
- y.emit(i, q, c.value);
443
+ y.emit(i, K, c.value);
411
444
  }
412
445
  }), y.on(i, {
413
446
  name: G,
414
447
  callback: () => {
415
- w(), f.value = `_article-key_${j()}`;
448
+ w(), f.value = `_article-key_${U()}`;
416
449
  }
417
450
  });
418
451
  }), { html: k, key: f };
419
- }, lt = at, ce = {
452
+ }, nt = tt, ce = {
420
453
  modelValue: {
421
454
  type: String,
422
455
  default: ""
423
456
  },
424
457
  setting: {
425
458
  type: Object,
426
- default: () => ({})
459
+ default: () => ({ preview: !0 })
427
460
  },
428
461
  onHtmlChanged: {
429
462
  type: Function,
@@ -470,7 +503,7 @@ const Ae = (e, a) => {
470
503
  sanitizeMermaid: {
471
504
  type: Function
472
505
  }
473
- }, $t = {
506
+ }, vt = {
474
507
  ...ce,
475
508
  onChange: {
476
509
  type: Function,
@@ -542,46 +575,44 @@ const Ae = (e, a) => {
542
575
  onInputBoxWitdhChange: {
543
576
  type: Function
544
577
  }
545
- }, it = /* @__PURE__ */ ne({
578
+ }, ot = /* @__PURE__ */ ne({
546
579
  name: "ContentPreview",
547
580
  props: ce,
548
581
  setup(e) {
549
- const a = _("editorId"), l = _("previewTheme"), t = _("showCodeRowNumber"), {
582
+ const a = P("editorId"), l = P("previewTheme"), t = P("showCodeRowNumber"), {
550
583
  html: n,
551
584
  key: i
552
- } = lt(e, e.previewOnly);
553
- return Oe(e, n, i), Be(e, n), () => M(pe, null, [M("div", {
585
+ } = nt(e, e.previewOnly);
586
+ return Ne(e, n, i), Be(e, n), () => M(pe, null, [e.setting.preview && M("div", {
554
587
  id: `${a}-preview-wrapper`,
555
588
  class: `${h}-preview-wrapper`,
556
- "data-show": e.setting.preview,
557
589
  key: "content-preview-wrapper"
558
590
  }, [M("div", {
559
591
  key: i.value,
560
592
  id: `${a}-preview`,
561
593
  class: [`${h}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${h}-scrn`],
562
594
  innerHTML: n.value
563
- }, null)]), !e.previewOnly && M("div", {
595
+ }, null)]), !e.previewOnly && e.setting.htmlPreview && M("div", {
564
596
  id: `${a}-html-wrapper`,
565
597
  class: `${h}-preview-wrapper`,
566
- "data-show": e.setting.htmlPreview,
567
598
  key: "html-preview-wrapper"
568
599
  }, [M("div", {
569
600
  class: `${h}-html`
570
601
  }, [n.value])])]);
571
602
  }
572
- }), Ct = (e, a) => {
603
+ }), bt = (e, a) => {
573
604
  const { editorId: l } = e, t = oe({
574
605
  // 是否已编译成html
575
606
  buildFinished: !1,
576
607
  // 存储当前最新的html
577
608
  html: ""
578
609
  });
579
- C(
610
+ I(
580
611
  () => e.modelValue,
581
612
  () => {
582
613
  t.buildFinished = !1;
583
614
  }
584
- ), P(() => {
615
+ ), _(() => {
585
616
  y.on(l, {
586
617
  name: A,
587
618
  callback(n) {
@@ -610,13 +641,13 @@ const Ae = (e, a) => {
610
641
  }, se = (e) => {
611
642
  var n, i;
612
643
  const { editorId: a } = e, l = (i = (n = S) == null ? void 0 : n.editorExtensions) == null ? void 0 : i.highlight;
613
- H("editorId", a), H(
644
+ x("editorId", a), x(
614
645
  "theme",
615
646
  F(() => e.theme)
616
- ), H(
647
+ ), x(
617
648
  "language",
618
649
  F(() => e.language)
619
- ), H(
650
+ ), x(
620
651
  "highlight",
621
652
  F(() => {
622
653
  const r = {
@@ -628,7 +659,7 @@ const Ae = (e, a) => {
628
659
  css: r[e.codeTheme] ? r[e.codeTheme][u] : V.atom[u]
629
660
  };
630
661
  })
631
- ), H("showCodeRowNumber", e.showCodeRowNumber);
662
+ ), x("showCodeRowNumber", e.showCodeRowNumber);
632
663
  const t = F(() => {
633
664
  var u, c;
634
665
  const r = {
@@ -637,17 +668,17 @@ const Ae = (e, a) => {
637
668
  };
638
669
  return r[e.language] ? r[e.language] : z["zh-CN"];
639
670
  });
640
- H("usedLanguageText", t), H(
671
+ x("usedLanguageText", t), x(
641
672
  "previewTheme",
642
673
  F(() => e.previewTheme)
643
- ), H(
674
+ ), x(
644
675
  "customIcon",
645
676
  F(() => e.customIcon)
646
677
  );
647
- }, It = (e) => {
648
- se(e), H("tabWidth", e.tabWidth);
678
+ }, wt = (e) => {
679
+ se(e), x("tabWidth", e.tabWidth);
649
680
  }, ue = (e) => {
650
- P(() => {
681
+ _(() => {
651
682
  var a, l;
652
683
  if (!e.noIconfont)
653
684
  if (S.iconfontType === "svg") {
@@ -658,29 +689,29 @@ const Ae = (e, a) => {
658
689
  t.rel = "stylesheet", t.href = ((l = S.editorExtensions) == null ? void 0 : l.iconfontClass) || be, t.id = `${h}-icon-class`, T(t);
659
690
  }
660
691
  });
661
- }, St = (e) => {
692
+ }, kt = (e) => {
662
693
  var u, c, s, o, d, b;
663
694
  const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = S, n = a || !!((c = (u = S.editorExtensions) == null ? void 0 : u.prettier) != null && c.prettierInstance), i = a || !!((o = (s = S.editorExtensions) == null ? void 0 : s.prettier) != null && o.parserMarkdownInstance), r = l || !!((b = (d = S.editorExtensions) == null ? void 0 : d.cropper) != null && b.instance);
664
- P(() => {
695
+ _(() => {
665
696
  var k, g, w, E;
666
697
  const v = document.createElement("script"), m = document.createElement("script");
667
698
  v.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || W.main, v.id = `${h}-prettier`, m.src = ((g = t == null ? void 0 : t.prettier) == null ? void 0 : g.parserMarkdownJs) || W.markdown, m.id = `${h}-prettierMD`;
668
699
  const p = document.createElement("link");
669
- p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || K.css, p.id = `${h}-cropperCss`;
700
+ p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || q.css, p.id = `${h}-cropperCss`;
670
701
  const f = document.createElement("script");
671
- f.src = ((E = t == null ? void 0 : t.cropper) == null ? void 0 : E.js) || K.js, f.id = `${h}-cropper`, r || (T(p), T(f)), n || T(v), i || T(m);
702
+ f.src = ((E = t == null ? void 0 : t.cropper) == null ? void 0 : E.js) || q.js, f.id = `${h}-cropper`, r || (T(p), T(f)), n || T(v), i || T(m);
672
703
  }), ue(e);
673
- }, Et = (e, a) => {
704
+ }, $t = (e, a) => {
674
705
  const { editorId: l } = e;
675
- P(() => {
706
+ _(() => {
676
707
  y.on(l, {
677
- name: Se,
708
+ name: Ie,
678
709
  callback: (t) => {
679
710
  e.onError instanceof Function ? e.onError(t) : a.emit("onError", t);
680
711
  }
681
712
  });
682
713
  });
683
- }, Pt = (e, a) => {
714
+ }, Ct = (e, a) => {
684
715
  const { editorId: l } = e, t = oe({
685
716
  pageFullscreen: e.pageFullscreen,
686
717
  fullscreen: !1,
@@ -693,9 +724,9 @@ const Ae = (e, a) => {
693
724
  const r = () => {
694
725
  t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = i;
695
726
  };
696
- return C(() => [t.pageFullscreen, t.fullscreen], r), P(() => {
727
+ return I(() => [t.pageFullscreen, t.fullscreen], r), _(() => {
697
728
  y.on(l, {
698
- name: Ee,
729
+ name: Se,
699
730
  callback(u, c) {
700
731
  const s = (o) => {
701
732
  y.emit(l, le, "image", {
@@ -707,9 +738,9 @@ const Ae = (e, a) => {
707
738
  }
708
739
  }), i = document.body.style.overflow, r();
709
740
  }), [t, n];
710
- }, _t = (e) => {
741
+ }, It = (e) => {
711
742
  const { editorId: a } = e, l = R(!1);
712
- return P(() => {
743
+ return _(() => {
713
744
  y.on(a, {
714
745
  name: ae,
715
746
  callback: (n) => {
@@ -717,29 +748,29 @@ const Ae = (e, a) => {
717
748
  }
718
749
  });
719
750
  }), F(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
720
- }, Tt = (e, a, l, t, n, i) => {
751
+ }, St = (e, a, l, t, n, i) => {
721
752
  const { editorId: r } = e;
722
- C(
753
+ I(
723
754
  () => t.pageFullscreen,
724
755
  (c) => {
725
756
  y.emit(r, Z, c);
726
757
  }
727
- ), C(
758
+ ), I(
728
759
  () => t.fullscreen,
729
760
  (c) => {
730
761
  y.emit(r, J, c);
731
762
  }
732
- ), C(
763
+ ), I(
733
764
  () => t.preview,
734
765
  (c) => {
735
- y.emit(r, Q, c);
766
+ y.emit(r, X, c);
736
767
  }
737
- ), C(
768
+ ), I(
738
769
  () => t.htmlPreview,
739
770
  (c) => {
740
- y.emit(r, X, c);
771
+ y.emit(r, Q, c);
741
772
  }
742
- ), C(l, (c) => {
773
+ ), I(l, (c) => {
743
774
  y.emit(r, Y, c);
744
775
  });
745
776
  const u = {
@@ -765,7 +796,7 @@ const Ae = (e, a) => {
765
796
  }
766
797
  case "preview": {
767
798
  y.on(r, {
768
- name: Q,
799
+ name: X,
769
800
  callback(o) {
770
801
  s(o);
771
802
  }
@@ -774,7 +805,7 @@ const Ae = (e, a) => {
774
805
  }
775
806
  case "htmlPreview": {
776
807
  y.on(r, {
777
- name: X,
808
+ name: Q,
778
809
  callback(o) {
779
810
  s(o);
780
811
  }
@@ -796,7 +827,7 @@ const Ae = (e, a) => {
796
827
  n("pageFullscreen", c);
797
828
  },
798
829
  toggleFullscreen(c) {
799
- y.emit(r, Pe, c);
830
+ y.emit(r, Ee, c);
800
831
  },
801
832
  togglePreview(c) {
802
833
  n("preview", c);
@@ -830,7 +861,7 @@ const Ae = (e, a) => {
830
861
  }
831
862
  };
832
863
  a.expose(u);
833
- }, ct = (e) => e, de = {
864
+ }, rt = (e) => e, de = {
834
865
  /**
835
866
  * markdown content.
836
867
  *
@@ -886,7 +917,7 @@ const Ae = (e, a) => {
886
917
  */
887
918
  editorId: {
888
919
  type: String,
889
- default: we
920
+ default: () => Pe("md-editor-v3_")
890
921
  },
891
922
  /**
892
923
  * 预览中代码是否显示行号
@@ -920,7 +951,7 @@ const Ae = (e, a) => {
920
951
  */
921
952
  mdHeadingId: {
922
953
  type: Function,
923
- default: ct
954
+ default: rt
924
955
  },
925
956
  /**
926
957
  *
@@ -1018,7 +1049,7 @@ const Ae = (e, a) => {
1018
1049
  type: Function,
1019
1050
  default: (e) => Promise.resolve(e)
1020
1051
  }
1021
- }, Ht = {
1052
+ }, Et = {
1022
1053
  ...de,
1023
1054
  /**
1024
1055
  * input回调事件
@@ -1083,7 +1114,7 @@ const Ae = (e, a) => {
1083
1114
  */
1084
1115
  toolbars: {
1085
1116
  type: Array,
1086
- default: ke
1117
+ default: we
1087
1118
  },
1088
1119
  /**
1089
1120
  * 工具栏选择不显示
@@ -1147,7 +1178,7 @@ const Ae = (e, a) => {
1147
1178
  */
1148
1179
  footers: {
1149
1180
  type: Array,
1150
- default: $e
1181
+ default: ke
1151
1182
  },
1152
1183
  /**
1153
1184
  * 是否默认激活输入框和预览框同步滚动
@@ -1270,7 +1301,7 @@ const Ae = (e, a) => {
1270
1301
  onInputBoxWitdhChange: {
1271
1302
  type: Function
1272
1303
  }
1273
- }, me = ["onHtmlChanged", "onGetCatalog"], Ft = [
1304
+ }, me = ["onHtmlChanged", "onGetCatalog"], Pt = [
1274
1305
  ...me,
1275
1306
  "onChange",
1276
1307
  "onSave",
@@ -1282,14 +1313,14 @@ const Ae = (e, a) => {
1282
1313
  "onInput",
1283
1314
  "onDrop",
1284
1315
  "onInputBoxWitdhChange"
1285
- ], st = (e, a) => {
1316
+ ], at = (e, a) => {
1286
1317
  const { editorId: l } = e, t = {
1287
1318
  rerender() {
1288
1319
  y.emit(l, G);
1289
1320
  }
1290
1321
  };
1291
1322
  a.expose(t);
1292
- }, ut = /* @__PURE__ */ ne({
1323
+ }, O = /* @__PURE__ */ ne({
1293
1324
  name: "MdPreview",
1294
1325
  props: de,
1295
1326
  emits: me,
@@ -1300,13 +1331,13 @@ const Ae = (e, a) => {
1300
1331
  noMermaid: n,
1301
1332
  noHighlight: i
1302
1333
  } = e;
1303
- return se(e), ue(e), st(e, a), he(() => {
1334
+ return se(e), ue(e), at(e, a), he(() => {
1304
1335
  y.clear(l);
1305
1336
  }), () => M("div", {
1306
1337
  id: l,
1307
1338
  class: [h, e.class, e.theme === "dark" && `${h}-dark`, `${h}-previewOnly`],
1308
1339
  style: e.style
1309
- }, [M(it, {
1340
+ }, [M(ot, {
1310
1341
  modelValue: e.modelValue,
1311
1342
  onHtmlChanged: (r) => {
1312
1343
  e.onHtmlChanged ? e.onHtmlChanged(r) : a.emit("onHtmlChanged", r);
@@ -1325,19 +1356,19 @@ const Ae = (e, a) => {
1325
1356
  sanitizeMermaid: e.sanitizeMermaid
1326
1357
  }, null)]);
1327
1358
  }
1328
- }), O = ut;
1359
+ });
1329
1360
  O.install = (e) => (e.component(O.name, O), e);
1330
1361
  export {
1331
- it as C,
1362
+ ot as C,
1332
1363
  O as M,
1333
- Ft as a,
1334
- It as b,
1335
- $t as c,
1336
- St as d,
1337
- Ht as e,
1338
- Et as f,
1339
- Pt as g,
1340
- _t as h,
1341
- Tt as i,
1342
- Ct as u
1364
+ Pt as a,
1365
+ wt as b,
1366
+ vt as c,
1367
+ kt as d,
1368
+ Et as e,
1369
+ $t as f,
1370
+ Ct as g,
1371
+ It as h,
1372
+ St as i,
1373
+ bt as u
1343
1374
  };