md-editor-v3 3.0.0-beta.5 → 3.0.1

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.
@@ -16,8 +16,8 @@ import Nt from "markdown-it";
16
16
  import Vt from "markdown-it-image-figures";
17
17
  import Ut from "markdown-it-task-lists";
18
18
  import qt from "markdown-it-codetabs";
19
- import Wt from "lru-cache";
20
- const s = "md-editor", Gt = "md-editor-v3", Kt = "https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js", L = "https://cdnjs.cloudflare.com/ajax/libs", zt = `${L}/highlight.js/11.7.0/highlight.min.js`, Ge = {
19
+ import Gt from "lru-cache";
20
+ const s = "md-editor", Wt = "md-editor-v3", Kt = "https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js", L = "https://cdnjs.cloudflare.com/ajax/libs", zt = `${L}/highlight.js/11.7.0/highlight.min.js`, We = {
21
21
  main: `${L}/prettier/2.8.0/standalone.js`,
22
22
  markdown: `${L}/prettier/2.8.0/parser-markdown.js`
23
23
  }, Ke = {
@@ -277,7 +277,7 @@ const Yt = /* @__PURE__ */ M({
277
277
  class: `${s}-divider`
278
278
  }, null);
279
279
  }
280
- }), W = ({
280
+ }), G = ({
281
281
  instance: e,
282
282
  ctx: l,
283
283
  props: o = {}
@@ -346,9 +346,9 @@ const Qt = {
346
346
  }), Se(() => {
347
347
  e.trigger === "click" ? (r.value.removeEventListener("click", a), document.removeEventListener("click", m)) : (r.value.removeEventListener("mouseenter", a), r.value.removeEventListener("mouseleave", c), n.value.removeEventListener("mouseenter", d), n.value.removeEventListener("mouseleave", c));
348
348
  }), () => {
349
- const f = W({
349
+ const f = G({
350
350
  ctx: l
351
- }), h = W({
351
+ }), h = G({
352
352
  props: e,
353
353
  ctx: l
354
354
  }, "overlay"), p = St(f instanceof Array ? f[0] : f, {
@@ -659,9 +659,9 @@ const ml = {
659
659
  t.value = t.value.filter((c) => c !== "zoom-out"), o.value = u;
660
660
  }, 130));
661
661
  }), () => {
662
- const u = W({
662
+ const u = G({
663
663
  ctx: l
664
- }), c = W({
664
+ }), c = G({
665
665
  props: e,
666
666
  ctx: l
667
667
  }, "title");
@@ -1024,7 +1024,7 @@ const hl = {
1024
1024
  c.value.addEventListener("change", f);
1025
1025
  });
1026
1026
  const h = (p) => {
1027
- var v, b, y, C, $, T, I, w, F, j, R, P, _, N, D, Q, z, ue, re, ee, X, ie, te, O, G, ae, me, Ie, He, Fe, Me, Be, Re, je, Pe, De, Oe, _e, Ne, Ve, Ue, qe, We;
1027
+ var v, b, y, C, $, T, I, w, F, j, R, P, _, N, D, Q, z, ue, re, ee, X, ie, te, O, W, ae, me, Ie, He, Fe, Me, Be, Re, je, Pe, De, Oe, _e, Ne, Ve, Ue, qe, Ge;
1028
1028
  if (bt.includes(p))
1029
1029
  switch (p) {
1030
1030
  case "-":
@@ -1354,7 +1354,7 @@ const hl = {
1354
1354
  case "next":
1355
1355
  return i("div", {
1356
1356
  class: `${s}-toolbar-item`,
1357
- title: (G = o.value.toolbarTips) == null ? void 0 : G.next,
1357
+ title: (W = o.value.toolbarTips) == null ? void 0 : W.next,
1358
1358
  onClick: () => {
1359
1359
  k.emit(l, "ctrlShiftZ");
1360
1360
  }
@@ -1557,7 +1557,7 @@ const hl = {
1557
1557
  onClick: () => {
1558
1558
  a("katexBlock");
1559
1559
  }
1560
- }, [(We = o.value.katex) == null ? void 0 : We.block])]),
1560
+ }, [(Ge = o.value.katex) == null ? void 0 : Ge.block])]),
1561
1561
  key: "bar-katex"
1562
1562
  }, {
1563
1563
  default: () => {
@@ -1689,9 +1689,9 @@ const hl = {
1689
1689
  Number(w[w.length - 1].dataset.line) * (F / j)
1690
1690
  ), P = (C = l.firstElementChild) == null ? void 0 : C.firstElementChild;
1691
1691
  for (let O = R; O >= 0; O--) {
1692
- const G = l.querySelector(`[data-line="${O}"]`);
1693
- if (G) {
1694
- P = G, R = O;
1692
+ const W = l.querySelector(`[data-line="${O}"]`);
1693
+ if (W) {
1694
+ P = W, R = O;
1695
1695
  break;
1696
1696
  }
1697
1697
  }
@@ -1700,21 +1700,21 @@ const hl = {
1700
1700
  const O = w.indexOf(P);
1701
1701
  if (O + 1 >= w.length)
1702
1702
  break;
1703
- const G = w[O + 1], ae = P.offsetTop;
1703
+ const W = w[O + 1], ae = P.offsetTop;
1704
1704
  if (ae > F) {
1705
1705
  if (O === 0) {
1706
- _ = P, N = G;
1706
+ _ = P, N = W;
1707
1707
  break;
1708
1708
  }
1709
1709
  P = w[O - 1];
1710
1710
  continue;
1711
1711
  }
1712
- const me = G.offsetTop;
1712
+ const me = W.offsetTop;
1713
1713
  if (ae <= F && me > F) {
1714
- _ = P, N = G;
1714
+ _ = P, N = W;
1715
1715
  break;
1716
1716
  }
1717
- P = G;
1717
+ P = W;
1718
1718
  }
1719
1719
  const D = _.offsetTop, Q = N.offsetTop;
1720
1720
  let z = 0;
@@ -1805,7 +1805,7 @@ const hl = {
1805
1805
  break;
1806
1806
  }
1807
1807
  case "strikeThrough": {
1808
- t = `~~${m}~~`, r = 1, n = -1;
1808
+ t = `~~${m}~~`, r = 2, n = -2;
1809
1809
  break;
1810
1810
  }
1811
1811
  case "sub": {
@@ -2187,7 +2187,7 @@ $$
2187
2187
  { tag: [g.atom, g.bool, g.special(g.variableName)], color: ut },
2188
2188
  { tag: [g.processingInstruction, g.string, g.inserted], color: Ol },
2189
2189
  { tag: g.invalid, color: Pl }
2190
- ]), Wl = [
2190
+ ]), Gl = [
2191
2191
  Ul,
2192
2192
  pt(ql)
2193
2193
  ], le = (e) => {
@@ -2196,7 +2196,7 @@ $$
2196
2196
  effects: At.appendConfig.of(l.of(t))
2197
2197
  }), !0);
