md-editor-v3 6.5.6 → 7.0.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.
@@ -48,9 +48,9 @@ export {
48
48
  h as d,
49
49
  V as e,
50
50
  S as f,
51
- _ as g,
52
- A as h,
53
- R as i,
54
- g as j,
55
- D as k
51
+ D as g,
52
+ _ as h,
53
+ A as i,
54
+ R as j,
55
+ g as k
56
56
  };
@@ -1,14 +1,14 @@
1
1
  import { defineComponent as z, inject as q, ref as D, watch as J, onMounted as K, createVNode as M, reactive as X, shallowRef as G, provide as V, computed as Y, onBeforeUnmount as Z, Fragment as ee } from "vue";
2
- import { p as O } from "./config.mjs";
3
- import { b as $, f as j, G as U, P as te, S as le } from "./event-bus.mjs";
4
- import { g as ne } from "./index5.mjs";
5
- import { createSmoothScroll as oe, debounce as ie } from "@vavt/util";
6
- const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).getPropertyValue(l).replace("px", ""), he = (e, l) => {
7
- const I = ie(() => {
2
+ import { p as w } from "./config.mjs";
3
+ import { createSmoothScroll as te, debounce as le } from "@vavt/util";
4
+ import { b as $, f as j, G as U, P as ne, S as oe } from "./event-bus.mjs";
5
+ import { g as ie } from "./index5.mjs";
6
+ const ce = `.${w}-preview > [data-line]`, R = (e, l) => +getComputedStyle(e).getPropertyValue(l).replace("px", ""), he = (e, l) => {
7
+ const I = le(() => {
8
8
  e.removeEventListener("scroll", o), e.addEventListener("scroll", o), l.removeEventListener("scroll", o), l.addEventListener("scroll", o);
9
- }, 50), o = (k) => {
9
+ }, 50), o = (H) => {
10
10
  const d = e.clientHeight, y = l.clientHeight, m = e.scrollHeight, a = l.scrollHeight, s = (m - d) / (a - y);
11
- k.target === e ? (l.removeEventListener("scroll", o), l.scrollTo({
11
+ H.target === e ? (l.removeEventListener("scroll", o), l.scrollTo({
12
12
  top: e.scrollTop / s
13
13
  // behavior: 'smooth'
14
14
  }), I()) : (e.removeEventListener("scroll", o), e.scrollTo({
@@ -27,7 +27,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
27
27
  }
28
28
  ];
29
29
  }, ge = (e, l, I) => {
30
- const { view: o } = I, k = oe(), d = (c) => o.lineBlockAt(o.state.doc.line(c + 1).from).top, y = (c) => o.lineBlockAt(o.state.doc.line(c + 1).from).bottom;
30
+ const { view: o } = I, H = te(), d = (c) => o.lineBlockAt(o.state.doc.line(c + 1).from).top, y = (c) => o.lineBlockAt(o.state.doc.line(c + 1).from).bottom;
31
31
  let m = [], a = [], s = [];
32
32
  const L = () => {
33
33
  m = [], a = Array.from(
@@ -35,27 +35,27 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
35
35
  ), s = a.map((n) => Number(n.dataset.line));
36
36
  const c = [...s], { lines: v } = o.state.doc;
37
37
  c[0] !== 0 && c.unshift(0);
38
- let H = c.shift() || 0, t = c.shift() || v;
38
+ let k = c.shift() || 0, t = c.shift() || v;
39
39
  for (let n = 0; n < v; n++)
40
- n === t && (H = n, t = c.shift() || v), m.push({
41
- start: H,
40
+ n === t && (k = n, t = c.shift() || v), m.push({
41
+ start: k,
42
42
  end: t - 1
43
43
  });
44
- }, R = (c, v) => {
45
- let H = 1;
44
+ }, O = (c, v) => {
45
+ let k = 1;
46
46
  for (let t = a.length - 1; t - 1 >= 0; t--) {
47
47
  const n = a[t];
48
48
  if (n.offsetTop <= v) {
49
- H = Number(n.dataset.line);
49
+ k = Number(n.dataset.line);
50
50
  break;
51
51
  }
52
52
  }
53
53
  for (let t = m.length - 1; t >= 0; t--)
54
54
  if (d(m[t].start) <= c) {
55
- H = H < m[t].start ? H : m[t].start;
55
+ k = k < m[t].start ? k : m[t].start;
56
56
  break;
57
57
  }
58
- return H;
58
+ return k;
59
59
  };
60
60
  let x = 0, B = 0;
61
61
  const _ = () => {
@@ -63,8 +63,8 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
63
63
  return !1;
64
64
  x++;
65
65
  const { scrollDOM: c } = o;
66
- let v = w(l, "padding-block-start");
67
- const H = o.lineBlockAtHeight(c.scrollTop), { number: t } = o.state.doc.lineAt(H.from), n = m[t - 1];
66
+ let v = R(l, "padding-block-start");
67
+ const k = o.lineBlockAtHeight(c.scrollTop), { number: t } = o.state.doc.lineAt(k.from), n = m[t - 1];
68
68
  if (!n)
69
69
  return !1;
70
70
  let E = 1;
@@ -73,24 +73,24 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
73
73
  g === 0 && (r = 0, f === u ? (v = 0, b = 0) : b = u.offsetTop), E = (c.scrollTop - g) / (p - g);
74
74
  const A = u == l.lastElementChild?.lastElementChild ? u.offsetTop + u.clientHeight : u.offsetTop;
75
75
  if (p >= h || A > i) {
76
- const S = R(h, i);
76
+ const S = O(h, i);
77
77
  g = d(S), E = (c.scrollTop - g) / (h - g);
78
78
  const T = l.querySelector(`[data-line="${S}"]`);
79
- g > 0 && T && (r = T.offsetTop), b = i - r + w(l, "padding-block-start");
79
+ g > 0 && T && (r = T.offsetTop), b = i - r + R(l, "padding-block-start");
80
80
  }
81
81
  const F = r - v + b * E;
82
- k(l, F, () => {
82
+ H(l, F, () => {
83
83
  x--;
84
84
  });
85
85
  }, P = () => {
86
86
  if (x !== 0)
87
87
  return;
88
88
  B++;
89
- const { scrollDOM: c } = o, v = l.scrollTop, H = l.scrollHeight, t = c.scrollHeight - c.clientHeight, n = l.scrollHeight - l.clientHeight;
89
+ const { scrollDOM: c } = o, v = l.scrollTop, k = l.scrollHeight, t = c.scrollHeight - c.clientHeight, n = l.scrollHeight - l.clientHeight;
90
90
  let E = l.firstElementChild?.firstElementChild, f = l.firstElementChild?.lastElementChild;
91
91
  if (s.length > 0) {
92
92
  let S = Math.ceil(
93
- s[s.length - 1] * (v / H)
93
+ s[s.length - 1] * (v / k)
94
94
  ), T = s.findLastIndex((C) => C <= S);
95
95
  T = T === -1 ? 0 : T, S = s[T];
96
96
  for (let C = T; C >= 0 && C < s.length; )
@@ -122,7 +122,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
122
122
  E = a[T], f = a[T + 1];
123
123
  }
124
124
  }
125
- let u = E === l.firstElementChild?.firstElementChild ? 0 : E.offsetTop - w(E, "margin-block-start"), h = f.offsetTop, i = 0;
125
+ let u = E === l.firstElementChild?.firstElementChild ? 0 : E.offsetTop - R(E, "margin-block-start"), h = f.offsetTop, i = 0;
126
126
  const { start: g, end: p } = m[Number(E.dataset.line || 0)];
127
127
  let r = d(g);
128
128
  const b = d(
@@ -131,18 +131,18 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
131
131
  let A = 0;
132
132
  const F = f == l.lastElementChild?.lastElementChild ? f.offsetTop + f.offsetHeight : f.offsetTop;
133
133
  if (b > t || F > n) {
134
- const S = R(t, n), T = l.querySelector(`[data-line="${S}"]`);
135
- u = T ? T.offsetTop - w(T, "margin-block-start") : u, r = d(S), i = (v - u) / (n - u), A = t - r;
136
- } else E === l.firstElementChild?.firstElementChild ? (E === f && (h = f.offsetTop + f.offsetHeight + w(f, "margin-block-end")), A = b, r = 0, i = Math.max(v / h, 0)) : (i = Math.max(
134
+ const S = O(t, n), T = l.querySelector(`[data-line="${S}"]`);
135
+ u = T ? T.offsetTop - R(T, "margin-block-start") : u, r = d(S), i = (v - u) / (n - u), A = t - r;
136
+ } else E === l.firstElementChild?.firstElementChild ? (E === f && (h = f.offsetTop + f.offsetHeight + R(f, "margin-block-end")), A = b, r = 0, i = Math.max(v / h, 0)) : (i = Math.max(
137
137
  (v - u) / (h - u),
138
138
  0
139
139
  ), A = b - r);
140
- k(e, r + A * i, () => {
140
+ H(e, r + A * i, () => {
141
141
  B--;
142
142
  });
143
143
  }, N = (c) => {
144
- const { scrollDOM: v, contentHeight: H } = o, t = v.clientHeight;
145
- if (H <= t || l.firstElementChild.clientHeight <= l.clientHeight || o.state.doc.lines <= m[m.length - 1]?.end)
144
+ const { scrollDOM: v, contentHeight: k } = o, t = v.clientHeight;
145
+ if (k <= t || l.firstElementChild.clientHeight <= l.clientHeight || o.state.doc.lines <= m[m.length - 1]?.end)
146
146
  return !1;
147
147
  c.target === e ? _() : P();
148
148
  };
@@ -187,7 +187,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
187
187
  }), K(() => {
188
188
  e.tocItem.active && e.onActive(e.tocItem, o.value);
189
189
  });
190
- const k = (d) => {
190
+ const H = (d) => {
191
191
  if (d.stopPropagation(), e.onClick(d, e.tocItem), d.defaultPrevented)
192
192
  return;
193
193
  const y = e.mdHeadingId({
@@ -202,9 +202,9 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
202
202
  if (a.contains(s))
203
203
  for (; s && a != s; )
204
204
  L += s?.offsetTop, s = s?.offsetParent;
205
- const R = m.previousElementSibling;
205
+ const O = m.previousElementSibling;
206
206
  let x = 0;
207
- R || (x = w(m, "margin-block-start")), a?.scrollTo({
207
+ O || (x = R(m, "margin-block-start")), a?.scrollTo({
208
208
  top: L - e.scrollElementOffsetTop - x,
209
209
  behavior: "smooth"
210
210
  });
@@ -212,12 +212,12 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
212
212
  };
213
213
  return () => M("div", {
214
214
  ref: o,
215
- class: [`${O}-catalog-link`, e.tocItem.active && `${O}-catalog-active`],
216
- onClick: k
215
+ class: [`${w}-catalog-link`, e.tocItem.active && `${w}-catalog-active`],
216
+ onClick: H
217
217
  }, [M("span", {
218
218
  title: e.tocItem.text
219
219
  }, [e.tocItem.text]), e.tocItem.children && e.tocItem.children.length > 0 && M("div", {
220
- class: `${O}-catalog-wrapper`
220
+ class: `${w}-catalog-wrapper`
221
221
  }, [e.tocItem.children.map((d) => M(Q, {
222
222
  mdHeadingId: e.mdHeadingId,
223
223
  key: `${e.tocItem.text}-link-${d.level}-${d.text}`,
@@ -315,15 +315,15 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
315
315
  props: re,
316
316
  emits: ["onClick", "onActive"],
317
317
  setup(e, l) {
318
- const I = e.editorId, o = `#${I}-preview-wrapper`, k = X({
318
+ const I = e.editorId, o = `#${I}-preview-wrapper`, H = X({
319
319
  list: [],
320
320
  show: !1,
321
321
  scrollElement: e.scrollElement || o
322
- }), d = G(), y = D(), m = D(), a = D(), s = D(), L = G(), R = D({});
322
+ }), d = G(), y = D(), m = D(), a = D(), s = D(), L = G(), O = D({});
323
323
  V("scrollElementRef", m), V("roorNodeRef", s);
324
324
  const x = Y(() => {
325
325
  const t = [];
326
- return k.list.forEach((n, E) => {
326
+ return H.list.forEach((n, E) => {
327
327
  if (e.catalogMaxDepth && n.level > e.catalogMaxDepth)
328
328
  return;
329
329
  const {
@@ -360,13 +360,13 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
360
360
  }
361
361
  }), t;
362
362
  }), B = () => {
363
- if (k.scrollElement instanceof HTMLElement)
364
- return k.scrollElement;
363
+ if (H.scrollElement instanceof HTMLElement)
364
+ return H.scrollElement;
365
365
  let t = document;
366
- return (k.scrollElement === o || e.isScrollElementInShadow) && (t = y.value?.getRootNode()), t.querySelector(k.scrollElement);
366
+ return (H.scrollElement === o || e.isScrollElementInShadow) && (t = y.value?.getRootNode()), t.querySelector(H.scrollElement);
367
367
  }, _ = (t) => {
368
368
  if (t.length === 0)
369
- return d.value = void 0, k.list = [], !1;
369
+ return d.value = void 0, H.list = [], !1;
370
370
  const {
371
371
  activeHead: n,
372
372
  activeIndex: E
@@ -380,7 +380,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
380
380
  currentToken: i.currentToken,
381
381
  nextToken: i.nextToken
382
382
  }));
383
- r instanceof HTMLElement && (p = ne(r, m.value));
383
+ r instanceof HTMLElement && (p = ie(r, m.value));
384
384
  } else {
385
385
  const r = L.value;
386
386
  if (r) {
@@ -415,11 +415,11 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
415
415
  h && (f = h);
416
416
  }
417
417
  }
418
- d.value = f, k.list = t;
418
+ d.value = f, H.list = t;
419
419
  }, P = (t, n) => {
420
- R.value.top = n.offsetTop + w(n, "padding-block-start") + "px", e.onActive?.(t, n), l.emit("onActive", t, n);
420
+ O.value.top = n.offsetTop + R(n, "padding-block-start") + "px", e.onActive?.(t, n), l.emit("onActive", t, n);
421
421
  }, N = () => {
422
- _(k.list);
422
+ _(H.list);
423
423
  }, c = (t) => {
424
424
  if (a.value?.removeEventListener("scroll", N), e.syncWith === "editor")
425
425
  a.value = L.value?.scrollDOM;
@@ -432,7 +432,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
432
432
  L.value = t;
433
433
  };
434
434
  J([() => e.syncWith, L, () => e.catalogMaxDepth], () => {
435
- c(k.list);
435
+ c(H.list);
436
436
  }), K(() => {
437
437
  s.value = y.value.getRootNode(), $.on(I, {
438
438
  name: j,
@@ -440,27 +440,28 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
440
440
  }), $.on(I, {
441
441
  name: U,
442
442
  callback: v
443
- }), $.emit(I, te), $.emit(I, le);
443
+ }), $.emit(I, ne), $.emit(I, oe);
444
444
  }), Z(() => {
445
445
  $.remove(I, j, c), $.remove(I, U, v), a.value?.removeEventListener("scroll", N);
446
446
  });
447
- const H = (t, n) => {
447
+ const k = (t, n) => {
448
448
  e.onClick?.(t, n), l.emit("onClick", t, n);
449
449
  };
450
450
  return () => M("div", {
451
- class: [`${O}-catalog`, e.theme === "dark" && `${O}-catalog-dark`, e.class || ""],
451
+ class: [`${w}-catalog`, e.class || ""],
452
+ "data-theme": e.theme,
452
453
  ref: y
453
454
  }, [x.value.length > 0 && M(ee, null, [M("div", {
454
- class: `${O}-catalog-indicator`,
455
- style: R.value
455
+ class: `${w}-catalog-indicator`,
456
+ style: O.value
456
457
  }, null), M("div", {
457
- class: `${O}-catalog-container`
458
+ class: `${w}-catalog-container`
458
459
  }, [x.value.map((t) => M(Q, {
459
460
  mdHeadingId: e.mdHeadingId,
460
461
  tocItem: t,
461
462
  key: `link-${t.level}-${t.text}`,
462
463
  onActive: P,
463
- onClick: H,
464
+ onClick: k,
464
465
  scrollElementOffsetTop: e.scrollElementOffsetTop
465
466
  }, null))])])]);
466
467
  }