md-editor-v3 4.3.0-beta.5 → 4.3.0-beta.6
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/README.md +1 -2
- package/lib/cjs/MdEditor.cjs +11 -11
- package/lib/es/MdEditor.mjs +196 -196
- package/lib/umd/index.js +1 -1
- package/package.json +1 -1
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -3,7 +3,7 @@ var xt = (e, a, l) => a in e ? wt(e, a, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var K = (e, a, l) => (xt(e, typeof a != "symbol" ? a + "" : a, l), l);
|
|
4
4
|
import { defineComponent as V, createVNode as t, inject as A, ref as q, onMounted as Y, reactive as J, computed as he, watch as H, nextTick as ce, Fragment as kt, cloneVNode as at, toRef as le, shallowRef as St, onBeforeUnmount as At } from "vue";
|
|
5
5
|
import { p as o, a as z, s as Mt, b as Lt, d as Dt } from "./chunks/config.mjs";
|
|
6
|
-
import { draggingScroll as It, linkTo as Nt, debounce as Et, throttle as Ht, smoothScroll as
|
|
6
|
+
import { draggingScroll as It, linkTo as Nt, debounce as Et, throttle as Ht, smoothScroll as nt } from "@vavt/util";
|
|
7
7
|
import { a as te, D as Bt } from "./chunks/index2.mjs";
|
|
8
8
|
import { b as h, a as Ft } from "./chunks/index3.mjs";
|
|
9
9
|
import { C as Vt, a as Ot, O as pt, T as Rt, b as Pt, e as qt, c as Ut, u as Gt, d as Kt, f as jt, g as _t, h as Wt, i as zt, j as Yt, M as Zt } from "./chunks/index.mjs";
|
|
@@ -14,13 +14,13 @@ import { EditorView as be, placeholder as Qt, keymap as el } from "@codemirror/v
|
|
|
14
14
|
import { languages as tl } from "@codemirror/language-data";
|
|
15
15
|
import { markdown as ll } from "@codemirror/lang-markdown";
|
|
16
16
|
import { htmlCompletionSource as ol, html as al } from "@codemirror/lang-html";
|
|
17
|
-
import { deleteLine as
|
|
17
|
+
import { deleteLine as nl, indentWithTab as rl, undo as il, redo as sl } from "@codemirror/commands";
|
|
18
18
|
import { HighlightStyle as $t, syntaxHighlighting as yt, indentUnit as cl } from "@codemirror/language";
|
|
19
19
|
import { tags as s } from "@lezer/highlight";
|
|
20
20
|
import { EditorSelection as P, EditorState as ue, Compartment as dl, StateEffect as ul } from "@codemirror/state";
|
|
21
21
|
import { autocompletion as ml } from "@codemirror/autocomplete";
|
|
22
22
|
import Tt from "./MdCatalog.mjs";
|
|
23
|
-
import { g as
|
|
23
|
+
import { g as rt } from "./chunks/vue-tsx.mjs";
|
|
24
24
|
import fl from "./NormalToolbar.mjs";
|
|
25
25
|
import gl from "./ModalToolbar.mjs";
|
|
26
26
|
import "medium-zoom";
|
|
@@ -88,7 +88,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
88
88
|
var c, f, m, b;
|
|
89
89
|
const a = A("editorId");
|
|
90
90
|
let l = (f = (c = z.editorExtensions) == null ? void 0 : c.screenfull) == null ? void 0 : f.instance;
|
|
91
|
-
const
|
|
91
|
+
const n = (b = (m = z.editorExtensions) == null ? void 0 : m.screenfull) == null ? void 0 : b.js, r = q(!1), i = ($) => {
|
|
92
92
|
if (!l) {
|
|
93
93
|
h.emit(a, "errorCatcher", {
|
|
94
94
|
name: "fullscreen",
|
|
@@ -96,10 +96,10 @@ const hl = /* @__PURE__ */ V({
|
|
|
96
96
|
});
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
l.isEnabled ? (
|
|
99
|
+
l.isEnabled ? (r.value = !0, ($ === void 0 ? !l.isFullscreen : $) ? l.request() : l.exit()) : console.error("browser does not support screenfull!");
|
|
100
100
|
}, u = () => {
|
|
101
101
|
l && l.isEnabled && l.on("change", () => {
|
|
102
|
-
(
|
|
102
|
+
(r.value || e.setting.fullscreen) && (r.value = !1, e.updateSetting("fullscreen"));
|
|
103
103
|
});
|
|
104
104
|
}, d = () => {
|
|
105
105
|
l = window.screenfull, u();
|
|
@@ -107,7 +107,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
107
107
|
return Y(() => {
|
|
108
108
|
if (u(), !l) {
|
|
109
109
|
const $ = document.createElement("script");
|
|
110
|
-
$.src =
|
|
110
|
+
$.src = n || Mt, $.onload = d, $.id = `${o}-screenfull`, Jt($, "screenfull");
|
|
111
111
|
}
|
|
112
112
|
}), Y(() => {
|
|
113
113
|
h.on(a, {
|
|
@@ -138,20 +138,20 @@ const hl = /* @__PURE__ */ V({
|
|
|
138
138
|
onMouseleave: () => {
|
|
139
139
|
a.x = -1, a.y = -1;
|
|
140
140
|
}
|
|
141
|
-
}, [new Array(e.tableShape[1]).fill("").map((l,
|
|
141
|
+
}, [new Array(e.tableShape[1]).fill("").map((l, n) => t("div", {
|
|
142
142
|
class: `${o}-table-shape-row`,
|
|
143
|
-
key: `table-shape-row-${
|
|
144
|
-
}, [new Array(e.tableShape[0]).fill("").map((
|
|
143
|
+
key: `table-shape-row-${n}`
|
|
144
|
+
}, [new Array(e.tableShape[0]).fill("").map((r, i) => t("div", {
|
|
145
145
|
class: `${o}-table-shape-col`,
|
|
146
146
|
key: `table-shape-col-${i}`,
|
|
147
147
|
onMouseenter: () => {
|
|
148
|
-
a.x =
|
|
148
|
+
a.x = n, a.y = i;
|
|
149
149
|
},
|
|
150
150
|
onClick: () => {
|
|
151
151
|
e.onSelected(a);
|
|
152
152
|
}
|
|
153
153
|
}, [t("div", {
|
|
154
|
-
class: [`${o}-table-shape-col-default`,
|
|
154
|
+
class: [`${o}-table-shape-col-default`, n <= a.x && i <= a.y && `${o}-table-shape-col-include`]
|
|
155
155
|
}, null)]))]))]);
|
|
156
156
|
}
|
|
157
157
|
}), Cl = pl, $l = {
|
|
@@ -176,7 +176,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
176
176
|
}, yl = /* @__PURE__ */ V({
|
|
177
177
|
props: $l,
|
|
178
178
|
setup(e) {
|
|
179
|
-
const a = A("usedLanguageText"), l = A("editorId"),
|
|
179
|
+
const a = A("usedLanguageText"), l = A("editorId"), n = he(() => {
|
|
180
180
|
var i, u;
|
|
181
181
|
switch (e.type) {
|
|
182
182
|
case "link":
|
|
@@ -186,16 +186,16 @@ const hl = /* @__PURE__ */ V({
|
|
|
186
186
|
default:
|
|
187
187
|
return "";
|
|
188
188
|
}
|
|
189
|
-
}),
|
|
189
|
+
}), r = J({
|
|
190
190
|
desc: "",
|
|
191
191
|
url: ""
|
|
192
192
|
});
|
|
193
193
|
return H(() => e.visible, (i) => {
|
|
194
194
|
i || setTimeout(() => {
|
|
195
|
-
|
|
195
|
+
r.desc = "", r.url = "";
|
|
196
196
|
}, 200);
|
|
197
197
|
}), () => t(Ct, {
|
|
198
|
-
title:
|
|
198
|
+
title: n.value,
|
|
199
199
|
visible: e.visible,
|
|
200
200
|
onClose: e.onCancel
|
|
201
201
|
}, {
|
|
@@ -211,9 +211,9 @@ const hl = /* @__PURE__ */ V({
|
|
|
211
211
|
class: `${o}-input`,
|
|
212
212
|
id: `link-desc-${l}`,
|
|
213
213
|
type: "text",
|
|
214
|
-
value:
|
|
214
|
+
value: r.desc,
|
|
215
215
|
onChange: (m) => {
|
|
216
|
-
|
|
216
|
+
r.desc = m.target.value;
|
|
217
217
|
},
|
|
218
218
|
autocomplete: "off"
|
|
219
219
|
}, null)]), t("div", {
|
|
@@ -226,9 +226,9 @@ const hl = /* @__PURE__ */ V({
|
|
|
226
226
|
class: `${o}-input`,
|
|
227
227
|
id: `link-url-${l}`,
|
|
228
228
|
type: "text",
|
|
229
|
-
value:
|
|
229
|
+
value: r.url,
|
|
230
230
|
onChange: (m) => {
|
|
231
|
-
|
|
231
|
+
r.url = m.target.value;
|
|
232
232
|
},
|
|
233
233
|
autocomplete: "off"
|
|
234
234
|
}, null)]), t("div", {
|
|
@@ -237,7 +237,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
237
237
|
class: [`${o}-btn`, `${o}-btn-row`],
|
|
238
238
|
type: "button",
|
|
239
239
|
onClick: () => {
|
|
240
|
-
e.onOk(
|
|
240
|
+
e.onOk(r), r.desc = "", r.url = "";
|
|
241
241
|
}
|
|
242
242
|
}, [(f = a.value.linkModalTips) == null ? void 0 : f.buttonOK])])];
|
|
243
243
|
}
|
|
@@ -263,8 +263,8 @@ const hl = /* @__PURE__ */ V({
|
|
|
263
263
|
setup(e) {
|
|
264
264
|
var m, b, $;
|
|
265
265
|
const a = A("usedLanguageText"), l = A("editorId");
|
|
266
|
-
let
|
|
267
|
-
const
|
|
266
|
+
let n = ($ = (b = (m = z) == null ? void 0 : m.editorExtensions) == null ? void 0 : b.cropper) == null ? void 0 : $.instance;
|
|
267
|
+
const r = q(), i = q(), u = q(), d = J({
|
|
268
268
|
cropperInited: !1,
|
|
269
269
|
imgSelected: !1,
|
|
270
270
|
imgSrc: "",
|
|
@@ -273,20 +273,20 @@ const hl = /* @__PURE__ */ V({
|
|
|
273
273
|
});
|
|
274
274
|
let c = null;
|
|
275
275
|
H(() => e.visible, () => {
|
|
276
|
-
e.visible && !d.cropperInited && (
|
|
277
|
-
if (!
|
|
276
|
+
e.visible && !d.cropperInited && (n = n || window.Cropper, r.value.onchange = () => {
|
|
277
|
+
if (!n) {
|
|
278
278
|
h.emit(l, "errorCatcher", {
|
|
279
279
|
name: "Cropper",
|
|
280
280
|
message: "Cropper is undefined"
|
|
281
281
|
});
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
const T =
|
|
284
|
+
const T = r.value.files || [];
|
|
285
285
|
if (d.imgSelected = !0, (T == null ? void 0 : T.length) > 0) {
|
|
286
286
|
const v = new FileReader();
|
|
287
287
|
v.onload = (g) => {
|
|
288
288
|
d.imgSrc = g.target.result, ce(() => {
|
|
289
|
-
c = new
|
|
289
|
+
c = new n(i.value, {
|
|
290
290
|
viewMode: 2,
|
|
291
291
|
preview: `.${o}-clip-preview-target`
|
|
292
292
|
// aspectRatio: 16 / 9,
|
|
@@ -299,7 +299,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
299
299
|
u.value.style = "";
|
|
300
300
|
}), H(() => d.isFullscreen, () => {
|
|
301
301
|
ce(() => {
|
|
302
|
-
c == null || c.destroy(), u.value.style = "", i.value && (c = new
|
|
302
|
+
c == null || c.destroy(), u.value.style = "", i.value && (c = new n(i.value, {
|
|
303
303
|
viewMode: 2,
|
|
304
304
|
preview: `.${o}-clip-preview-target`
|
|
305
305
|
// aspectRatio: 16 / 9,
|
|
@@ -307,7 +307,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
307
307
|
});
|
|
308
308
|
});
|
|
309
309
|
const f = () => {
|
|
310
|
-
c.clear(), c.destroy(), c = null,
|
|
310
|
+
c.clear(), c.destroy(), c = null, r.value.value = "", d.imgSelected = !1;
|
|
311
311
|
};
|
|
312
312
|
return () => {
|
|
313
313
|
var T;
|
|
@@ -350,7 +350,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
350
350
|
}, null)])])]) : t("div", {
|
|
351
351
|
class: `${o}-clip-upload`,
|
|
352
352
|
onClick: () => {
|
|
353
|
-
|
|
353
|
+
r.value.click();
|
|
354
354
|
}
|
|
355
355
|
}, [t("svg", {
|
|
356
356
|
class: `${o}-icon`,
|
|
@@ -374,7 +374,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
}, [((v = a.value.clipModalTips) == null ? void 0 : v.buttonUpload) || ((g = a.value.linkModalTips) == null ? void 0 : g.buttonOK)])]), t("input", {
|
|
377
|
-
ref:
|
|
377
|
+
ref: r,
|
|
378
378
|
accept: "image/*",
|
|
379
379
|
type: "file",
|
|
380
380
|
multiple: !1,
|
|
@@ -428,8 +428,8 @@ const hl = /* @__PURE__ */ V({
|
|
|
428
428
|
props: bl,
|
|
429
429
|
setup(e) {
|
|
430
430
|
const a = A("editorId"), l = A("usedLanguageText"), {
|
|
431
|
-
fullscreenHandler:
|
|
432
|
-
} = vl(e),
|
|
431
|
+
fullscreenHandler: n
|
|
432
|
+
} = vl(e), r = `${a}-toolbar-wrapper`, i = q(), u = J({
|
|
433
433
|
title: !1,
|
|
434
434
|
catalog: !1,
|
|
435
435
|
// 图片上传下拉
|
|
@@ -464,7 +464,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
464
464
|
b.value.addEventListener("change", $);
|
|
465
465
|
});
|
|
466
466
|
const T = (v) => {
|
|
467
|
-
var g, k, y, w, x, L, C, M, R, D, I, O, B, N, j, U,
|
|
467
|
+
var g, k, y, w, x, L, C, M, R, D, I, O, B, N, j, U, ne, X, _, G, Q, W, E, F, ee, re, ve, ke, pe, Ce, $e, ye, Te, we, xe, Se, Ae, Me, Le, De, Ie, Ne, Ee, He, Be, Fe, Ve, Oe, Re, Pe, qe, Ue, Ge, Ke, je, _e, We, ze, Ye, Ze, Je, Xe, Qe, et, tt, lt, ot;
|
|
468
468
|
if (Lt.includes(v))
|
|
469
469
|
switch (v) {
|
|
470
470
|
case "-":
|
|
@@ -531,7 +531,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
531
531
|
}, [(M = l.value.toolbarTips) == null ? void 0 : M.strikeThrough])]);
|
|
532
532
|
case "title":
|
|
533
533
|
return t(te, {
|
|
534
|
-
relative: `#${
|
|
534
|
+
relative: `#${r}`,
|
|
535
535
|
visible: u.title,
|
|
536
536
|
onChange: (p) => {
|
|
537
537
|
u.title = p;
|
|
@@ -606,7 +606,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
606
606
|
case "sup":
|
|
607
607
|
return t("div", {
|
|
608
608
|
class: `${o}-toolbar-item`,
|
|
609
|
-
title: (
|
|
609
|
+
title: (ne = l.value.toolbarTips) == null ? void 0 : ne.sup,
|
|
610
610
|
onClick: () => {
|
|
611
611
|
d("sup");
|
|
612
612
|
}
|
|
@@ -677,7 +677,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
677
677
|
"xlink:href": "#md-editor-icon-task"
|
|
678
678
|
}, null)]), e.showToolbarName && t("div", {
|
|
679
679
|
class: `${o}-toolbar-item-name`
|
|
680
|
-
}, [(
|
|
680
|
+
}, [(re = l.value.toolbarTips) == null ? void 0 : re.task])]);
|
|
681
681
|
case "codeRow":
|
|
682
682
|
return t("div", {
|
|
683
683
|
class: `${o}-toolbar-item`,
|
|
@@ -738,7 +738,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
738
738
|
}, null)]), e.showToolbarName && t("div", {
|
|
739
739
|
class: `${o}-toolbar-item-name`
|
|
740
740
|
}, [(we = l.value.toolbarTips) == null ? void 0 : we.image])]) : t(te, {
|
|
741
|
-
relative: `#${
|
|
741
|
+
relative: `#${r}`,
|
|
742
742
|
visible: u.image,
|
|
743
743
|
onChange: (p) => {
|
|
744
744
|
u.image = p;
|
|
@@ -782,7 +782,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
782
782
|
});
|
|
783
783
|
case "table":
|
|
784
784
|
return t(te, {
|
|
785
|
-
relative: `#${
|
|
785
|
+
relative: `#${r}`,
|
|
786
786
|
visible: u.table,
|
|
787
787
|
onChange: (p) => {
|
|
788
788
|
u.table = p;
|
|
@@ -892,7 +892,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
892
892
|
class: `${o}-toolbar-item`,
|
|
893
893
|
title: (Oe = l.value.toolbarTips) == null ? void 0 : Oe.fullscreen,
|
|
894
894
|
onClick: () => {
|
|
895
|
-
|
|
895
|
+
n();
|
|
896
896
|
}
|
|
897
897
|
}, [t("svg", {
|
|
898
898
|
class: `${o}-icon`,
|
|
@@ -963,7 +963,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
963
963
|
}, [(We = l.value.toolbarTips) == null ? void 0 : We.github])]);
|
|
964
964
|
case "mermaid":
|
|
965
965
|
return t(te, {
|
|
966
|
-
relative: `#${
|
|
966
|
+
relative: `#${r}`,
|
|
967
967
|
visible: u.mermaid,
|
|
968
968
|
onChange: (p) => {
|
|
969
969
|
u.mermaid = p;
|
|
@@ -1033,7 +1033,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
1033
1033
|
});
|
|
1034
1034
|
case "katex":
|
|
1035
1035
|
return t(te, {
|
|
1036
|
-
relative: `#${
|
|
1036
|
+
relative: `#${r}`,
|
|
1037
1037
|
visible: u.katex,
|
|
1038
1038
|
onChange: (p) => {
|
|
1039
1039
|
u.katex = p;
|
|
@@ -1104,7 +1104,7 @@ const hl = /* @__PURE__ */ V({
|
|
|
1104
1104
|
return t(kt, null, [e.toolbars.length > 0 && t("div", {
|
|
1105
1105
|
class: `${o}-toolbar-wrapper`,
|
|
1106
1106
|
ref: i,
|
|
1107
|
-
id:
|
|
1107
|
+
id: r
|
|
1108
1108
|
}, [t("div", {
|
|
1109
1109
|
class: [`${o}-toolbar`, e.showToolbarName && `${o}-stn`]
|
|
1110
1110
|
}, [t("div", {
|
|
@@ -1138,13 +1138,13 @@ const hl = /* @__PURE__ */ V({
|
|
|
1138
1138
|
}
|
|
1139
1139
|
}), Ml = (e, a) => {
|
|
1140
1140
|
const l = Et(() => {
|
|
1141
|
-
e.removeEventListener("scroll",
|
|
1142
|
-
}, 50),
|
|
1141
|
+
e.removeEventListener("scroll", n), e.addEventListener("scroll", n), a.removeEventListener("scroll", n), a.addEventListener("scroll", n);
|
|
1142
|
+
}, 50), n = (r) => {
|
|
1143
1143
|
const i = e.clientHeight, u = a.clientHeight, d = e.scrollHeight, c = a.scrollHeight, f = (d - i) / (c - u);
|
|
1144
|
-
|
|
1144
|
+
r.target === e ? (a.removeEventListener("scroll", n), a.scrollTo({
|
|
1145
1145
|
top: e.scrollTop / f
|
|
1146
1146
|
// behavior: 'smooth'
|
|
1147
|
-
}), l()) : (e.removeEventListener("scroll",
|
|
1147
|
+
}), l()) : (e.removeEventListener("scroll", n), e.scrollTo({
|
|
1148
1148
|
top: a.scrollTop * f
|
|
1149
1149
|
// behavior: 'smooth'
|
|
1150
1150
|
}), l());
|
|
@@ -1156,17 +1156,17 @@ const hl = /* @__PURE__ */ V({
|
|
|
1156
1156
|
});
|
|
1157
1157
|
},
|
|
1158
1158
|
() => {
|
|
1159
|
-
e.removeEventListener("scroll",
|
|
1159
|
+
e.removeEventListener("scroll", n), a.removeEventListener("scroll", n);
|
|
1160
1160
|
}
|
|
1161
1161
|
];
|
|
1162
1162
|
}, Ll = (e, a, l) => {
|
|
1163
|
-
const { view:
|
|
1163
|
+
const { view: n } = l, r = (b) => n.lineBlockAt(n.state.doc.line(b).from).top, i = (b) => n.lineBlockAt(n.state.doc.line(b).from).height;
|
|
1164
1164
|
let u = [];
|
|
1165
1165
|
const d = () => {
|
|
1166
1166
|
u = [];
|
|
1167
1167
|
const b = Array.from(a.querySelectorAll("[data-line]")).map(
|
|
1168
1168
|
(g) => Number(g.dataset.line) + 1
|
|
1169
|
-
), { lines: $ } =
|
|
1169
|
+
), { lines: $ } = n.state.doc;
|
|
1170
1170
|
let T = 1, v = b.shift() ?? $;
|
|
1171
1171
|
for (let g = 1; g <= $; g++)
|
|
1172
1172
|
g === v && (T = g, v = b.shift() || $ + 1), u.push({
|
|
@@ -1179,19 +1179,19 @@ const hl = /* @__PURE__ */ V({
|
|
|
1179
1179
|
var v, g, k, y, w, x, L;
|
|
1180
1180
|
if (!((v = a.firstElementChild) != null && v.firstElementChild))
|
|
1181
1181
|
return;
|
|
1182
|
-
const $ =
|
|
1183
|
-
if (!(T > u.length) && !(
|
|
1182
|
+
const $ = n.lineBlockAtHeight(n.scrollDOM.scrollTop), { number: T } = n.state.doc.lineAt($.from);
|
|
1183
|
+
if (!(T > u.length) && !(n.state.doc.lines < u[u.length - 1].end))
|
|
1184
1184
|
if (b.target === e) {
|
|
1185
1185
|
if (f !== 0)
|
|
1186
1186
|
return;
|
|
1187
1187
|
c++;
|
|
1188
|
-
const C = u[T - 1], M =
|
|
1188
|
+
const C = u[T - 1], M = r(C.end) + i(C.end);
|
|
1189
1189
|
let R = 0;
|
|
1190
|
-
const D =
|
|
1190
|
+
const D = r(C.start), I = a.querySelector(`[data-line="${C.start - 1}"]`) || ((g = a.firstElementChild) == null ? void 0 : g.firstElementChild), O = a.querySelector(`[data-line="${C.end}"]`) || ((k = a.lastElementChild) == null ? void 0 : k.lastElementChild);
|
|
1191
1191
|
let B = 0, N = 0;
|
|
1192
|
-
D === 0 ? (R = (
|
|
1192
|
+
D === 0 ? (R = (n.scrollDOM.scrollTop - D) / (M - D), B = O.offsetTop) : M > n.scrollDOM.scrollHeight - n.scrollDOM.clientHeight ? (R = (n.scrollDOM.scrollTop - D) / (n.scrollDOM.scrollHeight - n.scrollDOM.clientHeight - D), N = I.offsetTop, B = a.scrollHeight - a.clientHeight - N + 10) : (R = (n.scrollDOM.scrollTop - D) / (M - D), N = I.offsetTop, B = O.offsetTop - N);
|
|
1193
1193
|
const j = N - 10 + B * R;
|
|
1194
|
-
|
|
1194
|
+
nt(a, j, () => {
|
|
1195
1195
|
c--;
|
|
1196
1196
|
});
|
|
1197
1197
|
} else {
|
|
@@ -1230,8 +1230,8 @@ const hl = /* @__PURE__ */ V({
|
|
|
1230
1230
|
I = C[E - 1];
|
|
1231
1231
|
continue;
|
|
1232
1232
|
}
|
|
1233
|
-
const
|
|
1234
|
-
if (ee <= M &&
|
|
1233
|
+
const re = F.offsetTop;
|
|
1234
|
+
if (ee <= M && re > M) {
|
|
1235
1235
|
O = I, B = F;
|
|
1236
1236
|
break;
|
|
1237
1237
|
}
|
|
@@ -1239,17 +1239,17 @@ const hl = /* @__PURE__ */ V({
|
|
|
1239
1239
|
}
|
|
1240
1240
|
const N = O.offsetTop, j = B.offsetTop;
|
|
1241
1241
|
let U = 0;
|
|
1242
|
-
const { start:
|
|
1243
|
-
let G =
|
|
1242
|
+
const { start: ne, end: X } = u[Number(O.dataset.line || 0)], _ = r(ne);
|
|
1243
|
+
let G = r(X);
|
|
1244
1244
|
const Q = i(X);
|
|
1245
1245
|
let W = 0;
|
|
1246
|
-
O === ((L = a.firstElementChild) == null ? void 0 : L.firstElementChild) ? (U = Math.max(M / j, 0), W = G + Q - _) : G >
|
|
1246
|
+
O === ((L = a.firstElementChild) == null ? void 0 : L.firstElementChild) ? (U = Math.max(M / j, 0), W = G + Q - _) : G > n.scrollDOM.scrollHeight - n.scrollDOM.clientHeight ? (U = Math.max(
|
|
1247
1247
|
(M - N) / (a.scrollHeight - N - a.clientHeight),
|
|
1248
1248
|
0
|
|
1249
|
-
), G = n
|
|
1249
|
+
), G = r(n.state.doc.lines) + i(n.state.doc.lines), W = 8 + G - _ - e.clientHeight) : (U = Math.max(
|
|
1250
1250
|
(M - N) / (j - N),
|
|
1251
1251
|
0
|
|
1252
|
-
), W = G + Q - _),
|
|
1252
|
+
), W = G + Q - _), nt(e, _ + W * U, () => {
|
|
1253
1253
|
f--;
|
|
1254
1254
|
});
|
|
1255
1255
|
}
|
|
@@ -1263,18 +1263,18 @@ const hl = /* @__PURE__ */ V({
|
|
|
1263
1263
|
}
|
|
1264
1264
|
];
|
|
1265
1265
|
}, Dl = (e, a, l) => {
|
|
1266
|
-
const
|
|
1267
|
-
let
|
|
1266
|
+
const n = A("editorId");
|
|
1267
|
+
let r = () => {
|
|
1268
1268
|
}, i = () => {
|
|
1269
1269
|
};
|
|
1270
1270
|
const u = () => {
|
|
1271
|
-
|
|
1271
|
+
r();
|
|
1272
1272
|
const d = document.querySelector(".cm-scroller"), c = document.querySelector(
|
|
1273
|
-
`[id="${
|
|
1273
|
+
`[id="${n}-preview-wrapper"][data-show="true"]`
|
|
1274
1274
|
), f = document.querySelector(
|
|
1275
|
-
`[id="${
|
|
1275
|
+
`[id="${n}-html-wrapper"][data-show="true"]`
|
|
1276
1276
|
);
|
|
1277
|
-
(c || f) && ([i,
|
|
1277
|
+
(c || f) && ([i, r] = (c ? Ll : Ml)(
|
|
1278
1278
|
d,
|
|
1279
1279
|
c || f,
|
|
1280
1280
|
l.value
|
|
@@ -1294,16 +1294,16 @@ const hl = /* @__PURE__ */ V({
|
|
|
1294
1294
|
), H(
|
|
1295
1295
|
() => e.scrollAuto,
|
|
1296
1296
|
(d) => {
|
|
1297
|
-
d ? i() :
|
|
1297
|
+
d ? i() : r();
|
|
1298
1298
|
}
|
|
1299
1299
|
), Y(u);
|
|
1300
1300
|
}, Il = Dl, Nl = (e, a, l) => {
|
|
1301
1301
|
var m, b, $, T, v, g;
|
|
1302
|
-
let
|
|
1302
|
+
let n = "", r = 0, i = 0, u = !0, d = !1;
|
|
1303
1303
|
const c = a.getSelectedText(), f = (m = z.editorConfig) == null ? void 0 : m.mermaidTemplate;
|
|
1304
1304
|
if (/^h[1-6]{1}$/.test(e)) {
|
|
1305
1305
|
const k = e.replace(/^h(\d)/, (y, w) => new Array(Number(w)).fill("#", 0, w).join(""));
|
|
1306
|
-
|
|
1306
|
+
n = `${k} ${c}`, r = k.length + 1;
|
|
1307
1307
|
} else if (e === "prettier") {
|
|
1308
1308
|
const k = window.prettier || (($ = (b = z.editorExtensions) == null ? void 0 : b.prettier) == null ? void 0 : $.prettierInstance), y = [
|
|
1309
1309
|
((T = window.prettierPlugins) == null ? void 0 : T.markdown) || ((g = (v = z.editorExtensions) == null ? void 0 : v.prettier) == null ? void 0 : g.parserMarkdownInstance)
|
|
@@ -1311,114 +1311,114 @@ const hl = /* @__PURE__ */ V({
|
|
|
1311
1311
|
!k || y[0] === void 0 ? (h.emit(l.editorId, "errorCatcher", {
|
|
1312
1312
|
name: "prettier",
|
|
1313
1313
|
message: "prettier is undefined"
|
|
1314
|
-
}),
|
|
1314
|
+
}), n = a.getValue()) : n = k.format(a.getValue(), {
|
|
1315
1315
|
parser: "markdown",
|
|
1316
1316
|
plugins: y
|
|
1317
1317
|
}), u = !1, d = !0;
|
|
1318
1318
|
} else
|
|
1319
1319
|
switch (e) {
|
|
1320
1320
|
case "bold": {
|
|
1321
|
-
|
|
1321
|
+
n = `**${c}**`, r = 2, i = -2;
|
|
1322
1322
|
break;
|
|
1323
1323
|
}
|
|
1324
1324
|
case "underline": {
|
|
1325
|
-
|
|
1325
|
+
n = `<u>${c}</u>`, r = 3, i = -4;
|
|
1326
1326
|
break;
|
|
1327
1327
|
}
|
|
1328
1328
|
case "italic": {
|
|
1329
|
-
|
|
1329
|
+
n = `*${c}*`, r = 1, i = -1;
|
|
1330
1330
|
break;
|
|
1331
1331
|
}
|
|
1332
1332
|
case "strikeThrough": {
|
|
1333
|
-
|
|
1333
|
+
n = `~~${c}~~`, r = 2, i = -2;
|
|
1334
1334
|
break;
|
|
1335
1335
|
}
|
|
1336
1336
|
case "sub": {
|
|
1337
|
-
|
|
1337
|
+
n = `<sub>${c}</sub>`, r = 5, i = -6;
|
|
1338
1338
|
break;
|
|
1339
1339
|
}
|
|
1340
1340
|
case "sup": {
|
|
1341
|
-
|
|
1341
|
+
n = `<sup>${c}</sup>`, r = 5, i = -6;
|
|
1342
1342
|
break;
|
|
1343
1343
|
}
|
|
1344
1344
|
case "codeRow": {
|
|
1345
|
-
|
|
1345
|
+
n = "`" + c + "`", r = 1, i = -1;
|
|
1346
1346
|
break;
|
|
1347
1347
|
}
|
|
1348
1348
|
case "quote": {
|
|
1349
|
-
|
|
1349
|
+
n = `> ${c}`, r = 2;
|
|
1350
1350
|
break;
|
|
1351
1351
|
}
|
|
1352
1352
|
case "orderedList": {
|
|
1353
|
-
|
|
1353
|
+
n = `1. ${c}`, r = 3;
|
|
1354
1354
|
break;
|
|
1355
1355
|
}
|
|
1356
1356
|
case "unorderedList": {
|
|
1357
|
-
|
|
1357
|
+
n = `- ${c}`, r = 2;
|
|
1358
1358
|
break;
|
|
1359
1359
|
}
|
|
1360
1360
|
case "task": {
|
|
1361
|
-
|
|
1361
|
+
n = `- [ ] ${c}`, r = 6;
|
|
1362
1362
|
break;
|
|
1363
1363
|
}
|
|
1364
1364
|
case "code": {
|
|
1365
1365
|
const k = l.text || c || "", y = l.mode || "language";
|
|
1366
|
-
|
|
1366
|
+
n = `\`\`\`${y}
|
|
1367
1367
|
${k}
|
|
1368
1368
|
\`\`\`
|
|
1369
|
-
`,
|
|
1369
|
+
`, r = 3, i = 3 + y.length - n.length;
|
|
1370
1370
|
break;
|
|
1371
1371
|
}
|
|
1372
1372
|
case "table": {
|
|
1373
|
-
|
|
1373
|
+
n = "|";
|
|
1374
1374
|
const { selectedShape: k = { x: 1, y: 1 } } = l, { x: y, y: w } = k;
|
|
1375
1375
|
for (let x = 0; x <= w; x++)
|
|
1376
|
-
|
|
1377
|
-
|
|
1376
|
+
n += " col |";
|
|
1377
|
+
n += `
|
|
1378
1378
|
|`;
|
|
1379
1379
|
for (let x = 0; x <= w; x++)
|
|
1380
|
-
|
|
1380
|
+
n += " - |";
|
|
1381
1381
|
for (let x = 0; x <= y; x++) {
|
|
1382
|
-
|
|
1382
|
+
n += `
|
|
1383
1383
|
|`;
|
|
1384
1384
|
for (let L = 0; L <= w; L++)
|
|
1385
|
-
|
|
1385
|
+
n += " content |";
|
|
1386
1386
|
}
|
|
1387
|
-
|
|
1387
|
+
r = 2, i = 5 - n.length;
|
|
1388
1388
|
break;
|
|
1389
1389
|
}
|
|
1390
1390
|
case "link": {
|
|
1391
1391
|
const { desc: k, url: y } = l;
|
|
1392
|
-
|
|
1392
|
+
n = `[${k}](${y})`, u = !1;
|
|
1393
1393
|
break;
|
|
1394
1394
|
}
|
|
1395
1395
|
case "image": {
|
|
1396
1396
|
const { desc: k, url: y, urls: w } = l;
|
|
1397
|
-
w instanceof Array ?
|
|
1398
|
-
`, "") :
|
|
1397
|
+
w instanceof Array ? n = w.reduce((x, L) => x + `
|
|
1398
|
+
`, "") : n = `
|
|
1399
1399
|
`, u = !1;
|
|
1400
1400
|
break;
|
|
1401
1401
|
}
|
|
1402
1402
|
case "flow": {
|
|
1403
|
-
|
|
1403
|
+
n = `\`\`\`mermaid
|
|
1404
1404
|
${(f == null ? void 0 : f.flow) || `flowchart TD
|
|
1405
1405
|
Start --> Stop`}
|
|
1406
1406
|
\`\`\`
|
|
1407
|
-
`,
|
|
1407
|
+
`, r = 3, i = 10 - n.length;
|
|
1408
1408
|
break;
|
|
1409
1409
|
}
|
|
1410
1410
|
case "sequence": {
|
|
1411
|
-
|
|
1411
|
+
n = `\`\`\`mermaid
|
|
1412
1412
|
${(f == null ? void 0 : f.sequence) || `sequenceDiagram
|
|
1413
1413
|
A->>B: hello!
|
|
1414
1414
|
B-->>A: hi!
|
|
1415
1415
|
A-)B: bye!`}
|
|
1416
1416
|
\`\`\`
|
|
1417
|
-
`,
|
|
1417
|
+
`, r = 3, i = 10 - n.length;
|
|
1418
1418
|
break;
|
|
1419
1419
|
}
|
|
1420
1420
|
case "gantt": {
|
|
1421
|
-
|
|
1421
|
+
n = `\`\`\`mermaid
|
|
1422
1422
|
${(f == null ? void 0 : f.gantt) || `gantt
|
|
1423
1423
|
title A Gantt Diagram
|
|
1424
1424
|
dateFormat YYYY-MM-DD
|
|
@@ -1426,47 +1426,47 @@ section Section
|
|
|
1426
1426
|
A task :a1, 2014-01-01, 30d
|
|
1427
1427
|
Another task :after a1, 20d`}
|
|
1428
1428
|
\`\`\`
|
|
1429
|
-
`,
|
|
1429
|
+
`, r = 3, i = 10 - n.length;
|
|
1430
1430
|
break;
|
|
1431
1431
|
}
|
|
1432
1432
|
case "class": {
|
|
1433
|
-
|
|
1433
|
+
n = `\`\`\`mermaid
|
|
1434
1434
|
${(f == null ? void 0 : f.class) || `classDiagram
|
|
1435
1435
|
class Animal
|
|
1436
1436
|
Vehicle <|-- Car`}
|
|
1437
1437
|
\`\`\`
|
|
1438
|
-
`,
|
|
1438
|
+
`, r = 3, i = 10 - n.length;
|
|
1439
1439
|
break;
|
|
1440
1440
|
}
|
|
1441
1441
|
case "state": {
|
|
1442
|
-
|
|
1442
|
+
n = `\`\`\`mermaid
|
|
1443
1443
|
${(f == null ? void 0 : f.state) || `stateDiagram-v2
|
|
1444
1444
|
s1 --> s2`}
|
|
1445
1445
|
\`\`\`
|
|
1446
|
-
`,
|
|
1446
|
+
`, r = 3, i = 10 - n.length;
|
|
1447
1447
|
break;
|
|
1448
1448
|
}
|
|
1449
1449
|
case "pie": {
|
|
1450
|
-
|
|
1450
|
+
n = `\`\`\`mermaid
|
|
1451
1451
|
${(f == null ? void 0 : f.pie) || `pie title Pets adopted by volunteers
|
|
1452
1452
|
"Dogs" : 386
|
|
1453
1453
|
"Cats" : 85
|
|
1454
1454
|
"Rats" : 15`}
|
|
1455
1455
|
\`\`\`
|
|
1456
|
-
`,
|
|
1456
|
+
`, r = 3, i = 10 - n.length;
|
|
1457
1457
|
break;
|
|
1458
1458
|
}
|
|
1459
1459
|
case "relationship": {
|
|
1460
|
-
|
|
1460
|
+
n = `\`\`\`mermaid
|
|
1461
1461
|
${(f == null ? void 0 : f.relationship) || `erDiagram
|
|
1462
1462
|
CAR ||--o{ NAMED-DRIVER : allows
|
|
1463
1463
|
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
1464
1464
|
\`\`\`
|
|
1465
|
-
`,
|
|
1465
|
+
`, r = 3, i = 10 - n.length;
|
|
1466
1466
|
break;
|
|
1467
1467
|
}
|
|
1468
1468
|
case "journey": {
|
|
1469
|
-
|
|
1469
|
+
n = `\`\`\`mermaid
|
|
1470
1470
|
${(f == null ? void 0 : f.journey) || `journey
|
|
1471
1471
|
title My working day
|
|
1472
1472
|
section Go to work
|
|
@@ -1477,32 +1477,32 @@ ${(f == null ? void 0 : f.journey) || `journey
|
|
|
1477
1477
|
Go downstairs: 5: Me
|
|
1478
1478
|
Sit down: 5: Me`}
|
|
1479
1479
|
\`\`\`
|
|
1480
|
-
`,
|
|
1480
|
+
`, r = 3, i = 10 - n.length;
|
|
1481
1481
|
break;
|
|
1482
1482
|
}
|
|
1483
1483
|
case "katexInline": {
|
|
1484
|
-
|
|
1484
|
+
n = "$$", r = 1, i = -1;
|
|
1485
1485
|
break;
|
|
1486
1486
|
}
|
|
1487
1487
|
case "katexBlock": {
|
|
1488
|
-
|
|
1488
|
+
n = `$$
|
|
1489
1489
|
|
|
1490
1490
|
$$
|
|
1491
|
-
`,
|
|
1491
|
+
`, r = 3, i = -4;
|
|
1492
1492
|
break;
|
|
1493
1493
|
}
|
|
1494
1494
|
case "universal": {
|
|
1495
1495
|
const { generate: k } = l, y = k(c);
|
|
1496
|
-
|
|
1496
|
+
n = y.targetValue, u = y.select, r = y.deviationStart, i = y.deviationEnd;
|
|
1497
1497
|
}
|
|
1498
1498
|
}
|
|
1499
1499
|
return {
|
|
1500
|
-
text:
|
|
1500
|
+
text: n,
|
|
1501
1501
|
options: {
|
|
1502
1502
|
// 是否选中
|
|
1503
1503
|
select: u,
|
|
1504
1504
|
// 选中时,开始位置的偏移量
|
|
1505
|
-
deviationStart:
|
|
1505
|
+
deviationStart: r,
|
|
1506
1506
|
// 结束的偏移量
|
|
1507
1507
|
deviationEnd: i,
|
|
1508
1508
|
// 是否整个替换
|
|
@@ -1713,15 +1713,15 @@ $$
|
|
|
1713
1713
|
]), lo = [
|
|
1714
1714
|
eo,
|
|
1715
1715
|
yt(to)
|
|
1716
|
-
], se = (e, a, l,
|
|
1716
|
+
], se = (e, a, l, n, r) => (i, u, d, c) => {
|
|
1717
1717
|
const f = `${e}${a}`.slice(c - d);
|
|
1718
|
-
i.dispatch(i.state.replaceSelection(`${f}${l}${
|
|
1719
|
-
const m = d + u.label.length + (
|
|
1718
|
+
i.dispatch(i.state.replaceSelection(`${f}${l}${n}`));
|
|
1719
|
+
const m = d + u.label.length + (r === "title" ? l.length : 0);
|
|
1720
1720
|
i.dispatch({
|
|
1721
1721
|
selection: P.create(
|
|
1722
1722
|
[
|
|
1723
1723
|
P.range(
|
|
1724
|
-
d + u.label.length + (
|
|
1724
|
+
d + u.label.length + (r === "title" ? 1 : -a.length),
|
|
1725
1725
|
m
|
|
1726
1726
|
),
|
|
1727
1727
|
P.cursor(m)
|
|
@@ -1729,19 +1729,19 @@ $$
|
|
|
1729
1729
|
1
|
|
1730
1730
|
)
|
|
1731
1731
|
}), i.focus();
|
|
1732
|
-
}, vt = (e) => (a, l,
|
|
1733
|
-
const i = e.slice(
|
|
1732
|
+
}, vt = (e) => (a, l, n, r) => {
|
|
1733
|
+
const i = e.slice(r - n);
|
|
1734
1734
|
a.dispatch(a.state.replaceSelection(`${i} `));
|
|
1735
1735
|
}, oo = (e) => {
|
|
1736
1736
|
const a = (l) => {
|
|
1737
|
-
const
|
|
1737
|
+
const n = l.matchBefore(
|
|
1738
1738
|
/^#+|^-\s*\[*\s*\]*|`+|\[|!\[*|^\|\s?\|?|^\$\$?|!+\s*\w*/
|
|
1739
1739
|
);
|
|
1740
|
-
return
|
|
1741
|
-
from:
|
|
1740
|
+
return n === null || n.from == n.to && l.explicit ? null : {
|
|
1741
|
+
from: n.from,
|
|
1742
1742
|
options: [
|
|
1743
1743
|
// 标题
|
|
1744
|
-
...["h1", "h2", "h3", "h4", "h5", "h6"].map((
|
|
1744
|
+
...["h1", "h2", "h3", "h4", "h5", "h6"].map((r, i) => {
|
|
1745
1745
|
const u = new Array(i + 1).fill("#").join("");
|
|
1746
1746
|
return {
|
|
1747
1747
|
label: u,
|
|
@@ -1750,8 +1750,8 @@ $$
|
|
|
1750
1750
|
};
|
|
1751
1751
|
}),
|
|
1752
1752
|
// 任务列表
|
|
1753
|
-
...["unchecked", "checked"].map((
|
|
1754
|
-
const i =
|
|
1753
|
+
...["unchecked", "checked"].map((r) => {
|
|
1754
|
+
const i = r === "checked" ? "- [x]" : "- [ ]";
|
|
1755
1755
|
return {
|
|
1756
1756
|
label: i,
|
|
1757
1757
|
type: "text",
|
|
@@ -1763,10 +1763,10 @@ $$
|
|
|
1763
1763
|
["`", ""],
|
|
1764
1764
|
["```", "language"],
|
|
1765
1765
|
["```mermaid\n", ""]
|
|
1766
|
-
].map((
|
|
1767
|
-
label: `${
|
|
1766
|
+
].map((r) => ({
|
|
1767
|
+
label: `${r[0]}${r[1]}`,
|
|
1768
1768
|
type: "text",
|
|
1769
|
-
apply: se(
|
|
1769
|
+
apply: se(r[0], r[1], "", r[0] === "`" ? "`" : "\n```", "type")
|
|
1770
1770
|
})),
|
|
1771
1771
|
// 链接
|
|
1772
1772
|
{
|
|
@@ -1818,10 +1818,10 @@ $$`, "title")
|
|
|
1818
1818
|
"caution",
|
|
1819
1819
|
"error",
|
|
1820
1820
|
"attention"
|
|
1821
|
-
].map((
|
|
1822
|
-
label: `!!! ${
|
|
1821
|
+
].map((r) => ({
|
|
1822
|
+
label: `!!! ${r}`,
|
|
1823
1823
|
type: "text",
|
|
1824
|
-
apply: se("!!!", ` ${
|
|
1824
|
+
apply: se("!!!", ` ${r}`, " Title", `
|
|
1825
1825
|
|
|
1826
1826
|
!!!`, "title")
|
|
1827
1827
|
}))
|
|
@@ -1833,11 +1833,11 @@ $$`, "title")
|
|
|
1833
1833
|
});
|
|
1834
1834
|
}, ao = oo, Z = (e) => {
|
|
1835
1835
|
const a = new dl();
|
|
1836
|
-
return (
|
|
1837
|
-
effects: ul.appendConfig.of(a.of(
|
|
1836
|
+
return (n) => (a.get(e.state) ? e.dispatch({ effects: a.reconfigure(n) }) : e.dispatch({
|
|
1837
|
+
effects: ul.appendConfig.of(a.of(n))
|
|
1838
1838
|
}), !0);
|
|
1839
1839
|
};
|
|
1840
|
-
class
|
|
1840
|
+
class no {
|
|
1841
1841
|
constructor(a) {
|
|
1842
1842
|
K(this, "view");
|
|
1843
1843
|
// 切换tabSize的执行方法。切换时,Compartment实例需要相同
|
|
@@ -1862,11 +1862,11 @@ class ro {
|
|
|
1862
1862
|
* @param from 插入开始位置
|
|
1863
1863
|
* @param to 插入结束位置
|
|
1864
1864
|
*/
|
|
1865
|
-
setValue(a, l = 0,
|
|
1865
|
+
setValue(a, l = 0, n = this.view.state.doc.length) {
|
|
1866
1866
|
this.view.dispatch({
|
|
1867
1867
|
changes: {
|
|
1868
1868
|
from: l,
|
|
1869
|
-
to:
|
|
1869
|
+
to: n,
|
|
1870
1870
|
insert: a
|
|
1871
1871
|
}
|
|
1872
1872
|
});
|
|
@@ -1893,8 +1893,8 @@ class ro {
|
|
|
1893
1893
|
deviationEnd: 0,
|
|
1894
1894
|
// 直接替换所有文本
|
|
1895
1895
|
replaceAll: !1
|
|
1896
|
-
},
|
|
1897
|
-
var
|
|
1896
|
+
}, n) {
|
|
1897
|
+
var r;
|
|
1898
1898
|
try {
|
|
1899
1899
|
if (l.replaceAll) {
|
|
1900
1900
|
this.setValue(a);
|
|
@@ -1915,8 +1915,8 @@ class ro {
|
|
|
1915
1915
|
}
|
|
1916
1916
|
this.view.focus();
|
|
1917
1917
|
} catch (i) {
|
|
1918
|
-
if ((
|
|
1919
|
-
h.emit(
|
|
1918
|
+
if ((r = i.message) != null && r.includes("Selection points outside of document"))
|
|
1919
|
+
h.emit(n, "errorCatcher", {
|
|
1920
1920
|
name: "overlength",
|
|
1921
1921
|
message: "The input text is too long",
|
|
1922
1922
|
data: a
|
|
@@ -1947,21 +1947,21 @@ class ro {
|
|
|
1947
1947
|
focus(a) {
|
|
1948
1948
|
if (this.view.focus(), !a)
|
|
1949
1949
|
return;
|
|
1950
|
-
let l = 0,
|
|
1950
|
+
let l = 0, n = 0, r = 0;
|
|
1951
1951
|
switch (a) {
|
|
1952
1952
|
case "start":
|
|
1953
1953
|
break;
|
|
1954
1954
|
case "end": {
|
|
1955
|
-
l =
|
|
1955
|
+
l = n = r = this.getValue().length;
|
|
1956
1956
|
break;
|
|
1957
1957
|
}
|
|
1958
1958
|
default:
|
|
1959
|
-
l = a.rangeAnchor || a.cursorPos,
|
|
1959
|
+
l = a.rangeAnchor || a.cursorPos, n = a.rangeHead || a.cursorPos, r = a.cursorPos;
|
|
1960
1960
|
}
|
|
1961
1961
|
this.view.dispatch({
|
|
1962
1962
|
scrollIntoView: !0,
|
|
1963
1963
|
selection: P.create(
|
|
1964
|
-
[P.range(l,
|
|
1964
|
+
[P.range(l, n), P.cursor(r)],
|
|
1965
1965
|
1
|
|
1966
1966
|
)
|
|
1967
1967
|
});
|
|
@@ -1978,43 +1978,43 @@ class ro {
|
|
|
1978
1978
|
]);
|
|
1979
1979
|
}
|
|
1980
1980
|
}
|
|
1981
|
-
const
|
|
1981
|
+
const ro = (e) => {
|
|
1982
1982
|
const a = A("editorId");
|
|
1983
|
-
return (
|
|
1984
|
-
if (!
|
|
1983
|
+
return (n) => {
|
|
1984
|
+
if (!n.clipboardData)
|
|
1985
1985
|
return;
|
|
1986
|
-
if (
|
|
1987
|
-
const { files: i } =
|
|
1986
|
+
if (n.clipboardData.files.length > 0) {
|
|
1987
|
+
const { files: i } = n.clipboardData;
|
|
1988
1988
|
h.emit(
|
|
1989
1989
|
a,
|
|
1990
1990
|
"uploadImage",
|
|
1991
1991
|
Array.from(i).filter((u) => /image\/.*/.test(u.type))
|
|
1992
|
-
),
|
|
1992
|
+
), n.preventDefault();
|
|
1993
1993
|
return;
|
|
1994
1994
|
}
|
|
1995
|
-
if (e.autoDetectCode &&
|
|
1996
|
-
const i = JSON.parse(
|
|
1995
|
+
if (e.autoDetectCode && n.clipboardData.types.includes("vscode-editor-data")) {
|
|
1996
|
+
const i = JSON.parse(n.clipboardData.getData("vscode-editor-data"));
|
|
1997
1997
|
h.emit(a, "replace", "code", {
|
|
1998
1998
|
mode: i.mode,
|
|
1999
|
-
text:
|
|
2000
|
-
}),
|
|
1999
|
+
text: n.clipboardData.getData("text/plain")
|
|
2000
|
+
}), n.preventDefault();
|
|
2001
2001
|
return;
|
|
2002
2002
|
}
|
|
2003
|
-
const
|
|
2004
|
-
e.maxlength &&
|
|
2003
|
+
const r = n.clipboardData.getData("text/plain");
|
|
2004
|
+
e.maxlength && r.length + e.value.length > e.maxlength && h.emit(a, "errorCatcher", {
|
|
2005
2005
|
name: "overlength",
|
|
2006
2006
|
message: "The input text is too long",
|
|
2007
|
-
data:
|
|
2007
|
+
data: r
|
|
2008
2008
|
});
|
|
2009
2009
|
};
|
|
2010
|
-
}, io =
|
|
2010
|
+
}, io = ro, so = (e) => {
|
|
2011
2011
|
const a = A("editorId");
|
|
2012
2012
|
Y(() => {
|
|
2013
2013
|
h.on(a, {
|
|
2014
2014
|
name: Rt,
|
|
2015
2015
|
callback(l) {
|
|
2016
|
-
var
|
|
2017
|
-
(
|
|
2016
|
+
var n;
|
|
2017
|
+
(n = e.value) == null || n.focus(l);
|
|
2018
2018
|
}
|
|
2019
2019
|
});
|
|
2020
2020
|
});
|
|
@@ -2027,7 +2027,7 @@ const no = (e) => {
|
|
|
2027
2027
|
{
|
|
2028
2028
|
key: "Ctrl-d",
|
|
2029
2029
|
mac: "Cmd-d",
|
|
2030
|
-
run:
|
|
2030
|
+
run: nl,
|
|
2031
2031
|
preventDefault: !0
|
|
2032
2032
|
},
|
|
2033
2033
|
{
|
|
@@ -2115,8 +2115,8 @@ const no = (e) => {
|
|
|
2115
2115
|
any: (L, C) => (C.ctrlKey || C.metaKey) && C.altKey && C.shiftKey && C.code === "KeyT" ? (h.emit(e, "replace", "table"), !0) : !1
|
|
2116
2116
|
}
|
|
2117
2117
|
], mo = uo, fo = (e) => {
|
|
2118
|
-
const a = A("tabWidth"), l = A("editorId"),
|
|
2119
|
-
el.of([...u,
|
|
2118
|
+
const a = A("tabWidth"), l = A("editorId"), n = A("theme"), r = q(), i = St(), u = mo(l, e), d = io(e), c = [
|
|
2119
|
+
el.of([...u, rl]),
|
|
2120
2120
|
Xt,
|
|
2121
2121
|
al(),
|
|
2122
2122
|
ll({ codeLanguages: tl }),
|
|
@@ -2132,7 +2132,7 @@ const no = (e) => {
|
|
|
2132
2132
|
input: (m) => {
|
|
2133
2133
|
e.onInput && e.onInput(m);
|
|
2134
2134
|
const { data: b } = m;
|
|
2135
|
-
e.value.length + b.length && h.emit(l, "errorCatcher", {
|
|
2135
|
+
e.maxlength && e.value.length + b.length > e.maxlength && h.emit(l, "errorCatcher", {
|
|
2136
2136
|
name: "overlength",
|
|
2137
2137
|
message: "The input text is too long",
|
|
2138
2138
|
data: b
|
|
@@ -2142,18 +2142,18 @@ const no = (e) => {
|
|
|
2142
2142
|
], f = () => {
|
|
2143
2143
|
const m = [
|
|
2144
2144
|
...c,
|
|
2145
|
-
|
|
2145
|
+
n.value === "light" ? lo : Kl,
|
|
2146
2146
|
ao(e.completions)
|
|
2147
2147
|
];
|
|
2148
|
-
return z.codeMirrorExtensions(
|
|
2148
|
+
return z.codeMirrorExtensions(n.value, m, [
|
|
2149
2149
|
...u
|
|
2150
2150
|
]);
|
|
2151
2151
|
};
|
|
2152
2152
|
return Y(() => {
|
|
2153
2153
|
const m = new ie({
|
|
2154
2154
|
doc: e.value,
|
|
2155
|
-
parent:
|
|
2156
|
-
}), b = new
|
|
2155
|
+
parent: r.value
|
|
2156
|
+
}), b = new no(m);
|
|
2157
2157
|
i.value = b, setTimeout(() => {
|
|
2158
2158
|
b.setTabSize(a), b.setDisabled(e.disabled), b.setReadOnly(e.readonly), b.setExtensions(f()), e.placeholder && b.setPlaceholder(e.placeholder), typeof e.maxlength == "number" && b.setMaxLength(e.maxlength), e.autofocus && m.focus();
|
|
2159
2159
|
}, 0), h.on(l, {
|
|
@@ -2175,7 +2175,7 @@ const no = (e) => {
|
|
|
2175
2175
|
}
|
|
2176
2176
|
});
|
|
2177
2177
|
}), H(
|
|
2178
|
-
[
|
|
2178
|
+
[n, le(e, "completions")],
|
|
2179
2179
|
() => {
|
|
2180
2180
|
var m;
|
|
2181
2181
|
(m = i.value) == null || m.setExtensions(f());
|
|
@@ -2214,7 +2214,7 @@ const no = (e) => {
|
|
|
2214
2214
|
e.maxlength && ((m = i.value) == null || m.setMaxLength(e.maxlength));
|
|
2215
2215
|
}
|
|
2216
2216
|
), co(i), {
|
|
2217
|
-
inputWrapperRef:
|
|
2217
|
+
inputWrapperRef: r,
|
|
2218
2218
|
codeMirrorUt: i
|
|
2219
2219
|
};
|
|
2220
2220
|
}, go = fo, ho = {
|
|
@@ -2325,14 +2325,14 @@ const no = (e) => {
|
|
|
2325
2325
|
props: ho,
|
|
2326
2326
|
setup(e) {
|
|
2327
2327
|
const a = A("editorId"), l = q(""), {
|
|
2328
|
-
inputWrapperRef:
|
|
2329
|
-
codeMirrorUt:
|
|
2328
|
+
inputWrapperRef: n,
|
|
2329
|
+
codeMirrorUt: r
|
|
2330
2330
|
} = go(e);
|
|
2331
|
-
return Il(e, l,
|
|
2331
|
+
return Il(e, l, r), () => t("div", {
|
|
2332
2332
|
class: `${o}-content`
|
|
2333
2333
|
}, [t("div", {
|
|
2334
2334
|
class: `${o}-input-wrapper`,
|
|
2335
|
-
ref:
|
|
2335
|
+
ref: n
|
|
2336
2336
|
}, null), t(Pt, {
|
|
2337
2337
|
modelValue: e.value,
|
|
2338
2338
|
setting: e.setting,
|
|
@@ -2364,12 +2364,12 @@ const no = (e) => {
|
|
|
2364
2364
|
setup(e) {
|
|
2365
2365
|
const a = A("usedLanguageText");
|
|
2366
2366
|
return () => {
|
|
2367
|
-
var l,
|
|
2367
|
+
var l, n;
|
|
2368
2368
|
return t("div", {
|
|
2369
2369
|
class: `${o}-footer-item`
|
|
2370
2370
|
}, [t("label", {
|
|
2371
2371
|
class: `${o}-footer-label`
|
|
2372
|
-
}, [`${(l = a.value.footer) == null ? void 0 : l.markdownTotal}:`]), t("span", null, [((
|
|
2372
|
+
}, [`${(l = a.value.footer) == null ? void 0 : l.markdownTotal}:`]), t("span", null, [((n = e.modelValue) == null ? void 0 : n.length) || 0])]);
|
|
2373
2373
|
};
|
|
2374
2374
|
}
|
|
2375
2375
|
}), ko = {
|
|
@@ -2445,11 +2445,11 @@ const no = (e) => {
|
|
|
2445
2445
|
props: yo,
|
|
2446
2446
|
setup(e) {
|
|
2447
2447
|
const a = he(() => {
|
|
2448
|
-
const
|
|
2449
|
-
return [
|
|
2450
|
-
}), l = (
|
|
2451
|
-
if (Dt.includes(
|
|
2452
|
-
switch (
|
|
2448
|
+
const n = e.footers.indexOf("="), r = n === -1 ? e.footers : e.footers.slice(0, n), i = n === -1 ? [] : e.footers.slice(n, Number.MAX_SAFE_INTEGER);
|
|
2449
|
+
return [r, i];
|
|
2450
|
+
}), l = (n) => {
|
|
2451
|
+
if (Dt.includes(n))
|
|
2452
|
+
switch (n) {
|
|
2453
2453
|
case "markdownTotal":
|
|
2454
2454
|
return t(vo, {
|
|
2455
2455
|
modelValue: e.modelValue
|
|
@@ -2461,17 +2461,17 @@ const no = (e) => {
|
|
|
2461
2461
|
}, null);
|
|
2462
2462
|
}
|
|
2463
2463
|
else
|
|
2464
|
-
return e.defFooters instanceof Array ? e.defFooters[
|
|
2464
|
+
return e.defFooters instanceof Array ? e.defFooters[n] || "" : e.defFooters && e.defFooters.children instanceof Array && e.defFooters.children[n] || "";
|
|
2465
2465
|
};
|
|
2466
2466
|
return () => {
|
|
2467
|
-
const
|
|
2467
|
+
const n = a.value[0].map((i) => l(i)), r = a.value[1].map((i) => l(i));
|
|
2468
2468
|
return t("div", {
|
|
2469
2469
|
class: `${o}-footer`
|
|
2470
2470
|
}, [t("div", {
|
|
2471
2471
|
class: `${o}-footer-left`
|
|
2472
|
-
}, [
|
|
2472
|
+
}, [n]), t("div", {
|
|
2473
2473
|
class: `${o}-footer-right`
|
|
2474
|
-
}, [
|
|
2474
|
+
}, [r])]);
|
|
2475
2475
|
};
|
|
2476
2476
|
}
|
|
2477
2477
|
}), wo = /* @__PURE__ */ V({
|
|
@@ -2481,8 +2481,8 @@ const no = (e) => {
|
|
|
2481
2481
|
setup(e, a) {
|
|
2482
2482
|
const {
|
|
2483
2483
|
editorId: l,
|
|
2484
|
-
noKatex:
|
|
2485
|
-
noMermaid:
|
|
2484
|
+
noKatex: n,
|
|
2485
|
+
noMermaid: r,
|
|
2486
2486
|
noPrettier: i,
|
|
2487
2487
|
noUploadImg: u,
|
|
2488
2488
|
noHighlight: d
|
|
@@ -2495,10 +2495,10 @@ const no = (e) => {
|
|
|
2495
2495
|
h.clear(l);
|
|
2496
2496
|
}), Yt(e, a, b, f, m), () => {
|
|
2497
2497
|
var v;
|
|
2498
|
-
const $ =
|
|
2498
|
+
const $ = rt({
|
|
2499
2499
|
props: e,
|
|
2500
2500
|
ctx: a
|
|
2501
|
-
}, "defToolbars"), T =
|
|
2501
|
+
}, "defToolbars"), T = rt({
|
|
2502
2502
|
props: e,
|
|
2503
2503
|
ctx: a
|
|
2504
2504
|
}, "defFooters");
|
|
@@ -2520,11 +2520,11 @@ const no = (e) => {
|
|
|
2520
2520
|
value: e.modelValue,
|
|
2521
2521
|
setting: f,
|
|
2522
2522
|
mdHeadingId: e.mdHeadingId,
|
|
2523
|
-
noMermaid:
|
|
2523
|
+
noMermaid: r,
|
|
2524
2524
|
noPrettier: i,
|
|
2525
2525
|
sanitize: e.sanitize,
|
|
2526
2526
|
placeholder: e.placeholder,
|
|
2527
|
-
noKatex:
|
|
2527
|
+
noKatex: n,
|
|
2528
2528
|
scrollAuto: c.scrollAuto,
|
|
2529
2529
|
formatCopiedText: e.formatCopiedText,
|
|
2530
2530
|
autofocus: e.autoFocus,
|