2198
2198
  };
2199
- class Gl {
2199
+ class Wl {
2200
2200
  constructor(l) {
2201
2201
  K(this, "view");
2202
2202
  // 切换tabSize的执行方法。切换时,Compartment实例需要相同
@@ -2450,12 +2450,12 @@ const Kl = (e) => {
2450
2450
  })
2451
2451
  ], u = () => t.value === "light" ? A.codeMirrorExtensions(
2452
2452
  t.value,
2453
- [...m, Wl],
2454
- a
2453
+ [...m, Gl],
2454
+ [...a]
2455
2455
  ) : A.codeMirrorExtensions(
2456
2456
  t.value,
2457
2457
  [...m, Bl],
2458
- a
2458
+ [...a]
2459
2459
  );
2460
2460
  return H(() => {
2461
2461
  const c = ge.create({
@@ -2464,7 +2464,7 @@ const Kl = (e) => {
2464
2464
  state: c,
2465
2465
  parent: r.value
2466
2466
  });
2467
- n.value = new Gl(f), n.value.setTabSize(l), n.value.setExtensions(u()), n.value.setPlaceholder(e.placeholder), n.value.setDisabled(e.disabled), n.value.setReadOnly(e.readonly), e.autofocus && f.focus(), e.maxlength && n.value.setMaxLength(e.maxlength), k.on(o, {
2467
+ n.value = new Wl(f), n.value.setTabSize(l), n.value.setExtensions(u()), n.value.setPlaceholder(e.placeholder), n.value.setDisabled(e.disabled), n.value.setReadOnly(e.readonly), e.autofocus && f.focus(), e.maxlength && n.value.setMaxLength(e.maxlength), k.on(o, {
2468
2468
  name: "ctrlZ",
2469
2469
  callback() {
2470
2470
  jt(f);
@@ -2556,16 +2556,14 @@ const Kl = (e) => {
2556
2556
  var n;
2557
2557
  const l = (n = A.editorExtensions) == null ? void 0 : n.highlight, o = l == null ? void 0 : l.instance, t = x("highlight"), r = de(o);
2558
2558
  return H(() => {
2559
- if (e.noHighlight)
2560
- return;
2561
- if (!r.value) {
2562
- const d = document.createElement("script");
2563
- d.src = t.value.js, d.onload = () => {
2559
+ if (!e.noHighlight && !r.value) {
2560
+ const a = document.createElement("script");
2561
+ a.src = t.value.js, a.onload = () => {
2564
2562
  r.value = window.hljs;
2565
- }, d.id = `${s}-hljs`, V(d, "hljs");
2563
+ }, a.id = `${s}-hljs`, V(a, "hljs");
2564
+ const d = document.createElement("link");
2565
+ d.rel = "stylesheet", d.href = t.value.css, d.id = `${s}-hlCss`, V(d);
2566
2566
  }
2567
- const a = document.createElement("link");
2568
- a.rel = "stylesheet", a.href = t.value.css, a.id = `${s}-hlCss`, V(a);
2569
2567
  }), S(
2570
2568
  () => t.value.css,
2571
2569
  (a) => {
@@ -2573,7 +2571,7 @@ const Kl = (e) => {
2573
2571
  }
2574
2572
  ), r;
2575
2573
  }, eo = (e) => {
2576
- const l = x("theme"), { editorExtensions: o } = A, t = o == null ? void 0 : o.mermaid, r = de(t == null ? void 0 : t.instance), n = de(!1), a = new Wt({
2574
+ const l = x("theme"), { editorExtensions: o } = A, t = o == null ? void 0 : o.mermaid, r = de(t == null ? void 0 : t.instance), n = de(!1), a = new Gt({
2577
2575
  max: 1e3,
2578
2576
  // 缓存10分钟
2579
2577
  ttl: 6e5
@@ -2790,18 +2788,15 @@ const Kl = (e) => {
2790
2788
  return `<pre><code class="language-${C}" language=${C}>${T}</code></pre>`;
2791
2789
  }
2792
2790
  }), so(h), o(h);
2793
- const p = B(e.sanitize(h.render(e.value))), v = ve(
2791
+ const p = B(e.sanitize(h.render(e.value)));
2792
+ k.emit(t, "buildFinished", p.value), e.onHtmlChanged(p.value), e.onGetCatalog(d.value), k.emit(t, "catalogChanged", d.value), f();
2793
+ const v = ve(
2794
2794
  async () => {
2795
- d.value = [], p.value = e.sanitize(h.render(e.value)), k.emit(t, "buildFinished", p.value), e.onHtmlChanged(p.value), f();
2795
+ d.value = [], p.value = e.sanitize(h.render(e.value)), k.emit(t, "buildFinished", p.value), e.onHtmlChanged(p.value), e.onGetCatalog(d.value), k.emit(t, "catalogChanged", d.value), f();
2796
2796
  },
2797
2797
  (l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : n ? 0 : 500
2798
- ), b = U(() => e.noHighlight || m.value);
2799
- return S([ne(e, "value"), b, c], v), S(
2800
- () => d.value,
2801
- (y) => {
2802
- e.onGetCatalog(y), k.emit(t, "catalogChanged", y);
2803
- }
2804
- ), H(() => {
2798
+ ), b = U(() => (e.noKatex || u.value) && (e.noHighlight || m.value));
2799
+ return S([ne(e, "value"), b, c], v), H(() => {
2805
2800
  k.on(t, {
2806
2801
  name: "pushCatalog",
2807
2802
  callback() {
@@ -3353,7 +3348,7 @@ const Co = {
3353
3348
  const b = document.createElement("script");
3354
3349
  b.src = (n == null ? void 0 : n.iconfont) || Kt, b.id = `${s}-icon`;
3355
3350
  const y = document.createElement("script"), C = document.createElement("script");
3356
- y.src = ((I = n == null ? void 0 : n.prettier) == null ? void 0 : I.standaloneJs) || Ge.main, y.id = `${s}-prettier`, C.src = ((w = n == null ? void 0 : n.prettier) == null ? void 0 : w.parserMarkdownJs) || Ge.markdown, C.id = `${s}-prettierMD`;
3351
+ y.src = ((I = n == null ? void 0 : n.prettier) == null ? void 0 : I.standaloneJs) || We.main, y.id = `${s}-prettier`, C.src = ((w = n == null ? void 0 : n.prettier) == null ? void 0 : w.parserMarkdownJs) || We.markdown, C.id = `${s}-prettierMD`;
3357
3352
  const $ = document.createElement("link");
3358
3353
  $.rel = "stylesheet", $.href = ((F = n == null ? void 0 : n.cropper) == null ? void 0 : F.css) || Ke.css, $.id = `${s}-cropperCss`;
3359
3354
  const T = document.createElement("script");
@@ -3636,7 +3631,7 @@ const Co = {
3636
3631
  */
3637
3632
  editorId: {
3638
3633
  type: String,
3639
- default: Gt
3634
+ default: Wt
3640
3635
  },
3641
3636
  /**
3642
3637
  * 一个tab等于空格数
@@ -3903,10 +3898,10 @@ const J = /* @__PURE__ */ M({
3903
3898
  k.clear(o);
3904
3899
  }), Eo(e, l, h, c, f), () => {
3905
3900
  var y;
3906
- const v = W({
3901
+ const v = G({
3907
3902
  props: e,
3908
3903
  ctx: l
3909
- }, "defToolbars"), b = W({
3904
+ }, "defToolbars"), b = G({
3910
3905
  props: e,
3911
3906
  ctx: l
3912
3907
  }, "defFooters");
@@ -3990,7 +3985,7 @@ const J = /* @__PURE__ */ M({
3990
3985
  emits: ["onClick"],
3991
3986
  setup(e, l) {
3992
3987
  return () => {
3993
- const o = W({
3988
+ const o = G({
3994
3989
  props: e,
3995
3990
  ctx: l
3996
3991
  }, "trigger");
@@ -4029,10 +4024,10 @@ const J = /* @__PURE__ */ M({
4029
4024
  setup(e, l) {
4030
4025
  const o = x("editorId");
4031
4026
  return () => {
4032
- const t = W({
4027
+ const t = G({
4033
4028
  props: e,
4034
4029
  ctx: l
4035
- }, "trigger"), r = W({
4030
+ }, "trigger"), r = G({
4036
4031
  props: e,
4037
4032
  ctx: l
4038
4033
  }, "overlay");
@@ -4105,10 +4100,10 @@ const Bo = {
4105
4100
  emits: ["onClick", "onClose", "onAdjust"],
4106
4101
  setup(e, l) {
4107
4102
  return () => {
4108
- const o = W({
4103
+ const o = G({
4109
4104
  props: e,
4110
4105
  ctx: l
4111
- }, "trigger"), t = W({
4106
+ }, "trigger"), t = G({
4112
4107
  props: e,
4113
4108
  ctx: l
4114
4109
  }, "default");