md-editor-v3 6.3.2-0 → 6.4.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,7 +1,7 @@
1
- import { useId as Fe, provide as T, computed as R, reactive as re, watch as E, onMounted as H, ref as G, inject as w, nextTick as U, shallowRef as ee, onBeforeUnmount as te, toRef as Re, defineComponent as ce, createVNode as N, Fragment as Ae, h as He } from "vue";
1
+ import { useId as Fe, provide as T, computed as R, reactive as re, watch as k, onMounted as H, ref as G, inject as w, nextTick as U, shallowRef as ee, onBeforeUnmount as te, toRef as Re, defineComponent as ce, createVNode as j, Fragment as Ae, h as He } from "vue";
2
2
  import { deepMerge as Me, deepClone as Pe, randomId as le, debounce as Le } from "@vavt/util";
3
3
  import { p as f, g as P, f as ue, s as me, b as Oe, a as _e } from "./config.mjs";
4
- import { b as y, U as je, C as Ee, B as X, O as ke, E as Q, P as fe, F as he, f as pe, g as ge, H as ve, h as ye, R as ie, e as Ne, i as de, d as Be, j as oe, k as De, T as Ve } from "./event-bus.mjs";
4
+ import { b as y, U as Be, C as ke, B as X, O as Ee, E as Q, P as fe, F as he, f as pe, g as ge, H as ve, h as ye, R as ie, e as je, i as de, d as Ne, j as oe, k as De, T as Ve } from "./event-bus.mjs";
5
5
  import { a as O, u as Ge, S as Ue, c as ze, z as We } from "./dom.mjs";
6
6
  import qe from "@vavt/copy2clipboard";
7
7
  import Ke from "markdown-it";
@@ -31,7 +31,7 @@ const M = {
31
31
  // 存储当前最新的html
32
32
  html: ""
33
33
  });
