md-editor-v3 4.0.3 → 4.0.4
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/LICENSE +4 -16
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +15 -15
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/ModalToolbar.cjs +1 -1
- package/lib/cjs/chunks/dom.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +3 -3
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdCatalog.mjs +2 -2
- package/lib/es/MdEditor.mjs +135 -137
- package/lib/es/MdPreview.mjs +2 -2
- package/lib/es/ModalToolbar.mjs +1 -1
- package/lib/es/chunks/dom.mjs +1 -1
- package/lib/es/chunks/index.mjs +8 -8
- package/lib/es/chunks/index4.mjs +63 -53
- package/lib/es/index.mjs +1 -1
- package/lib/types/MdEditor/utils/index.d.ts +0 -26
- package/lib/umd/index.js +24 -24
- package/package.json +2 -1
- package/lib/cjs/chunks/event-bus.cjs +0 -1
- package/lib/es/chunks/event-bus.mjs +0 -38
- package/lib/types/MdEditor/utils/smooth-scroll.d.ts +0 -8
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
var Ze = Object.defineProperty;
|
|
2
2
|
var Je = (e, o, n) => o in e ? Ze(e, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[o] = n;
|
|
3
3
|
var U = (e, o, n) => (Je(e, typeof o != "symbol" ? o + "" : o, n), n);
|
|
4
|
-
import { defineComponent as
|
|
4
|
+
import { defineComponent as O, createVNode as t, inject as A, ref as q, onMounted as W, reactive as Y, computed as me, watch as B, nextTick as ue, Fragment as Ke, toRef as ae, shallowRef as Xe, onBeforeUnmount as Qe } from "vue";
|
|
5
5
|
import { p as a, a as G, s as et, b as tt, d as lt } from "./chunks/config.mjs";
|
|
6
6
|
import { a as Q, D as ot } from "./chunks/index2.mjs";
|
|
7
|
-
import { b as h } from "./chunks/
|
|
8
|
-
import {
|
|
9
|
-
import { C as
|
|
10
|
-
import { a as
|
|
11
|
-
import { a as _e, M as
|
|
12
|
-
import { minimalSetup as
|
|
13
|
-
import { EditorView as fe, placeholder as
|
|
14
|
-
import { languages as
|
|
15
|
-
import { markdown as
|
|
16
|
-
import { deleteLine as
|
|
17
|
-
import { HighlightStyle as We, syntaxHighlighting as ze, indentUnit as
|
|
7
|
+
import { b as h, a as at } from "./chunks/index4.mjs";
|
|
8
|
+
import { linkTo as nt, debounce as rt, throttle as it, smoothScroll as De } from "@vavt/util";
|
|
9
|
+
import { C as st, a as ct, O as je, T as dt, b as ut, e as mt, c as ft, u as gt, d as ht, f as bt, g as vt, h as kt, i as pt, M as Ct } from "./chunks/index.mjs";
|
|
10
|
+
import { a as $t } from "./chunks/dom.mjs";
|
|
11
|
+
import { a as _e, M as yt } from "./chunks/index3.mjs";
|
|
12
|
+
import { minimalSetup as xt, EditorView as ne } from "codemirror";
|
|
13
|
+
import { EditorView as fe, placeholder as wt, keymap as Tt } from "@codemirror/view";
|
|
14
|
+
import { languages as St } from "@codemirror/language-data";
|
|
15
|
+
import { markdown as At } from "@codemirror/lang-markdown";
|
|
16
|
+
import { deleteLine as Mt, indentWithTab as Lt, undo as Dt, redo as Et } from "@codemirror/commands";
|
|
17
|
+
import { HighlightStyle as We, syntaxHighlighting as ze, indentUnit as Ht } from "@codemirror/language";
|
|
18
18
|
import { tags as i } from "@lezer/highlight";
|
|
19
|
-
import { EditorSelection as re, EditorState as ie, Compartment as
|
|
20
|
-
import { g as
|
|
19
|
+
import { EditorSelection as re, EditorState as ie, Compartment as Ft, StateEffect as It } from "@codemirror/state";
|
|
20
|
+
import { g as Ee } from "./chunks/vue-tsx.mjs";
|
|
21
21
|
import Ye from "./MdCatalog.mjs";
|
|
22
|
-
import
|
|
22
|
+
import Bt from "./NormalToolbar.mjs";
|
|
23
23
|
import "medium-zoom";
|
|
24
24
|
import "copy-to-clipboard";
|
|
25
25
|
import "markdown-it";
|
|
26
26
|
import "markdown-it-image-figures";
|
|
27
27
|
import "markdown-it-task-lists";
|
|
28
28
|
import "lru-cache";
|
|
29
|
-
const
|
|
29
|
+
const Ot = /* @__PURE__ */ O({
|
|
30
30
|
setup() {
|
|
31
31
|
return () => t("div", {
|
|
32
32
|
class: `${a}-divider`
|
|
33
33
|
}, null);
|
|
34
34
|
}
|
|
35
|
-
}),
|
|
35
|
+
}), Vt = {
|
|
36
36
|
noPrettier: {
|
|
37
37
|
type: Boolean
|
|
38
38
|
},
|
|
@@ -73,9 +73,9 @@ const Bt = /* @__PURE__ */ I({
|
|
|
73
73
|
noUploadImg: {
|
|
74
74
|
type: Boolean
|
|
75
75
|
}
|
|
76
|
-
},
|
|
76
|
+
}, Rt = (e) => {
|
|
77
77
|
var f, d, u, k;
|
|
78
|
-
const o =
|
|
78
|
+
const o = A("editorId");
|
|
79
79
|
let n = (d = (f = G.editorExtensions) == null ? void 0 : f.screenfull) == null ? void 0 : d.instance;
|
|
80
80
|
const l = (k = (u = G.editorExtensions) == null ? void 0 : u.screenfull) == null ? void 0 : k.js, s = q(!1), r = ($) => {
|
|
81
81
|
if (!n) {
|
|
@@ -96,15 +96,15 @@ const Bt = /* @__PURE__ */ I({
|
|
|
96
96
|
return W(() => {
|
|
97
97
|
if (c(), !n) {
|
|
98
98
|
const $ = document.createElement("script");
|
|
99
|
-
$.src = l || et, $.onload = g, $.id = `${a}-screenfull`,
|
|
99
|
+
$.src = l || et, $.onload = g, $.id = `${a}-screenfull`, $t($, "screenfull");
|
|
100
100
|
}
|
|
101
101
|
}), W(() => {
|
|
102
102
|
h.on(o, {
|
|
103
|
-
name:
|
|
103
|
+
name: st,
|
|
104
104
|
callback: r
|
|
105
105
|
});
|
|
106
106
|
}), { fullscreenHandler: r };
|
|
107
|
-
},
|
|
107
|
+
}, Nt = {
|
|
108
108
|
tableShape: {
|
|
109
109
|
type: Array,
|
|
110
110
|
default: () => [6, 4]
|
|
@@ -114,9 +114,9 @@ const Bt = /* @__PURE__ */ I({
|
|
|
114
114
|
default: () => {
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
},
|
|
117
|
+
}, Pt = /* @__PURE__ */ O({
|
|
118
118
|
name: "TableShape",
|
|
119
|
-
props:
|
|
119
|
+
props: Nt,
|
|
120
120
|
setup(e) {
|
|
121
121
|
const o = Y({
|
|
122
122
|
x: -1,
|
|
@@ -143,7 +143,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
143
143
|
class: [`${a}-table-shape-col-default`, l <= o.x && r <= o.y && `${a}-table-shape-col-include`]
|
|
144
144
|
}, null)]))]))]);
|
|
145
145
|
}
|
|
146
|
-
}),
|
|
146
|
+
}), Ut = Pt, qt = {
|
|
147
147
|
type: {
|
|
148
148
|
type: String,
|
|
149
149
|
default: "link"
|
|
@@ -162,10 +162,10 @@ const Bt = /* @__PURE__ */ I({
|
|
|
162
162
|
default: () => {
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
},
|
|
166
|
-
props:
|
|
165
|
+
}, Gt = /* @__PURE__ */ O({
|
|
166
|
+
props: qt,
|
|
167
167
|
setup(e) {
|
|
168
|
-
const o =
|
|
168
|
+
const o = A("usedLanguageText"), n = A("editorId"), l = me(() => {
|
|
169
169
|
var r, c;
|
|
170
170
|
switch (e.type) {
|
|
171
171
|
case "link":
|
|
@@ -179,7 +179,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
179
179
|
desc: "",
|
|
180
180
|
url: ""
|
|
181
181
|
});
|
|
182
|
-
return
|
|
182
|
+
return B(() => e.visible, (r) => {
|
|
183
183
|
r || setTimeout(() => {
|
|
184
184
|
s.desc = "", s.url = "";
|
|
185
185
|
}, 200);
|
|
@@ -232,7 +232,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
}),
|
|
235
|
+
}), Kt = {
|
|
236
236
|
visible: {
|
|
237
237
|
type: Boolean,
|
|
238
238
|
default: !1
|
|
@@ -247,11 +247,11 @@ const Bt = /* @__PURE__ */ I({
|
|
|
247
247
|
default: () => {
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
},
|
|
251
|
-
props:
|
|
250
|
+
}, jt = /* @__PURE__ */ O({
|
|
251
|
+
props: Kt,
|
|
252
252
|
setup(e) {
|
|
253
253
|
var u, k, $;
|
|
254
|
-
const o =
|
|
254
|
+
const o = A("usedLanguageText"), n = A("editorId");
|
|
255
255
|
let l = ($ = (k = (u = G) == null ? void 0 : u.editorExtensions) == null ? void 0 : k.cropper) == null ? void 0 : $.instance;
|
|
256
256
|
const s = q(), r = q(), c = q(), g = Y({
|
|
257
257
|
cropperInited: !1,
|
|
@@ -261,7 +261,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
261
261
|
isFullscreen: !1
|
|
262
262
|
});
|
|
263
263
|
let f = null;
|
|
264
|
-
|
|
264
|
+
B(() => e.visible, () => {
|
|
265
265
|
e.visible && !g.cropperInited && (l = l || window.Cropper, s.value.onchange = () => {
|
|
266
266
|
if (!l) {
|
|
267
267
|
h.emit(n, "errorCatcher", {
|
|
@@ -284,9 +284,9 @@ const Bt = /* @__PURE__ */ I({
|
|
|
284
284
|
}, v.readAsDataURL(b[0]);
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
|
-
}),
|
|
287
|
+
}), B(() => [g.imgSelected], () => {
|
|
288
288
|
c.value.style = "";
|
|
289
|
-
}),
|
|
289
|
+
}), B(() => g.isFullscreen, () => {
|
|
290
290
|
ue(() => {
|
|
291
291
|
f == null || f.destroy(), c.value.style = "", r.value && (f = new l(r.value, {
|
|
292
292
|
viewMode: 2,
|
|
@@ -375,7 +375,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
375
375
|
});
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
|
-
}),
|
|
378
|
+
}), _t = {
|
|
379
379
|
type: {
|
|
380
380
|
type: String,
|
|
381
381
|
default: "link"
|
|
@@ -398,27 +398,27 @@ const Bt = /* @__PURE__ */ I({
|
|
|
398
398
|
default: () => {
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
},
|
|
402
|
-
props:
|
|
401
|
+
}, Wt = /* @__PURE__ */ O({
|
|
402
|
+
props: _t,
|
|
403
403
|
setup(e) {
|
|
404
|
-
return () => t(Ke, null, [t(
|
|
404
|
+
return () => t(Ke, null, [t(Gt, {
|
|
405
405
|
type: e.type,
|
|
406
406
|
visible: e.linkVisible,
|
|
407
407
|
onOk: e.onOk,
|
|
408
408
|
onCancel: e.onCancel
|
|
409
|
-
}, null), t(
|
|
409
|
+
}, null), t(jt, {
|
|
410
410
|
visible: e.clipVisible,
|
|
411
411
|
onOk: e.onOk,
|
|
412
412
|
onCancel: e.onCancel
|
|
413
413
|
}, null)]);
|
|
414
414
|
}
|
|
415
|
-
}),
|
|
415
|
+
}), zt = /* @__PURE__ */ O({
|
|
416
416
|
name: "MDEditorToolbar",
|
|
417
|
-
props:
|
|
417
|
+
props: Vt,
|
|
418
418
|
setup(e) {
|
|
419
|
-
const o =
|
|
419
|
+
const o = A("editorId"), n = A("usedLanguageText"), {
|
|
420
420
|
fullscreenHandler: l
|
|
421
|
-
} =
|
|
421
|
+
} = Rt(e), s = `${o}-toolbar-wrapper`, r = Y({
|
|
422
422
|
title: !1,
|
|
423
423
|
catalog: !1,
|
|
424
424
|
// 图片上传下拉
|
|
@@ -453,11 +453,11 @@ const Bt = /* @__PURE__ */ I({
|
|
|
453
453
|
u.value.addEventListener("change", k);
|
|
454
454
|
});
|
|
455
455
|
const $ = (b) => {
|
|
456
|
-
var v, m, y, x, T, w,
|
|
456
|
+
var v, m, y, x, T, w, M, p, S, R, L, D, V, F, E, K, N, le, Z, j, P, J, _, H, I, X, oe, ge, he, be, ve, ke, pe, Ce, $e, ye, xe, we, Te, Se, Ae, Me, Le;
|
|
457
457
|
if (tt.includes(b))
|
|
458
458
|
switch (b) {
|
|
459
459
|
case "-":
|
|
460
|
-
return t(
|
|
460
|
+
return t(Ot, null, null);
|
|
461
461
|
case "bold":
|
|
462
462
|
return t("div", {
|
|
463
463
|
class: `${a}-toolbar-item`,
|
|
@@ -537,7 +537,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
537
537
|
onClick: () => {
|
|
538
538
|
c("h3");
|
|
539
539
|
}
|
|
540
|
-
}, [(
|
|
540
|
+
}, [(M = n.value.titleItem) == null ? void 0 : M.h3]), t("li", {
|
|
541
541
|
class: `${a}-menu-item`,
|
|
542
542
|
onClick: () => {
|
|
543
543
|
c("h4");
|
|
@@ -547,7 +547,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
547
547
|
onClick: () => {
|
|
548
548
|
c("h5");
|
|
549
549
|
}
|
|
550
|
-
}, [(
|
|
550
|
+
}, [(S = n.value.titleItem) == null ? void 0 : S.h5]), t("li", {
|
|
551
551
|
class: `${a}-menu-item`,
|
|
552
552
|
onClick: () => {
|
|
553
553
|
c("h6");
|
|
@@ -596,7 +596,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
596
596
|
case "quote":
|
|
597
597
|
return t("div", {
|
|
598
598
|
class: `${a}-toolbar-item`,
|
|
599
|
-
title: (
|
|
599
|
+
title: (V = n.value.toolbarTips) == null ? void 0 : V.quote,
|
|
600
600
|
onClick: () => {
|
|
601
601
|
c("quote");
|
|
602
602
|
}
|
|
@@ -609,7 +609,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
609
609
|
case "unorderedList":
|
|
610
610
|
return t("div", {
|
|
611
611
|
class: `${a}-toolbar-item`,
|
|
612
|
-
title: (
|
|
612
|
+
title: (F = n.value.toolbarTips) == null ? void 0 : F.unorderedList,
|
|
613
613
|
onClick: () => {
|
|
614
614
|
c("unorderedList");
|
|
615
615
|
}
|
|
@@ -745,7 +745,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
745
745
|
r.table = C;
|
|
746
746
|
},
|
|
747
747
|
key: "bar-table",
|
|
748
|
-
overlay: t(
|
|
748
|
+
overlay: t(Ut, {
|
|
749
749
|
tableShape: e.tableShape,
|
|
750
750
|
onSelected: (C) => {
|
|
751
751
|
c("table", {
|
|
@@ -783,7 +783,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
783
783
|
case "next":
|
|
784
784
|
return t("div", {
|
|
785
785
|
class: `${a}-toolbar-item`,
|
|
786
|
-
title: (
|
|
786
|
+
title: (I = n.value.toolbarTips) == null ? void 0 : I.next,
|
|
787
787
|
onClick: () => {
|
|
788
788
|
h.emit(o, "ctrlShiftZ");
|
|
789
789
|
}
|
|
@@ -876,7 +876,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
876
876
|
class: `${a}-toolbar-item`,
|
|
877
877
|
title: (ke = n.value.toolbarTips) == null ? void 0 : ke.catalog,
|
|
878
878
|
onClick: () => {
|
|
879
|
-
h.emit(o,
|
|
879
|
+
h.emit(o, ct);
|
|
880
880
|
},
|
|
881
881
|
key: "bar-catalog"
|
|
882
882
|
}, [t("svg", {
|
|
@@ -1026,7 +1026,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1026
1026
|
style: {
|
|
1027
1027
|
display: "none"
|
|
1028
1028
|
}
|
|
1029
|
-
}, null), t(
|
|
1029
|
+
}, null), t(Wt, {
|
|
1030
1030
|
linkVisible: g.linkVisible,
|
|
1031
1031
|
clipVisible: g.clipVisible,
|
|
1032
1032
|
type: g.type,
|
|
@@ -1042,14 +1042,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1042
1042
|
}, null)]);
|
|
1043
1043
|
};
|
|
1044
1044
|
}
|
|
1045
|
-
}),
|
|
1046
|
-
let l = e.scrollTop;
|
|
1047
|
-
const s = () => {
|
|
1048
|
-
const r = o - l;
|
|
1049
|
-
l = l + r / 5, Math.abs(r) < 1 ? (e.scrollTo(0, o), n && setTimeout(n, 100)) : (e.scrollTo(0, l), requestAnimationFrame(s));
|
|
1050
|
-
};
|
|
1051
|
-
s();
|
|
1052
|
-
}, Ee = zt, Yt = (e, o) => {
|
|
1045
|
+
}), Yt = (e, o) => {
|
|
1053
1046
|
const n = rt(() => {
|
|
1054
1047
|
e.removeEventListener("scroll", l), e.addEventListener("scroll", l), o.removeEventListener("scroll", l), o.addEventListener("scroll", l);
|
|
1055
1048
|
}, 50), l = (s) => {
|
|
@@ -1088,8 +1081,8 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1088
1081
|
});
|
|
1089
1082
|
};
|
|
1090
1083
|
let f = 0, d = 0;
|
|
1091
|
-
const u = (k) => {
|
|
1092
|
-
var v, m, y, x, T, w,
|
|
1084
|
+
const u = it((k) => {
|
|
1085
|
+
var v, m, y, x, T, w, M;
|
|
1093
1086
|
if (!((v = o.firstElementChild) != null && v.firstElementChild))
|
|
1094
1087
|
return;
|
|
1095
1088
|
const $ = l.lineBlockAtHeight(l.scrollDOM.scrollTop), { number: b } = l.state.doc.lineAt($.from);
|
|
@@ -1098,13 +1091,13 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1098
1091
|
if (d !== 0)
|
|
1099
1092
|
return;
|
|
1100
1093
|
f++;
|
|
1101
|
-
const p = c[b - 1],
|
|
1094
|
+
const p = c[b - 1], S = s(p.end) + r(p.end);
|
|
1102
1095
|
let R = 0;
|
|
1103
|
-
const L = s(p.start), D = o.querySelector(`[data-line="${p.start - 1}"]`) || ((m = o.firstElementChild) == null ? void 0 : m.firstElementChild),
|
|
1104
|
-
let
|
|
1105
|
-
L === 0 ? (R = (l.scrollDOM.scrollTop - L) / (
|
|
1106
|
-
const K = E - 10 +
|
|
1107
|
-
|
|
1096
|
+
const L = s(p.start), D = o.querySelector(`[data-line="${p.start - 1}"]`) || ((m = o.firstElementChild) == null ? void 0 : m.firstElementChild), V = o.querySelector(`[data-line="${p.end}"]`) || ((y = o.lastElementChild) == null ? void 0 : y.lastElementChild);
|
|
1097
|
+
let F = 0, E = 0;
|
|
1098
|
+
L === 0 ? (R = (l.scrollDOM.scrollTop - L) / (S - L), F = V.offsetTop) : S > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (R = (l.scrollDOM.scrollTop - L) / (l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight - L), E = D.offsetTop, F = o.scrollHeight - o.clientHeight - E + 10) : (R = (l.scrollDOM.scrollTop - L) / (S - L), E = D.offsetTop, F = V.offsetTop - E);
|
|
1099
|
+
const K = E - 10 + F * R;
|
|
1100
|
+
De(o, K, () => {
|
|
1108
1101
|
f--;
|
|
1109
1102
|
});
|
|
1110
1103
|
} else {
|
|
@@ -1113,55 +1106,60 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1113
1106
|
d++;
|
|
1114
1107
|
const p = Array.from(
|
|
1115
1108
|
o.querySelectorAll("[data-line]")
|
|
1116
|
-
),
|
|
1109
|
+
), S = o.scrollTop, R = o.scrollHeight;
|
|
1117
1110
|
let L = p.length === 0 ? 1 : Math.ceil(
|
|
1118
|
-
Number(p[p.length - 1].dataset.line) * (
|
|
1111
|
+
Number(p[p.length - 1].dataset.line) * (S / R)
|
|
1119
1112
|
), D = (x = o.firstElementChild) == null ? void 0 : x.firstElementChild;
|
|
1120
1113
|
for (let H = L; H >= 0; H--) {
|
|
1121
|
-
const
|
|
1122
|
-
if (
|
|
1123
|
-
D =
|
|
1114
|
+
const I = o.querySelector(`[data-line="${H}"]`);
|
|
1115
|
+
if (I && I.offsetTop <= S) {
|
|
1116
|
+
D = I, L = H;
|
|
1124
1117
|
break;
|
|
1125
1118
|
}
|
|
1126
1119
|
}
|
|
1127
|
-
let
|
|
1120
|
+
let V = (T = o.firstElementChild) == null ? void 0 : T.firstElementChild, F = (w = o.firstElementChild) == null ? void 0 : w.lastElementChild;
|
|
1128
1121
|
for (; p.length > 0; ) {
|
|
1129
1122
|
const H = p.indexOf(D);
|
|
1130
1123
|
if (H + 1 >= p.length)
|
|
1131
1124
|
break;
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1125
|
+
const I = p[H + 1];
|
|
1126
|
+
if (H === -1) {
|
|
1127
|
+
F = I;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
const X = D.offsetTop;
|
|
1131
|
+
if (X > S) {
|
|
1134
1132
|
if (H === 0) {
|
|
1135
|
-
|
|
1133
|
+
V = D, F = I;
|
|
1136
1134
|
break;
|
|
1137
1135
|
}
|
|
1138
1136
|
D = p[H - 1];
|
|
1139
1137
|
continue;
|
|
1140
1138
|
}
|
|
1141
|
-
const oe =
|
|
1142
|
-
if (X <=
|
|
1143
|
-
|
|
1139
|
+
const oe = I.offsetTop;
|
|
1140
|
+
if (X <= S && oe > S) {
|
|
1141
|
+
V = D, F = I;
|
|
1144
1142
|
break;
|
|
1145
1143
|
}
|
|
1146
|
-
D =
|
|
1144
|
+
D = I;
|
|
1147
1145
|
}
|
|
1148
|
-
const E =
|
|
1146
|
+
const E = V.offsetTop, K = F.offsetTop;
|
|
1149
1147
|
let N = 0;
|
|
1150
|
-
const { start: le, end: Z } = c[Number(
|
|
1148
|
+
const { start: le, end: Z } = c[Number(V.dataset.line || 0)], j = s(le);
|
|
1151
1149
|
let P = s(Z);
|
|
1152
1150
|
const J = r(Z);
|
|
1153
1151
|
let _ = 0;
|
|
1154
|
-
|
|
1155
|
-
(
|
|
1152
|
+
V === ((M = o.firstElementChild) == null ? void 0 : M.firstElementChild) ? (N = Math.max(S / K, 0), _ = P + J - j) : P > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (N = Math.max(
|
|
1153
|
+
(S - E) / (o.scrollHeight - E - o.clientHeight),
|
|
1156
1154
|
0
|
|
1157
1155
|
), P = s(l.state.doc.lines) + r(l.state.doc.lines), _ = 8 + P - j - e.clientHeight) : (N = Math.max(
|
|
1158
|
-
(
|
|
1156
|
+
(S - E) / (K - E),
|
|
1159
1157
|
0
|
|
1160
|
-
), _ = P + J - j),
|
|
1158
|
+
), _ = P + J - j), De(e, j + _ * N, () => {
|
|
1161
1159
|
d--;
|
|
1162
1160
|
});
|
|
1163
1161
|
}
|
|
1164
|
-
};
|
|
1162
|
+
}, 10);
|
|
1165
1163
|
return [
|
|
1166
1164
|
() => {
|
|
1167
1165
|
g(), e.addEventListener("scroll", u), o.addEventListener("scroll", u), e.dispatchEvent(new Event("scroll"));
|
|
@@ -1171,7 +1169,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1171
1169
|
}
|
|
1172
1170
|
];
|
|
1173
1171
|
}, Jt = (e, o, n) => {
|
|
1174
|
-
const l =
|
|
1172
|
+
const l = A("editorId");
|
|
1175
1173
|
let s = () => {
|
|
1176
1174
|
}, r = () => {
|
|
1177
1175
|
};
|
|
@@ -1188,7 +1186,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1188
1186
|
n.value
|
|
1189
1187
|
)), e.scrollAuto && r();
|
|
1190
1188
|
};
|
|
1191
|
-
|
|
1189
|
+
B(
|
|
1192
1190
|
[
|
|
1193
1191
|
o,
|
|
1194
1192
|
ae(e.setting, "preview"),
|
|
@@ -1199,7 +1197,7 @@ const Bt = /* @__PURE__ */ I({
|
|
|
1199
1197
|
() => {
|
|
1200
1198
|
ue(c);
|
|
1201
1199
|
}
|
|
1202
|
-
),
|
|
1200
|
+
), B(
|
|
1203
1201
|
() => e.scrollAuto,
|
|
1204
1202
|
(g) => {
|
|
1205
1203
|
g ? r() : s();
|
|
@@ -1289,7 +1287,7 @@ ${y}
|
|
|
1289
1287
|
for (let w = 0; w <= x; w++) {
|
|
1290
1288
|
l += `
|
|
1291
1289
|
|`;
|
|
1292
|
-
for (let
|
|
1290
|
+
for (let M = 0; M <= T; M++)
|
|
1293
1291
|
l += " content |";
|
|
1294
1292
|
}
|
|
1295
1293
|
s = 2, r = 5 - l.length;
|
|
@@ -1302,7 +1300,7 @@ ${y}
|
|
|
1302
1300
|
}
|
|
1303
1301
|
case "image": {
|
|
1304
1302
|
const { desc: y, url: x, urls: T } = n;
|
|
1305
|
-
T instanceof Array ? l = T.reduce((w,
|
|
1303
|
+
T instanceof Array ? l = T.reduce((w, M) => w + `
|
|
1306
1304
|
`, "") : l = `
|
|
1307
1305
|
`, c = !1;
|
|
1308
1306
|
break;
|
|
@@ -1624,9 +1622,9 @@ $$
|
|
|
1624
1622
|
pl,
|
|
1625
1623
|
ze(Cl)
|
|
1626
1624
|
], z = (e) => {
|
|
1627
|
-
const o = new
|
|
1625
|
+
const o = new Ft();
|
|
1628
1626
|
return (l) => (o.get(e.state) ? e.dispatch({ effects: o.reconfigure(l) }) : e.dispatch({
|
|
1629
|
-
effects:
|
|
1627
|
+
effects: It.appendConfig.of(o.of(l))
|
|
1630
1628
|
}), !0);
|
|
1631
1629
|
};
|
|
1632
1630
|
class yl {
|
|
@@ -1712,7 +1710,7 @@ class yl {
|
|
|
1712
1710
|
setTabSize(o) {
|
|
1713
1711
|
this.toggleTabSize([
|
|
1714
1712
|
ie.tabSize.of(o),
|
|
1715
|
-
|
|
1713
|
+
Ht.of(" ".repeat(o))
|
|
1716
1714
|
]);
|
|
1717
1715
|
}
|
|
1718
1716
|
/**
|
|
@@ -1721,7 +1719,7 @@ class yl {
|
|
|
1721
1719
|
* @param t 目标内容
|
|
1722
1720
|
*/
|
|
1723
1721
|
setPlaceholder(o) {
|
|
1724
|
-
this.togglePlaceholder(
|
|
1722
|
+
this.togglePlaceholder(wt(o));
|
|
1725
1723
|
}
|
|
1726
1724
|
focus() {
|
|
1727
1725
|
this.view.focus();
|
|
@@ -1739,7 +1737,7 @@ class yl {
|
|
|
1739
1737
|
}
|
|
1740
1738
|
}
|
|
1741
1739
|
const xl = (e) => {
|
|
1742
|
-
const o =
|
|
1740
|
+
const o = A("editorId");
|
|
1743
1741
|
return (l) => {
|
|
1744
1742
|
if (l.clipboardData) {
|
|
1745
1743
|
if (l.clipboardData.files.length > 0) {
|
|
@@ -1760,10 +1758,10 @@ const xl = (e) => {
|
|
|
1760
1758
|
}
|
|
1761
1759
|
};
|
|
1762
1760
|
}, wl = xl, Tl = (e) => {
|
|
1763
|
-
const o =
|
|
1761
|
+
const o = A("editorId");
|
|
1764
1762
|
W(() => {
|
|
1765
1763
|
h.on(o, {
|
|
1766
|
-
name:
|
|
1764
|
+
name: dt,
|
|
1767
1765
|
callback() {
|
|
1768
1766
|
var n;
|
|
1769
1767
|
(n = e.value) == null || n.focus();
|
|
@@ -1779,13 +1777,13 @@ const xl = (e) => {
|
|
|
1779
1777
|
{
|
|
1780
1778
|
key: "Ctrl-d",
|
|
1781
1779
|
mac: "Cmd-d",
|
|
1782
|
-
run:
|
|
1780
|
+
run: Mt,
|
|
1783
1781
|
preventDefault: !0
|
|
1784
1782
|
},
|
|
1785
1783
|
{
|
|
1786
1784
|
key: "Ctrl-s",
|
|
1787
1785
|
mac: "Cmd-s",
|
|
1788
|
-
run: (
|
|
1786
|
+
run: (M) => (h.emit(e, je, M.state.doc.toString()), !0),
|
|
1789
1787
|
shift: () => (h.emit(e, "replace", "strikeThrough"), !0)
|
|
1790
1788
|
},
|
|
1791
1789
|
{
|
|
@@ -1849,7 +1847,7 @@ const xl = (e) => {
|
|
|
1849
1847
|
key: "Ctrl-c",
|
|
1850
1848
|
mac: "Cmd-c",
|
|
1851
1849
|
shift: () => (h.emit(e, "replace", "code"), !0),
|
|
1852
|
-
any(
|
|
1850
|
+
any(M, p) {
|
|
1853
1851
|
return (p.ctrlKey || p.metaKey) && p.altKey && p.code === "KeyC" ? (h.emit(e, "replace", "codeRow"), !0) : !1;
|
|
1854
1852
|
}
|
|
1855
1853
|
},
|
|
@@ -1864,13 +1862,13 @@ const xl = (e) => {
|
|
|
1864
1862
|
shift: () => o.noPrettier ? !1 : (h.emit(e, "replace", "prettier"), !0)
|
|
1865
1863
|
},
|
|
1866
1864
|
{
|
|
1867
|
-
any: (
|
|
1865
|
+
any: (M, p) => (p.ctrlKey || p.metaKey) && p.altKey && p.shiftKey && p.code === "KeyT" ? (h.emit(e, "replace", "table"), !0) : !1
|
|
1868
1866
|
}
|
|
1869
1867
|
], Ml = Al, Ll = (e) => {
|
|
1870
|
-
const o =
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1868
|
+
const o = A("tabWidth"), n = A("editorId"), l = A("theme"), s = q(), r = Xe(), c = Ml(n, e), g = wl(e), f = [
|
|
1869
|
+
Tt.of([...c, Lt]),
|
|
1870
|
+
xt,
|
|
1871
|
+
At({ codeLanguages: St }),
|
|
1874
1872
|
// 横向换行
|
|
1875
1873
|
ne.lineWrapping,
|
|
1876
1874
|
ne.updateListener.of((u) => {
|
|
@@ -1898,12 +1896,12 @@ const xl = (e) => {
|
|
|
1898
1896
|
r.value = new yl(u), r.value.setTabSize(o), r.value.setExtensions(d()), r.value.setDisabled(e.disabled), r.value.setReadOnly(e.readonly), e.placeholder && r.value.setPlaceholder(e.placeholder), e.autofocus && u.focus(), e.maxlength && r.value.setMaxLength(e.maxlength), h.on(n, {
|
|
1899
1897
|
name: "ctrlZ",
|
|
1900
1898
|
callback() {
|
|
1901
|
-
|
|
1899
|
+
Dt(u);
|
|
1902
1900
|
}
|
|
1903
1901
|
}), h.on(n, {
|
|
1904
1902
|
name: "ctrlShiftZ",
|
|
1905
1903
|
callback() {
|
|
1906
|
-
|
|
1904
|
+
Et(u);
|
|
1907
1905
|
}
|
|
1908
1906
|
}), h.on(n, {
|
|
1909
1907
|
name: "replace",
|
|
@@ -1913,37 +1911,37 @@ const xl = (e) => {
|
|
|
1913
1911
|
(m = r.value) == null || m.replaceSelectedText(b, v);
|
|
1914
1912
|
}
|
|
1915
1913
|
});
|
|
1916
|
-
}),
|
|
1914
|
+
}), B(
|
|
1917
1915
|
() => l.value,
|
|
1918
1916
|
() => {
|
|
1919
1917
|
var u, k;
|
|
1920
1918
|
l.value === "dark" ? (u = r.value) == null || u.setExtensions(d()) : (k = r.value) == null || k.setExtensions(d());
|
|
1921
1919
|
}
|
|
1922
|
-
),
|
|
1920
|
+
), B(
|
|
1923
1921
|
() => e.value,
|
|
1924
1922
|
() => {
|
|
1925
1923
|
var u, k;
|
|
1926
1924
|
((u = r.value) == null ? void 0 : u.getValue()) !== e.value && ((k = r.value) == null || k.setValue(e.value));
|
|
1927
1925
|
}
|
|
1928
|
-
),
|
|
1926
|
+
), B(
|
|
1929
1927
|
() => e.placeholder,
|
|
1930
1928
|
() => {
|
|
1931
1929
|
var u;
|
|
1932
1930
|
(u = r.value) == null || u.setPlaceholder(e.placeholder);
|
|
1933
1931
|
}
|
|
1934
|
-
),
|
|
1932
|
+
), B(
|
|
1935
1933
|
() => e.disabled,
|
|
1936
1934
|
() => {
|
|
1937
1935
|
var u;
|
|
1938
1936
|
(u = r.value) == null || u.setDisabled(e.disabled);
|
|
1939
1937
|
}
|
|
1940
|
-
),
|
|
1938
|
+
), B(
|
|
1941
1939
|
() => e.readonly,
|
|
1942
1940
|
() => {
|
|
1943
1941
|
var u;
|
|
1944
1942
|
(u = r.value) == null || u.setDisabled(e.readonly);
|
|
1945
1943
|
}
|
|
1946
|
-
),
|
|
1944
|
+
), B(
|
|
1947
1945
|
() => e.maxlength,
|
|
1948
1946
|
() => {
|
|
1949
1947
|
var u;
|
|
@@ -2043,7 +2041,7 @@ const xl = (e) => {
|
|
|
2043
2041
|
type: Boolean,
|
|
2044
2042
|
default: !1
|
|
2045
2043
|
}
|
|
2046
|
-
}, Hl = /* @__PURE__ */
|
|
2044
|
+
}, Hl = /* @__PURE__ */ O({
|
|
2047
2045
|
name: "MDEditorContent",
|
|
2048
2046
|
props: El,
|
|
2049
2047
|
setup(e) {
|
|
@@ -2056,7 +2054,7 @@ const xl = (e) => {
|
|
|
2056
2054
|
}, [t("div", {
|
|
2057
2055
|
class: `${a}-input-wrapper`,
|
|
2058
2056
|
ref: n
|
|
2059
|
-
}, null), t(
|
|
2057
|
+
}, null), t(ut, {
|
|
2060
2058
|
modelValue: e.value,
|
|
2061
2059
|
setting: e.setting,
|
|
2062
2060
|
onHtmlChanged: (s) => {
|
|
@@ -2071,7 +2069,7 @@ const xl = (e) => {
|
|
|
2071
2069
|
noHighlight: e.noHighlight
|
|
2072
2070
|
}, null)]);
|
|
2073
2071
|
}
|
|
2074
|
-
}), Fl = /* @__PURE__ */
|
|
2072
|
+
}), Fl = /* @__PURE__ */ O({
|
|
2075
2073
|
props: {
|
|
2076
2074
|
modelValue: {
|
|
2077
2075
|
type: String,
|
|
@@ -2079,7 +2077,7 @@ const xl = (e) => {
|
|
|
2079
2077
|
}
|
|
2080
2078
|
},
|
|
2081
2079
|
setup(e) {
|
|
2082
|
-
const o =
|
|
2080
|
+
const o = A("usedLanguageText");
|
|
2083
2081
|
return () => {
|
|
2084
2082
|
var n, l;
|
|
2085
2083
|
return t("div", {
|
|
@@ -2099,7 +2097,7 @@ const xl = (e) => {
|
|
|
2099
2097
|
default: () => {
|
|
2100
2098
|
}
|
|
2101
2099
|
}
|
|
2102
|
-
}, Bl = /* @__PURE__ */
|
|
2100
|
+
}, Bl = /* @__PURE__ */ O({
|
|
2103
2101
|
props: Il,
|
|
2104
2102
|
setup(e) {
|
|
2105
2103
|
return () => t("div", {
|
|
@@ -2118,10 +2116,10 @@ const xl = (e) => {
|
|
|
2118
2116
|
default: () => {
|
|
2119
2117
|
}
|
|
2120
2118
|
}
|
|
2121
|
-
}, Vl = /* @__PURE__ */
|
|
2119
|
+
}, Vl = /* @__PURE__ */ O({
|
|
2122
2120
|
props: Ol,
|
|
2123
2121
|
setup(e) {
|
|
2124
|
-
const o =
|
|
2122
|
+
const o = A("usedLanguageText");
|
|
2125
2123
|
return () => {
|
|
2126
2124
|
var n;
|
|
2127
2125
|
return t("div", {
|
|
@@ -2157,7 +2155,7 @@ const xl = (e) => {
|
|
|
2157
2155
|
defFooters: {
|
|
2158
2156
|
type: Object
|
|
2159
2157
|
}
|
|
2160
|
-
}, Nl = /* @__PURE__ */
|
|
2158
|
+
}, Nl = /* @__PURE__ */ O({
|
|
2161
2159
|
name: "MDEditorFooter",
|
|
2162
2160
|
props: Rl,
|
|
2163
2161
|
setup(e) {
|
|
@@ -2191,10 +2189,10 @@ const xl = (e) => {
|
|
|
2191
2189
|
}, [s])]);
|
|
2192
2190
|
};
|
|
2193
2191
|
}
|
|
2194
|
-
}), Pl = /* @__PURE__ */
|
|
2192
|
+
}), Pl = /* @__PURE__ */ O({
|
|
2195
2193
|
name: "MdEditorV3",
|
|
2196
|
-
props:
|
|
2197
|
-
emits:
|
|
2194
|
+
props: mt,
|
|
2195
|
+
emits: ft,
|
|
2198
2196
|
setup(e, o) {
|
|
2199
2197
|
const {
|
|
2200
2198
|
editorId: n,
|
|
@@ -2206,16 +2204,16 @@ const xl = (e) => {
|
|
|
2206
2204
|
} = e, f = Y({
|
|
2207
2205
|
scrollAuto: e.scrollAuto
|
|
2208
2206
|
});
|
|
2209
|
-
|
|
2210
|
-
const [d, u] =
|
|
2207
|
+
gt(e, o), ht(e), bt(e);
|
|
2208
|
+
const [d, u] = vt(e, o), k = kt(e);
|
|
2211
2209
|
return Qe(() => {
|
|
2212
2210
|
h.clear(n);
|
|
2213
|
-
}),
|
|
2211
|
+
}), pt(e, o, k, d, u), () => {
|
|
2214
2212
|
var v;
|
|
2215
|
-
const $ =
|
|
2213
|
+
const $ = Ee({
|
|
2216
2214
|
props: e,
|
|
2217
2215
|
ctx: o
|
|
2218
|
-
}, "defToolbars"), b =
|
|
2216
|
+
}, "defToolbars"), b = Ee({
|
|
2219
2217
|
props: e,
|
|
2220
2218
|
ctx: o
|
|
2221
2219
|
}, "defFooters");
|
|
@@ -2223,7 +2221,7 @@ const xl = (e) => {
|
|
|
2223
2221
|
id: n,
|
|
2224
2222
|
class: [a, e.class, e.theme === "dark" && `${a}-dark`, d.fullscreen || d.pageFullscreen ? `${a}-fullscreen` : ""],
|
|
2225
2223
|
style: e.style
|
|
2226
|
-
}, [t(
|
|
2224
|
+
}, [t(zt, {
|
|
2227
2225
|
noPrettier: r,
|
|
2228
2226
|
toolbars: e.toolbars,
|
|
2229
2227
|
toolbarsExclude: e.toolbarsExclude,
|
|
@@ -2280,7 +2278,7 @@ const xl = (e) => {
|
|
|
2280
2278
|
};
|
|
2281
2279
|
}
|
|
2282
2280
|
}), de = Pl;
|
|
2283
|
-
de.install = (e) => (e.component(de.name, de), e.use(
|
|
2281
|
+
de.install = (e) => (e.component(de.name, de), e.use(Bt).use(ot).use(yt).use(Ye).use(Ct), e);
|
|
2284
2282
|
export {
|
|
2285
2283
|
de as default
|
|
2286
2284
|
};
|