md-editor-v3 6.5.5 → 7.0.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.
- package/lib/cjs/MdEditor.cjs +1 -1
- package/lib/cjs/chunks/config.cjs +14 -1
- package/lib/cjs/chunks/index2.cjs +1 -1
- package/lib/cjs/chunks/index3.cjs +1 -1
- package/lib/cjs/chunks/index4.cjs +45 -45
- package/lib/cjs/chunks/index5.cjs +7 -2
- package/lib/es/MdEditor.mjs +5 -4
- package/lib/es/chunks/config.mjs +919 -69
- package/lib/es/chunks/event-bus.mjs +5 -5
- package/lib/es/chunks/index2.mjs +11 -11
- package/lib/es/chunks/index3.mjs +60 -57
- package/lib/es/chunks/index4.mjs +786 -714
- package/lib/es/chunks/index5.mjs +199 -32
- package/lib/preview.css +2 -2
- package/lib/style.css +4 -4
- package/lib/types/index.d.ts +12 -12
- package/package.json +3 -2
package/lib/es/chunks/index2.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createVNode as t, defineComponent as k, h as j, inject as p, ref as c, shallowRef as O, reactive as E, computed as g, watch as x, nextTick as b, onMounted as W, Teleport as q } from "vue";
|
|
2
2
|
import { p as l, g as C } from "./config.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { Upload as N, Trash2 as D, X as U, SquareSigma as X, ChartArea as G, ListTree as Q, CodeXml as V, Eye as Z, View as J, Expand as K, Shrink as Y, Maximize2 as _, Minimize2 as ee, SquareCode as w, Save as te, Forward as ne, Reply as oe, Table as ie, Image as le, Link as se, Code as ae, ListTodo as re, ListOrdered as ue, List as ce, Quote as de, Superscript as me, Subscript as fe, Heading as he, Strikethrough as ve, Italic as ye, Underline as ge, Bold as Se } from "@lucide/vue";
|
|
4
|
+
import { c as I } from "./index5.mjs";
|
|
5
|
+
import { k as z } from "./dom.mjs";
|
|
6
|
+
import { g as M } from "./vue-tsx.mjs";
|
|
7
7
|
const pe = () => t("svg", {
|
|
8
8
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9
9
|
viewBox: "0 0 24 24",
|
|
@@ -30,14 +30,14 @@ const pe = () => t("svg", {
|
|
|
30
30
|
"ordered-list": ue,
|
|
31
31
|
task: re,
|
|
32
32
|
"code-row": ae,
|
|
33
|
-
code:
|
|
33
|
+
code: w,
|
|
34
34
|
link: se,
|
|
35
35
|
image: le,
|
|
36
36
|
table: ie,
|
|
37
37
|
revoke: oe,
|
|
38
38
|
next: ne,
|
|
39
39
|
save: te,
|
|
40
|
-
prettier:
|
|
40
|
+
prettier: w,
|
|
41
41
|
minimize: ee,
|
|
42
42
|
maximize: _,
|
|
43
43
|
"fullscreen-exit": Y,
|
|
@@ -161,14 +161,14 @@ const pe = () => t("svg", {
|
|
|
161
161
|
});
|
|
162
162
|
x(() => e.isFullscreen, (o) => {
|
|
163
163
|
o ? d() : b(() => {
|
|
164
|
-
d =
|
|
164
|
+
d = z(h.value, (i, s) => {
|
|
165
165
|
n.initPos.insetInlineStart = i + "px", n.initPos.insetBlockStart = s + "px";
|
|
166
166
|
});
|
|
167
167
|
});
|
|
168
168
|
}), x(() => e.visible, (o) => {
|
|
169
|
-
o ? (n.maskStyle.zIndex = C.editorConfig.zIndex +
|
|
169
|
+
o ? (n.maskStyle.zIndex = C.editorConfig.zIndex + I(), n.modalStyle.zIndex = C.editorConfig.zIndex + I(), r.value.push("zoom-in"), m.value = o, b(() => {
|
|
170
170
|
const i = f.value.offsetWidth / 2, s = f.value.offsetHeight / 2, T = document.documentElement.clientWidth / 2, H = document.documentElement.clientHeight / 2;
|
|
171
|
-
n.initPos.insetInlineStart = T - i + "px", n.initPos.insetBlockStart = H - s + "px", e.isFullscreen || (d =
|
|
171
|
+
n.initPos.insetInlineStart = T - i + "px", n.initPos.insetBlockStart = H - s + "px", e.isFullscreen || (d = z(h.value, (A, L) => {
|
|
172
172
|
n.initPos.insetInlineStart = A + "px", n.initPos.insetBlockStart = L + "px";
|
|
173
173
|
}));
|
|
174
174
|
}), setTimeout(() => {
|
|
@@ -192,9 +192,9 @@ const pe = () => t("svg", {
|
|
|
192
192
|
const o = $.value?.getRootNode();
|
|
193
193
|
v.value = o instanceof Document ? document.body : o;
|
|
194
194
|
}), () => {
|
|
195
|
-
const o =
|
|
195
|
+
const o = M({
|
|
196
196
|
ctx: u
|
|
197
|
-
}), i =
|
|
197
|
+
}), i = M({
|
|
198
198
|
props: e,
|
|
199
199
|
ctx: u
|
|
200
200
|
}, "title");
|
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -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
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const ce = `.${
|
|
7
|
-
const I =
|
|
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 = (
|
|
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
|
-
|
|
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,
|
|
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
|
|
38
|
+
let k = c.shift() || 0, t = c.shift() || v;
|
|
39
39
|
for (let n = 0; n < v; n++)
|
|
40
|
-
n === t && (
|
|
41
|
-
start:
|
|
40
|
+
n === t && (k = n, t = c.shift() || v), m.push({
|
|
41
|
+
start: k,
|
|
42
42
|
end: t - 1
|
|
43
43
|
});
|
|
44
|
-
},
|
|
45
|
-
let
|
|
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
|
-
|
|
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
|
-
|
|
55
|
+
k = k < m[t].start ? k : m[t].start;
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return k;
|
|
59
59
|
};
|
|
60
60
|
let x = 0, B = 0;
|
|
61
61
|
const _ = () => {
|
|
@@ -63,34 +63,36 @@ 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 =
|
|
67
|
-
const
|
|
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;
|
|
71
71
|
const f = l.querySelector(`[data-line="${n.start}"]`) || l.firstElementChild?.firstElementChild, u = l.querySelector(`[data-line="${n.end + 1}"]`) || l.lastElementChild?.lastElementChild, h = c.scrollHeight - c.clientHeight, i = l.scrollHeight - l.clientHeight;
|
|
72
|
-
let g = d(n.start)
|
|
72
|
+
let g = d(n.start);
|
|
73
|
+
const p = y(n.end);
|
|
74
|
+
let r = f.offsetTop, b = u.offsetTop - r;
|
|
73
75
|
g === 0 && (r = 0, f === u ? (v = 0, b = 0) : b = u.offsetTop), E = (c.scrollTop - g) / (p - g);
|
|
74
76
|
const A = u == l.lastElementChild?.lastElementChild ? u.offsetTop + u.clientHeight : u.offsetTop;
|
|
75
77
|
if (p >= h || A > i) {
|
|
76
|
-
const S =
|
|
78
|
+
const S = O(h, i);
|
|
77
79
|
g = d(S), E = (c.scrollTop - g) / (h - g);
|
|
78
80
|
const T = l.querySelector(`[data-line="${S}"]`);
|
|
79
|
-
g > 0 && T && (r = T.offsetTop), b = i - r +
|
|
81
|
+
g > 0 && T && (r = T.offsetTop), b = i - r + R(l, "padding-block-start");
|
|
80
82
|
}
|
|
81
83
|
const F = r - v + b * E;
|
|
82
|
-
|
|
84
|
+
H(l, F, () => {
|
|
83
85
|
x--;
|
|
84
86
|
});
|
|
85
87
|
}, P = () => {
|
|
86
88
|
if (x !== 0)
|
|
87
89
|
return;
|
|
88
90
|
B++;
|
|
89
|
-
const { scrollDOM: c } = o, v = l.scrollTop,
|
|
91
|
+
const { scrollDOM: c } = o, v = l.scrollTop, k = l.scrollHeight, t = c.scrollHeight - c.clientHeight, n = l.scrollHeight - l.clientHeight;
|
|
90
92
|
let E = l.firstElementChild?.firstElementChild, f = l.firstElementChild?.lastElementChild;
|
|
91
93
|
if (s.length > 0) {
|
|
92
94
|
let S = Math.ceil(
|
|
93
|
-
s[s.length - 1] * (v /
|
|
95
|
+
s[s.length - 1] * (v / k)
|
|
94
96
|
), T = s.findLastIndex((C) => C <= S);
|
|
95
97
|
T = T === -1 ? 0 : T, S = s[T];
|
|
96
98
|
for (let C = T; C >= 0 && C < s.length; )
|
|
@@ -122,7 +124,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
122
124
|
E = a[T], f = a[T + 1];
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
|
-
let u = E === l.firstElementChild?.firstElementChild ? 0 : E.offsetTop -
|
|
127
|
+
let u = E === l.firstElementChild?.firstElementChild ? 0 : E.offsetTop - R(E, "margin-block-start"), h = f.offsetTop, i = 0;
|
|
126
128
|
const { start: g, end: p } = m[Number(E.dataset.line || 0)];
|
|
127
129
|
let r = d(g);
|
|
128
130
|
const b = d(
|
|
@@ -131,18 +133,18 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
131
133
|
let A = 0;
|
|
132
134
|
const F = f == l.lastElementChild?.lastElementChild ? f.offsetTop + f.offsetHeight : f.offsetTop;
|
|
133
135
|
if (b > t || F > n) {
|
|
134
|
-
const S =
|
|
135
|
-
u = T ? T.offsetTop -
|
|
136
|
-
} else E === l.firstElementChild?.firstElementChild ? (E === f && (h = f.offsetTop + f.offsetHeight +
|
|
136
|
+
const S = O(t, n), T = l.querySelector(`[data-line="${S}"]`);
|
|
137
|
+
u = T ? T.offsetTop - R(T, "margin-block-start") : u, r = d(S), i = (v - u) / (n - u), A = t - r;
|
|
138
|
+
} 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
139
|
(v - u) / (h - u),
|
|
138
140
|
0
|
|
139
141
|
), A = b - r);
|
|
140
|
-
|
|
142
|
+
H(e, r + A * i, () => {
|
|
141
143
|
B--;
|
|
142
144
|
});
|
|
143
145
|
}, N = (c) => {
|
|
144
|
-
const { scrollDOM: v, contentHeight:
|
|
145
|
-
if (
|
|
146
|
+
const { scrollDOM: v, contentHeight: k } = o, t = v.clientHeight;
|
|
147
|
+
if (k <= t || l.firstElementChild.clientHeight <= l.clientHeight || o.state.doc.lines <= m[m.length - 1]?.end)
|
|
146
148
|
return !1;
|
|
147
149
|
c.target === e ? _() : P();
|
|
148
150
|
};
|
|
@@ -187,7 +189,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
187
189
|
}), K(() => {
|
|
188
190
|
e.tocItem.active && e.onActive(e.tocItem, o.value);
|
|
189
191
|
});
|
|
190
|
-
const
|
|
192
|
+
const H = (d) => {
|
|
191
193
|
if (d.stopPropagation(), e.onClick(d, e.tocItem), d.defaultPrevented)
|
|
192
194
|
return;
|
|
193
195
|
const y = e.mdHeadingId({
|
|
@@ -202,9 +204,9 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
202
204
|
if (a.contains(s))
|
|
203
205
|
for (; s && a != s; )
|
|
204
206
|
L += s?.offsetTop, s = s?.offsetParent;
|
|
205
|
-
const
|
|
207
|
+
const O = m.previousElementSibling;
|
|
206
208
|
let x = 0;
|
|
207
|
-
|
|
209
|
+
O || (x = R(m, "margin-block-start")), a?.scrollTo({
|
|
208
210
|
top: L - e.scrollElementOffsetTop - x,
|
|
209
211
|
behavior: "smooth"
|
|
210
212
|
});
|
|
@@ -212,12 +214,12 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
212
214
|
};
|
|
213
215
|
return () => M("div", {
|
|
214
216
|
ref: o,
|
|
215
|
-
class: [`${
|
|
216
|
-
onClick:
|
|
217
|
+
class: [`${w}-catalog-link`, e.tocItem.active && `${w}-catalog-active`],
|
|
218
|
+
onClick: H
|
|
217
219
|
}, [M("span", {
|
|
218
220
|
title: e.tocItem.text
|
|
219
221
|
}, [e.tocItem.text]), e.tocItem.children && e.tocItem.children.length > 0 && M("div", {
|
|
220
|
-
class: `${
|
|
222
|
+
class: `${w}-catalog-wrapper`
|
|
221
223
|
}, [e.tocItem.children.map((d) => M(Q, {
|
|
222
224
|
mdHeadingId: e.mdHeadingId,
|
|
223
225
|
key: `${e.tocItem.text}-link-${d.level}-${d.text}`,
|
|
@@ -315,15 +317,15 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
315
317
|
props: re,
|
|
316
318
|
emits: ["onClick", "onActive"],
|
|
317
319
|
setup(e, l) {
|
|
318
|
-
const I = e.editorId, o = `#${I}-preview-wrapper`,
|
|
320
|
+
const I = e.editorId, o = `#${I}-preview-wrapper`, H = X({
|
|
319
321
|
list: [],
|
|
320
322
|
show: !1,
|
|
321
323
|
scrollElement: e.scrollElement || o
|
|
322
|
-
}), d = G(), y = D(), m = D(), a = D(), s = D(), L = G(),
|
|
324
|
+
}), d = G(), y = D(), m = D(), a = D(), s = D(), L = G(), O = D({});
|
|
323
325
|
V("scrollElementRef", m), V("roorNodeRef", s);
|
|
324
326
|
const x = Y(() => {
|
|
325
327
|
const t = [];
|
|
326
|
-
return
|
|
328
|
+
return H.list.forEach((n, E) => {
|
|
327
329
|
if (e.catalogMaxDepth && n.level > e.catalogMaxDepth)
|
|
328
330
|
return;
|
|
329
331
|
const {
|
|
@@ -360,13 +362,13 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
360
362
|
}
|
|
361
363
|
}), t;
|
|
362
364
|
}), B = () => {
|
|
363
|
-
if (
|
|
364
|
-
return
|
|
365
|
+
if (H.scrollElement instanceof HTMLElement)
|
|
366
|
+
return H.scrollElement;
|
|
365
367
|
let t = document;
|
|
366
|
-
return (
|
|
368
|
+
return (H.scrollElement === o || e.isScrollElementInShadow) && (t = y.value?.getRootNode()), t.querySelector(H.scrollElement);
|
|
367
369
|
}, _ = (t) => {
|
|
368
370
|
if (t.length === 0)
|
|
369
|
-
return d.value = void 0,
|
|
371
|
+
return d.value = void 0, H.list = [], !1;
|
|
370
372
|
const {
|
|
371
373
|
activeHead: n,
|
|
372
374
|
activeIndex: E
|
|
@@ -380,7 +382,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
380
382
|
currentToken: i.currentToken,
|
|
381
383
|
nextToken: i.nextToken
|
|
382
384
|
}));
|
|
383
|
-
r instanceof HTMLElement && (p =
|
|
385
|
+
r instanceof HTMLElement && (p = ie(r, m.value));
|
|
384
386
|
} else {
|
|
385
387
|
const r = L.value;
|
|
386
388
|
if (r) {
|
|
@@ -415,11 +417,11 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
415
417
|
h && (f = h);
|
|
416
418
|
}
|
|
417
419
|
}
|
|
418
|
-
d.value = f,
|
|
420
|
+
d.value = f, H.list = t;
|
|
419
421
|
}, P = (t, n) => {
|
|
420
|
-
|
|
422
|
+
O.value.top = n.offsetTop + R(n, "padding-block-start") + "px", e.onActive?.(t, n), l.emit("onActive", t, n);
|
|
421
423
|
}, N = () => {
|
|
422
|
-
_(
|
|
424
|
+
_(H.list);
|
|
423
425
|
}, c = (t) => {
|
|
424
426
|
if (a.value?.removeEventListener("scroll", N), e.syncWith === "editor")
|
|
425
427
|
a.value = L.value?.scrollDOM;
|
|
@@ -432,7 +434,7 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
432
434
|
L.value = t;
|
|
433
435
|
};
|
|
434
436
|
J([() => e.syncWith, L, () => e.catalogMaxDepth], () => {
|
|
435
|
-
c(
|
|
437
|
+
c(H.list);
|
|
436
438
|
}), K(() => {
|
|
437
439
|
s.value = y.value.getRootNode(), $.on(I, {
|
|
438
440
|
name: j,
|
|
@@ -440,27 +442,28 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
440
442
|
}), $.on(I, {
|
|
441
443
|
name: U,
|
|
442
444
|
callback: v
|
|
443
|
-
}), $.emit(I,
|
|
445
|
+
}), $.emit(I, ne), $.emit(I, oe);
|
|
444
446
|
}), Z(() => {
|
|
445
447
|
$.remove(I, j, c), $.remove(I, U, v), a.value?.removeEventListener("scroll", N);
|
|
446
448
|
});
|
|
447
|
-
const
|
|
449
|
+
const k = (t, n) => {
|
|
448
450
|
e.onClick?.(t, n), l.emit("onClick", t, n);
|
|
449
451
|
};
|
|
450
452
|
return () => M("div", {
|
|
451
|
-
class: [`${
|
|
453
|
+
class: [`${w}-catalog`, e.class || ""],
|
|
454
|
+
"data-theme": e.theme,
|
|
452
455
|
ref: y
|
|
453
456
|
}, [x.value.length > 0 && M(ee, null, [M("div", {
|
|
454
|
-
class: `${
|
|
455
|
-
style:
|
|
457
|
+
class: `${w}-catalog-indicator`,
|
|
458
|
+
style: O.value
|
|
456
459
|
}, null), M("div", {
|
|
457
|
-
class: `${
|
|
460
|
+
class: `${w}-catalog-container`
|
|
458
461
|
}, [x.value.map((t) => M(Q, {
|
|
459
462
|
mdHeadingId: e.mdHeadingId,
|
|
460
463
|
tocItem: t,
|
|
461
464
|
key: `link-${t.level}-${t.text}`,
|
|
462
465
|
onActive: P,
|
|
463
|
-
onClick:
|
|
466
|
+
onClick: k,
|
|
464
467
|
scrollElementOffsetTop: e.scrollElementOffsetTop
|
|
465
468
|
}, null))])])]);
|
|
466
469
|
}
|