md-editor-v3 6.5.2 → 6.5.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/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +2 -2
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/chunks/index3.cjs +1 -65
- package/lib/cjs/chunks/index4.cjs +65 -1
- package/lib/cjs/index.cjs +2 -2
- package/lib/es/MdCatalog.mjs +1 -1
- package/lib/es/MdEditor.mjs +13 -9
- package/lib/es/MdPreview.mjs +1 -1
- package/lib/es/chunks/config.mjs +2 -2
- package/lib/es/chunks/event-bus.mjs +7 -7
- package/lib/es/chunks/index3.mjs +389 -2027
- package/lib/es/chunks/index4.mjs +2018 -378
- package/lib/es/chunks/index5.mjs +2 -2
- package/lib/es/config.mjs +1 -1
- package/lib/es/index.mjs +4 -4
- package/lib/preview.css +13 -2255
- package/lib/style.css +15 -2256
- package/lib/types/index.d.ts +6 -6
- package/package.json +2 -2
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -1,308 +1,2015 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
import { useId as He, provide as x, computed as F, reactive as le, watch as E, onMounted as M, ref as z, inject as C, nextTick as W, shallowRef as ee, onBeforeUnmount as te, toRef as Me, defineComponent as de, createVNode as N, Fragment as Pe, h as Le } from "vue";
|
|
2
|
+
import { deepMerge as _e, deepClone as Oe, randomId as ie, debounce as Be } from "@vavt/util";
|
|
3
|
+
import { p as h, g as L, f as me, s as fe, a as je, b as Ne } from "./config.mjs";
|
|
4
|
+
import { b as y, U as De, C as ke, B as X, O as xe, E as Q, g as he, F as pe, h as ge, i as ve, H as ye, j as be, R as se, e as Ve, k as ue, d as Ge, f as ae, P as Ue, T as ze } from "./event-bus.mjs";
|
|
5
|
+
import { a as O, u as We, S as qe, c as Ke, z as Ze } from "./dom.mjs";
|
|
6
|
+
import Je from "@vavt/copy2clipboard";
|
|
7
|
+
import Xe from "markdown-it";
|
|
8
|
+
import Ye from "markdown-it-image-figures";
|
|
9
|
+
import Qe from "markdown-it-sub";
|
|
10
|
+
import et from "markdown-it-sup";
|
|
11
|
+
import { a as tt } from "./index5.mjs";
|
|
12
|
+
import nt from "medium-zoom";
|
|
13
|
+
const P = {
|
|
14
|
+
hljs: `${h}-hljs`,
|
|
15
|
+
hlcss: `${h}-hlCss`,
|
|
16
|
+
prettier: `${h}-prettier`,
|
|
17
|
+
prettierMD: `${h}-prettierMD`,
|
|
18
|
+
cropperjs: `${h}-cropper`,
|
|
19
|
+
croppercss: `${h}-cropperCss`,
|
|
20
|
+
screenfull: `${h}-screenfull`,
|
|
21
|
+
mermaidM: `${h}-mermaid-m`,
|
|
22
|
+
mermaid: `${h}-mermaid`,
|
|
23
|
+
katexjs: `${h}-katex`,
|
|
24
|
+
katexcss: `${h}-katexCss`,
|
|
25
|
+
echarts: `${h}-echarts`
|
|
26
|
+
}, Qt = (e, t, a) => {
|
|
27
|
+
const { editorId: n } = a, o = le({
|
|
28
|
+
// 是否已编译成html
|
|
29
|
+
buildFinished: !1,
|
|
30
|
+
// 存储当前最新的html
|
|
31
|
+
html: ""
|
|
32
|
+
});
|
|
33
|
+
E(
|
|
34
|
+
() => e.modelValue,
|
|
20
35
|
() => {
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
o.buildFinished = !1;
|
|
37
|
+
}
|
|
38
|
+
), M(() => {
|
|
39
|
+
y.on(n, {
|
|
40
|
+
name: X,
|
|
41
|
+
callback(m) {
|
|
42
|
+
o.buildFinished = !0, o.html = m;
|
|
43
|
+
}
|
|
44
|
+
}), y.on(n, {
|
|
45
|
+
name: xe,
|
|
46
|
+
callback() {
|
|
47
|
+
const m = new Promise((c) => {
|
|
48
|
+
if (o.buildFinished)
|
|
49
|
+
c(o.html);
|
|
50
|
+
else {
|
|
51
|
+
const u = (s) => {
|
|
52
|
+
c(s), y.remove(n, X, u);
|
|
53
|
+
};
|
|
54
|
+
y.on(n, {
|
|
55
|
+
name: X,
|
|
56
|
+
callback: u
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
e.onSave ? e.onSave(e.modelValue, m) : t.emit("onSave", e.modelValue, m);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}, Te = (e, {
|
|
65
|
+
editorId: t,
|
|
66
|
+
rootRef: a,
|
|
67
|
+
setting: n
|
|
68
|
+
}) => {
|
|
69
|
+
const o = L.editorExtensions.highlight, m = L.editorExtensionsAttrs.highlight;
|
|
70
|
+
x("editorId", t), x("rootRef", a), x(
|
|
71
|
+
"theme",
|
|
72
|
+
F(() => e.theme)
|
|
73
|
+
), x(
|
|
74
|
+
"language",
|
|
75
|
+
F(() => e.language)
|
|
76
|
+
), x(
|
|
77
|
+
"highlight",
|
|
78
|
+
F(() => {
|
|
79
|
+
const { js: u } = o, s = {
|
|
80
|
+
...me,
|
|
81
|
+
...o.css
|
|
82
|
+
}, { js: l, css: i = {} } = m || {}, r = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme, d = s[e.codeTheme] ? s[e.codeTheme][r] : me.atom[r], f = s[e.codeTheme] && i[e.codeTheme] ? i[e.codeTheme][r] : i.atom ? i.atom[r] : {};
|
|
83
|
+
return {
|
|
84
|
+
js: {
|
|
85
|
+
src: u,
|
|
86
|
+
...l
|
|
87
|
+
},
|
|
88
|
+
css: {
|
|
89
|
+
href: d,
|
|
90
|
+
...f
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
})
|
|
94
|
+
), x("showCodeRowNumber", e.showCodeRowNumber);
|
|
95
|
+
const c = F(() => {
|
|
96
|
+
const u = {
|
|
97
|
+
...fe,
|
|
98
|
+
...L.editorConfig.languageUserDefined
|
|
99
|
+
};
|
|
100
|
+
return _e(
|
|
101
|
+
Oe(fe["en-US"]),
|
|
102
|
+
u[e.language] || {}
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
return x("usedLanguageText", c), x(
|
|
106
|
+
"previewTheme",
|
|
107
|
+
F(() => e.previewTheme)
|
|
108
|
+
), x(
|
|
109
|
+
"customIcon",
|
|
110
|
+
F(() => e.customIcon)
|
|
111
|
+
), x(
|
|
112
|
+
"setting",
|
|
113
|
+
F(() => n ? {
|
|
114
|
+
// setting是reactive,不转化是可以直接赋值的
|
|
115
|
+
...n
|
|
116
|
+
} : {
|
|
117
|
+
preview: !0,
|
|
118
|
+
htmlPreview: !1,
|
|
119
|
+
previewOnly: !1,
|
|
120
|
+
pageFullscreen: !1,
|
|
121
|
+
fullscreen: !1
|
|
122
|
+
})
|
|
123
|
+
), { editorId: t };
|
|
124
|
+
}, en = (e, t) => (x("tabWidth", e.tabWidth), x(
|
|
125
|
+
"disabled",
|
|
126
|
+
F(() => e.disabled)
|
|
127
|
+
), x(
|
|
128
|
+
"showToolbarName",
|
|
129
|
+
F(() => e.showToolbarName)
|
|
130
|
+
), x("noUploadImg", e.noUploadImg), x(
|
|
131
|
+
"tableShape",
|
|
132
|
+
F(() => e.tableShape)
|
|
133
|
+
), x("noPrettier", e.noPrettier), x(
|
|
134
|
+
"codeTheme",
|
|
135
|
+
F(() => e.codeTheme)
|
|
136
|
+
), x("updateSetting", t.updateSetting), x(
|
|
137
|
+
"catalogVisible",
|
|
138
|
+
F(() => t.catalogVisible.value)
|
|
139
|
+
), x("defToolbars", t.defToolbars), x(
|
|
140
|
+
"floatingToolbars",
|
|
141
|
+
F(() => e.floatingToolbars)
|
|
142
|
+
), Te(e, t)), tn = (e) => {
|
|
143
|
+
const { noPrettier: t, noUploadImg: a } = e, { editorExtensions: n, editorExtensionsAttrs: o } = L, m = t || n.prettier.prettierInstance, c = t || n.prettier.parserMarkdownInstance, u = a || n.cropper.instance;
|
|
144
|
+
M(() => {
|
|
145
|
+
if (!u) {
|
|
146
|
+
const { js: s = {}, css: l = {} } = o.cropper || {};
|
|
147
|
+
O("link", {
|
|
148
|
+
...l,
|
|
149
|
+
rel: "stylesheet",
|
|
150
|
+
href: n.cropper.css,
|
|
151
|
+
id: P.croppercss
|
|
152
|
+
}), O("script", {
|
|
153
|
+
...s,
|
|
154
|
+
src: n.cropper.js,
|
|
155
|
+
id: P.cropperjs
|
|
23
156
|
});
|
|
24
|
-
},
|
|
25
|
-
() => {
|
|
26
|
-
e.removeEventListener("scroll", o), l.removeEventListener("scroll", o);
|
|
27
157
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end: t - 1
|
|
158
|
+
if (!m) {
|
|
159
|
+
const { standaloneJs: s = {} } = o.prettier || {};
|
|
160
|
+
O("script", {
|
|
161
|
+
...s,
|
|
162
|
+
src: n.prettier.standaloneJs,
|
|
163
|
+
id: P.prettier
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (!c) {
|
|
167
|
+
const { parserMarkdownJs: s = {} } = o.prettier || {};
|
|
168
|
+
O("script", {
|
|
169
|
+
...s,
|
|
170
|
+
src: n.prettier.parserMarkdownJs,
|
|
171
|
+
id: P.prettierMD
|
|
43
172
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}, nn = (e, t, a) => {
|
|
176
|
+
const { editorId: n } = a;
|
|
177
|
+
M(() => {
|
|
178
|
+
y.on(n, {
|
|
179
|
+
name: Q,
|
|
180
|
+
callback: (o) => {
|
|
181
|
+
e.onError?.(o), t.emit("onError", o);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}, on = (e, t, a) => {
|
|
186
|
+
const { editorId: n } = a, o = le({
|
|
187
|
+
pageFullscreen: e.pageFullscreen,
|
|
188
|
+
fullscreen: !1,
|
|
189
|
+
preview: e.preview,
|
|
190
|
+
htmlPreview: e.preview ? !1 : e.htmlPreview,
|
|
191
|
+
previewOnly: !1
|
|
192
|
+
}), m = le({ ...o }), c = (l, i) => {
|
|
193
|
+
const r = i === void 0 ? !o[l] : i;
|
|
194
|
+
switch (l) {
|
|
195
|
+
case "preview": {
|
|
196
|
+
o.htmlPreview = !1, o.previewOnly = !1;
|
|
50
197
|
break;
|
|
51
198
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
199
|
+
case "htmlPreview": {
|
|
200
|
+
o.preview = !1, o.previewOnly = !1;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case "previewOnly": {
|
|
204
|
+
r ? !o.preview && !o.htmlPreview && (o.preview = !0) : (m.preview || (o.preview = !1), m.htmlPreview || (o.htmlPreview = !1));
|
|
57
205
|
break;
|
|
58
206
|
}
|
|
59
207
|
}
|
|
60
|
-
|
|
208
|
+
m[l] = r, o[l] = r;
|
|
61
209
|
};
|
|
62
|
-
let
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
210
|
+
let u = "";
|
|
211
|
+
const s = () => {
|
|
212
|
+
o.pageFullscreen || o.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = u;
|
|
213
|
+
};
|
|
214
|
+
return E(() => [o.pageFullscreen, o.fullscreen], s), M(() => {
|
|
215
|
+
y.on(n, {
|
|
216
|
+
name: De,
|
|
217
|
+
callback(l, i) {
|
|
218
|
+
const r = (d) => {
|
|
219
|
+
y.emit(n, se, "image", {
|
|
220
|
+
desc: "",
|
|
221
|
+
urls: d
|
|
222
|
+
}), i?.();
|
|
223
|
+
};
|
|
224
|
+
e.onUploadImg ? e.onUploadImg(l, r) : t.emit("onUploadImg", l, r);
|
|
225
|
+
}
|
|
226
|
+
}), u = document.body.style.overflow, s();
|
|
227
|
+
}), [o, c];
|
|
228
|
+
}, an = (e, t) => {
|
|
229
|
+
const { editorId: a } = t, n = z(!1);
|
|
230
|
+
return M(() => {
|
|
231
|
+
y.on(a, {
|
|
232
|
+
name: ke,
|
|
233
|
+
callback: (o) => {
|
|
234
|
+
o === void 0 ? n.value = !n.value : n.value = o;
|
|
235
|
+
}
|
|
86
236
|
});
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
237
|
+
}), n;
|
|
238
|
+
}, rn = (e, t, a) => {
|
|
239
|
+
const { editorId: n, catalogVisible: o, setting: m, updateSetting: c, codeRef: u } = a;
|
|
240
|
+
E(
|
|
241
|
+
() => m.pageFullscreen,
|
|
242
|
+
(l) => {
|
|
243
|
+
y.emit(n, he, l);
|
|
244
|
+
}
|
|
245
|
+
), E(
|
|
246
|
+
() => m.fullscreen,
|
|
247
|
+
(l) => {
|
|
248
|
+
y.emit(n, pe, l);
|
|
249
|
+
}
|
|
250
|
+
), E(
|
|
251
|
+
() => m.preview,
|
|
252
|
+
(l) => {
|
|
253
|
+
y.emit(n, ge, l);
|
|
254
|
+
}
|
|
255
|
+
), E(
|
|
256
|
+
() => m.previewOnly,
|
|
257
|
+
(l) => {
|
|
258
|
+
y.emit(n, ve, l);
|
|
259
|
+
}
|
|
260
|
+
), E(
|
|
261
|
+
() => m.htmlPreview,
|
|
262
|
+
(l) => {
|
|
263
|
+
y.emit(n, ye, l);
|
|
264
|
+
}
|
|
265
|
+
), E(o, (l) => {
|
|
266
|
+
y.emit(n, be, l);
|
|
267
|
+
});
|
|
268
|
+
const s = {
|
|
269
|
+
on(l, i) {
|
|
270
|
+
switch (l) {
|
|
271
|
+
case "pageFullscreen": {
|
|
272
|
+
y.on(n, {
|
|
273
|
+
name: he,
|
|
274
|
+
callback(r) {
|
|
275
|
+
i(r);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
105
278
|
break;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
279
|
+
}
|
|
280
|
+
case "fullscreen": {
|
|
281
|
+
y.on(n, {
|
|
282
|
+
name: pe,
|
|
283
|
+
callback(r) {
|
|
284
|
+
i(r);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case "preview": {
|
|
290
|
+
y.on(n, {
|
|
291
|
+
name: ge,
|
|
292
|
+
callback(r) {
|
|
293
|
+
i(r);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
112
296
|
break;
|
|
113
297
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
298
|
+
case "previewOnly": {
|
|
299
|
+
y.on(n, {
|
|
300
|
+
name: ve,
|
|
301
|
+
callback(r) {
|
|
302
|
+
i(r);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
case "htmlPreview": {
|
|
308
|
+
y.on(n, {
|
|
309
|
+
name: ye,
|
|
310
|
+
callback(r) {
|
|
311
|
+
i(r);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
117
314
|
break;
|
|
118
315
|
}
|
|
119
|
-
case
|
|
120
|
-
|
|
316
|
+
case "catalog": {
|
|
317
|
+
y.on(n, {
|
|
318
|
+
name: be,
|
|
319
|
+
callback(r) {
|
|
320
|
+
i(r);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
121
323
|
break;
|
|
122
324
|
}
|
|
123
|
-
default:
|
|
124
|
-
a = s[T], u = s[T + 1 === s.length ? T : T + 1];
|
|
125
325
|
}
|
|
326
|
+
},
|
|
327
|
+
togglePageFullscreen(l) {
|
|
328
|
+
c("pageFullscreen", l);
|
|
329
|
+
},
|
|
330
|
+
toggleFullscreen(l) {
|
|
331
|
+
y.emit(n, Ge, l);
|
|
332
|
+
},
|
|
333
|
+
togglePreview(l) {
|
|
334
|
+
c("preview", l);
|
|
335
|
+
},
|
|
336
|
+
togglePreviewOnly(l) {
|
|
337
|
+
c("previewOnly", l);
|
|
338
|
+
},
|
|
339
|
+
toggleHtmlPreview(l) {
|
|
340
|
+
c("htmlPreview", l);
|
|
341
|
+
},
|
|
342
|
+
toggleCatalog(l) {
|
|
343
|
+
y.emit(n, ke, l);
|
|
344
|
+
},
|
|
345
|
+
triggerSave() {
|
|
346
|
+
y.emit(n, xe);
|
|
347
|
+
},
|
|
348
|
+
insert(l) {
|
|
349
|
+
y.emit(n, se, "universal", { generate: l });
|
|
350
|
+
},
|
|
351
|
+
focus(l) {
|
|
352
|
+
u.value?.focus(l);
|
|
353
|
+
},
|
|
354
|
+
rerender() {
|
|
355
|
+
y.emit(n, ue);
|
|
356
|
+
},
|
|
357
|
+
getSelectedText() {
|
|
358
|
+
return u.value?.getSelectedText();
|
|
359
|
+
},
|
|
360
|
+
resetHistory() {
|
|
361
|
+
u.value?.resetHistory();
|
|
362
|
+
},
|
|
363
|
+
domEventHandlers(l) {
|
|
364
|
+
y.emit(n, Ve, l);
|
|
365
|
+
},
|
|
366
|
+
execCommand(l) {
|
|
367
|
+
y.emit(n, se, l);
|
|
368
|
+
},
|
|
369
|
+
getEditorView() {
|
|
370
|
+
return u.value?.getEditorView();
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
t.expose(s);
|
|
374
|
+
}, ot = (e) => {
|
|
375
|
+
const t = He();
|
|
376
|
+
return e.id || e.editorId || `${h}-${t}`;
|
|
377
|
+
}, at = (e, t, a) => {
|
|
378
|
+
const n = C("editorId"), o = C("rootRef"), m = C("usedLanguageText"), c = C("setting"), u = () => {
|
|
379
|
+
o.value.querySelectorAll(`#${n} .${h}-preview .${h}-code`).forEach((i) => {
|
|
380
|
+
let r = -1;
|
|
381
|
+
const d = i.querySelector(
|
|
382
|
+
`.${h}-copy-button:not([data-processed])`
|
|
383
|
+
);
|
|
384
|
+
d && (d.onclick = (f) => {
|
|
385
|
+
f.preventDefault(), clearTimeout(r);
|
|
386
|
+
const v = (i.querySelector("input:checked + pre code") || i.querySelector("pre code")).textContent, { text: p, successTips: T, failTips: b } = m.value.copyCode;
|
|
387
|
+
let $ = T;
|
|
388
|
+
Je(e.formatCopiedText(v || "")).catch(() => {
|
|
389
|
+
$ = b;
|
|
390
|
+
}).finally(() => {
|
|
391
|
+
d.dataset.isIcon ? d.dataset.tips = $ : d.textContent = $, r = window.setTimeout(() => {
|
|
392
|
+
d.dataset.isIcon ? d.dataset.tips = p : d.textContent = p;
|
|
393
|
+
}, 1500);
|
|
394
|
+
});
|
|
395
|
+
}, d.setAttribute("data-processed", "true"));
|
|
396
|
+
});
|
|
397
|
+
}, s = () => {
|
|
398
|
+
W(u);
|
|
399
|
+
}, l = (i) => {
|
|
400
|
+
i && W(u);
|
|
401
|
+
};
|
|
402
|
+
E([t, a], s), E(() => c.value.preview, l), E(() => c.value.htmlPreview, l), M(u);
|
|
403
|
+
}, rt = (e) => {
|
|
404
|
+
const t = C("editorId"), a = C("theme"), n = C("rootRef"), { editorExtensions: o, editorExtensionsAttrs: m, echartsConfig: c } = L;
|
|
405
|
+
let u = o.echarts.instance;
|
|
406
|
+
const s = ee(-1), l = () => {
|
|
407
|
+
!e.noEcharts && u && (s.value = s.value + 1);
|
|
408
|
+
};
|
|
409
|
+
E(
|
|
410
|
+
() => a.value,
|
|
411
|
+
() => {
|
|
412
|
+
l();
|
|
126
413
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
414
|
+
), M(() => {
|
|
415
|
+
if (e.noEcharts || u)
|
|
416
|
+
return;
|
|
417
|
+
const v = o.echarts.js;
|
|
418
|
+
O(
|
|
419
|
+
"script",
|
|
420
|
+
{
|
|
421
|
+
...m.echarts?.js,
|
|
422
|
+
src: v,
|
|
423
|
+
id: P.echarts,
|
|
424
|
+
onload() {
|
|
425
|
+
u = window.echarts, l();
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
"echarts"
|
|
132
429
|
);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
430
|
+
});
|
|
431
|
+
let i = [], r = [], d = [];
|
|
432
|
+
const f = (v = !1) => {
|
|
433
|
+
if (!i.length) {
|
|
434
|
+
v && (r.forEach(($) => {
|
|
435
|
+
$.dispose?.();
|
|
436
|
+
}), d.forEach(($) => {
|
|
437
|
+
$.disconnect?.();
|
|
438
|
+
}), r = [], d = []);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const p = [], T = [], b = [];
|
|
442
|
+
i.forEach(($, S) => {
|
|
443
|
+
const w = r[S], I = d[S];
|
|
444
|
+
if (v || !$ || !$.isConnected || (n?.value ? !n.value.contains($) : !1)) {
|
|
445
|
+
w?.dispose?.(), I?.disconnect?.();
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
p.push($), w && T.push(w), I && b.push(I);
|
|
449
|
+
}), i = p, r = T, d = b;
|
|
450
|
+
}, g = () => {
|
|
451
|
+
f(), !e.noEcharts && u && Array.from(
|
|
452
|
+
n.value.querySelectorAll(
|
|
453
|
+
`#${t} div.${h}-echarts:not([data-processed])`
|
|
454
|
+
)
|
|
455
|
+
).forEach((p) => {
|
|
456
|
+
if (p.dataset.closed === "false")
|
|
457
|
+
return !1;
|
|
458
|
+
try {
|
|
459
|
+
const T = o.echarts.parseOption(p.innerText, {
|
|
460
|
+
editorId: t,
|
|
461
|
+
element: p
|
|
462
|
+
}), b = c(T), $ = u.init(p, a.value);
|
|
463
|
+
$.setOption(b), p.setAttribute("data-processed", ""), i.push(p), r.push($);
|
|
464
|
+
const S = new ResizeObserver(() => {
|
|
465
|
+
$.resize();
|
|
466
|
+
});
|
|
467
|
+
S.observe(p), d.push(S);
|
|
468
|
+
} catch (T) {
|
|
469
|
+
y.emit(t, Q, {
|
|
470
|
+
name: "echarts",
|
|
471
|
+
message: T?.message,
|
|
472
|
+
error: T
|
|
473
|
+
});
|
|
474
|
+
}
|
|
143
475
|
});
|
|
144
|
-
}, M = (i) => {
|
|
145
|
-
const { scrollDOM: h, contentHeight: H } = o, t = h.clientHeight;
|
|
146
|
-
if (H <= t || l.firstElementChild.clientHeight <= l.clientHeight || o.state.doc.lines <= f[f.length - 1]?.end)
|
|
147
|
-
return !1;
|
|
148
|
-
i.target === e ? _() : F();
|
|
149
476
|
};
|
|
150
|
-
return
|
|
477
|
+
return te(() => {
|
|
478
|
+
f(!0);
|
|
479
|
+
}), { reRenderEcharts: s, replaceEcharts: g };
|
|
480
|
+
}, lt = (e) => {
|
|
481
|
+
const t = C("highlight"), a = ee(L.editorExtensions.highlight.instance);
|
|
482
|
+
return M(() => {
|
|
483
|
+
e.noHighlight || a.value || (O("link", {
|
|
484
|
+
...t.value.css,
|
|
485
|
+
rel: "stylesheet",
|
|
486
|
+
id: P.hlcss
|
|
487
|
+
}), O(
|
|
488
|
+
"script",
|
|
489
|
+
{
|
|
490
|
+
...t.value.js,
|
|
491
|
+
id: P.hljs,
|
|
492
|
+
onload() {
|
|
493
|
+
a.value = window.hljs;
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
"hljs"
|
|
497
|
+
));
|
|
498
|
+
}), E(
|
|
499
|
+
() => t.value.css,
|
|
151
500
|
() => {
|
|
152
|
-
|
|
153
|
-
|
|
501
|
+
e.noHighlight || L.editorExtensions.highlight.instance || We("link", {
|
|
502
|
+
...t.value.css,
|
|
503
|
+
rel: "stylesheet",
|
|
504
|
+
id: P.hlcss
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
), a;
|
|
508
|
+
}, it = (e) => {
|
|
509
|
+
const t = ee(L.editorExtensions.katex.instance);
|
|
510
|
+
return M(() => {
|
|
511
|
+
if (e.noKatex || t.value)
|
|
512
|
+
return;
|
|
513
|
+
const { editorExtensions: a, editorExtensionsAttrs: n } = L;
|
|
514
|
+
O(
|
|
515
|
+
"script",
|
|
516
|
+
{
|
|
517
|
+
...n.katex?.js,
|
|
518
|
+
src: a.katex.js,
|
|
519
|
+
id: P.katexjs,
|
|
520
|
+
onload() {
|
|
521
|
+
t.value = window.katex;
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
"katex"
|
|
525
|
+
), O("link", {
|
|
526
|
+
...n.katex?.css,
|
|
527
|
+
rel: "stylesheet",
|
|
528
|
+
href: a.katex.css,
|
|
529
|
+
id: P.katexcss
|
|
530
|
+
});
|
|
531
|
+
}), t;
|
|
532
|
+
};
|
|
533
|
+
class st {
|
|
534
|
+
constructor(t) {
|
|
535
|
+
this.options = t;
|
|
536
|
+
}
|
|
537
|
+
options;
|
|
538
|
+
cache = /* @__PURE__ */ new Map();
|
|
539
|
+
isExpired(t) {
|
|
540
|
+
return t.expiresAt <= Date.now();
|
|
541
|
+
}
|
|
542
|
+
deleteExpired(t, a) {
|
|
543
|
+
const n = a ?? this.cache.get(t);
|
|
544
|
+
return !n || !this.isExpired(n) ? !1 : (this.cache.delete(t), !0);
|
|
545
|
+
}
|
|
546
|
+
trim() {
|
|
547
|
+
for (const [t, a] of this.cache)
|
|
548
|
+
if (!this.deleteExpired(t, a))
|
|
549
|
+
break;
|
|
550
|
+
for (; this.cache.size > this.options.max; ) {
|
|
551
|
+
const t = this.cache.keys().next().value;
|
|
552
|
+
if (t === void 0)
|
|
553
|
+
break;
|
|
554
|
+
this.cache.delete(t);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
get(t) {
|
|
558
|
+
const a = this.cache.get(t);
|
|
559
|
+
if (!(!a || this.deleteExpired(t, a)))
|
|
560
|
+
return this.cache.delete(t), this.cache.set(t, a), a.value;
|
|
561
|
+
}
|
|
562
|
+
set(t, a) {
|
|
563
|
+
this.cache.delete(t), this.cache.set(t, {
|
|
564
|
+
value: a,
|
|
565
|
+
expiresAt: Date.now() + this.options.ttl
|
|
566
|
+
}), this.trim();
|
|
567
|
+
}
|
|
568
|
+
clear() {
|
|
569
|
+
this.cache.clear();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const Y = new st({
|
|
573
|
+
max: 1e3,
|
|
574
|
+
// 缓存10分钟
|
|
575
|
+
ttl: 6e5
|
|
576
|
+
}), ct = (e) => {
|
|
577
|
+
const t = C("editorId"), a = C("theme"), n = C("rootRef"), { editorExtensions: o, editorExtensionsAttrs: m, mermaidConfig: c } = L;
|
|
578
|
+
let u = o.mermaid.instance;
|
|
579
|
+
const s = ee(-1), l = () => {
|
|
580
|
+
if (!e.noMermaid && u) {
|
|
581
|
+
const r = a.value === "dark" ? {
|
|
582
|
+
startOnLoad: !1,
|
|
583
|
+
theme: "dark"
|
|
584
|
+
} : {
|
|
585
|
+
startOnLoad: !1,
|
|
586
|
+
theme: "base",
|
|
587
|
+
themeVariables: {
|
|
588
|
+
background: "#ffffff",
|
|
589
|
+
primaryColor: "#ffffff",
|
|
590
|
+
primaryTextColor: "#1f2329",
|
|
591
|
+
primaryBorderColor: "#b7c0cc",
|
|
592
|
+
secondaryColor: "#f7f8fa",
|
|
593
|
+
tertiaryColor: "#f7f8fa",
|
|
594
|
+
lineColor: "#596273",
|
|
595
|
+
edgeLabelBackground: "#ffffff",
|
|
596
|
+
clusterBkg: "#ffffff",
|
|
597
|
+
clusterBorder: "#b7c0cc"
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
u.initialize(c(r)), s.value = s.value + 1;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
return E(
|
|
604
|
+
() => a.value,
|
|
154
605
|
() => {
|
|
155
|
-
|
|
606
|
+
Y.clear(), l();
|
|
607
|
+
}
|
|
608
|
+
), M(() => {
|
|
609
|
+
if (e.noMermaid || u)
|
|
610
|
+
return;
|
|
611
|
+
const r = o.mermaid.js;
|
|
612
|
+
/\.mjs/.test(r) ? (O("link", {
|
|
613
|
+
...m.mermaid?.js,
|
|
614
|
+
rel: "modulepreload",
|
|
615
|
+
href: r,
|
|
616
|
+
id: P.mermaidM
|
|
617
|
+
}), import(
|
|
618
|
+
/* @vite-ignore */
|
|
619
|
+
/* webpackIgnore: true */
|
|
620
|
+
r
|
|
621
|
+
).then((d) => {
|
|
622
|
+
u = d.default, l();
|
|
623
|
+
}).catch((d) => {
|
|
624
|
+
y.emit(t, Q, {
|
|
625
|
+
name: "mermaid",
|
|
626
|
+
message: `Failed to load mermaid module: ${d.message}`,
|
|
627
|
+
error: d
|
|
628
|
+
});
|
|
629
|
+
})) : O(
|
|
630
|
+
"script",
|
|
631
|
+
{
|
|
632
|
+
...m.mermaid?.js,
|
|
633
|
+
src: r,
|
|
634
|
+
id: P.mermaid,
|
|
635
|
+
onload() {
|
|
636
|
+
u = window.mermaid, l();
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
"mermaid"
|
|
640
|
+
);
|
|
641
|
+
}), { reRenderRef: s, replaceMermaid: async () => {
|
|
642
|
+
if (!e.noMermaid && u) {
|
|
643
|
+
const r = n.value.querySelectorAll(
|
|
644
|
+
`div.${h}-mermaid`
|
|
645
|
+
), d = document.createElement("div"), f = document.body.offsetWidth > 1366 ? document.body.offsetWidth : 1366, g = document.body.offsetHeight > 768 ? document.body.offsetHeight : 768;
|
|
646
|
+
d.style.width = f + "px", d.style.height = g + "px", d.style.position = "fixed", d.style.zIndex = "-10000", d.style.top = "-10000";
|
|
647
|
+
let v = r.length;
|
|
648
|
+
v > 0 && document.body.appendChild(d), await Promise.allSettled(
|
|
649
|
+
Array.from(r).map((p) => (async (b) => {
|
|
650
|
+
if (b.dataset.closed === "false")
|
|
651
|
+
return !1;
|
|
652
|
+
const $ = b.innerText;
|
|
653
|
+
let S = Y.get($);
|
|
654
|
+
if (!S) {
|
|
655
|
+
const w = ie();
|
|
656
|
+
let I = { svg: "" };
|
|
657
|
+
try {
|
|
658
|
+
I = await u.render(w, $, d), S = await e.sanitizeMermaid(I.svg);
|
|
659
|
+
const k = document.createElement("p");
|
|
660
|
+
k.className = `${h}-mermaid`, k.setAttribute("data-processed", ""), k.setAttribute("data-content", $), k.innerHTML = S, k.children[0]?.removeAttribute("height"), Y.set($, k.innerHTML), b.dataset.line !== void 0 && (k.dataset.line = b.dataset.line), b.replaceWith(k);
|
|
661
|
+
} catch (k) {
|
|
662
|
+
y.emit(t, Q, {
|
|
663
|
+
name: "mermaid",
|
|
664
|
+
message: k.message,
|
|
665
|
+
error: k
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
--v === 0 && d.remove();
|
|
669
|
+
}
|
|
670
|
+
})(p))
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
} };
|
|
674
|
+
}, dt = (e, t) => {
|
|
675
|
+
t = t || {};
|
|
676
|
+
const a = 3, n = t.marker || "!", o = n.charCodeAt(0), m = n.length;
|
|
677
|
+
let c = "", u = "";
|
|
678
|
+
const s = (i, r, d, f, g) => {
|
|
679
|
+
const v = i[r];
|
|
680
|
+
return v.type === "admonition_open" ? i[r].attrPush([
|
|
681
|
+
"class",
|
|
682
|
+
`${h}-admonition ${h}-admonition-${v.info}`
|
|
683
|
+
]) : v.type === "admonition_title_open" && i[r].attrPush(["class", `${h}-admonition-title`]), g.renderToken(i, r, d);
|
|
684
|
+
}, l = (i) => {
|
|
685
|
+
const r = i.trim().split(" ", 2);
|
|
686
|
+
u = "", c = r[0], r.length > 1 && (u = i.substring(c.length + 2));
|
|
687
|
+
};
|
|
688
|
+
e.block.ruler.before(
|
|
689
|
+
"code",
|
|
690
|
+
"admonition",
|
|
691
|
+
(i, r, d, f) => {
|
|
692
|
+
let g, v, p, T = !1, b = i.bMarks[r] + i.tShift[r], $ = i.eMarks[r];
|
|
693
|
+
if (o !== i.src.charCodeAt(b))
|
|
694
|
+
return !1;
|
|
695
|
+
for (g = b + 1; g <= $ && n[(g - b) % m] === i.src[g]; g++)
|
|
696
|
+
;
|
|
697
|
+
const S = Math.floor((g - b) / m);
|
|
698
|
+
if (S !== a)
|
|
699
|
+
return !1;
|
|
700
|
+
g -= (g - b) % m;
|
|
701
|
+
const w = i.src.slice(b, g), I = i.src.slice(g, $);
|
|
702
|
+
if (l(I), f)
|
|
703
|
+
return !0;
|
|
704
|
+
for (v = r; v++, !(v >= d || (b = i.bMarks[v] + i.tShift[v], $ = i.eMarks[v], b < $ && i.sCount[v] < i.blkIndent)); )
|
|
705
|
+
if (o === i.src.charCodeAt(b) && !(i.sCount[v] - i.blkIndent >= 4)) {
|
|
706
|
+
for (g = b + 1; g <= $ && n[(g - b) % m] === i.src[g]; g++)
|
|
707
|
+
;
|
|
708
|
+
if (!(Math.floor((g - b) / m) < S) && (g -= (g - b) % m, g = i.skipSpaces(g), !(g < $))) {
|
|
709
|
+
T = !0;
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const k = i.parentType, R = i.lineMax;
|
|
714
|
+
return i.parentType = "root", i.lineMax = v, p = i.push("admonition_open", "div", 1), p.markup = w, p.block = !0, p.info = c, p.map = [r, v], u && (p = i.push("admonition_title_open", "p", 1), p.markup = w + " " + c, p.map = [r, v], p = i.push("inline", "", 0), p.content = u, p.map = [r, i.line - 1], p.children = [], p = i.push("admonition_title_close", "p", -1), p.markup = w + " " + c), i.md.block.tokenize(i, r + 1, v), p = i.push("admonition_close", "div", -1), p.markup = i.src.slice(b, g), p.block = !0, i.parentType = k, i.lineMax = R, i.line = v + (T ? 1 : 0), !0;
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
718
|
+
}
|
|
719
|
+
), e.renderer.rules.admonition_open = s, e.renderer.rules.admonition_title_open = s, e.renderer.rules.admonition_title_close = s, e.renderer.rules.admonition_close = s;
|
|
720
|
+
}, ce = (e, t) => {
|
|
721
|
+
const a = e.attrs ? e.attrs.slice() : [];
|
|
722
|
+
return t.forEach((n) => {
|
|
723
|
+
const o = e.attrIndex(n[0]);
|
|
724
|
+
o < 0 ? a.push(n) : (a[o] = a[o].slice(), a[o][1] += ` ${n[1]}`);
|
|
725
|
+
}), a;
|
|
726
|
+
}, ut = (e) => Array.from(e).map(
|
|
727
|
+
(t) => /[A-Za-z0-9_-]/.test(t) ? t : `_${t.codePointAt(0).toString(16)}_`
|
|
728
|
+
).join(""), mt = (e, t) => {
|
|
729
|
+
const a = e.renderer.rules.fence, n = e.utils.unescapeAll, o = /\[(\w*)(?::([\w ]*))?\]/, m = /::(open|close)/, c = ut(t.editorId), u = (d) => d.info ? n(d.info).trim() : "", s = (d) => {
|
|
730
|
+
const f = u(d), [g = null, v = ""] = (o.exec(f) || []).slice(1);
|
|
731
|
+
return [g, v];
|
|
732
|
+
}, l = (d) => {
|
|
733
|
+
const f = u(d);
|
|
734
|
+
return f ? f.split(/(\s+)/g)[0] : "";
|
|
735
|
+
}, i = (d) => {
|
|
736
|
+
const f = d.info.match(m) || [], g = f[1] === "open" || f[1] !== "close" && t.codeFoldable && d.content.trim().split(`
|
|
737
|
+
`).length < t.autoFoldThreshold, v = f[1] || t.codeFoldable ? "details" : "div", p = f[1] || t.codeFoldable ? "summary" : "div";
|
|
738
|
+
return { open: g, tagContainer: v, tagHeader: p };
|
|
739
|
+
}, r = (d, f, g, v, p) => {
|
|
740
|
+
if (d[f].hidden)
|
|
741
|
+
return "";
|
|
742
|
+
const T = t.usedLanguageTextRef.value?.copyCode.text || "", b = t.customIconRef.value.copy, $ = e.utils.escapeHtml(T), S = b || $, w = !!b, I = `<span class="${h}-collapse-tips">${qe("collapse-tips", t.customIconRef.value)}</span>`, [k] = s(d[f]);
|
|
743
|
+
if (k === null) {
|
|
744
|
+
const { open: A, tagContainer: _, tagHeader: J } = i(d[f]), U = [["class", `${h}-code`]];
|
|
745
|
+
A && U.push(["open", ""]);
|
|
746
|
+
const Fe = {
|
|
747
|
+
attrs: ce(d[f], U)
|
|
748
|
+
};
|
|
749
|
+
d[f].info = d[f].info.replace(m, "");
|
|
750
|
+
const Re = a(d, f, g, v, p);
|
|
751
|
+
return `
|
|
752
|
+
<${_} ${p.renderAttrs(Fe)}>
|
|
753
|
+
<${J} class="${h}-code-head">
|
|
754
|
+
<div class="${h}-code-flag"><span></span><span></span><span></span></div>
|
|
755
|
+
<div class="${h}-code-action">
|
|
756
|
+
<span class="${h}-code-lang">${e.utils.escapeHtml(d[f].info.trim())}</span>
|
|
757
|
+
<span class="${h}-copy-button" data-tips="${$}"${w ? " data-is-icon=true" : ""}>${S}</span>
|
|
758
|
+
${t.extraTools instanceof Function ? t.extraTools({ lang: d[f].info.trim() }) : t.extraTools || ""}
|
|
759
|
+
${_ === "details" ? I : ""}
|
|
760
|
+
</div>
|
|
761
|
+
</${J}>
|
|
762
|
+
${Re}
|
|
763
|
+
</${_}>
|
|
764
|
+
`;
|
|
765
|
+
}
|
|
766
|
+
let R, B, V, j, q = "", K = "", Z = "";
|
|
767
|
+
const { open: ne, tagContainer: G, tagHeader: H } = i(d[f]), D = [["class", `${h}-code`]];
|
|
768
|
+
ne && D.push(["open", ""]);
|
|
769
|
+
const oe = {
|
|
770
|
+
attrs: ce(d[f], D)
|
|
771
|
+
};
|
|
772
|
+
for (let A = f; A < d.length && (R = d[A], [B, V] = s(R), B === k); A++) {
|
|
773
|
+
R.info = R.info.replace(o, "").replace(m, ""), R.hidden = !0;
|
|
774
|
+
const _ = `${h}-codetab-${c}-${f}-${A - f}`;
|
|
775
|
+
j = A - f > 0 ? "" : "checked", q += `
|
|
776
|
+
<li>
|
|
777
|
+
<input
|
|
778
|
+
type="radio"
|
|
779
|
+
id="label-${h}-codetab-label-1-${c}-${f}-${A - f}"
|
|
780
|
+
name="${h}-codetab-label-${c}-${f}"
|
|
781
|
+
class="${_}"
|
|
782
|
+
${j}
|
|
783
|
+
>
|
|
784
|
+
<label
|
|
785
|
+
for="label-${h}-codetab-label-1-${c}-${f}-${A - f}"
|
|
786
|
+
onclick="this.getRootNode().querySelectorAll('.${_}').forEach(e => e.click())"
|
|
787
|
+
>
|
|
788
|
+
${e.utils.escapeHtml(V || l(R))}
|
|
789
|
+
</label>
|
|
790
|
+
</li>`, K += `
|
|
791
|
+
<div role="tabpanel">
|
|
792
|
+
<input
|
|
793
|
+
type="radio"
|
|
794
|
+
name="${h}-codetab-pre-${c}-${f}"
|
|
795
|
+
class="${_}"
|
|
796
|
+
${j}
|
|
797
|
+
role="presentation">
|
|
798
|
+
${a(d, A, g, v, p)}
|
|
799
|
+
</div>`, Z += `
|
|
800
|
+
<input
|
|
801
|
+
type="radio"
|
|
802
|
+
name="${h}-codetab-lang-${c}-${f}"
|
|
803
|
+
class="${_}"
|
|
804
|
+
${j}
|
|
805
|
+
role="presentation">
|
|
806
|
+
<span class=${h}-code-lang role="note">${e.utils.escapeHtml(l(R))}</span>`;
|
|
807
|
+
}
|
|
808
|
+
return `
|
|
809
|
+
<${G} ${p.renderAttrs(oe)}>
|
|
810
|
+
<${H} class="${h}-code-head">
|
|
811
|
+
<div class="${h}-code-flag">
|
|
812
|
+
<ul class="${h}-codetab-label" role="tablist">${q}</ul>
|
|
813
|
+
</div>
|
|
814
|
+
<div class="${h}-code-action">
|
|
815
|
+
<span class="${h}-codetab-lang">${Z}</span>
|
|
816
|
+
<span class="${h}-copy-button" data-tips="${$}"${w ? " data-is-icon=true" : ""}>${S}</span>
|
|
817
|
+
${t.extraTools instanceof Function ? t.extraTools({ lang: d[f].info.trim() }) : t.extraTools || ""}
|
|
818
|
+
${G === "details" ? I : ""}
|
|
819
|
+
</div>
|
|
820
|
+
</${H}>
|
|
821
|
+
${K}
|
|
822
|
+
</${G}>
|
|
823
|
+
`;
|
|
824
|
+
};
|
|
825
|
+
e.renderer.rules.fence = r, e.renderer.rules.code_block = r;
|
|
826
|
+
}, ft = (e, t) => {
|
|
827
|
+
const a = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
828
|
+
e.renderer.rules.fence = (n, o, m, c, u) => {
|
|
829
|
+
const s = n[o], l = s.content.trim();
|
|
830
|
+
if (s.info === "echarts") {
|
|
831
|
+
if (s.attrSet("class", `${h}-echarts`), s.attrSet("data-echarts-theme", t.themeRef.value), s.map && s.level === 0) {
|
|
832
|
+
const i = s.map[1] - 1, d = !!c.srcLines[i]?.trim()?.startsWith("```");
|
|
833
|
+
s.attrSet("data-closed", `${d}`), s.attrSet("data-line", String(s.map[0]));
|
|
834
|
+
}
|
|
835
|
+
return `<div ${u.renderAttrs(s)} style="width: 100%; aspect-ratio: 4 / 3;">${e.utils.escapeHtml(l)}</div>`;
|
|
836
|
+
}
|
|
837
|
+
return a(n, o, m, c, u);
|
|
838
|
+
};
|
|
839
|
+
}, ht = (e, t) => {
|
|
840
|
+
e.renderer.rules.heading_open = (a, n) => {
|
|
841
|
+
const o = a[n], m = a[n + 1].children?.reduce((u, s) => u + (["text", "code_inline", "math_inline"].includes(s.type) && s.content || ""), "") || "", c = o.markup.length;
|
|
842
|
+
return t.headsRef.value.push({
|
|
843
|
+
text: m,
|
|
844
|
+
level: c,
|
|
845
|
+
line: o.map[0],
|
|
846
|
+
currentToken: o,
|
|
847
|
+
nextToken: a[n + 1]
|
|
848
|
+
}), o.map && o.level === 0 && o.attrSet(
|
|
849
|
+
"id",
|
|
850
|
+
t.mdHeadingId({
|
|
851
|
+
text: m,
|
|
852
|
+
level: c,
|
|
853
|
+
index: t.headsRef.value.length,
|
|
854
|
+
currentToken: o,
|
|
855
|
+
nextToken: a[n + 1]
|
|
856
|
+
})
|
|
857
|
+
), e.renderer.renderToken(a, n, t);
|
|
858
|
+
}, e.renderer.rules.heading_close = (a, n, o, m, c) => c.renderToken(a, n, o);
|
|
859
|
+
}, $e = {
|
|
860
|
+
block: [
|
|
861
|
+
{ open: "$$", close: "$$" },
|
|
862
|
+
{ open: "\\[", close: "\\]" }
|
|
863
|
+
],
|
|
864
|
+
inline: [
|
|
865
|
+
{ open: "$$", close: "$$" },
|
|
866
|
+
{ open: "$", close: "$" },
|
|
867
|
+
{ open: "\\[", close: "\\]" },
|
|
868
|
+
{ open: "\\(", close: "\\)" }
|
|
869
|
+
]
|
|
870
|
+
}, pt = (e) => (t, a) => {
|
|
871
|
+
const n = e.delimiters;
|
|
872
|
+
for (const o of n) {
|
|
873
|
+
if (!t.src.startsWith(o.open, t.pos))
|
|
874
|
+
continue;
|
|
875
|
+
const m = t.pos + o.open.length;
|
|
876
|
+
let c = m;
|
|
877
|
+
for (; (c = t.src.indexOf(o.close, c)) !== -1; ) {
|
|
878
|
+
let u = 0, s = c - 1;
|
|
879
|
+
for (; s >= 0 && t.src[s] === "\\"; )
|
|
880
|
+
u++, s--;
|
|
881
|
+
if (u % 2 === 0)
|
|
882
|
+
break;
|
|
883
|
+
c += o.close.length;
|
|
884
|
+
}
|
|
885
|
+
if (c !== -1) {
|
|
886
|
+
if (c - m === 0)
|
|
887
|
+
return a || (t.pending += o.open + o.close), t.pos = c + o.close.length, !0;
|
|
888
|
+
if (!a) {
|
|
889
|
+
const u = t.push("math_inline", "math", 0);
|
|
890
|
+
u.markup = o.open, u.content = t.src.slice(m, c);
|
|
891
|
+
}
|
|
892
|
+
return t.pos = c + o.close.length, !0;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
return !1;
|
|
896
|
+
}, gt = (e) => (t, a, n, o) => {
|
|
897
|
+
const m = e.delimiters, c = t.bMarks[a] + t.tShift[a], u = t.eMarks[a], s = (l, i, r) => {
|
|
898
|
+
t.line = i;
|
|
899
|
+
const d = t.push("math_block", "math", 0);
|
|
900
|
+
return d.block = !0, d.content = l, d.map = [a, t.line], d.markup = r, !0;
|
|
901
|
+
};
|
|
902
|
+
for (const l of m) {
|
|
903
|
+
const i = c;
|
|
904
|
+
if (t.src.slice(i, i + l.open.length) !== l.open)
|
|
905
|
+
continue;
|
|
906
|
+
const r = i + l.open.length, d = t.src.slice(r, u).trim(), f = d === "", g = d === l.close, v = d.endsWith(l.close);
|
|
907
|
+
if (!f && !g && !v)
|
|
908
|
+
continue;
|
|
909
|
+
if (o)
|
|
910
|
+
return !0;
|
|
911
|
+
if (g)
|
|
912
|
+
return s("", a + 1, l.open);
|
|
913
|
+
if (!f && v) {
|
|
914
|
+
const w = d.slice(0, -l.close.length);
|
|
915
|
+
return s(w, a + 1, l.open);
|
|
916
|
+
}
|
|
917
|
+
let p = a + 1, T = !1, b = "";
|
|
918
|
+
for (; p < n; p++) {
|
|
919
|
+
const w = t.bMarks[p] + t.tShift[p], I = t.eMarks[p];
|
|
920
|
+
if (w < I && t.tShift[p] < t.blkIndent)
|
|
921
|
+
break;
|
|
922
|
+
if (t.src.slice(w, I).trim().endsWith(l.close)) {
|
|
923
|
+
const R = t.src.slice(0, I).lastIndexOf(l.close);
|
|
924
|
+
b = t.src.slice(w, R), T = !0;
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
if (!T)
|
|
929
|
+
continue;
|
|
930
|
+
const S = t.getLines(a + 1, p, t.tShift[a], !0) + (b.trim() ? b : "");
|
|
931
|
+
return s(S, p + 1, l.open);
|
|
932
|
+
}
|
|
933
|
+
return !1;
|
|
934
|
+
}, vt = (e, { katexRef: t, inlineDelimiters: a, blockDelimiters: n }) => {
|
|
935
|
+
const o = (u, s, l, i, r = !1) => {
|
|
936
|
+
const d = {
|
|
937
|
+
attrs: ce(u, [["class", s]])
|
|
938
|
+
}, f = i.renderAttrs(d);
|
|
939
|
+
if (!t.value)
|
|
940
|
+
return `<${l} ${f}>${u.content}</${l}>`;
|
|
941
|
+
const g = t.value.renderToString(
|
|
942
|
+
u.content,
|
|
943
|
+
L.katexConfig({
|
|
944
|
+
throwOnError: !1,
|
|
945
|
+
displayMode: r
|
|
946
|
+
})
|
|
947
|
+
);
|
|
948
|
+
return `<${l} ${f} data-processed>${g}</${l}>`;
|
|
949
|
+
}, m = (u, s, l, i, r) => o(u[s], `${h}-katex-inline`, "span", r), c = (u, s, l, i, r) => o(u[s], `${h}-katex-block`, "p", r, !0);
|
|
950
|
+
e.inline.ruler.before(
|
|
951
|
+
"escape",
|
|
952
|
+
"math_inline",
|
|
953
|
+
pt({
|
|
954
|
+
delimiters: a || $e.inline
|
|
955
|
+
})
|
|
956
|
+
), e.block.ruler.after(
|
|
957
|
+
"blockquote",
|
|
958
|
+
"math_block",
|
|
959
|
+
gt({
|
|
960
|
+
delimiters: n || $e.block
|
|
961
|
+
}),
|
|
962
|
+
{
|
|
963
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
964
|
+
}
|
|
965
|
+
), e.renderer.rules.math_inline = m, e.renderer.rules.math_block = c;
|
|
966
|
+
}, yt = (e, t) => {
|
|
967
|
+
const a = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
968
|
+
e.renderer.rules.fence = (n, o, m, c, u) => {
|
|
969
|
+
const s = n[o], l = s.content.trim();
|
|
970
|
+
if (s.info === "mermaid") {
|
|
971
|
+
if (s.attrSet("class", `${h}-mermaid`), s.attrSet("data-mermaid-theme", t.themeRef.value), s.map && s.level === 0) {
|
|
972
|
+
const r = s.map[1] - 1, f = !!c.srcLines[r]?.trim()?.startsWith("```");
|
|
973
|
+
s.attrSet("data-closed", `${f}`), s.attrSet("data-line", String(s.map[0]));
|
|
974
|
+
}
|
|
975
|
+
const i = Y.get(l);
|
|
976
|
+
return i ? (s.attrSet("data-processed", ""), s.attrSet("data-content", l), `<p ${u.renderAttrs(s)}>${i}</p>`) : `<div ${u.renderAttrs(s)}>${e.utils.escapeHtml(l)}</div>`;
|
|
977
|
+
}
|
|
978
|
+
return a(n, o, m, c, u);
|
|
979
|
+
};
|
|
980
|
+
}, we = (e, t, a) => {
|
|
981
|
+
const n = e.attrIndex(t), o = [t, a];
|
|
982
|
+
n < 0 ? e.attrPush(o) : (e.attrs = e.attrs || [], e.attrs[n] = o);
|
|
983
|
+
}, bt = (e) => e.type === "inline", $t = (e) => e.type === "paragraph_open", wt = (e) => e.type === "list_item_open", Ct = (e) => e.content.indexOf("[ ] ") === 0 || e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0, Et = (e, t) => bt(e[t]) && $t(e[t - 1]) && wt(e[t - 2]) && Ct(e[t]), kt = (e, t) => {
|
|
984
|
+
const a = e[t].level - 1;
|
|
985
|
+
for (let n = t - 1; n >= 0; n--)
|
|
986
|
+
if (e[n].level === a)
|
|
987
|
+
return n;
|
|
988
|
+
return -1;
|
|
989
|
+
}, xt = (e) => {
|
|
990
|
+
const t = new e("html_inline", "", 0);
|
|
991
|
+
return t.content = "<label>", t;
|
|
992
|
+
}, Tt = (e) => {
|
|
993
|
+
const t = new e("html_inline", "", 0);
|
|
994
|
+
return t.content = "</label>", t;
|
|
995
|
+
}, St = (e, t, a) => {
|
|
996
|
+
const n = new a("html_inline", "", 0);
|
|
997
|
+
return n.content = '<label class="task-list-item-label" for="' + t + '">' + e + "</label>", n.attrs = [["for", t]], n;
|
|
998
|
+
}, It = (e, t, a) => {
|
|
999
|
+
const n = new t("html_inline", "", 0), o = a.enabled ? " " : ' disabled="" ';
|
|
1000
|
+
return e.content.indexOf("[ ] ") === 0 ? n.content = '<input class="task-list-item-checkbox"' + o + 'type="checkbox">' : (e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0) && (n.content = '<input class="task-list-item-checkbox" checked=""' + o + 'type="checkbox">'), n;
|
|
1001
|
+
}, At = (e, t, a) => {
|
|
1002
|
+
if (e.children = e.children || [], e.children.unshift(It(e, t, a)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), a.label)
|
|
1003
|
+
if (a.labelAfter) {
|
|
1004
|
+
e.children.pop();
|
|
1005
|
+
const n = "task-item-" + Math.ceil(Math.random() * (1e4 * 1e3) - 1e3);
|
|
1006
|
+
e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + n + '">', e.children.push(St(e.content, n, t));
|
|
1007
|
+
} else
|
|
1008
|
+
e.children.unshift(xt(t)), e.children.push(Tt(t));
|
|
1009
|
+
}, Ft = (e, t = {}) => {
|
|
1010
|
+
e.core.ruler.after("inline", "github-task-lists", (a) => {
|
|
1011
|
+
const n = a.tokens;
|
|
1012
|
+
for (let o = 2; o < n.length; o++)
|
|
1013
|
+
Et(n, o) && (At(n[o], a.Token, t), we(
|
|
1014
|
+
n[o - 2],
|
|
1015
|
+
"class",
|
|
1016
|
+
"task-list-item" + (t.enabled ? " enabled" : " ")
|
|
1017
|
+
), we(n[kt(n, o - 2)], "class", "contains-task-list"));
|
|
1018
|
+
});
|
|
1019
|
+
}, Rt = (e) => {
|
|
1020
|
+
e.core.ruler.push("init-line-number", (t) => (t.tokens.forEach((a) => {
|
|
1021
|
+
a.map && (a.attrs || (a.attrs = []), a.attrs.push(["data-line", a.map[0].toString()]));
|
|
1022
|
+
}), !0));
|
|
1023
|
+
}, Ht = (e, t) => {
|
|
1024
|
+
const { editorConfig: a, markdownItConfig: n, markdownItPlugins: o, editorExtensions: m } = L, c = C("editorId"), u = C("language"), s = C(
|
|
1025
|
+
"usedLanguageText"
|
|
1026
|
+
), l = C("showCodeRowNumber"), i = C("theme"), r = C("customIcon"), d = C("rootRef"), f = C("setting"), g = z([]), v = lt(e), p = it(e), { reRenderRef: T, replaceMermaid: b } = ct(e), { reRenderEcharts: $, replaceEcharts: S } = rt(e), w = Xe({
|
|
1027
|
+
html: !0,
|
|
1028
|
+
breaks: !0,
|
|
1029
|
+
linkify: !0
|
|
1030
|
+
});
|
|
1031
|
+
n(w, {
|
|
1032
|
+
editorId: c
|
|
1033
|
+
});
|
|
1034
|
+
const I = [
|
|
1035
|
+
{
|
|
1036
|
+
type: "image",
|
|
1037
|
+
plugin: Ye,
|
|
1038
|
+
options: { figcaption: !0, classes: "md-zoom" }
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
type: "admonition",
|
|
1042
|
+
plugin: dt,
|
|
1043
|
+
options: {}
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
type: "taskList",
|
|
1047
|
+
plugin: Ft,
|
|
1048
|
+
options: {}
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
type: "heading",
|
|
1052
|
+
plugin: ht,
|
|
1053
|
+
options: { mdHeadingId: e.mdHeadingId, headsRef: g }
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
type: "code",
|
|
1057
|
+
plugin: mt,
|
|
1058
|
+
options: {
|
|
1059
|
+
editorId: c,
|
|
1060
|
+
usedLanguageTextRef: s,
|
|
1061
|
+
// showCodeRowNumber,
|
|
1062
|
+
codeFoldable: e.codeFoldable,
|
|
1063
|
+
autoFoldThreshold: e.autoFoldThreshold,
|
|
1064
|
+
customIconRef: r
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
type: "sub",
|
|
1069
|
+
plugin: Qe,
|
|
1070
|
+
options: {}
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
type: "sup",
|
|
1074
|
+
plugin: et,
|
|
1075
|
+
options: {}
|
|
156
1076
|
}
|
|
157
1077
|
];
|
|
158
|
-
|
|
159
|
-
|
|
1078
|
+
e.noKatex || I.push({
|
|
1079
|
+
type: "katex",
|
|
1080
|
+
plugin: vt,
|
|
1081
|
+
options: { katexRef: p }
|
|
1082
|
+
}), e.noMermaid || I.push({
|
|
1083
|
+
type: "mermaid",
|
|
1084
|
+
plugin: yt,
|
|
1085
|
+
options: { themeRef: i }
|
|
1086
|
+
}), e.noEcharts || I.push({
|
|
1087
|
+
type: "echarts",
|
|
1088
|
+
plugin: ft,
|
|
1089
|
+
options: { themeRef: i }
|
|
1090
|
+
}), o(I, {
|
|
1091
|
+
editorId: c
|
|
1092
|
+
}).forEach((H) => {
|
|
1093
|
+
w.use(H.plugin, H.options);
|
|
1094
|
+
});
|
|
1095
|
+
const k = w.options.highlight;
|
|
1096
|
+
w.set({
|
|
1097
|
+
highlight: (H, D, oe) => {
|
|
1098
|
+
if (k) {
|
|
1099
|
+
const U = k(H, D, oe);
|
|
1100
|
+
if (U)
|
|
1101
|
+
return U;
|
|
1102
|
+
}
|
|
1103
|
+
let A;
|
|
1104
|
+
!e.noHighlight && v.value ? v.value.getLanguage(D) ? A = v.value.highlight(H, {
|
|
1105
|
+
language: D,
|
|
1106
|
+
ignoreIllegals: !0
|
|
1107
|
+
}).value : A = v.value.highlightAuto(H).value : A = w.utils.escapeHtml(H);
|
|
1108
|
+
const _ = w.utils.escapeHtml(D), J = l ? tt(
|
|
1109
|
+
A.replace(/^\n+|\n+$/g, ""),
|
|
1110
|
+
H.replace(/^\n+|\n+$/g, "")
|
|
1111
|
+
) : `<span class="${h}-code-block">${A.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
1112
|
+
return `<pre><code class="language-${_}" language="${_}">${J}</code></pre>`;
|
|
1113
|
+
}
|
|
1114
|
+
}), Rt(w);
|
|
1115
|
+
const R = z(`_article-key_${ie()}`), B = z(
|
|
1116
|
+
e.sanitize(
|
|
1117
|
+
w.render(e.modelValue, {
|
|
1118
|
+
srcLines: e.modelValue.split(`
|
|
1119
|
+
`)
|
|
1120
|
+
})
|
|
1121
|
+
)
|
|
1122
|
+
);
|
|
1123
|
+
let V = () => {
|
|
1124
|
+
}, j = () => {
|
|
1125
|
+
};
|
|
1126
|
+
const q = () => {
|
|
1127
|
+
const H = d.value?.querySelectorAll(
|
|
1128
|
+
`#${c} p.${h}-mermaid:not([data-closed=false])`
|
|
1129
|
+
);
|
|
1130
|
+
j(), j = Ke(H, {
|
|
1131
|
+
customIcon: r.value
|
|
1132
|
+
}), m.mermaid?.enableZoom && (V(), V = Ze(H, {
|
|
1133
|
+
customIcon: r.value
|
|
1134
|
+
}));
|
|
1135
|
+
}, K = () => {
|
|
1136
|
+
y.emit(c, X, B.value), e.onHtmlChanged(B.value), e.onGetCatalog(g.value), y.emit(c, ae, g.value), W(() => {
|
|
1137
|
+
b().then(q), S();
|
|
1138
|
+
});
|
|
1139
|
+
}, Z = () => {
|
|
1140
|
+
g.value = [], B.value = e.sanitize(
|
|
1141
|
+
w.render(e.modelValue, {
|
|
1142
|
+
srcLines: e.modelValue.split(`
|
|
1143
|
+
`)
|
|
1144
|
+
})
|
|
1145
|
+
);
|
|
1146
|
+
}, ne = F(() => (e.noKatex || !!p.value) && (e.noHighlight || !!v.value));
|
|
1147
|
+
let G = -1;
|
|
1148
|
+
return E([Me(e, "modelValue"), ne, T, u], () => {
|
|
1149
|
+
G = window.setTimeout(
|
|
1150
|
+
() => {
|
|
1151
|
+
Z();
|
|
1152
|
+
},
|
|
1153
|
+
t ? 0 : a.renderDelay
|
|
1154
|
+
);
|
|
1155
|
+
}), E(
|
|
1156
|
+
() => f.value.preview,
|
|
1157
|
+
() => {
|
|
1158
|
+
f.value.preview && W(() => {
|
|
1159
|
+
b().then(q), S(), y.emit(c, ae, g.value);
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
), E([B, $], () => {
|
|
1163
|
+
K();
|
|
1164
|
+
}), M(K), M(() => {
|
|
1165
|
+
y.on(c, {
|
|
1166
|
+
name: Ue,
|
|
1167
|
+
callback() {
|
|
1168
|
+
y.emit(c, ae, g.value);
|
|
1169
|
+
}
|
|
1170
|
+
}), y.on(c, {
|
|
1171
|
+
name: ue,
|
|
1172
|
+
callback: () => {
|
|
1173
|
+
R.value = `_article-key_${ie()}`, Z();
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
}), te(() => {
|
|
1177
|
+
V(), j(), clearTimeout(G);
|
|
1178
|
+
}), { html: B, key: R };
|
|
1179
|
+
}, Mt = (e, t) => {
|
|
1180
|
+
const a = C("editorId"), n = C("setting"), { noImgZoomIn: o } = e, m = Be(() => {
|
|
1181
|
+
const c = document.querySelectorAll(
|
|
1182
|
+
`#${a}-preview img:not(.not-zoom):not(.medium-zoom-image)`
|
|
1183
|
+
);
|
|
1184
|
+
c.length !== 0 && nt(c, {
|
|
1185
|
+
background: "#00000073"
|
|
1186
|
+
});
|
|
1187
|
+
});
|
|
1188
|
+
M(async () => {
|
|
1189
|
+
!o && n.value.preview && await m();
|
|
1190
|
+
}), E([t, () => n.value.preview], async () => {
|
|
1191
|
+
!o && n.value.preview && await m();
|
|
1192
|
+
});
|
|
1193
|
+
}, Ce = {
|
|
1194
|
+
checked: {
|
|
1195
|
+
regexp: /- \[x\]/,
|
|
1196
|
+
value: "- [ ]"
|
|
1197
|
+
},
|
|
1198
|
+
unChecked: {
|
|
1199
|
+
regexp: /- \[\s\]/,
|
|
1200
|
+
value: "- [x]"
|
|
1201
|
+
}
|
|
1202
|
+
}, Pt = (e, t) => {
|
|
1203
|
+
const a = C("editorId"), n = C("rootRef");
|
|
1204
|
+
let o = () => {
|
|
1205
|
+
};
|
|
1206
|
+
const m = () => {
|
|
1207
|
+
if (!n.value)
|
|
1208
|
+
return !1;
|
|
1209
|
+
const c = n.value.querySelectorAll(".task-list-item.enabled"), u = (s) => {
|
|
1210
|
+
s.preventDefault();
|
|
1211
|
+
const l = s.target.checked ? "unChecked" : "checked", i = s.target.parentElement?.dataset.line;
|
|
1212
|
+
if (!i)
|
|
1213
|
+
return;
|
|
1214
|
+
const r = Number(i), d = e.modelValue.split(`
|
|
1215
|
+
`), f = d[Number(r)].replace(
|
|
1216
|
+
Ce[l].regexp,
|
|
1217
|
+
Ce[l].value
|
|
1218
|
+
);
|
|
1219
|
+
e.previewOnly ? (d[Number(r)] = f, e.onChange(d.join(`
|
|
1220
|
+
`))) : y.emit(a, ze, r + 1, f);
|
|
1221
|
+
};
|
|
1222
|
+
c.forEach((s) => {
|
|
1223
|
+
s.addEventListener("click", u);
|
|
1224
|
+
}), o = () => {
|
|
1225
|
+
c.forEach((s) => {
|
|
1226
|
+
s.removeEventListener("click", u);
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
};
|
|
1230
|
+
te(() => {
|
|
1231
|
+
o();
|
|
1232
|
+
}), E(
|
|
1233
|
+
[t],
|
|
1234
|
+
() => {
|
|
1235
|
+
o(), W(m);
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
immediate: !0
|
|
1239
|
+
}
|
|
1240
|
+
);
|
|
1241
|
+
}, Lt = (e, t, a) => {
|
|
1242
|
+
const n = C("setting"), o = () => {
|
|
1243
|
+
W(() => {
|
|
1244
|
+
e.onRemount?.();
|
|
1245
|
+
});
|
|
1246
|
+
}, m = (c) => {
|
|
1247
|
+
c && o();
|
|
1248
|
+
};
|
|
1249
|
+
E([t, a], o), E(() => n.value.preview, m), E(() => n.value.htmlPreview, m), M(o);
|
|
1250
|
+
}, Se = {
|
|
1251
|
+
modelValue: {
|
|
1252
|
+
type: String,
|
|
1253
|
+
default: ""
|
|
1254
|
+
},
|
|
1255
|
+
onChange: {
|
|
1256
|
+
type: Function,
|
|
1257
|
+
default: () => {
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
onHtmlChanged: {
|
|
1261
|
+
type: Function,
|
|
1262
|
+
default: () => {
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
onGetCatalog: {
|
|
1266
|
+
type: Function,
|
|
1267
|
+
default: () => {
|
|
1268
|
+
}
|
|
1269
|
+
},
|
|
1270
|
+
mdHeadingId: {
|
|
1271
|
+
type: Function,
|
|
1272
|
+
default: () => ""
|
|
1273
|
+
},
|
|
1274
|
+
noMermaid: {
|
|
1275
|
+
type: Boolean,
|
|
1276
|
+
default: !1
|
|
1277
|
+
},
|
|
1278
|
+
sanitize: {
|
|
1279
|
+
type: Function,
|
|
1280
|
+
default: (e) => e
|
|
1281
|
+
},
|
|
1282
|
+
// 不使用该函数功能
|
|
1283
|
+
noKatex: {
|
|
1284
|
+
type: Boolean,
|
|
1285
|
+
default: !1
|
|
1286
|
+
},
|
|
1287
|
+
formatCopiedText: {
|
|
1288
|
+
type: Function,
|
|
1289
|
+
default: (e) => e
|
|
1290
|
+
},
|
|
1291
|
+
noHighlight: {
|
|
1292
|
+
type: Boolean,
|
|
1293
|
+
default: !1
|
|
1294
|
+
},
|
|
1295
|
+
previewOnly: {
|
|
1296
|
+
type: Boolean,
|
|
1297
|
+
default: !1
|
|
1298
|
+
},
|
|
1299
|
+
noImgZoomIn: {
|
|
1300
|
+
type: Boolean
|
|
1301
|
+
},
|
|
1302
|
+
sanitizeMermaid: {
|
|
1303
|
+
type: Function
|
|
1304
|
+
},
|
|
1305
|
+
codeFoldable: {
|
|
1306
|
+
type: Boolean
|
|
1307
|
+
},
|
|
1308
|
+
autoFoldThreshold: {
|
|
1309
|
+
type: Number
|
|
1310
|
+
},
|
|
1311
|
+
onRemount: {
|
|
1312
|
+
type: Function
|
|
1313
|
+
},
|
|
1314
|
+
noEcharts: {
|
|
1315
|
+
type: Boolean
|
|
1316
|
+
},
|
|
1317
|
+
previewComponent: {
|
|
1318
|
+
type: [Object, Function],
|
|
1319
|
+
default: void 0
|
|
1320
|
+
}
|
|
1321
|
+
}, ln = {
|
|
1322
|
+
...Se,
|
|
1323
|
+
updateModelValue: {
|
|
1324
|
+
type: Function,
|
|
1325
|
+
default: () => {
|
|
1326
|
+
}
|
|
1327
|
+
},
|
|
1328
|
+
placeholder: {
|
|
1329
|
+
type: String,
|
|
1330
|
+
default: ""
|
|
1331
|
+
},
|
|
1332
|
+
scrollAuto: {
|
|
1333
|
+
type: Boolean
|
|
1334
|
+
},
|
|
1335
|
+
autofocus: {
|
|
1336
|
+
type: Boolean
|
|
1337
|
+
},
|
|
1338
|
+
readonly: {
|
|
1339
|
+
type: Boolean
|
|
1340
|
+
},
|
|
1341
|
+
maxlength: {
|
|
1342
|
+
type: Number
|
|
1343
|
+
},
|
|
1344
|
+
autoDetectCode: {
|
|
1345
|
+
type: Boolean
|
|
1346
|
+
},
|
|
1347
|
+
/**
|
|
1348
|
+
* 输入框失去焦点时触发事件
|
|
1349
|
+
*/
|
|
1350
|
+
onBlur: {
|
|
1351
|
+
type: Function,
|
|
1352
|
+
default: () => {
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
/**
|
|
1356
|
+
* 输入框获得焦点时触发事件
|
|
1357
|
+
*/
|
|
1358
|
+
onFocus: {
|
|
1359
|
+
type: Function,
|
|
1360
|
+
default: () => {
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
completions: {
|
|
1364
|
+
type: Array
|
|
1365
|
+
},
|
|
1366
|
+
onInput: {
|
|
1367
|
+
type: Function
|
|
1368
|
+
},
|
|
1369
|
+
onDrop: {
|
|
1370
|
+
type: Function,
|
|
1371
|
+
default: () => {
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1374
|
+
inputBoxWidth: {
|
|
1375
|
+
type: String
|
|
1376
|
+
},
|
|
1377
|
+
oninputBoxWidthChange: {
|
|
1378
|
+
type: Function
|
|
1379
|
+
},
|
|
1380
|
+
transformImgUrl: {
|
|
1381
|
+
type: Function,
|
|
1382
|
+
default: (e) => e
|
|
1383
|
+
},
|
|
1384
|
+
catalogLayout: {
|
|
1385
|
+
type: String
|
|
1386
|
+
},
|
|
1387
|
+
catalogMaxDepth: {
|
|
1388
|
+
type: Number
|
|
1389
|
+
}
|
|
1390
|
+
}, Ee = (e) => {
|
|
1391
|
+
const a = new DOMParser().parseFromString(e, "text/html");
|
|
1392
|
+
return Array.from(a.body.childNodes);
|
|
1393
|
+
}, _t = (e, t) => e.nodeType !== t.nodeType ? !1 : e.nodeType === Node.TEXT_NODE || e.nodeType === Node.COMMENT_NODE ? e.textContent === t.textContent : e.nodeType === Node.ELEMENT_NODE ? e.outerHTML === t.outerHTML : e.isEqualNode ? e.isEqualNode(t) : !1, Ot = /* @__PURE__ */ de({
|
|
1394
|
+
name: "UpdateOnDemand",
|
|
1395
|
+
props: {
|
|
1396
|
+
id: {
|
|
1397
|
+
type: String,
|
|
1398
|
+
required: !0
|
|
1399
|
+
},
|
|
1400
|
+
class: {
|
|
1401
|
+
type: [String, Array, Object],
|
|
1402
|
+
required: !0
|
|
1403
|
+
},
|
|
1404
|
+
html: {
|
|
1405
|
+
type: String,
|
|
1406
|
+
required: !0
|
|
1407
|
+
}
|
|
1408
|
+
},
|
|
1409
|
+
setup(e) {
|
|
1410
|
+
const t = z(), a = e.html, n = (o, m) => {
|
|
1411
|
+
if (!t.value) return;
|
|
1412
|
+
const c = t.value, u = Array.from(c.childNodes), s = Math.min(o.length, m.length);
|
|
1413
|
+
let l = -1;
|
|
1414
|
+
for (let r = 0; r < s; r++)
|
|
1415
|
+
if (!_t(o[r], m[r])) {
|
|
1416
|
+
l = r;
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
if (l === -1)
|
|
1420
|
+
if (m.length > o.length)
|
|
1421
|
+
l = o.length;
|
|
1422
|
+
else if (o.length > m.length)
|
|
1423
|
+
l = m.length;
|
|
1424
|
+
else
|
|
1425
|
+
return;
|
|
1426
|
+
const i = Math.min(l, u.length);
|
|
1427
|
+
for (let r = u.length - 1; r >= i; r--)
|
|
1428
|
+
u[r].remove();
|
|
1429
|
+
for (let r = l; r < o.length; r++)
|
|
1430
|
+
c.appendChild(o[r].cloneNode(!0));
|
|
1431
|
+
};
|
|
1432
|
+
return E(() => e.html, (o, m) => {
|
|
1433
|
+
const c = Ee(o), u = Ee(m || "");
|
|
1434
|
+
n(c, u);
|
|
1435
|
+
}), () => N("div", {
|
|
1436
|
+
id: e.id,
|
|
1437
|
+
class: e.class,
|
|
1438
|
+
innerHTML: a,
|
|
1439
|
+
ref: t
|
|
1440
|
+
}, null);
|
|
1441
|
+
}
|
|
1442
|
+
}), Bt = /* @__PURE__ */ de({
|
|
1443
|
+
name: "ContentPreview",
|
|
1444
|
+
props: Se,
|
|
1445
|
+
setup(e) {
|
|
1446
|
+
const t = C("editorId"), a = C("setting"), n = C("previewTheme"), o = C("showCodeRowNumber"), {
|
|
1447
|
+
html: m,
|
|
1448
|
+
key: c
|
|
1449
|
+
} = Ht(e, e.previewOnly);
|
|
1450
|
+
at(e, m, c), Mt(e, m), Pt(e, m), Lt(e, m, c);
|
|
1451
|
+
const u = F(() => [`${h}-preview`, `${n?.value}-theme`, o && `${h}-scrn`].filter(Boolean)), s = () => {
|
|
1452
|
+
const l = `${t}-preview`;
|
|
1453
|
+
return e.previewComponent ? Le(e.previewComponent, {
|
|
1454
|
+
key: c.value,
|
|
1455
|
+
html: m.value,
|
|
1456
|
+
id: l,
|
|
1457
|
+
class: u.value
|
|
1458
|
+
}) : N(Ot, {
|
|
1459
|
+
key: c.value,
|
|
1460
|
+
html: m.value,
|
|
1461
|
+
id: l,
|
|
1462
|
+
class: u.value
|
|
1463
|
+
}, null);
|
|
1464
|
+
};
|
|
1465
|
+
return () => N(Pe, null, [a.value.preview && (e.previewOnly ? s() : N("div", {
|
|
1466
|
+
id: `${t}-preview-wrapper`,
|
|
1467
|
+
class: `${h}-preview-wrapper`,
|
|
1468
|
+
key: "content-preview-wrapper"
|
|
1469
|
+
}, [s()])), a.value.htmlPreview && N("div", {
|
|
1470
|
+
id: `${t}-html-wrapper`,
|
|
1471
|
+
class: `${h}-preview-wrapper`,
|
|
1472
|
+
key: "html-preview-wrapper"
|
|
1473
|
+
}, [N("div", {
|
|
1474
|
+
class: `${h}-html`
|
|
1475
|
+
}, [m.value])])]);
|
|
1476
|
+
}
|
|
1477
|
+
}), jt = ({ text: e }) => e, Ie = {
|
|
1478
|
+
/**
|
|
1479
|
+
* markdown content.
|
|
1480
|
+
*
|
|
1481
|
+
* @default ''
|
|
1482
|
+
*/
|
|
1483
|
+
modelValue: {
|
|
1484
|
+
type: String,
|
|
1485
|
+
default: ""
|
|
1486
|
+
},
|
|
1487
|
+
/**
|
|
1488
|
+
* input回调事件
|
|
1489
|
+
*/
|
|
1490
|
+
onChange: {
|
|
1491
|
+
type: Function,
|
|
1492
|
+
default: void 0
|
|
1493
|
+
},
|
|
1494
|
+
/**
|
|
1495
|
+
* 主题,支持light和dark
|
|
1496
|
+
*
|
|
1497
|
+
* @default 'light'
|
|
1498
|
+
*/
|
|
1499
|
+
theme: {
|
|
1500
|
+
type: String,
|
|
1501
|
+
default: "light"
|
|
1502
|
+
},
|
|
1503
|
+
/**
|
|
1504
|
+
* 外层类名
|
|
1505
|
+
*
|
|
1506
|
+
* @default ''
|
|
1507
|
+
*/
|
|
1508
|
+
class: {
|
|
1509
|
+
type: String,
|
|
1510
|
+
default: ""
|
|
1511
|
+
},
|
|
1512
|
+
/**
|
|
1513
|
+
* 预设语言名称
|
|
1514
|
+
*
|
|
1515
|
+
* @default 'zh-CN'
|
|
1516
|
+
*/
|
|
1517
|
+
language: {
|
|
1518
|
+
type: String,
|
|
1519
|
+
default: "zh-CN"
|
|
1520
|
+
},
|
|
1521
|
+
/**
|
|
1522
|
+
* html变化事件
|
|
1523
|
+
*/
|
|
1524
|
+
onHtmlChanged: {
|
|
1525
|
+
type: Function,
|
|
1526
|
+
default: void 0
|
|
1527
|
+
},
|
|
1528
|
+
/**
|
|
1529
|
+
* 获取目录结构
|
|
1530
|
+
*/
|
|
1531
|
+
onGetCatalog: {
|
|
1532
|
+
type: Function,
|
|
1533
|
+
default: void 0
|
|
1534
|
+
},
|
|
1535
|
+
/**
|
|
1536
|
+
* 编辑器唯一标识
|
|
1537
|
+
*
|
|
1538
|
+
* @default 'md-editor-v3'
|
|
1539
|
+
* @deprecated 5.x版本开始使用 id 替换
|
|
1540
|
+
*/
|
|
1541
|
+
editorId: {
|
|
1542
|
+
type: String,
|
|
1543
|
+
default: void 0
|
|
1544
|
+
},
|
|
1545
|
+
/**
|
|
1546
|
+
* 5.x版本开始 editorId 的替换
|
|
1547
|
+
*
|
|
1548
|
+
* @default 'md-editor-v3'
|
|
1549
|
+
*/
|
|
1550
|
+
id: {
|
|
1551
|
+
type: String,
|
|
1552
|
+
default: void 0
|
|
1553
|
+
},
|
|
1554
|
+
/**
|
|
1555
|
+
* 预览中代码是否显示行号
|
|
1556
|
+
*
|
|
1557
|
+
* @default true
|
|
1558
|
+
*/
|
|
1559
|
+
showCodeRowNumber: {
|
|
1560
|
+
type: Boolean,
|
|
1561
|
+
default: !0
|
|
1562
|
+
},
|
|
1563
|
+
/**
|
|
1564
|
+
* 预览内容样式
|
|
1565
|
+
*
|
|
1566
|
+
* @default 'default'
|
|
1567
|
+
*/
|
|
1568
|
+
previewTheme: {
|
|
1569
|
+
type: String,
|
|
1570
|
+
default: "default"
|
|
1571
|
+
},
|
|
1572
|
+
/**
|
|
1573
|
+
* 编辑器样式
|
|
1574
|
+
*/
|
|
1575
|
+
style: {
|
|
160
1576
|
type: Object,
|
|
161
1577
|
default: () => ({})
|
|
162
1578
|
},
|
|
1579
|
+
/**
|
|
1580
|
+
* 标题的id生成方式
|
|
1581
|
+
*
|
|
1582
|
+
* @default (text: string) => text
|
|
1583
|
+
*/
|
|
163
1584
|
mdHeadingId: {
|
|
164
1585
|
type: Function,
|
|
165
|
-
default:
|
|
166
|
-
}
|
|
1586
|
+
default: jt
|
|
167
1587
|
},
|
|
168
|
-
|
|
1588
|
+
/**
|
|
1589
|
+
*
|
|
1590
|
+
* 不能保证文本正确的情况,在marked编译md文本后通过该方法处理
|
|
1591
|
+
* 推荐DOMPurify、sanitize-html
|
|
1592
|
+
*
|
|
1593
|
+
* @default (text: string) => text
|
|
1594
|
+
*/
|
|
1595
|
+
sanitize: {
|
|
169
1596
|
type: Function,
|
|
170
|
-
default: () =>
|
|
171
|
-
|
|
1597
|
+
default: (e) => e
|
|
1598
|
+
},
|
|
1599
|
+
/**
|
|
1600
|
+
* 不使用该mermaid
|
|
1601
|
+
*
|
|
1602
|
+
* @default false
|
|
1603
|
+
*/
|
|
1604
|
+
noMermaid: {
|
|
1605
|
+
type: Boolean,
|
|
1606
|
+
default: !1
|
|
1607
|
+
},
|
|
1608
|
+
/**
|
|
1609
|
+
* 不使用katex
|
|
1610
|
+
*
|
|
1611
|
+
* @default false
|
|
1612
|
+
*/
|
|
1613
|
+
noKatex: {
|
|
1614
|
+
type: Boolean,
|
|
1615
|
+
default: !1
|
|
1616
|
+
},
|
|
1617
|
+
/**
|
|
1618
|
+
* 代码主题
|
|
1619
|
+
*
|
|
1620
|
+
* @default 'atom'
|
|
1621
|
+
*/
|
|
1622
|
+
codeTheme: {
|
|
1623
|
+
type: String,
|
|
1624
|
+
default: "atom"
|
|
172
1625
|
},
|
|
173
|
-
|
|
1626
|
+
/**
|
|
1627
|
+
* 复制代码格式化方法
|
|
1628
|
+
*
|
|
1629
|
+
* @default (text) => text
|
|
1630
|
+
*/
|
|
1631
|
+
formatCopiedText: {
|
|
174
1632
|
type: Function,
|
|
175
|
-
default: () =>
|
|
176
|
-
|
|
1633
|
+
default: (e) => e
|
|
1634
|
+
},
|
|
1635
|
+
/**
|
|
1636
|
+
* 某些预览主题的代码模块背景是暗色系
|
|
1637
|
+
* 将这个属性设置为true,会自动在该主题下的light模式下使用暗色系的代码风格
|
|
1638
|
+
*
|
|
1639
|
+
* @default true
|
|
1640
|
+
*/
|
|
1641
|
+
codeStyleReverse: {
|
|
1642
|
+
type: Boolean,
|
|
1643
|
+
default: !0
|
|
1644
|
+
},
|
|
1645
|
+
/**
|
|
1646
|
+
* 需要自动调整的预览主题
|
|
1647
|
+
*
|
|
1648
|
+
* @default ['default', 'mk-cute']
|
|
1649
|
+
*/
|
|
1650
|
+
codeStyleReverseList: {
|
|
1651
|
+
type: Array,
|
|
1652
|
+
default: ["default", "mk-cute"]
|
|
1653
|
+
},
|
|
1654
|
+
noHighlight: {
|
|
1655
|
+
type: Boolean,
|
|
1656
|
+
default: !1
|
|
1657
|
+
},
|
|
1658
|
+
/**
|
|
1659
|
+
* 是否关闭编辑器默认的放大缩小功能
|
|
1660
|
+
*/
|
|
1661
|
+
noImgZoomIn: {
|
|
1662
|
+
type: Boolean,
|
|
1663
|
+
default: !1
|
|
1664
|
+
},
|
|
1665
|
+
/**
|
|
1666
|
+
* 自定义的图标
|
|
1667
|
+
*/
|
|
1668
|
+
customIcon: {
|
|
1669
|
+
type: Object,
|
|
1670
|
+
default: {}
|
|
1671
|
+
},
|
|
1672
|
+
sanitizeMermaid: {
|
|
1673
|
+
type: Function,
|
|
1674
|
+
default: (e) => Promise.resolve(e)
|
|
1675
|
+
},
|
|
1676
|
+
/**
|
|
1677
|
+
* 是否开启折叠代码功能
|
|
1678
|
+
* 不开启会使用div标签替代details标签
|
|
1679
|
+
*
|
|
1680
|
+
* @default true
|
|
1681
|
+
*/
|
|
1682
|
+
codeFoldable: {
|
|
1683
|
+
type: Boolean,
|
|
1684
|
+
default: !0
|
|
177
1685
|
},
|
|
178
|
-
|
|
1686
|
+
/**
|
|
1687
|
+
* 触发自动折叠代码的行数阈值
|
|
1688
|
+
*
|
|
1689
|
+
* @default 30
|
|
1690
|
+
*/
|
|
1691
|
+
autoFoldThreshold: {
|
|
179
1692
|
type: Number,
|
|
180
|
-
default:
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (f && s) {
|
|
202
|
-
let r = f.offsetParent, L = f.offsetTop;
|
|
203
|
-
if (s.contains(r))
|
|
204
|
-
for (; r && s != r; )
|
|
205
|
-
L += r?.offsetTop, r = r?.offsetParent;
|
|
206
|
-
const R = f.previousElementSibling;
|
|
207
|
-
let x = 0;
|
|
208
|
-
R || (x = w(f, "margin-block-start")), s?.scrollTo({
|
|
209
|
-
top: L - e.scrollElementOffsetTop - x,
|
|
210
|
-
behavior: "smooth"
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
return () => N("div", {
|
|
215
|
-
ref: o,
|
|
216
|
-
class: [`${O}-catalog-link`, e.tocItem.active && `${O}-catalog-active`],
|
|
217
|
-
onClick: E
|
|
218
|
-
}, [N("span", {
|
|
219
|
-
title: e.tocItem.text
|
|
220
|
-
}, [e.tocItem.text]), e.tocItem.children && e.tocItem.children.length > 0 && N("div", {
|
|
221
|
-
class: `${O}-catalog-wrapper`
|
|
222
|
-
}, [e.tocItem.children.map((m) => N(Q, {
|
|
223
|
-
mdHeadingId: e.mdHeadingId,
|
|
224
|
-
key: `${e.tocItem.text}-link-${m.level}-${m.text}`,
|
|
225
|
-
tocItem: m,
|
|
226
|
-
onActive: e.onActive,
|
|
227
|
-
onClick: e.onClick,
|
|
228
|
-
scrollElementOffsetTop: e.scrollElementOffsetTop
|
|
229
|
-
}, null))])]);
|
|
1693
|
+
default: 30
|
|
1694
|
+
},
|
|
1695
|
+
/**
|
|
1696
|
+
* 内容重新挂载事件
|
|
1697
|
+
*
|
|
1698
|
+
* 相比起onHtmlChanged,onRemount会在重新挂载后触发
|
|
1699
|
+
*/
|
|
1700
|
+
onRemount: {
|
|
1701
|
+
type: Function,
|
|
1702
|
+
default: void 0
|
|
1703
|
+
},
|
|
1704
|
+
/**
|
|
1705
|
+
* 不使用 echarts
|
|
1706
|
+
*/
|
|
1707
|
+
noEcharts: {
|
|
1708
|
+
type: Boolean,
|
|
1709
|
+
default: !1
|
|
1710
|
+
},
|
|
1711
|
+
previewComponent: {
|
|
1712
|
+
type: [Object, Function],
|
|
1713
|
+
default: void 0
|
|
230
1714
|
}
|
|
231
|
-
}
|
|
1715
|
+
}, sn = {
|
|
1716
|
+
...Ie,
|
|
232
1717
|
/**
|
|
233
|
-
*
|
|
1718
|
+
* input回调事件
|
|
234
1719
|
*/
|
|
235
|
-
|
|
236
|
-
type:
|
|
1720
|
+
onSave: {
|
|
1721
|
+
type: Function,
|
|
237
1722
|
default: void 0
|
|
238
1723
|
},
|
|
239
|
-
|
|
1724
|
+
/**
|
|
1725
|
+
* 上传图片事件
|
|
1726
|
+
*/
|
|
1727
|
+
onUploadImg: {
|
|
1728
|
+
type: Function,
|
|
1729
|
+
default: void 0
|
|
1730
|
+
},
|
|
1731
|
+
/**
|
|
1732
|
+
* 是否页面内全屏
|
|
1733
|
+
*
|
|
1734
|
+
* @default false
|
|
1735
|
+
*/
|
|
1736
|
+
pageFullscreen: {
|
|
1737
|
+
type: Boolean,
|
|
1738
|
+
default: !1
|
|
1739
|
+
},
|
|
1740
|
+
/**
|
|
1741
|
+
* 是否展开预览
|
|
1742
|
+
*
|
|
1743
|
+
* @default true
|
|
1744
|
+
*/
|
|
1745
|
+
preview: {
|
|
1746
|
+
type: Boolean,
|
|
1747
|
+
default: !0
|
|
1748
|
+
},
|
|
1749
|
+
/**
|
|
1750
|
+
* 是否展开html预览
|
|
1751
|
+
*
|
|
1752
|
+
* @default false
|
|
1753
|
+
*/
|
|
1754
|
+
htmlPreview: {
|
|
1755
|
+
type: Boolean,
|
|
1756
|
+
default: !1
|
|
1757
|
+
},
|
|
1758
|
+
/**
|
|
1759
|
+
* 仅预览模式,不显示toolbar和编辑框
|
|
1760
|
+
*
|
|
1761
|
+
* @4.0.0开始移除该设置,使用组件MdPreview替换
|
|
1762
|
+
*
|
|
1763
|
+
* @default false
|
|
1764
|
+
*/
|
|
1765
|
+
// previewOnly: {
|
|
1766
|
+
// type: Boolean as PropType<boolean>,
|
|
1767
|
+
// default: false
|
|
1768
|
+
// },
|
|
1769
|
+
/**
|
|
1770
|
+
* 工具栏选择显示
|
|
1771
|
+
*
|
|
1772
|
+
* @default allToolbar
|
|
1773
|
+
*/
|
|
1774
|
+
toolbars: {
|
|
1775
|
+
type: Array,
|
|
1776
|
+
default: Ne
|
|
1777
|
+
},
|
|
1778
|
+
/**
|
|
1779
|
+
* 浮动工具栏
|
|
1780
|
+
*
|
|
1781
|
+
* @version 6.0.0
|
|
1782
|
+
* @default []
|
|
1783
|
+
*/
|
|
1784
|
+
floatingToolbars: {
|
|
1785
|
+
type: Array,
|
|
1786
|
+
default: []
|
|
1787
|
+
},
|
|
1788
|
+
/**
|
|
1789
|
+
* 工具栏选择不显示
|
|
1790
|
+
*
|
|
1791
|
+
* @default []
|
|
1792
|
+
*/
|
|
1793
|
+
toolbarsExclude: {
|
|
1794
|
+
type: Array,
|
|
1795
|
+
default: []
|
|
1796
|
+
},
|
|
1797
|
+
/**
|
|
1798
|
+
* 格式化md
|
|
1799
|
+
*
|
|
1800
|
+
* @default true
|
|
1801
|
+
*/
|
|
1802
|
+
noPrettier: {
|
|
1803
|
+
type: Boolean,
|
|
1804
|
+
default: !1
|
|
1805
|
+
},
|
|
1806
|
+
/**
|
|
1807
|
+
* 一个tab等于空格数
|
|
1808
|
+
*
|
|
1809
|
+
* @default 2
|
|
1810
|
+
*/
|
|
1811
|
+
tabWidth: {
|
|
1812
|
+
type: Number,
|
|
1813
|
+
default: 2
|
|
1814
|
+
},
|
|
1815
|
+
/**
|
|
1816
|
+
* 表格预设格子数
|
|
1817
|
+
*
|
|
1818
|
+
* 也可以是[6, 4, 10, 8]
|
|
1819
|
+
*
|
|
1820
|
+
* @default [6, 4]
|
|
1821
|
+
*/
|
|
1822
|
+
tableShape: {
|
|
1823
|
+
type: Array,
|
|
1824
|
+
default: [6, 4]
|
|
1825
|
+
},
|
|
1826
|
+
/**
|
|
1827
|
+
* 空提示
|
|
1828
|
+
*
|
|
1829
|
+
* @default ''
|
|
1830
|
+
*/
|
|
1831
|
+
placeholder: {
|
|
240
1832
|
type: String,
|
|
241
1833
|
default: ""
|
|
242
1834
|
},
|
|
243
|
-
|
|
1835
|
+
/**
|
|
1836
|
+
* 自定义的工具栏列表
|
|
1837
|
+
*/
|
|
1838
|
+
defToolbars: {
|
|
1839
|
+
type: [String, Object],
|
|
1840
|
+
default: void 0
|
|
1841
|
+
},
|
|
1842
|
+
/**
|
|
1843
|
+
* 内部错误捕获
|
|
1844
|
+
*/
|
|
1845
|
+
onError: {
|
|
244
1846
|
type: Function,
|
|
245
|
-
default:
|
|
246
|
-
|
|
247
|
-
|
|
1847
|
+
default: void 0
|
|
1848
|
+
},
|
|
1849
|
+
/**
|
|
1850
|
+
* 页脚列表显示顺序
|
|
1851
|
+
*/
|
|
1852
|
+
footers: {
|
|
1853
|
+
type: Array,
|
|
1854
|
+
default: je
|
|
248
1855
|
},
|
|
249
1856
|
/**
|
|
250
|
-
*
|
|
251
|
-
* 元素必须定位!!!!!!
|
|
1857
|
+
* 是否默认激活输入框和预览框同步滚动
|
|
252
1858
|
*
|
|
253
|
-
*
|
|
1859
|
+
* @default true
|
|
1860
|
+
*/
|
|
1861
|
+
scrollAuto: {
|
|
1862
|
+
type: Boolean,
|
|
1863
|
+
default: !0
|
|
1864
|
+
},
|
|
1865
|
+
/**
|
|
1866
|
+
* 自定义的也叫工具组件列表
|
|
254
1867
|
*/
|
|
255
|
-
|
|
1868
|
+
defFooters: {
|
|
256
1869
|
type: [String, Object],
|
|
257
1870
|
default: void 0
|
|
258
1871
|
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
1872
|
+
/**
|
|
1873
|
+
* 是否禁用上传图片
|
|
1874
|
+
*
|
|
1875
|
+
* @default false
|
|
1876
|
+
*/
|
|
1877
|
+
noUploadImg: {
|
|
1878
|
+
type: Boolean,
|
|
1879
|
+
default: !1
|
|
262
1880
|
},
|
|
263
1881
|
/**
|
|
264
|
-
*
|
|
1882
|
+
* 文本区域自动获得焦点
|
|
265
1883
|
*
|
|
266
|
-
*
|
|
1884
|
+
* @default false
|
|
267
1885
|
*/
|
|
268
|
-
|
|
269
|
-
type:
|
|
270
|
-
default:
|
|
1886
|
+
autoFocus: {
|
|
1887
|
+
type: Boolean,
|
|
1888
|
+
default: !1
|
|
1889
|
+
},
|
|
1890
|
+
/**
|
|
1891
|
+
* 禁用文本区域
|
|
1892
|
+
*
|
|
1893
|
+
* @default false
|
|
1894
|
+
*/
|
|
1895
|
+
disabled: {
|
|
1896
|
+
type: Boolean,
|
|
1897
|
+
default: !1
|
|
271
1898
|
},
|
|
272
1899
|
/**
|
|
273
|
-
*
|
|
1900
|
+
* 文本区域为只读
|
|
274
1901
|
*
|
|
275
|
-
*
|
|
1902
|
+
* @default false
|
|
1903
|
+
*/
|
|
1904
|
+
readOnly: {
|
|
1905
|
+
type: Boolean,
|
|
1906
|
+
default: !1
|
|
1907
|
+
},
|
|
1908
|
+
/**
|
|
1909
|
+
* 文本区域允许的最大字符数
|
|
276
1910
|
*/
|
|
277
|
-
|
|
1911
|
+
maxLength: {
|
|
278
1912
|
type: Number,
|
|
279
|
-
default: 0
|
|
1913
|
+
default: void 0
|
|
1914
|
+
},
|
|
1915
|
+
/**
|
|
1916
|
+
* 是否启用自动识别粘贴代码类别
|
|
1917
|
+
* 目前支持 vscode 复制的代码识别
|
|
1918
|
+
*
|
|
1919
|
+
* @default false
|
|
1920
|
+
*/
|
|
1921
|
+
autoDetectCode: {
|
|
1922
|
+
type: Boolean,
|
|
1923
|
+
default: !1
|
|
280
1924
|
},
|
|
281
|
-
|
|
1925
|
+
/**
|
|
1926
|
+
* 输入框失去焦点时触发事件
|
|
1927
|
+
*/
|
|
1928
|
+
onBlur: {
|
|
282
1929
|
type: Function,
|
|
283
1930
|
default: void 0
|
|
284
1931
|
},
|
|
285
|
-
|
|
1932
|
+
/**
|
|
1933
|
+
* 输入框获得焦点时触发事件
|
|
1934
|
+
*/
|
|
1935
|
+
onFocus: {
|
|
286
1936
|
type: Function,
|
|
287
1937
|
default: void 0
|
|
288
1938
|
},
|
|
289
1939
|
/**
|
|
290
|
-
*
|
|
1940
|
+
* @codemirror/autocomplete匹配关键词的方法列表
|
|
1941
|
+
*
|
|
1942
|
+
* 它会被像下面这样嵌入编辑器
|
|
1943
|
+
*
|
|
1944
|
+
* import { autocompletion } from '@codemirror/autocomplete';
|
|
1945
|
+
* autocompletion({
|
|
1946
|
+
* override: [...completions]
|
|
1947
|
+
* })
|
|
1948
|
+
*/
|
|
1949
|
+
completions: {
|
|
1950
|
+
type: Array,
|
|
1951
|
+
default: void 0
|
|
1952
|
+
},
|
|
1953
|
+
/**
|
|
1954
|
+
* 是否在工具栏下面显示对应的文字名称
|
|
291
1955
|
*
|
|
292
|
-
*
|
|
1956
|
+
* @default false
|
|
293
1957
|
*/
|
|
294
|
-
|
|
1958
|
+
showToolbarName: {
|
|
295
1959
|
type: Boolean,
|
|
296
1960
|
default: !1
|
|
297
1961
|
},
|
|
298
1962
|
/**
|
|
299
|
-
*
|
|
1963
|
+
* 字符输入事件
|
|
1964
|
+
*/
|
|
1965
|
+
onInput: {
|
|
1966
|
+
type: Function,
|
|
1967
|
+
default: void 0
|
|
1968
|
+
},
|
|
1969
|
+
onDrop: {
|
|
1970
|
+
type: Function,
|
|
1971
|
+
default: void 0
|
|
1972
|
+
},
|
|
1973
|
+
/**
|
|
1974
|
+
* 输入框的默认宽度
|
|
1975
|
+
*
|
|
1976
|
+
* @example '100px'/'50%'
|
|
1977
|
+
* @default '50%
|
|
1978
|
+
*/
|
|
1979
|
+
inputBoxWidth: {
|
|
1980
|
+
type: String,
|
|
1981
|
+
default: "50%"
|
|
1982
|
+
},
|
|
1983
|
+
/**
|
|
1984
|
+
* 输入框宽度变化事件
|
|
1985
|
+
*/
|
|
1986
|
+
oninputBoxWidthChange: {
|
|
1987
|
+
type: Function,
|
|
1988
|
+
default: void 0
|
|
1989
|
+
},
|
|
1990
|
+
/**
|
|
1991
|
+
* 替换粘贴的图片链接
|
|
1992
|
+
*
|
|
1993
|
+
* @param t 图片链接
|
|
1994
|
+
* @returns
|
|
1995
|
+
*/
|
|
1996
|
+
transformImgUrl: {
|
|
1997
|
+
type: Function,
|
|
1998
|
+
default: (e) => e
|
|
1999
|
+
},
|
|
2000
|
+
/**
|
|
2001
|
+
* 内置的目录显示的状态
|
|
2002
|
+
*
|
|
2003
|
+
* 'fixed': 悬浮在内容上方
|
|
2004
|
+
* 'flat': 展示在右侧
|
|
2005
|
+
*
|
|
2006
|
+
* \>=5.3.0
|
|
300
2007
|
*
|
|
301
|
-
*
|
|
2008
|
+
* @default 'fixed'
|
|
302
2009
|
*/
|
|
303
|
-
|
|
2010
|
+
catalogLayout: {
|
|
304
2011
|
type: String,
|
|
305
|
-
default: "
|
|
2012
|
+
default: "fixed"
|
|
306
2013
|
},
|
|
307
2014
|
/**
|
|
308
2015
|
* 控制最大显示的目录层级
|
|
@@ -311,164 +2018,97 @@ const ce = `.${O}-preview > [data-line]`, w = (e, l) => +getComputedStyle(e).get
|
|
|
311
2018
|
type: Number,
|
|
312
2019
|
default: void 0
|
|
313
2020
|
}
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (I = v[v.length - 1], c.level <= I.level) {
|
|
355
|
-
v.push(c);
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
else
|
|
360
|
-
t.push(c);
|
|
361
|
-
}
|
|
362
|
-
}), t;
|
|
363
|
-
}), B = () => {
|
|
364
|
-
if (E.scrollElement instanceof HTMLElement)
|
|
365
|
-
return E.scrollElement;
|
|
366
|
-
let t = document;
|
|
367
|
-
return (E.scrollElement === o || e.isScrollElementInShadow) && (t = y.value?.getRootNode()), t.querySelector(E.scrollElement);
|
|
368
|
-
}, _ = (t) => {
|
|
369
|
-
if (t.length === 0)
|
|
370
|
-
return m.value = void 0, E.list = [], !1;
|
|
371
|
-
const {
|
|
372
|
-
activeHead: n,
|
|
373
|
-
activeIndex: a
|
|
374
|
-
} = t.reduce((d, c, I) => {
|
|
375
|
-
let g = 0;
|
|
376
|
-
if (e.syncWith === "preview") {
|
|
377
|
-
const v = r.value?.getElementById(e.mdHeadingId({
|
|
378
|
-
text: c.text,
|
|
379
|
-
level: c.level,
|
|
380
|
-
index: I + 1,
|
|
381
|
-
currentToken: c.currentToken,
|
|
382
|
-
nextToken: c.nextToken
|
|
383
|
-
}));
|
|
384
|
-
v instanceof HTMLElement && (g = ne(v, f.value));
|
|
385
|
-
} else {
|
|
386
|
-
const v = L.value;
|
|
387
|
-
if (v) {
|
|
388
|
-
const C = v.lineBlockAt(v.state.doc.line(c.line + 1).from).top, S = v.scrollDOM.scrollTop;
|
|
389
|
-
g = C - S;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return g < e.offsetTop && g > d.minTop ? {
|
|
393
|
-
activeHead: c,
|
|
394
|
-
activeIndex: I,
|
|
395
|
-
minTop: g
|
|
396
|
-
} : d;
|
|
397
|
-
}, {
|
|
398
|
-
activeHead: t[0],
|
|
399
|
-
activeIndex: 0,
|
|
400
|
-
minTop: Number.MIN_SAFE_INTEGER
|
|
401
|
-
});
|
|
402
|
-
let u = n;
|
|
403
|
-
const {
|
|
404
|
-
catalogMaxDepth: k
|
|
405
|
-
} = e;
|
|
406
|
-
if (k && u.level > k) {
|
|
407
|
-
for (let d = a; d >= 0; d--) {
|
|
408
|
-
const c = t[d];
|
|
409
|
-
if (c.level <= k) {
|
|
410
|
-
u = c;
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
if (u.level > k) {
|
|
415
|
-
const d = t.find((c) => c.level <= k);
|
|
416
|
-
d && (u = d);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
m.value = u, E.list = t;
|
|
420
|
-
}, F = (t, n) => {
|
|
421
|
-
R.value.top = n.offsetTop + w(n, "padding-block-start") + "px", e.onActive?.(t, n), l.emit("onActive", t, n);
|
|
422
|
-
}, M = () => {
|
|
423
|
-
_(E.list);
|
|
424
|
-
}, i = (t) => {
|
|
425
|
-
if (s.value?.removeEventListener("scroll", M), e.syncWith === "editor")
|
|
426
|
-
s.value = L.value?.scrollDOM;
|
|
427
|
-
else {
|
|
428
|
-
const n = B();
|
|
429
|
-
f.value = n, s.value = n === document.documentElement ? document : n;
|
|
430
|
-
}
|
|
431
|
-
_(t), s.value?.addEventListener("scroll", M);
|
|
432
|
-
}, h = (t) => {
|
|
433
|
-
L.value = t;
|
|
434
|
-
};
|
|
435
|
-
J([() => e.syncWith, L, () => e.catalogMaxDepth], () => {
|
|
436
|
-
i(E.list);
|
|
437
|
-
}), K(() => {
|
|
438
|
-
r.value = y.value.getRootNode(), $.on(b, {
|
|
439
|
-
name: j,
|
|
440
|
-
callback: i
|
|
441
|
-
}), $.on(b, {
|
|
442
|
-
name: U,
|
|
443
|
-
callback: h
|
|
444
|
-
}), $.emit(b, te), $.emit(b, le);
|
|
445
|
-
}), Z(() => {
|
|
446
|
-
$.remove(b, j, i), $.remove(b, U, h), s.value?.removeEventListener("scroll", M);
|
|
2021
|
+
}, Ae = [
|
|
2022
|
+
"onHtmlChanged",
|
|
2023
|
+
"onGetCatalog",
|
|
2024
|
+
"onChange",
|
|
2025
|
+
"onRemount",
|
|
2026
|
+
"update:modelValue"
|
|
2027
|
+
], cn = [
|
|
2028
|
+
...Ae,
|
|
2029
|
+
"onSave",
|
|
2030
|
+
"onUploadImg",
|
|
2031
|
+
"onError",
|
|
2032
|
+
"onBlur",
|
|
2033
|
+
"onFocus",
|
|
2034
|
+
"onInput",
|
|
2035
|
+
"onDrop",
|
|
2036
|
+
"oninputBoxWidthChange"
|
|
2037
|
+
], Nt = (e, t, a) => {
|
|
2038
|
+
const { editorId: n } = a, o = {
|
|
2039
|
+
rerender() {
|
|
2040
|
+
y.emit(n, ue);
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
t.expose(o);
|
|
2044
|
+
}, re = /* @__PURE__ */ de({
|
|
2045
|
+
name: "MdPreview",
|
|
2046
|
+
props: Ie,
|
|
2047
|
+
emits: Ae,
|
|
2048
|
+
setup(e, t) {
|
|
2049
|
+
const {
|
|
2050
|
+
noKatex: a,
|
|
2051
|
+
noMermaid: n,
|
|
2052
|
+
noHighlight: o
|
|
2053
|
+
} = e, m = z(), c = ot(e);
|
|
2054
|
+
Te(e, {
|
|
2055
|
+
rootRef: m,
|
|
2056
|
+
editorId: c
|
|
2057
|
+
}), Nt(e, t, {
|
|
2058
|
+
editorId: c
|
|
2059
|
+
}), te(() => {
|
|
2060
|
+
y.clear(c);
|
|
447
2061
|
});
|
|
448
|
-
const
|
|
449
|
-
e.
|
|
2062
|
+
const u = (r) => {
|
|
2063
|
+
e.onChange?.(r), t.emit("onChange", r), t.emit("update:modelValue", r);
|
|
2064
|
+
}, s = (r) => {
|
|
2065
|
+
e.onHtmlChanged?.(r), t.emit("onHtmlChanged", r);
|
|
2066
|
+
}, l = (r) => {
|
|
2067
|
+
e.onGetCatalog?.(r), t.emit("onGetCatalog", r);
|
|
2068
|
+
}, i = () => {
|
|
2069
|
+
e.onRemount?.(), t.emit("onRemount");
|
|
450
2070
|
};
|
|
451
2071
|
return () => N("div", {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
2072
|
+
id: c,
|
|
2073
|
+
class: [h, e.class, e.theme === "dark" && `${h}-dark`, `${h}-previewOnly`],
|
|
2074
|
+
style: e.style,
|
|
2075
|
+
ref: m
|
|
2076
|
+
}, [N(Bt, {
|
|
2077
|
+
modelValue: e.modelValue,
|
|
2078
|
+
onChange: u,
|
|
2079
|
+
onHtmlChanged: s,
|
|
2080
|
+
onGetCatalog: l,
|
|
460
2081
|
mdHeadingId: e.mdHeadingId,
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
2082
|
+
noMermaid: n,
|
|
2083
|
+
sanitize: e.sanitize,
|
|
2084
|
+
noKatex: a,
|
|
2085
|
+
formatCopiedText: e.formatCopiedText,
|
|
2086
|
+
noHighlight: o,
|
|
2087
|
+
noImgZoomIn: e.noImgZoomIn,
|
|
2088
|
+
previewOnly: !0,
|
|
2089
|
+
sanitizeMermaid: e.sanitizeMermaid,
|
|
2090
|
+
codeFoldable: e.codeFoldable,
|
|
2091
|
+
autoFoldThreshold: e.autoFoldThreshold,
|
|
2092
|
+
onRemount: i,
|
|
2093
|
+
noEcharts: e.noEcharts,
|
|
2094
|
+
previewComponent: e.previewComponent
|
|
2095
|
+
}, null)]);
|
|
467
2096
|
}
|
|
468
2097
|
});
|
|
469
|
-
|
|
2098
|
+
re.install = (e) => (e.component(re.name, re), e);
|
|
470
2099
|
export {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
2100
|
+
P as C,
|
|
2101
|
+
re as M,
|
|
2102
|
+
Bt as a,
|
|
2103
|
+
sn as b,
|
|
2104
|
+
ln as c,
|
|
2105
|
+
on as d,
|
|
2106
|
+
cn as e,
|
|
2107
|
+
an as f,
|
|
2108
|
+
Qt as g,
|
|
2109
|
+
tn as h,
|
|
2110
|
+
nn as i,
|
|
2111
|
+
rn as j,
|
|
2112
|
+
en as k,
|
|
2113
|
+
ot as u
|
|
474
2114
|
};
|