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,9 +1,9 @@
1
1
  var Ft = Object.defineProperty;
2
2
  var Rt = (e, o, l) => o in e ? Ft(e, o, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[o] = l;
3
- var q = (e, o, l) => (Rt(e, typeof o != "symbol" ? o + "" : o, l), l);
4
- import { defineComponent as P, createVNode as t, inject as A, ref as U, onMounted as Y, reactive as G, computed as we, watch as H, nextTick as ve, Fragment as Lt, cloneVNode as gt, toRef as te, shallowRef as Pt, onBeforeUnmount as It } from "vue";
5
- import { p as n, e as Q, n as Wt, b as Ut, M as ge, d as _t } from "./chunks/config.mjs";
6
- import { draggingScroll as qt, linkTo as zt, debounce as Gt, createSmoothScroll as Kt, throttle as jt } from "@vavt/util";
3
+ var _ = (e, o, l) => (Rt(e, typeof o != "symbol" ? o + "" : o, l), l);
4
+ import { defineComponent as P, createVNode as t, inject as A, ref as z, onMounted as Y, reactive as G, computed as we, watch as H, nextTick as ve, Fragment as Lt, cloneVNode as gt, toRef as te, shallowRef as Pt, onBeforeUnmount as It } from "vue";
5
+ import { p as n, e as Q, n as Wt, b as zt, M as ge, d as Ut } from "./chunks/config.mjs";
6
+ import { draggingScroll as _t, linkTo as qt, debounce as Gt, createSmoothScroll as Kt, throttle as jt } from "@vavt/util";
7
7
  import { a as se, D as Zt } from "./chunks/index2.mjs";
8
8
  import { b as v, h as Xt, E as le, U as xe, i as Yt, j as Te, R as x, c as Jt, O as Dt, k as Et, l as Ht, T as Qt } from "./chunks/index4.mjs";
9
9
  import { a as el } from "./chunks/dom.mjs";
@@ -12,7 +12,7 @@ import { minimalSetup as tl, EditorView as fe } from "codemirror";
12
12
  import { EditorView as Se, placeholder as ll, keymap as ol } from "@codemirror/view";
13
13
  import { languages as al } from "@codemirror/language-data";
14
14
  import { markdown as nl } from "@codemirror/lang-markdown";
15
- import { EditorSelection as z, EditorState as Ce, Compartment as be, StateEffect as il } from "@codemirror/state";
15
+ import { EditorSelection as q, EditorState as Ce, Compartment as be, StateEffect as il } from "@codemirror/state";
16
16
  import { deleteLine as rl, indentWithTab as sl, undo as cl, redo as ul } from "@codemirror/commands";
17
17
  import { HighlightStyle as Bt, syntaxHighlighting as Ot, indentUnit as dl } from "@codemirror/language";
18
18
  import { tags as c } from "@lezer/highlight";
@@ -87,7 +87,7 @@ const Al = /* @__PURE__ */ P({
87
87
  var u, s, h, w;
88
88
  const o = A("editorId");
89
89
  let l = (s = (u = Q.editorExtensions) == null ? void 0 : u.screenfull) == null ? void 0 : s.instance;
90
- const a = (w = (h = Q.editorExtensions) == null ? void 0 : h.screenfull) == null ? void 0 : w.js, i = U(!1), r = (C) => {
90
+ const a = (w = (h = Q.editorExtensions) == null ? void 0 : h.screenfull) == null ? void 0 : w.js, i = z(!1), r = (C) => {
91
91
  if (!l) {
92
92
  v.emit(o, le, {
93
93
  name: "fullscreen",
@@ -263,7 +263,7 @@ const Al = /* @__PURE__ */ P({
263
263
  var h, w, C;
264
264
  const o = A("usedLanguageText"), l = A("editorId");
265
265
  let a = (C = (w = (h = Q) == null ? void 0 : h.editorExtensions) == null ? void 0 : w.cropper) == null ? void 0 : C.instance;
266
- const i = U(), r = U(), m = U(), g = G({
266
+ const i = z(), r = z(), m = z(), g = G({
267
267
  cropperInited: !1,
268
268
  imgSelected: !1,
269
269
  imgSrc: "",
@@ -422,7 +422,7 @@ const Al = /* @__PURE__ */ P({
422
422
  setup(e) {
423
423
  const o = A("editorId"), l = A("usedLanguageText"), a = A("theme"), i = A("language"), {
424
424
  fullscreenHandler: r
425
- } = Ll(e), m = `${o}-toolbar-wrapper`, g = U(), u = G({
425
+ } = Ll(e), m = `${o}-toolbar-wrapper`, g = z(), u = G({
426
426
  title: !1,
427
427
  catalog: !1,
428
428
  // 图片上传下拉
@@ -438,7 +438,7 @@ const Al = /* @__PURE__ */ P({
438
438
  type: "link",
439
439
  linkVisible: !1,
440
440
  clipVisible: !1
441
- }), w = U();
441
+ }), w = z();
442
442
  Y(() => {
443
443
  v.on(o, {
444
444
  name: Te,
@@ -450,15 +450,15 @@ const Al = /* @__PURE__ */ P({
450
450
  const C = we(() => {
451
451
  const b = e.toolbars.filter((I) => !e.toolbarsExclude.includes(I)), $ = b.indexOf("="), T = $ === -1 ? b : b.slice(0, $ + 1), S = $ === -1 ? [] : b.slice($, Number.MAX_SAFE_INTEGER);
452
452
  return [T, S];
453
- }), d = U(), k = () => {
453
+ }), d = z(), k = () => {
454
454
  v.emit(o, xe, Array.from(d.value.files || [])), d.value.value = "";
455
455
  };
456
456
  Y(() => {
457
457
  d.value.addEventListener("change", k);
458
458
  });
459
459
  const f = (b) => {
460
- var $, T, S, I, D, oe, ae, M, L, _, W, O, N, B, V, K, j, de, ne, J, Z, ie, X, F, R, re, me, Ae, Me, Le, Ie, De, Ee, He, Ne, Be, Oe, Ve, Fe, Re, Pe, We, Ue, _e, qe, ze, Ge, Ke, je, Ze, Xe, Ye, Je, Qe, et, tt, lt, ot, at, nt, it, rt, st, ct, ut, dt, mt;
461
- if (Ut.includes(b))
460
+ var $, T, S, I, D, oe, ae, M, L, U, W, O, N, B, V, K, j, de, ne, J, Z, ie, X, F, R, re, me, Ae, Me, Le, Ie, De, Ee, He, Ne, Be, Oe, Ve, Fe, Re, Pe, We, ze, Ue, _e, qe, Ge, Ke, je, Ze, Xe, Ye, Je, Qe, et, tt, lt, ot, at, nt, it, rt, st, ct, ut, dt, mt;
461
+ if (zt.includes(b))
462
462
  switch (b) {
463
463
  case "-":
464
464
  return t(Al, null, null);
@@ -532,7 +532,7 @@ const Al = /* @__PURE__ */ P({
532
532
  onClick: () => {
533
533
  s("h2");
534
534
  }
535
- }, [(_ = l.value.titleItem) == null ? void 0 : _.h2]), t("li", {
535
+ }, [(U = l.value.titleItem) == null ? void 0 : U.h2]), t("li", {
536
536
  class: `${n}-menu-item ${n}-menu-item-title`,
537
537
  onClick: () => {
538
538
  s("h3");
@@ -789,11 +789,11 @@ const Al = /* @__PURE__ */ P({
789
789
  name: "baocun"
790
790
  }, null), e.showToolbarName && t("div", {
791
791
  class: `${n}-toolbar-item-name`
792
- }, [(Ue = l.value.toolbarTips) == null ? void 0 : Ue.save])]);
792
+ }, [(ze = l.value.toolbarTips) == null ? void 0 : ze.save])]);
793
793
  case "prettier":
794
794
  return e.noPrettier ? "" : t("div", {
795
795
  class: `${n}-toolbar-item`,
796
- title: (_e = l.value.toolbarTips) == null ? void 0 : _e.prettier,
796
+ title: (Ue = l.value.toolbarTips) == null ? void 0 : Ue.prettier,
797
797
  onClick: () => {
798
798
  s("prettier");
799
799
  }
@@ -801,11 +801,11 @@ const Al = /* @__PURE__ */ P({
801
801
  name: "prettier"
802
802
  }, null), e.showToolbarName && t("div", {
803
803
  class: `${n}-toolbar-item-name`
804
- }, [(qe = l.value.toolbarTips) == null ? void 0 : qe.prettier])]);
804
+ }, [(_e = l.value.toolbarTips) == null ? void 0 : _e.prettier])]);
805
805
  case "pageFullscreen":
806
806
  return !e.setting.fullscreen && t("div", {
807
807
  class: `${n}-toolbar-item`,
808
- title: (ze = l.value.toolbarTips) == null ? void 0 : ze.pageFullscreen,
808
+ title: (qe = l.value.toolbarTips) == null ? void 0 : qe.pageFullscreen,
809
809
  onClick: () => {
810
810
  e.updateSetting("pageFullscreen");
811
811
  }
@@ -867,7 +867,7 @@ const Al = /* @__PURE__ */ P({
867
867
  return t("div", {
868
868
  class: `${n}-toolbar-item`,
869
869
  title: (tt = l.value.toolbarTips) == null ? void 0 : tt.github,
870
- onClick: () => zt("https://github.com/imzbf/md-editor-v3")
870
+ onClick: () => qt("https://github.com/imzbf/md-editor-v3")
871
871
  }, [t(y, {
872
872
  name: "github"
873
873
  }, null), e.showToolbarName && t("div", {
@@ -1005,7 +1005,7 @@ const Al = /* @__PURE__ */ P({
1005
1005
  };
1006
1006
  return H(() => e.toolbars, () => {
1007
1007
  ve(() => {
1008
- g.value && qt(g.value);
1008
+ g.value && _t(g.value);
1009
1009
  });
1010
1010
  }, {
1011
1011
  immediate: !0
@@ -1099,11 +1099,11 @@ const Al = /* @__PURE__ */ P({
1099
1099
  return;
1100
1100
  s++;
1101
1101
  const M = g[k - 1];
1102
- let L = r(M.end) + m(M.end), _ = 0;
1102
+ let L = r(M.end) + m(M.end), U = 0;
1103
1103
  const W = r(M.start), O = o.querySelector(`[data-line="${M.start - 1}"]`) || ((T = o.firstElementChild) == null ? void 0 : T.firstElementChild), N = o.querySelector(`[data-line="${M.end}"]`) || ((S = o.lastElementChild) == null ? void 0 : S.lastElementChild);
1104
1104
  let B = 0, V = 0;
1105
- W === 0 ? O === N ? (f = 0, L = a.contentDOM.offsetHeight - a.scrollDOM.offsetHeight, _ = a.scrollDOM.scrollTop / L, B = N.offsetTop + N.offsetHeight - o.clientHeight) : (_ = a.scrollDOM.scrollTop / L, B = N.offsetTop) : L > a.scrollDOM.scrollHeight - a.scrollDOM.clientHeight ? (_ = (a.scrollDOM.scrollTop - W) / (a.scrollDOM.scrollHeight - a.scrollDOM.clientHeight - W), V = O.offsetTop, B = o.scrollHeight - o.clientHeight - V + 10) : (_ = (a.scrollDOM.scrollTop - W) / (L - W), V = O.offsetTop, B = N.offsetTop - V);
1106
- const K = V - f + B * _;
1105
+ W === 0 ? O === N ? (f = 0, L = a.contentDOM.offsetHeight - a.scrollDOM.offsetHeight, U = a.scrollDOM.scrollTop / L, B = N.offsetTop + N.offsetHeight - o.clientHeight) : (U = a.scrollDOM.scrollTop / L, B = N.offsetTop) : L > a.scrollDOM.scrollHeight - a.scrollDOM.clientHeight ? (U = (a.scrollDOM.scrollTop - W) / (a.scrollDOM.scrollHeight - a.scrollDOM.clientHeight - W), V = O.offsetTop, B = o.scrollHeight - o.clientHeight - V + 10) : (U = (a.scrollDOM.scrollTop - W) / (L - W), V = O.offsetTop, B = N.offsetTop - V);
1106
+ const K = V - f + B * U;
1107
1107
  i(o, K, () => {
1108
1108
  s--;
1109
1109
  });
@@ -1113,9 +1113,9 @@ const Al = /* @__PURE__ */ P({
1113
1113
  h++;
1114
1114
  const M = Array.from(
1115
1115
  o.querySelectorAll("[data-line]")
1116
- ), L = o.scrollTop, _ = o.scrollHeight;
1116
+ ), L = o.scrollTop, U = o.scrollHeight;
1117
1117
  let W = M.length === 0 ? 1 : Math.ceil(
1118
- Number(M[M.length - 1].dataset.line) * (L / _)
1118
+ Number(M[M.length - 1].dataset.line) * (L / U)
1119
1119
  ), O = (I = o.firstElementChild) == null ? void 0 : I.firstElementChild;
1120
1120
  for (let F = W; F >= 0; F--) {
1121
1121
  const R = o.querySelector(`[data-line="${F}"]`);
@@ -1175,7 +1175,7 @@ const Al = /* @__PURE__ */ P({
1175
1175
  g = [], e.removeEventListener("scroll", w), o.removeEventListener("scroll", w);
1176
1176
  }
1177
1177
  ];
1178
- }, Ul = (e, o, l) => {
1178
+ }, zl = (e, o, l) => {
1179
1179
  const a = A("editorId");
1180
1180
  let i = () => {
1181
1181
  }, r = () => {
@@ -1212,7 +1212,7 @@ const Al = /* @__PURE__ */ P({
1212
1212
  g ? r() : i();
1213
1213
  }
1214
1214
  ), Y(m);
1215
- }, _l = Ul, ql = (e, o, l) => {
1215
+ }, Ul = zl, _l = (e, o, l) => {
1216
1216
  var h, w, C, d, k, f;
1217
1217
  let a = "", i = 0, r = 0, m = !0, g = !1;
1218
1218
  const u = o.getSelectedText(), s = (h = Q.editorConfig) == null ? void 0 : h.mermaidTemplate;
@@ -1424,7 +1424,7 @@ $$
1424
1424
  replaceAll: g
1425
1425
  }
1426
1426
  };
1427
- }, zl = "#e5c07b", ht = "var(--md-color)", Gl = "#56b6c2", Kl = "#ffffff", ce = "var(--md-color)", bt = "#e5c07b", jl = "#e5c07b", Zl = "var(--md-color)", vt = "#d19a66", Xl = "#c678dd", Yl = "#21252b", Jl = "#2c313a", kt = "var(--md-bk-color)", $e = "var(--md-bk-color)", Ql = "#ceedfa33", Ct = "#528bff", eo = Se.theme(
1427
+ }, ql = "#e5c07b", ht = "var(--md-color)", Gl = "#56b6c2", Kl = "#ffffff", ce = "var(--md-color)", bt = "#e5c07b", jl = "#e5c07b", Zl = "var(--md-color)", vt = "#d19a66", Xl = "#c678dd", Yl = "#21252b", Jl = "#2c313a", kt = "var(--md-bk-color)", $e = "var(--md-bk-color)", Ql = "#ceedfa33", Ct = "#528bff", eo = Se.theme(
1428
1428
  {
1429
1429
  "&": {
1430
1430
  color: ce,
@@ -1500,7 +1500,7 @@ $$
1500
1500
  c.self,
1501
1501
  c.namespace
1502
1502
  ],
1503
- color: zl
1503
+ color: ql
1504
1504
  },
1505
1505
  {
1506
1506
  tag: [
@@ -1633,13 +1633,13 @@ $$
1633
1633
  r.dispatch(r.state.replaceSelection(`${s}${l}${a}`));
1634
1634
  const h = g + m.label.length + (i === "title" ? l.length : 0);
1635
1635
  r.dispatch({
1636
- selection: z.create(
1636
+ selection: q.create(
1637
1637
  [
1638
- z.range(
1638
+ q.range(
1639
1639
  g + m.label.length + (i === "title" ? 1 : -o.length),
1640
1640
  h
1641
1641
  ),
1642
- z.cursor(h)
1642
+ q.cursor(h)
1643
1643
  ],
1644
1644
  1
1645
1645
  )
@@ -1754,18 +1754,18 @@ $$`, "title")
1754
1754
  };
1755
1755
  class ho {
1756
1756
  constructor(o) {
1757
- q(this, "view");
1758
- q(this, "maxLength", Number.MAX_SAFE_INTEGER);
1757
+ _(this, "view");
1758
+ _(this, "maxLength", Number.MAX_SAFE_INTEGER);
1759
1759
  // 切换tabSize的执行方法。切换时,Compartment实例需要相同
1760
- q(this, "toggleTabSize");
1761
- q(this, "togglePlaceholder");
1760
+ _(this, "toggleTabSize");
1761
+ _(this, "togglePlaceholder");
1762
1762
  /**
1763
1763
  * 设置全部的扩展
1764
1764
  */
1765
- q(this, "setExtensions");
1766
- q(this, "toggleDisabled");
1767
- q(this, "toggleReadOnly");
1768
- q(this, "toggleMaxlength");
1765
+ _(this, "setExtensions");
1766
+ _(this, "toggleDisabled");
1767
+ _(this, "toggleReadOnly");
1768
+ _(this, "toggleMaxlength");
1769
1769
  this.view = o, this.toggleTabSize = ee(this.view), this.togglePlaceholder = ee(this.view), this.setExtensions = ee(this.view), this.toggleDisabled = ee(this.view), this.toggleReadOnly = ee(this.view), this.toggleMaxlength = ee(this.view);
1770
1770
  }
1771
1771
  getValue() {
@@ -1822,10 +1822,10 @@ class ho {
1822
1822
  if (this.view.dispatch(this.view.state.replaceSelection(o)), l.select) {
1823
1823
  const r = i + o.length + l.deviationEnd;
1824
1824
  this.view.dispatch({
1825
- selection: z.create(
1825
+ selection: q.create(
1826
1826
  [
1827
- z.range(i + l.deviationStart, r),
1828
- z.cursor(r)
1827
+ q.range(i + l.deviationStart, r),
1828
+ q.cursor(r)
1829
1829
  ],
1830
1830
  1
1831
1831
  )
@@ -1878,8 +1878,8 @@ class ho {
1878
1878
  }
1879
1879
  this.view.dispatch({
1880
1880
  scrollIntoView: !0,
1881
- selection: z.create(
1882
- [z.range(l, a), z.cursor(i)],
1881
+ selection: q.create(
1882
+ [q.range(l, a), q.cursor(i)],
1883
1883
  1
1884
1884
  )
1885
1885
  });
@@ -2033,7 +2033,7 @@ const bo = (e) => {
2033
2033
  any: (I, D) => (D.ctrlKey || D.metaKey) && D.altKey && D.shiftKey && D.code === "KeyT" ? (v.emit(e, x, "table"), !0) : !1
2034
2034
  }
2035
2035
  ], po = $o, yo = (e) => {
2036
- const o = A("tabWidth"), l = A("editorId"), a = A("theme"), i = U(), r = Pt(), m = new be(), g = new be(), u = new be(), s = po(l, e), h = vo(e), w = [
2036
+ const o = A("tabWidth"), l = A("editorId"), a = A("theme"), i = z(), r = Pt(), m = new be(), g = new be(), u = new be(), s = po(l, e), h = vo(e), w = [
2037
2037
  ol.of([...s, sl]),
2038
2038
  tl,
2039
2039
  m.of(nl({ codeLanguages: al })),
@@ -2089,7 +2089,7 @@ const bo = (e) => {
2089
2089
  name: x,
2090
2090
  callback(f, b = {}) {
2091
2091
  var S;
2092
- const { text: $, options: T } = ql(f, r.value, b);
2092
+ const { text: $, options: T } = _l(f, r.value, b);
2093
2093
  (S = r.value) == null || S.replaceSelectedText($, T, l);
2094
2094
  }
2095
2095
  });
@@ -2193,14 +2193,14 @@ const bo = (e) => {
2193
2193
  name: "MDEditorContent",
2194
2194
  props: gl,
2195
2195
  setup(e) {
2196
- const o = A("editorId"), l = U(""), a = U(), i = U(), {
2196
+ const o = A("editorId"), l = z(""), a = z(), i = z(), {
2197
2197
  inputWrapperRef: r,
2198
2198
  codeMirrorUt: m
2199
2199
  } = To(e), {
2200
2200
  inputWrapperStyle: g,
2201
2201
  resizeOperateStyle: u
2202
2202
  } = xo(e, a, i);
2203
- return _l(e, l, m), () => t("div", {
2203
+ return Ul(e, l, m), () => t("div", {
2204
2204
  class: `${n}-content${e.setting.htmlPreview || e.setting.preview ? " has-preview" : ""}`,
2205
2205
  ref: a
2206
2206
  }, [t("div", {
@@ -2224,7 +2224,8 @@ const bo = (e) => {
2224
2224
  noKatex: e.noKatex,
2225
2225
  formatCopiedText: e.formatCopiedText,
2226
2226
  noHighlight: e.noHighlight,
2227
- noImgZoomIn: e.noImgZoomIn
2227
+ noImgZoomIn: e.noImgZoomIn,
2228
+ sanitizeMermaid: e.sanitizeMermaid
2228
2229
  }, null), e.catalogVisible && t(Vt, {
2229
2230
  theme: e.theme,
2230
2231
  class: `${n}-catalog-editor`,
@@ -2327,7 +2328,7 @@ const bo = (e) => {
2327
2328
  const a = e.footers.indexOf("="), i = a === -1 ? e.footers : e.footers.slice(0, a), r = a === -1 ? [] : e.footers.slice(a, Number.MAX_SAFE_INTEGER);
2328
2329
  return [i, r];
2329
2330
  }), l = (a) => {
2330
- if (_t.includes(a))
2331
+ if (Ut.includes(a))
2331
2332
  switch (a) {
2332
2333
  case "markdownTotal":
2333
2334
  return t(Ao, {
@@ -2440,7 +2441,8 @@ const bo = (e) => {
2440
2441
  inputBoxWitdh: e.inputBoxWitdh,
2441
2442
  onInputBoxWitdhChange: (f) => {
2442
2443
  e.onInputBoxWitdhChange ? e.onInputBoxWitdhChange(f) : o.emit("onInputBoxWitdhChange", f);
2443
- }
2444
+ },
2445
+ sanitizeMermaid: e.sanitizeMermaid
2444
2446
  }, null), ((k = e.footers) == null ? void 0 : k.length) > 0 && t(Ho, {
2445
2447
  modelValue: e.modelValue,
2446
2448
  footers: e.footers,
@@ -200,7 +200,7 @@ const a = "md-editor", o = "md-editor-v3", r = "https://at.alicdn.com/t/c/font_2
200
200
  scrollAuto: "Scroll Auto"
201
201
  }
202
202
  }
203
- }, k = `${e}/mermaid/10.1.0/mermaid.esm.min.mjs`, b = {
203
+ }, k = `${e}/mermaid/10.6.1/mermaid.esm.min.mjs`, b = {
204
204
  js: `${e}/KaTeX/0.16.3/katex.min.js`,
205
205
  css: `${e}/KaTeX/0.16.3/katex.min.css`
206
206
  }, f = {
@@ -239,16 +239,17 @@ const a = "md-editor", o = "md-editor-v3", r = "https://at.alicdn.com/t/c/font_2
239
239
  }, l = {
240
240
  editorExtensions: {},
241
241
  editorConfig: {},
242
- codeMirrorExtensions: (t, i) => i,
242
+ codeMirrorExtensions: (i, t) => t,
243
243
  markdownItConfig: () => {
244
244
  },
245
- markdownItPlugins: (t) => t,
246
- iconfontType: "svg"
247
- }, j = (t) => {
248
- if (t)
249
- for (const i in t) {
250
- const s = t[i];
251
- s && (l[i] = s);
245
+ markdownItPlugins: (i) => i,
246
+ iconfontType: "svg",
247
+ mermaidConfig: (i) => i
248
+ }, j = (i) => {
249
+ if (i)
250
+ for (const t in i) {
251
+ const s = i[t];
252
+ s && (l[t] = s);
252
253
  }
253
254
  }, v = 170;
254
255
  export {