34
- E(
34
+ k(
35
35
  () => e.modelValue,
36
36
  () => {
37
37
  o.buildFinished = !1;
@@ -43,7 +43,7 @@ const M = {
43
43
  o.buildFinished = !0, o.html = u;
44
44
  }
45
45
  }), y.on(n, {
46
- name: ke,
46
+ name: Ee,
47
47
  callback() {
48
48
  const u = new Promise((c) => {
49
49
  if (o.buildFinished)
@@ -212,9 +212,9 @@ const M = {
212
212
  const s = () => {
213
213
  o.pageFullscreen || o.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = m;
214
214
  };
215
- return E(() => [o.pageFullscreen, o.fullscreen], s), H(() => {
215
+ return k(() => [o.pageFullscreen, o.fullscreen], s), H(() => {
216
216
  y.on(n, {
217
- name: je,
217
+ name: Be,
218
218
  callback(l, i) {
219
219
  const a = (d) => {
220
220
  y.emit(n, ie, "image", {
@@ -230,7 +230,7 @@ const M = {
230
230
  const { editorId: r } = t, n = G(!1);
231
231
  return H(() => {
232
232
  y.on(r, {
233
- name: Ee,
233
+ name: ke,
234
234
  callback: (o) => {
235
235
  o === void 0 ? n.value = !n.value : n.value = o;
236
236
  }
@@ -238,32 +238,32 @@ const M = {
238
238
  }), n;
239
239
  }, nn = (e, t, r) => {
240
240
  const { editorId: n, catalogVisible: o, setting: u, updateSetting: c, codeRef: m } = r;
241
- E(
241
+ k(
242
242
  () => u.pageFullscreen,
243
243
  (l) => {
244
244
  y.emit(n, fe, l);
245
245
  }
246
- ), E(
246
+ ), k(
247
247
  () => u.fullscreen,
248
248
  (l) => {
249
249
  y.emit(n, he, l);
250
250
  }
251
- ), E(
251
+ ), k(
252
252
  () => u.preview,
253
253
  (l) => {
254
254
  y.emit(n, pe, l);
255
255
  }
256
- ), E(
256
+ ), k(
257
257
  () => u.previewOnly,
258
258
  (l) => {
259
259
  y.emit(n, ge, l);
260
260
  }
261
- ), E(
261
+ ), k(
262
262
  () => u.htmlPreview,
263
263
  (l) => {
264
264
  y.emit(n, ve, l);
265
265
  }
266
- ), E(o, (l) => {
266
+ ), k(o, (l) => {
267
267
  y.emit(n, ye, l);
268
268
  });
269
269
  const s = {
@@ -329,7 +329,7 @@ const M = {
329
329
  c("pageFullscreen", l);
330
330
  },
331
331
  toggleFullscreen(l) {
332
- y.emit(n, Be, l);
332
+ y.emit(n, Ne, l);
333
333
  },
334
334
  togglePreview(l) {
335
335
  c("preview", l);
@@ -341,10 +341,10 @@ const M = {
341
341
  c("htmlPreview", l);
342
342
  },
343
343
  toggleCatalog(l) {
344
- y.emit(n, Ee, l);
344
+ y.emit(n, ke, l);
345
345
  },
346
346
  triggerSave() {
347
- y.emit(n, ke);
347
+ y.emit(n, Ee);
348
348
  },
349
349
  insert(l) {
350
350
  y.emit(n, ie, "universal", { generate: l });
@@ -362,7 +362,7 @@ const M = {
362
362
  m.value?.resetHistory();
363
363
  },
364
364
  domEventHandlers(l) {
365
- y.emit(n, Ne, l);
365
+ y.emit(n, je, l);
366
366
  },
367
367
  execCommand(l) {
368
368
  y.emit(n, ie, l);
@@ -400,14 +400,14 @@ const M = {
400
400
  }, l = (i) => {
401
401
  i && U(m);
402
402
  };
403
- E([t, r], s), E(() => c.value.preview, l), E(() => c.value.htmlPreview, l), H(m);
403
+ k([t, r], s), k(() => c.value.preview, l), k(() => c.value.htmlPreview, l), H(m);
404
404
  }, ot = (e) => {
405
405
  const t = w("editorId"), r = w("theme"), n = w("rootRef"), { editorExtensions: o, editorExtensionsAttrs: u } = P;
406
406
  let c = o.echarts.instance;
407
407
  const m = ee(-1), s = () => {
408
408
  !e.noEcharts && c && (m.value = m.value + 1);
409
409
  };
410
- E(
410
+ k(
411
411
  () => r.value,
412
412
  () => {
413
413
  s();
@@ -493,7 +493,7 @@ const M = {
493
493
  },
494
494
  "hljs"
495
495
  ));
496
- }), E(
496
+ }), k(
497
497
  () => t.value.css,
498
498
  () => {
499
499
  e.noHighlight || P.editorExtensions.highlight.instance || Ge("link", {
@@ -535,14 +535,30 @@ const M = {
535
535
  const t = w("editorId"), r = w("theme"), n = w("rootRef"), { editorExtensions: o, editorExtensionsAttrs: u, mermaidConfig: c } = P;
536
536
  let m = o.mermaid.instance;
537
537
  const s = ee(-1), l = () => {
538
- !e.noMermaid && m && (m.initialize(
539
- c({
538
+ if (!e.noMermaid && m) {
539
+ const a = r.value === "dark" ? {
540
540
  startOnLoad: !1,
541
- theme: r.value === "dark" ? "dark" : "default"
542
- })
543
- ), s.value = s.value + 1);
541
+ theme: "dark"
542
+ } : {
543
+ startOnLoad: !1,
544
+ theme: "base",
545
+ themeVariables: {
546
+ background: "#ffffff",
547
+ primaryColor: "#ffffff",
548
+ primaryTextColor: "#1f2329",
549
+ primaryBorderColor: "#b7c0cc",
550
+ secondaryColor: "#f7f8fa",
551
+ tertiaryColor: "#f7f8fa",
552
+ lineColor: "#596273",
553
+ edgeLabelBackground: "#ffffff",
554
+ clusterBkg: "#ffffff",
555
+ clusterBorder: "#b7c0cc"
556
+ }
557
+ };
558
+ m.initialize(c(a)), s.value = s.value + 1;
559
+ }
544
560
  };
545
- return E(
561
+ return k(
546
562
  () => r.value,
547
563
  () => {
548
564
  Y.clear(), l();
@@ -681,10 +697,10 @@ const M = {
681
697
  return "";
682
698
  const g = t.usedLanguageTextRef.value?.copyCode.text, I = t.customIconRef.value.copy || g, v = !!t.customIconRef.value.copy, C = `<span class="${f}-collapse-tips">${Ue("collapse-tips", t.customIconRef.value)}</span>`, [x] = m(a[d]);
683
699
  if (x === null) {
684
- const { open: k, tagContainer: A, tagHeader: J } = l(a[d]), j = [["class", `${f}-code`]];
685
- k && j.push(["open", ""]);
700
+ const { open: E, tagContainer: A, tagHeader: J } = l(a[d]), B = [["class", `${f}-code`]];
701
+ E && B.push(["open", ""]);
686
702
  const ne = {
687
- attrs: se(a[d], j)
703
+ attrs: se(a[d], B)
688
704
  };
689
705
  a[d].info = a[d].info.replace(u, "");
690
706
  const W = r(a, d, $, h, p);
@@ -703,31 +719,31 @@ const M = {
703
719
  </${A}>
704
720
  `;
705
721
  }
706
- let b, F, S, L, _ = "", B = "", D = "";
722
+ let b, F, S, L, _ = "", N = "", D = "";
707
723
  const { open: q, tagContainer: V, tagHeader: z } = l(a[d]), K = [["class", `${f}-code`]];
708
724
  q && K.push(["open", ""]);
709
725
  const Z = {
710
726
  attrs: se(a[d], K)
711
727
  };
712
- for (let k = d; k < a.length && (b = a[k], [F, S] = m(b), F === x); k++) {
728
+ for (let E = d; E < a.length && (b = a[E], [F, S] = m(b), F === x); E++) {
713
729
  b.info = b.info.replace(o, "").replace(u, ""), b.hidden = !0;
714
- const A = `${f}-codetab-${t.editorId}-${d}-${k - d}`;
715
- L = k - d > 0 ? "" : "checked", _ += `
730
+ const A = `${f}-codetab-${t.editorId}-${d}-${E - d}`;
731
+ L = E - d > 0 ? "" : "checked", _ += `
716
732
  <li>
717
733
  <input
718
734
  type="radio"
719
- id="label-${f}-codetab-label-1-${t.editorId}-${d}-${k - d}"
735
+ id="label-${f}-codetab-label-1-${t.editorId}-${d}-${E - d}"
720
736
  name="${f}-codetab-label-${t.editorId}-${d}"
721
737
  class="${A}"
722
738
  ${L}
723
739
  >
724
740
  <label
725
- for="label-${f}-codetab-label-1-${t.editorId}-${d}-${k - d}"
741
+ for="label-${f}-codetab-label-1-${t.editorId}-${d}-${E - d}"
726
742
  onclick="this.getRootNode().querySelectorAll('.${A}').forEach(e => e.click())"
727
743
  >
728
744
  ${e.utils.escapeHtml(S || s(b))}
729
745
  </label>
730
- </li>`, B += `
746
+ </li>`, N += `
731
747
  <div role="tabpanel">
732
748
  <input
733
749
  type="radio"
@@ -735,7 +751,7 @@ const M = {
735
751
  class="${A}"
736
752
  ${L}
737
753
  role="presentation">
738
- ${r(a, k, $, h, p)}
754
+ ${r(a, E, $, h, p)}
739
755
  </div>`, D += `
740
756
  <input
741
757
  type="radio"
@@ -758,7 +774,7 @@ const M = {
758
774
  ${V === "details" ? C : ""}
759
775
  </div>
760
776
  </${z}>
761
- ${B}
777
+ ${N}
762
778
  </${V}>
763
779
  `;
764
780
  };
@@ -932,18 +948,18 @@ const M = {
932
948
  }, Ct = (e) => {
933
949
  const t = new e("html_inline", "", 0);
934
950
  return t.content = "</label>", t;
935
- }, Et = (e, t, r) => {
951
+ }, kt = (e, t, r) => {
936
952
  const n = new r("html_inline", "", 0);
937
953
  return n.content = '<label class="task-list-item-label" for="' + t + '">' + e + "</label>", n.attrs = [["for", t]], n;
938
- }, kt = (e, t, r) => {
954
+ }, Et = (e, t, r) => {
939
955
  const n = new t("html_inline", "", 0), o = r.enabled ? " " : ' disabled="" ';
940
956
  return e.content.indexOf("[ ] ") === 0 ? n.content = '<input class="task-list-item-checkbox"' + o + 'type="checkbox">' : (e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0) && (n.content = '<input class="task-list-item-checkbox" checked=""' + o + 'type="checkbox">'), n;
941
957
  }, Tt = (e, t, r) => {
942
- if (e.children = e.children || [], e.children.unshift(kt(e, t, r)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), r.label)
958
+ if (e.children = e.children || [], e.children.unshift(Et(e, t, r)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), r.label)
943
959
  if (r.labelAfter) {
944
960
  e.children.pop();
945
961
  const n = "task-item-" + Math.ceil(Math.random() * (1e4 * 1e3) - 1e3);
946
- e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + n + '">', e.children.push(Et(e.content, n, t));
962
+ e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + n + '">', e.children.push(kt(e.content, n, t));
947
963
  } else
948
964
  e.children.unshift(wt(t)), e.children.push(Ct(t));
949
965
  }, It = (e, t = {}) => {
@@ -1029,26 +1045,26 @@ const M = {
1029
1045
  options: { themeRef: i }
1030
1046
  }), o(F, {
1031
1047
  editorId: c
1032
- }).forEach((k) => {
1033
- b.use(k.plugin, k.options);
1048
+ }).forEach((E) => {
1049
+ b.use(E.plugin, E.options);
1034
1050
  });
1035
1051
  const S = b.options.highlight;
1036
1052
  b.set({
1037
- highlight: (k, A, J) => {
1053
+ highlight: (E, A, J) => {
1038
1054
  if (S) {
1039
- const W = S(k, A, J);
1055
+ const W = S(E, A, J);
1040
1056
  if (W)
1041
1057
  return W;
1042
1058
  }
1043
- let j;
1044
- !e.noHighlight && p.value ? p.value.getLanguage(A) ? j = p.value.highlight(k, {
1059
+ let B;
1060
+ !e.noHighlight && p.value ? p.value.getLanguage(A) ? B = p.value.highlight(E, {
1045
1061
  language: A,
1046
1062
  ignoreIllegals: !0
1047
- }).value : j = p.value.highlightAuto(k).value : j = b.utils.escapeHtml(k);
1063
+ }).value : B = p.value.highlightAuto(E).value : B = b.utils.escapeHtml(E);
1048
1064
  const ne = l ? Ye(
1049
- j.replace(/^\n+|\n+$/g, ""),
1050
- k.replace(/^\n+|\n+$/g, "")
1051
- ) : `<span class="${f}-code-block">${j.replace(/^\n+|\n+$/g, "")}</span>`;
1065
+ B.replace(/^\n+|\n+$/g, ""),
1066
+ E.replace(/^\n+|\n+$/g, "")
1067
+ ) : `<span class="${f}-code-block">${B.replace(/^\n+|\n+$/g, "")}</span>`;
1052
1068
  return `<pre><code class="language-${A}" language=${A}>${ne}</code></pre>`;
1053
1069
  }
1054
1070
  }), St(b);
@@ -1060,16 +1076,16 @@ const M = {
1060
1076
  })
1061
1077
  )
1062
1078
  );
1063
- let B = () => {
1079
+ let N = () => {
1064
1080
  }, D = () => {
1065
1081
  };
1066
1082
  const q = () => {
1067
- const k = d.value?.querySelectorAll(
1083
+ const E = d.value?.querySelectorAll(
1068
1084
  `#${c} p.${f}-mermaid:not([data-closed=false])`
1069
1085
  );
1070
- D(), D = ze(k, {
1086
+ D(), D = ze(E, {
1071
1087
  customIcon: a.value
1072
- }), u.mermaid?.enableZoom && (B(), B = We(k, {
1088
+ }), u.mermaid?.enableZoom && (N(), N = We(E, {
1073
1089
  customIcon: a.value
1074
1090
  }));
1075
1091
  }, V = () => {
@@ -1085,21 +1101,21 @@ const M = {
1085
1101
  );
1086
1102
  }, K = R(() => (e.noKatex || !!g.value) && (e.noHighlight || !!p.value));
1087
1103
  let Z = -1;
1088
- return E([Re(e, "modelValue"), K, I, m], () => {
1104
+ return k([Re(e, "modelValue"), K, I, m], () => {
1089
1105
  Z = window.setTimeout(
1090
1106
  () => {
1091
1107
  z();
1092
1108
  },
1093
1109
  t ? 0 : r.renderDelay
1094
1110
  );
1095
- }), E(
1111
+ }), k(
1096
1112
  () => $.value.preview,
1097
1113
  () => {
1098
1114
  $.value.preview && U(() => {
1099
1115
  v().then(q), x(), y.emit(c, oe, h.value);
1100
1116
  });
1101
1117
  }
1102
- ), E([_, C], () => {
1118
+ ), k([_, C], () => {
1103
1119
  V();
1104
1120
  }), H(V), H(() => {
1105
1121
  y.on(c, {
@@ -1114,7 +1130,7 @@ const M = {
1114
1130
  }
1115
1131
  });
1116
1132
  }), te(() => {
1117
- B(), D(), clearTimeout(Z);
1133
+ N(), D(), clearTimeout(Z);
1118
1134
  }), { html: _, key: L };
1119
1135
  }, Ft = (e, t) => {
1120
1136
  const r = w("editorId"), n = w("setting"), { noImgZoomIn: o } = e, u = Le(() => {
@@ -1127,7 +1143,7 @@ const M = {
1127
1143
  });
1128
1144
  H(async () => {
1129
1145
  !o && n.value.preview && await u();
1130
- }), E([t, () => n.value.preview], async () => {
1146
+ }), k([t, () => n.value.preview], async () => {
1131
1147
  !o && n.value.preview && await u();
1132
1148
  });
1133
1149
  }, we = {
@@ -1169,7 +1185,7 @@ const M = {
1169
1185
  };
1170
1186
  te(() => {
1171
1187
  o();
1172
- }), E(
1188
+ }), k(
1173
1189
  [t],
1174
1190
  () => {
1175
1191
  o(), U(u);
@@ -1186,7 +1202,7 @@ const M = {
1186
1202
  }, u = (c) => {
1187
1203
  c && o();
1188
1204
  };
1189
- E([t, r], o), E(() => n.value.preview, u), E(() => n.value.htmlPreview, u), H(o);
1205
+ k([t, r], o), k(() => n.value.preview, u), k(() => n.value.htmlPreview, u), H(o);
1190
1206
  }, Ie = {
1191
1207
  modelValue: {
1192
1208
  type: String,
@@ -1369,10 +1385,10 @@ const M = {
1369
1385
  for (let a = l; a < o.length; a++)
1370
1386
  c.appendChild(o[a].cloneNode(!0));
1371
1387
  };
1372
- return E(() => e.html, (o, u) => {
1388
+ return k(() => e.html, (o, u) => {
1373
1389
  const c = Ce(o), m = Ce(u || "");
1374
1390
  n(c, m);
1375
- }), () => N("div", {
1391
+ }), () => j("div", {
1376
1392
  id: e.id,
1377
1393
  class: e.class,
1378
1394
  innerHTML: r,
@@ -1395,22 +1411,22 @@ const M = {
1395
1411
  html: u.value,
1396
1412
  id: l,
1397
1413
  class: m.value
1398
- }) : N(Mt, {
1414
+ }) : j(Mt, {
1399
1415
  key: c.value,
1400
1416
  html: u.value,
1401
1417
  id: l,
1402
1418
  class: m.value
1403
1419
  }, null);
1404
1420
  };
1405
- return () => N(Ae, null, [r.value.preview && (e.previewOnly ? s() : N("div", {
1421
+ return () => j(Ae, null, [r.value.preview && (e.previewOnly ? s() : j("div", {
1406
1422
  id: `${t}-preview-wrapper`,
1407
1423
  class: `${f}-preview-wrapper`,
1408
1424
  key: "content-preview-wrapper"
1409
- }, [s()])), r.value.htmlPreview && N("div", {
1425
+ }, [s()])), r.value.htmlPreview && j("div", {
1410
1426
  id: `${t}-html-wrapper`,
1411
1427
  class: `${f}-preview-wrapper`,
1412
1428
  key: "html-preview-wrapper"
1413
- }, [N("div", {
1429
+ }, [j("div", {
1414
1430
  class: `${f}-html`
1415
1431
  }, [u.value])])]);
1416
1432
  }
@@ -2008,12 +2024,12 @@ const M = {
2008
2024
  }, i = () => {
2009
2025
  e.onRemount?.(), t.emit("onRemount");
2010
2026
  };
2011
- return () => N("div", {
2027
+ return () => j("div", {
2012
2028
  id: c,
2013
2029
  class: [f, e.class, e.theme === "dark" && `${f}-dark`, `${f}-previewOnly`],
2014
2030
  style: e.style,
2015
2031
  ref: u
2016
- }, [N(Pt, {
2032
+ }, [j(Pt, {
2017
2033
  modelValue: e.modelValue,
2018
2034
  onChange: m,
2019
2035
  onHtmlChanged: s,