md-editor-v3 2.10.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -49
- package/lib/MdEditor/Editor.d.ts +43 -43
- package/lib/MdEditor/extensions/MdCatalog/CatalogLink.d.ts +11 -11
- package/lib/MdEditor/extensions/MdCatalog/index.d.ts +6 -6
- package/lib/MdEditor/index.d.ts +35 -35
- package/lib/MdEditor/type.d.ts +18 -21
- package/lib/md-editor-v3.cjs +64 -0
- package/lib/md-editor-v3.mjs +4155 -0
- package/lib/md-editor-v3.umd.js +113 -0
- package/lib/style.css +1 -1
- package/package.json +24 -16
- package/lib/md-editor-v3.js +0 -6592
- package/lib/md-editor-v3.umd.cjs +0 -125
|
@@ -0,0 +1,4155 @@
|
|
|
1
|
+
var Et = Object.defineProperty;
|
|
2
|
+
var Lt = (e, t, o) => t in e ? Et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var U = (e, t, o) => (Lt(e, typeof t != "symbol" ? t + "" : t, o), o);
|
|
4
|
+
import { defineComponent as M, createVNode as i, reactive as N, ref as F, watch as T, onMounted as A, onBeforeUnmount as ye, cloneVNode as Ht, inject as x, computed as D, nextTick as q, Fragment as Ce, toRef as ce, shallowRef as de, provide as G, isVNode as It } from "vue";
|
|
5
|
+
import { minimalSetup as At, EditorView as ie } from "codemirror";
|
|
6
|
+
import { EditorSelection as fe, EditorState as se, Compartment as Ft, StateEffect as Mt } from "@codemirror/state";
|
|
7
|
+
import { EditorView as $e, placeholder as jt, keymap as Bt } from "@codemirror/view";
|
|
8
|
+
import { languages as Pt } from "@codemirror/language-data";
|
|
9
|
+
import { markdown as Rt } from "@codemirror/lang-markdown";
|
|
10
|
+
import { deleteLine as Ot, indentWithTab as Dt, undo as Nt, redo as _t } from "@codemirror/commands";
|
|
11
|
+
import { HighlightStyle as yt, syntaxHighlighting as Ct, indentUnit as Vt } from "@codemirror/language";
|
|
12
|
+
import { tags as g } from "@lezer/highlight";
|
|
13
|
+
import Ut from "medium-zoom";
|
|
14
|
+
import qt from "copy-to-clipboard";
|
|
15
|
+
import Wt from "markdown-it";
|
|
16
|
+
import Gt from "markdown-it-image-figures";
|
|
17
|
+
import zt from "markdown-it-task-lists";
|
|
18
|
+
import Kt from "lru-cache";
|
|
19
|
+
const s = "md-editor", Xt = "md-editor-v3", Zt = "https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js", H = "https://cdnjs.cloudflare.com/ajax/libs", Jt = `${H}/highlight.js/11.7.0/highlight.min.js`, Ke = {
|
|
20
|
+
main: `${H}/prettier/2.8.0/standalone.js`,
|
|
21
|
+
markdown: `${H}/prettier/2.8.0/parser-markdown.js`
|
|
22
|
+
}, Xe = {
|
|
23
|
+
css: `${H}/cropperjs/1.5.13/cropper.min.css`,
|
|
24
|
+
js: `${H}/cropperjs/1.5.13/cropper.min.js`
|
|
25
|
+
}, Yt = `${H}/screenfull.js/5.2.0/screenfull.min.js`, $t = [
|
|
26
|
+
"bold",
|
|
27
|
+
"underline",
|
|
28
|
+
"italic",
|
|
29
|
+
"strikeThrough",
|
|
30
|
+
"-",
|
|
31
|
+
"title",
|
|
32
|
+
"sub",
|
|
33
|
+
"sup",
|
|
34
|
+
"quote",
|
|
35
|
+
"unorderedList",
|
|
36
|
+
"orderedList",
|
|
37
|
+
"task",
|
|
38
|
+
"-",
|
|
39
|
+
"codeRow",
|
|
40
|
+
"code",
|
|
41
|
+
"link",
|
|
42
|
+
"image",
|
|
43
|
+
"table",
|
|
44
|
+
"mermaid",
|
|
45
|
+
"katex",
|
|
46
|
+
"-",
|
|
47
|
+
"revoke",
|
|
48
|
+
"next",
|
|
49
|
+
"save",
|
|
50
|
+
"=",
|
|
51
|
+
"prettier",
|
|
52
|
+
"pageFullscreen",
|
|
53
|
+
"fullscreen",
|
|
54
|
+
"preview",
|
|
55
|
+
"htmlPreview",
|
|
56
|
+
"catalog",
|
|
57
|
+
"github"
|
|
58
|
+
], wt = ["markdownTotal", "=", "scrollSwitch"], Ze = {
|
|
59
|
+
"zh-CN": {
|
|
60
|
+
toolbarTips: {
|
|
61
|
+
bold: "加粗",
|
|
62
|
+
underline: "下划线",
|
|
63
|
+
italic: "斜体",
|
|
64
|
+
strikeThrough: "删除线",
|
|
65
|
+
title: "标题",
|
|
66
|
+
sub: "下标",
|
|
67
|
+
sup: "上标",
|
|
68
|
+
quote: "引用",
|
|
69
|
+
unorderedList: "无序列表",
|
|
70
|
+
orderedList: "有序列表",
|
|
71
|
+
task: "任务列表",
|
|
72
|
+
codeRow: "行内代码",
|
|
73
|
+
code: "块级代码",
|
|
74
|
+
link: "链接",
|
|
75
|
+
image: "图片",
|
|
76
|
+
table: "表格",
|
|
77
|
+
mermaid: "mermaid图",
|
|
78
|
+
katex: "katex公式",
|
|
79
|
+
revoke: "后退",
|
|
80
|
+
next: "前进",
|
|
81
|
+
save: "保存",
|
|
82
|
+
prettier: "美化",
|
|
83
|
+
pageFullscreen: "浏览器全屏",
|
|
84
|
+
fullscreen: "屏幕全屏",
|
|
85
|
+
preview: "预览",
|
|
86
|
+
htmlPreview: "html代码预览",
|
|
87
|
+
catalog: "目录",
|
|
88
|
+
github: "源码地址"
|
|
89
|
+
},
|
|
90
|
+
titleItem: {
|
|
91
|
+
h1: "一级标题",
|
|
92
|
+
h2: "二级标题",
|
|
93
|
+
h3: "三级标题",
|
|
94
|
+
h4: "四级标题",
|
|
95
|
+
h5: "五级标题",
|
|
96
|
+
h6: "六级标题"
|
|
97
|
+
},
|
|
98
|
+
imgTitleItem: {
|
|
99
|
+
link: "添加链接",
|
|
100
|
+
upload: "上传图片",
|
|
101
|
+
clip2upload: "裁剪上传"
|
|
102
|
+
},
|
|
103
|
+
linkModalTips: {
|
|
104
|
+
linkTitle: "添加链接",
|
|
105
|
+
imageTitle: "添加图片",
|
|
106
|
+
descLabel: "链接描述:",
|
|
107
|
+
descLabelPlaceHolder: "请输入描述...",
|
|
108
|
+
urlLabel: "链接地址:",
|
|
109
|
+
urlLabelPlaceHolder: "请输入链接...",
|
|
110
|
+
buttonOK: "确定"
|
|
111
|
+
},
|
|
112
|
+
clipModalTips: {
|
|
113
|
+
title: "裁剪图片上传",
|
|
114
|
+
buttonUpload: "上传"
|
|
115
|
+
},
|
|
116
|
+
copyCode: {
|
|
117
|
+
text: "复制代码",
|
|
118
|
+
successTips: "已复制!",
|
|
119
|
+
failTips: "复制失败!"
|
|
120
|
+
},
|
|
121
|
+
mermaid: {
|
|
122
|
+
flow: "流程图",
|
|
123
|
+
sequence: "时序图",
|
|
124
|
+
gantt: "甘特图",
|
|
125
|
+
class: "类图",
|
|
126
|
+
state: "状态图",
|
|
127
|
+
pie: "饼图",
|
|
128
|
+
relationship: "关系图",
|
|
129
|
+
journey: "旅程图"
|
|
130
|
+
},
|
|
131
|
+
katex: {
|
|
132
|
+
inline: "行内公式",
|
|
133
|
+
block: "块级公式"
|
|
134
|
+
},
|
|
135
|
+
footer: {
|
|
136
|
+
markdownTotal: "字数",
|
|
137
|
+
scrollAuto: "同步滚动"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"en-US": {
|
|
141
|
+
toolbarTips: {
|
|
142
|
+
bold: "bold",
|
|
143
|
+
underline: "underline",
|
|
144
|
+
italic: "italic",
|
|
145
|
+
strikeThrough: "strikeThrough",
|
|
146
|
+
title: "title",
|
|
147
|
+
sub: "subscript",
|
|
148
|
+
sup: "superscript",
|
|
149
|
+
quote: "quote",
|
|
150
|
+
unorderedList: "unordered list",
|
|
151
|
+
orderedList: "ordered list",
|
|
152
|
+
task: "task list",
|
|
153
|
+
codeRow: "inline code",
|
|
154
|
+
code: "block-level code",
|
|
155
|
+
link: "link",
|
|
156
|
+
image: "image",
|
|
157
|
+
table: "table",
|
|
158
|
+
mermaid: "mermaid",
|
|
159
|
+
katex: "formula",
|
|
160
|
+
revoke: "revoke",
|
|
161
|
+
next: "undo revoke",
|
|
162
|
+
save: "save",
|
|
163
|
+
prettier: "prettier",
|
|
164
|
+
pageFullscreen: "fullscreen in page",
|
|
165
|
+
fullscreen: "fullscreen",
|
|
166
|
+
preview: "preview",
|
|
167
|
+
htmlPreview: "html preview",
|
|
168
|
+
catalog: "catalog",
|
|
169
|
+
github: "source code"
|
|
170
|
+
},
|
|
171
|
+
titleItem: {
|
|
172
|
+
h1: "Lv1 Heading",
|
|
173
|
+
h2: "Lv2 Heading",
|
|
174
|
+
h3: "Lv3 Heading",
|
|
175
|
+
h4: "Lv4 Heading",
|
|
176
|
+
h5: "Lv5 Heading",
|
|
177
|
+
h6: "Lv6 Heading"
|
|
178
|
+
},
|
|
179
|
+
imgTitleItem: {
|
|
180
|
+
link: "Add Img Link",
|
|
181
|
+
upload: "Upload Img",
|
|
182
|
+
clip2upload: "Clip Upload"
|
|
183
|
+
},
|
|
184
|
+
linkModalTips: {
|
|
185
|
+
linkTitle: "Add Link",
|
|
186
|
+
imageTitle: "Add Image",
|
|
187
|
+
descLabel: "Desc:",
|
|
188
|
+
descLabelPlaceHolder: "Enter a description...",
|
|
189
|
+
urlLabel: "Link:",
|
|
190
|
+
urlLabelPlaceHolder: "Enter a link...",
|
|
191
|
+
buttonOK: "OK"
|
|
192
|
+
},
|
|
193
|
+
clipModalTips: {
|
|
194
|
+
title: "Crop Image",
|
|
195
|
+
buttonUpload: "Upload"
|
|
196
|
+
},
|
|
197
|
+
copyCode: {
|
|
198
|
+
text: "Copy",
|
|
199
|
+
successTips: "Copied!",
|
|
200
|
+
failTips: "Copy failed!"
|
|
201
|
+
},
|
|
202
|
+
mermaid: {
|
|
203
|
+
flow: "flow",
|
|
204
|
+
sequence: "sequence",
|
|
205
|
+
gantt: "gantt",
|
|
206
|
+
class: "class",
|
|
207
|
+
state: "state",
|
|
208
|
+
pie: "pie",
|
|
209
|
+
relationship: "relationship",
|
|
210
|
+
journey: "journey"
|
|
211
|
+
},
|
|
212
|
+
katex: {
|
|
213
|
+
inline: "inline",
|
|
214
|
+
block: "block"
|
|
215
|
+
},
|
|
216
|
+
footer: {
|
|
217
|
+
markdownTotal: "Word Count",
|
|
218
|
+
scrollAuto: "Scroll Auto"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, Qt = `${H}/mermaid/9.4.0/mermaid.min.js`, Je = {
|
|
222
|
+
js: `${H}/KaTeX/0.16.3/katex.min.js`,
|
|
223
|
+
css: `${H}/KaTeX/0.16.3/katex.min.css`
|
|
224
|
+
}, Ye = {
|
|
225
|
+
a11y: {
|
|
226
|
+
light: `${H}/highlight.js/11.7.0/styles/a11y-light.min.css`,
|
|
227
|
+
dark: `${H}/highlight.js/11.7.0/styles/a11y-dark.min.css`
|
|
228
|
+
},
|
|
229
|
+
atom: {
|
|
230
|
+
light: `${H}/highlight.js/11.7.0/styles/atom-one-light.min.css`,
|
|
231
|
+
dark: `${H}/highlight.js/11.7.0/styles/atom-one-dark.min.css`
|
|
232
|
+
},
|
|
233
|
+
github: {
|
|
234
|
+
light: `${H}/highlight.js/11.7.0/styles/github.min.css`,
|
|
235
|
+
dark: `${H}/highlight.js/11.7.0/styles/github-dark.min.css`
|
|
236
|
+
},
|
|
237
|
+
gradient: {
|
|
238
|
+
light: `${H}/highlight.js/11.7.0/styles/gradient-light.min.css`,
|
|
239
|
+
dark: `${H}/highlight.js/11.7.0/styles/gradient-dark.min.css`
|
|
240
|
+
},
|
|
241
|
+
kimbie: {
|
|
242
|
+
light: `${H}/highlight.js/11.7.0/styles/kimbie-light.min.css`,
|
|
243
|
+
dark: `${H}/highlight.js/11.7.0/styles/kimbie-dark.min.css`
|
|
244
|
+
},
|
|
245
|
+
paraiso: {
|
|
246
|
+
light: `${H}/highlight.js/11.7.0/styles/paraiso-light.min.css`,
|
|
247
|
+
dark: `${H}/highlight.js/11.7.0/styles/paraiso-dark.min.css`
|
|
248
|
+
},
|
|
249
|
+
qtcreator: {
|
|
250
|
+
light: `${H}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,
|
|
251
|
+
dark: `${H}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`
|
|
252
|
+
},
|
|
253
|
+
stackoverflow: {
|
|
254
|
+
light: `${H}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,
|
|
255
|
+
dark: `${H}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`
|
|
256
|
+
}
|
|
257
|
+
}, I = {
|
|
258
|
+
// markedRenderer: (r) => r,
|
|
259
|
+
// markedExtensions: [],
|
|
260
|
+
// markedOptions: {},
|
|
261
|
+
editorExtensions: {},
|
|
262
|
+
editorConfig: {},
|
|
263
|
+
codeMirrorExtensions: (e, t) => t,
|
|
264
|
+
markdownItConfig: () => {
|
|
265
|
+
}
|
|
266
|
+
}, el = (e) => {
|
|
267
|
+
if (e)
|
|
268
|
+
for (const t in e) {
|
|
269
|
+
const o = e[t];
|
|
270
|
+
o && (I[t] = o);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const tl = /* @__PURE__ */ M({
|
|
274
|
+
setup() {
|
|
275
|
+
return () => i("div", {
|
|
276
|
+
class: `${s}-divider`
|
|
277
|
+
}, null);
|
|
278
|
+
}
|
|
279
|
+
}), _ = ({
|
|
280
|
+
instance: e,
|
|
281
|
+
ctx: t,
|
|
282
|
+
props: o = {}
|
|
283
|
+
}, l = "default") => {
|
|
284
|
+
const r = (e == null ? void 0 : e.$slots[l]) || (t == null ? void 0 : t.slots[l]);
|
|
285
|
+
return (r ? r(e) : "") || o[l];
|
|
286
|
+
};
|
|
287
|
+
const ll = {
|
|
288
|
+
trigger: {
|
|
289
|
+
type: String,
|
|
290
|
+
default: "hover"
|
|
291
|
+
},
|
|
292
|
+
overlay: {
|
|
293
|
+
type: [String, Object],
|
|
294
|
+
default: ""
|
|
295
|
+
},
|
|
296
|
+
visible: {
|
|
297
|
+
type: Boolean,
|
|
298
|
+
default: !1
|
|
299
|
+
},
|
|
300
|
+
onChange: {
|
|
301
|
+
type: Function,
|
|
302
|
+
default: () => {
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
// 相对滚动的元素选择器
|
|
306
|
+
relative: {
|
|
307
|
+
type: String,
|
|
308
|
+
default: "html"
|
|
309
|
+
}
|
|
310
|
+
}, Y = /* @__PURE__ */ M({
|
|
311
|
+
props: ll,
|
|
312
|
+
setup(e, t) {
|
|
313
|
+
const o = `${s}-dropdown-hidden`, l = N({
|
|
314
|
+
overlayClass: [o],
|
|
315
|
+
overlayStyle: {},
|
|
316
|
+
triggerHover: !1,
|
|
317
|
+
overlayHover: !1
|
|
318
|
+
}), r = F(), n = F(), a = () => {
|
|
319
|
+
var w;
|
|
320
|
+
e.trigger === "hover" && (l.triggerHover = !0);
|
|
321
|
+
const f = r.value, h = n.value, v = f.getBoundingClientRect(), b = f.offsetTop, k = f.offsetLeft, p = v.height, y = v.width, $ = ((w = document.querySelector(e.relative)) == null ? void 0 : w.scrollLeft) || 0;
|
|
322
|
+
l.overlayStyle = {
|
|
323
|
+
...l.overlayStyle,
|
|
324
|
+
top: b + p + "px",
|
|
325
|
+
left: k - h.offsetWidth / 2 + y / 2 - $ + "px"
|
|
326
|
+
}, e.onChange(!0);
|
|
327
|
+
}, c = () => {
|
|
328
|
+
l.overlayHover = !0;
|
|
329
|
+
};
|
|
330
|
+
T(() => e.visible, (f) => {
|
|
331
|
+
f ? l.overlayClass = l.overlayClass.filter((h) => h !== o) : l.overlayClass.push(o);
|
|
332
|
+
});
|
|
333
|
+
const m = (f) => {
|
|
334
|
+
const h = r.value, v = n.value;
|
|
335
|
+
!h.contains(f.target) && !v.contains(f.target) && e.onChange(!1);
|
|
336
|
+
};
|
|
337
|
+
let u = -1;
|
|
338
|
+
const d = (f) => {
|
|
339
|
+
r.value === f.target ? l.triggerHover = !1 : l.overlayHover = !1, clearTimeout(u), u = window.setTimeout(() => {
|
|
340
|
+
!l.overlayHover && !l.triggerHover && e.onChange(!1);
|
|
341
|
+
}, 10);
|
|
342
|
+
};
|
|
343
|
+
return A(() => {
|
|
344
|
+
e.trigger === "click" ? (r.value.addEventListener("click", a), document.addEventListener("click", m)) : (r.value.addEventListener("mouseenter", a), r.value.addEventListener("mouseleave", d), n.value.addEventListener("mouseenter", c), n.value.addEventListener("mouseleave", d));
|
|
345
|
+
}), ye(() => {
|
|
346
|
+
e.trigger === "click" ? (r.value.removeEventListener("click", a), document.removeEventListener("click", m)) : (r.value.removeEventListener("mouseenter", a), r.value.removeEventListener("mouseleave", d), n.value.removeEventListener("mouseenter", c), n.value.removeEventListener("mouseleave", d));
|
|
347
|
+
}), () => {
|
|
348
|
+
const f = _({
|
|
349
|
+
ctx: t
|
|
350
|
+
}), h = _({
|
|
351
|
+
props: e,
|
|
352
|
+
ctx: t
|
|
353
|
+
}, "overlay"), v = Ht(f instanceof Array ? f[0] : f, {
|
|
354
|
+
ref: r
|
|
355
|
+
}), b = i("div", {
|
|
356
|
+
class: [`${s}-dropdown`, l.overlayClass],
|
|
357
|
+
style: l.overlayStyle,
|
|
358
|
+
ref: n
|
|
359
|
+
}, [i("div", {
|
|
360
|
+
class: `${s}-dropdown-overlay`
|
|
361
|
+
}, [h instanceof Array ? h[0] : h])]);
|
|
362
|
+
return [v, b];
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
class ol {
|
|
367
|
+
constructor() {
|
|
368
|
+
// 事件池
|
|
369
|
+
U(this, "pools", {});
|
|
370
|
+
}
|
|
371
|
+
// 移除事件监听
|
|
372
|
+
remove(t, o, l) {
|
|
373
|
+
const n = this.pools[t] && this.pools[t][o];
|
|
374
|
+
n && (this.pools[t][o] = n.filter((a) => a !== l));
|
|
375
|
+
}
|
|
376
|
+
// 清空全部事件,由于单一实例,多次注册会被共享内容
|
|
377
|
+
clear(t) {
|
|
378
|
+
this.pools[t] = {};
|
|
379
|
+
}
|
|
380
|
+
// 注册事件监听
|
|
381
|
+
on(t, o) {
|
|
382
|
+
return this.pools[t] || (this.pools[t] = {}), this.pools[t][o.name] || (this.pools[t][o.name] = []), this.pools[t][o.name].push(o.callback), this.pools[t][o.name].includes(o.callback);
|
|
383
|
+
}
|
|
384
|
+
// 触发事件
|
|
385
|
+
emit(t, o, ...l) {
|
|
386
|
+
this.pools[t] || (this.pools[t] = {});
|
|
387
|
+
const n = this.pools[t][o];
|
|
388
|
+
n && n.forEach((a) => {
|
|
389
|
+
try {
|
|
390
|
+
a(...l);
|
|
391
|
+
} catch (c) {
|
|
392
|
+
console.error(`${o} monitor event exception!`, c);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const C = new ol(), nl = (e, t = {
|
|
398
|
+
newWindow: !0,
|
|
399
|
+
nofollow: !0
|
|
400
|
+
}) => {
|
|
401
|
+
e || console.error("error link!");
|
|
402
|
+
const o = document.createElement("a");
|
|
403
|
+
o.href = e, o.style.display = "none", t.newWindow && (o.target = "_blank"), t.nofollow && (o.rel = "noopener noreferrer"), document.body.appendChild(o), o.click(), document.body.removeChild(o);
|
|
404
|
+
}, rl = (e, t = "image.png") => {
|
|
405
|
+
const o = e.split(","), l = o[0].match(/:(.*?);/);
|
|
406
|
+
if (l) {
|
|
407
|
+
const r = l[1], n = atob(o[1]);
|
|
408
|
+
let a = n.length;
|
|
409
|
+
const c = new Uint8Array(a);
|
|
410
|
+
for (; a--; )
|
|
411
|
+
c[a] = n.charCodeAt(a);
|
|
412
|
+
return new File([c], t, { type: r });
|
|
413
|
+
}
|
|
414
|
+
return null;
|
|
415
|
+
}, il = (e) => {
|
|
416
|
+
if (!e)
|
|
417
|
+
return e;
|
|
418
|
+
const t = e.split(`
|
|
419
|
+
`), o = ['<span rn-wrapper aria-hidden="true">'];
|
|
420
|
+
return t.forEach(() => {
|
|
421
|
+
o.push("<span></span>");
|
|
422
|
+
}), o.push("</span>"), `<span class="code-block">${e}</span>${o.join("")}`;
|
|
423
|
+
}, Q = (e, t = 200) => {
|
|
424
|
+
let o = 0;
|
|
425
|
+
return (...l) => new Promise((r) => {
|
|
426
|
+
o && (clearTimeout(o), r("cancel")), o = window.setTimeout(() => {
|
|
427
|
+
e.apply(void 0, l), o = 0, r("done");
|
|
428
|
+
}, t);
|
|
429
|
+
});
|
|
430
|
+
}, al = (e, t = 200) => {
|
|
431
|
+
let o = 0, l = null;
|
|
432
|
+
return (...r) => {
|
|
433
|
+
const n = (a) => {
|
|
434
|
+
o === 0 && (o = a), a - o >= t ? (e.apply(void 0, l), l = null, o = 0) : window.requestAnimationFrame(n);
|
|
435
|
+
};
|
|
436
|
+
l === null && window.requestAnimationFrame(n), l = r;
|
|
437
|
+
};
|
|
438
|
+
}, sl = (e, t) => {
|
|
439
|
+
const o = e == null ? void 0 : e.getBoundingClientRect();
|
|
440
|
+
if (t === document.documentElement)
|
|
441
|
+
return o.top - t.clientTop;
|
|
442
|
+
const l = t == null ? void 0 : t.getBoundingClientRect();
|
|
443
|
+
return o.top - l.top;
|
|
444
|
+
}, cl = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`, dl = {
|
|
445
|
+
noPrettier: {
|
|
446
|
+
type: Boolean
|
|
447
|
+
},
|
|
448
|
+
// 工具栏选择显示
|
|
449
|
+
toolbars: {
|
|
450
|
+
type: Array,
|
|
451
|
+
default: () => []
|
|
452
|
+
},
|
|
453
|
+
// 工具栏选择不显示
|
|
454
|
+
toolbarsExclude: {
|
|
455
|
+
type: Array,
|
|
456
|
+
default: () => []
|
|
457
|
+
},
|
|
458
|
+
setting: {
|
|
459
|
+
type: Object,
|
|
460
|
+
default: () => ({})
|
|
461
|
+
},
|
|
462
|
+
screenfull: {
|
|
463
|
+
type: Object,
|
|
464
|
+
default: null
|
|
465
|
+
},
|
|
466
|
+
screenfullJs: {
|
|
467
|
+
type: String,
|
|
468
|
+
default: ""
|
|
469
|
+
},
|
|
470
|
+
updateSetting: {
|
|
471
|
+
type: Function,
|
|
472
|
+
default: () => {
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
tableShape: {
|
|
476
|
+
type: Array,
|
|
477
|
+
default: () => [6, 4]
|
|
478
|
+
},
|
|
479
|
+
defToolbars: {
|
|
480
|
+
type: Object
|
|
481
|
+
},
|
|
482
|
+
noUploadImg: {
|
|
483
|
+
type: Boolean
|
|
484
|
+
}
|
|
485
|
+
}, me = "onSave", we = "changeCatalogVisible", Tt = "changeFullscreen", Qe = "pageFullscreenChanged", et = "fullscreenChanged", ve = "previewChanged", tt = "htmlPreviewChanged", lt = "catalogVisibleChanged", St = "textareaFocus", ot = (e, t) => {
|
|
486
|
+
const o = (l) => {
|
|
487
|
+
const r = e.parentElement || document.body, n = r.offsetWidth, a = r.offsetHeight, { clientWidth: c } = document.documentElement, { clientHeight: m } = document.documentElement, u = l.offsetX, d = l.offsetY, f = (v) => {
|
|
488
|
+
let b = v.x + document.body.scrollLeft - document.body.clientLeft - u, k = v.y + document.body.scrollTop - document.body.clientTop - d;
|
|
489
|
+
b = b < 1 ? 1 : b < c - n - 1 ? b : c - n - 1, k = k < 1 ? 1 : k < m - a - 1 ? k : m - a - 1, t ? t(b, k) : (r.style.left = `${b}px`, r.style.top = `${k}px`);
|
|
490
|
+
};
|
|
491
|
+
document.addEventListener("mousemove", f);
|
|
492
|
+
const h = () => {
|
|
493
|
+
document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", h);
|
|
494
|
+
};
|
|
495
|
+
document.addEventListener("mouseup", h);
|
|
496
|
+
};
|
|
497
|
+
return e.addEventListener("mousedown", o), () => {
|
|
498
|
+
e.removeEventListener("mousedown", o);
|
|
499
|
+
};
|
|
500
|
+
}, O = (e, t = "") => {
|
|
501
|
+
const o = document.getElementById(e.id), l = (r) => {
|
|
502
|
+
typeof e.onload == "function" && e.onload(r), e.removeEventListener("load", l);
|
|
503
|
+
};
|
|
504
|
+
o ? t !== "" && typeof e.onload == "function" && (Reflect.get(window, t) ? e.dispatchEvent(new Event("load")) : o.addEventListener("load", l)) : (e.addEventListener("load", l), document.head.appendChild(e));
|
|
505
|
+
}, ul = Q((e, t, o) => {
|
|
506
|
+
const l = document.getElementById(e);
|
|
507
|
+
l && l.setAttribute(t, o);
|
|
508
|
+
}, 10), ml = (e) => {
|
|
509
|
+
var m, u, d, f;
|
|
510
|
+
const t = x("editorId");
|
|
511
|
+
let o = (u = (m = I.editorExtensions) == null ? void 0 : m.screenfull) == null ? void 0 : u.instance;
|
|
512
|
+
const l = (f = (d = I.editorExtensions) == null ? void 0 : d.screenfull) == null ? void 0 : f.js, r = F(!1), n = (h) => {
|
|
513
|
+
if (!o) {
|
|
514
|
+
C.emit(t, "errorCatcher", {
|
|
515
|
+
name: "fullscreen",
|
|
516
|
+
message: "fullscreen is undefined"
|
|
517
|
+
});
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
o.isEnabled ? (r.value = !0, (h === void 0 ? !o.isFullscreen : h) ? o.request() : o.exit()) : console.error("browser does not support screenfull!");
|
|
521
|
+
}, a = () => {
|
|
522
|
+
o && o.isEnabled && o.on("change", () => {
|
|
523
|
+
(r.value || e.setting.fullscreen) && (r.value = !1, e.updateSetting("fullscreen"));
|
|
524
|
+
});
|
|
525
|
+
}, c = () => {
|
|
526
|
+
o = window.screenfull, a();
|
|
527
|
+
};
|
|
528
|
+
return A(() => {
|
|
529
|
+
if (a(), !o) {
|
|
530
|
+
const h = document.createElement("script");
|
|
531
|
+
h.src = l || Yt, h.onload = c, h.id = `${s}-screenfull`, O(h, "screenfull");
|
|
532
|
+
}
|
|
533
|
+
}), A(() => {
|
|
534
|
+
C.on(t, {
|
|
535
|
+
name: Tt,
|
|
536
|
+
callback: n
|
|
537
|
+
});
|
|
538
|
+
}), { fullscreenHandler: n };
|
|
539
|
+
}, fl = {
|
|
540
|
+
tableShape: {
|
|
541
|
+
type: Array,
|
|
542
|
+
default: () => [6, 4]
|
|
543
|
+
},
|
|
544
|
+
onSelected: {
|
|
545
|
+
type: Function,
|
|
546
|
+
default: () => {
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}, gl = /* @__PURE__ */ M({
|
|
550
|
+
name: "TableShape",
|
|
551
|
+
props: fl,
|
|
552
|
+
setup(e) {
|
|
553
|
+
const t = N({
|
|
554
|
+
x: -1,
|
|
555
|
+
y: -1
|
|
556
|
+
});
|
|
557
|
+
return () => i("div", {
|
|
558
|
+
class: `${s}-table-shape`,
|
|
559
|
+
onMouseleave: () => {
|
|
560
|
+
t.x = -1, t.y = -1;
|
|
561
|
+
}
|
|
562
|
+
}, [new Array(e.tableShape[1]).fill("").map((o, l) => i("div", {
|
|
563
|
+
class: `${s}-table-shape-row`,
|
|
564
|
+
key: `table-shape-row-${l}`
|
|
565
|
+
}, [new Array(e.tableShape[0]).fill("").map((r, n) => i("div", {
|
|
566
|
+
class: `${s}-table-shape-col`,
|
|
567
|
+
key: `table-shape-col-${n}`,
|
|
568
|
+
onMouseenter: () => {
|
|
569
|
+
t.x = l, t.y = n;
|
|
570
|
+
},
|
|
571
|
+
onClick: () => {
|
|
572
|
+
e.onSelected(t);
|
|
573
|
+
}
|
|
574
|
+
}, [i("div", {
|
|
575
|
+
class: [`${s}-table-shape-col-default`, l <= t.x && n <= t.y && `${s}-table-shape-col-include`]
|
|
576
|
+
}, null)]))]))]);
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
const hl = {
|
|
580
|
+
title: {
|
|
581
|
+
type: String,
|
|
582
|
+
default: ""
|
|
583
|
+
},
|
|
584
|
+
visible: {
|
|
585
|
+
type: Boolean,
|
|
586
|
+
default: !1
|
|
587
|
+
},
|
|
588
|
+
width: {
|
|
589
|
+
type: String,
|
|
590
|
+
default: "auto"
|
|
591
|
+
},
|
|
592
|
+
height: {
|
|
593
|
+
type: String,
|
|
594
|
+
default: "auto"
|
|
595
|
+
},
|
|
596
|
+
onClose: {
|
|
597
|
+
type: Function,
|
|
598
|
+
default: () => {
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
showAdjust: {
|
|
602
|
+
type: Boolean,
|
|
603
|
+
default: !1
|
|
604
|
+
},
|
|
605
|
+
isFullscreen: {
|
|
606
|
+
type: Boolean,
|
|
607
|
+
default: !1
|
|
608
|
+
},
|
|
609
|
+
onAdjust: {
|
|
610
|
+
type: Function,
|
|
611
|
+
default: () => {
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
class: {
|
|
615
|
+
type: String
|
|
616
|
+
}
|
|
617
|
+
}, Te = /* @__PURE__ */ M({
|
|
618
|
+
props: hl,
|
|
619
|
+
setup(e, t) {
|
|
620
|
+
const o = F(e.visible), l = F([`${s}-modal`]), r = F(), n = F();
|
|
621
|
+
let a = () => {
|
|
622
|
+
};
|
|
623
|
+
const c = N({
|
|
624
|
+
initPos: {
|
|
625
|
+
left: "0px",
|
|
626
|
+
top: "0px"
|
|
627
|
+
},
|
|
628
|
+
historyPos: {
|
|
629
|
+
left: "0px",
|
|
630
|
+
top: "0px"
|
|
631
|
+
}
|
|
632
|
+
}), m = D(() => e.isFullscreen ? {
|
|
633
|
+
width: "100%",
|
|
634
|
+
height: "100%"
|
|
635
|
+
} : {
|
|
636
|
+
width: e.width,
|
|
637
|
+
height: e.height
|
|
638
|
+
});
|
|
639
|
+
return A(() => {
|
|
640
|
+
a = ot(n.value, (u, d) => {
|
|
641
|
+
c.initPos.left = u + "px", c.initPos.top = d + "px";
|
|
642
|
+
});
|
|
643
|
+
}), ye(() => {
|
|
644
|
+
a();
|
|
645
|
+
}), T(() => e.isFullscreen, (u) => {
|
|
646
|
+
u ? a() : a = ot(n.value, (d, f) => {
|
|
647
|
+
c.initPos.left = d + "px", c.initPos.top = f + "px";
|
|
648
|
+
});
|
|
649
|
+
}), T(() => e.visible, (u) => {
|
|
650
|
+
u ? (l.value.push("zoom-in"), o.value = u, q(() => {
|
|
651
|
+
const d = r.value.offsetWidth / 2, f = r.value.offsetHeight / 2, h = document.documentElement.clientWidth / 2, v = document.documentElement.clientHeight / 2;
|
|
652
|
+
c.initPos.left = h - d + "px", c.initPos.top = v - f + "px";
|
|
653
|
+
}), setTimeout(() => {
|
|
654
|
+
l.value = l.value.filter((d) => d !== "zoom-in");
|
|
655
|
+
}, 140)) : (l.value.push("zoom-out"), setTimeout(() => {
|
|
656
|
+
l.value = l.value.filter((d) => d !== "zoom-out"), o.value = u;
|
|
657
|
+
}, 130));
|
|
658
|
+
}), () => {
|
|
659
|
+
const u = _({
|
|
660
|
+
ctx: t
|
|
661
|
+
}), d = _({
|
|
662
|
+
props: e,
|
|
663
|
+
ctx: t
|
|
664
|
+
}, "title");
|
|
665
|
+
return i("div", {
|
|
666
|
+
class: [e.class],
|
|
667
|
+
style: {
|
|
668
|
+
display: o.value ? "block" : "none"
|
|
669
|
+
}
|
|
670
|
+
}, [i("div", {
|
|
671
|
+
class: `${s}-modal-mask`,
|
|
672
|
+
onClick: e.onClose
|
|
673
|
+
}, null), i("div", {
|
|
674
|
+
class: l.value,
|
|
675
|
+
style: {
|
|
676
|
+
...c.initPos,
|
|
677
|
+
...m.value
|
|
678
|
+
},
|
|
679
|
+
ref: r
|
|
680
|
+
}, [i("div", {
|
|
681
|
+
class: `${s}-modal-header`,
|
|
682
|
+
ref: n
|
|
683
|
+
}, [d || ""]), i("div", {
|
|
684
|
+
class: `${s}-modal-body`
|
|
685
|
+
}, [u]), i("div", {
|
|
686
|
+
class: `${s}-modal-func`
|
|
687
|
+
}, [e.showAdjust && i("div", {
|
|
688
|
+
class: `${s}-modal-adjust`,
|
|
689
|
+
onClick: (f) => {
|
|
690
|
+
f.stopPropagation(), e.isFullscreen ? c.initPos = c.historyPos : (c.historyPos = c.initPos, c.initPos = {
|
|
691
|
+
left: "0",
|
|
692
|
+
top: "0"
|
|
693
|
+
}), e.onAdjust(!e.isFullscreen);
|
|
694
|
+
}
|
|
695
|
+
}, [i("svg", {
|
|
696
|
+
class: `${s}-icon`,
|
|
697
|
+
"aria-hidden": "true"
|
|
698
|
+
}, [i("use", {
|
|
699
|
+
"xlink:href": `#md-editor-icon-${e.isFullscreen ? "suoxiao" : "fangda"}`
|
|
700
|
+
}, null)])]), i("div", {
|
|
701
|
+
class: `${s}-modal-close`,
|
|
702
|
+
onClick: (f) => {
|
|
703
|
+
f.stopPropagation(), e.onClose && e.onClose();
|
|
704
|
+
}
|
|
705
|
+
}, [i("svg", {
|
|
706
|
+
class: `${s}-icon`,
|
|
707
|
+
"aria-hidden": "true"
|
|
708
|
+
}, [i("use", {
|
|
709
|
+
"xlink:href": "#md-editor-icon-close"
|
|
710
|
+
}, null)])])])])]);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
}), vl = {
|
|
714
|
+
type: {
|
|
715
|
+
type: String,
|
|
716
|
+
default: "link"
|
|
717
|
+
},
|
|
718
|
+
visible: {
|
|
719
|
+
type: Boolean,
|
|
720
|
+
default: !1
|
|
721
|
+
},
|
|
722
|
+
onCancel: {
|
|
723
|
+
type: Function,
|
|
724
|
+
default: () => {
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
onOk: {
|
|
728
|
+
type: Function,
|
|
729
|
+
default: () => {
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}, pl = /* @__PURE__ */ M({
|
|
733
|
+
props: vl,
|
|
734
|
+
setup(e) {
|
|
735
|
+
const t = x("usedLanguageText"), o = x("editorId"), l = D(() => {
|
|
736
|
+
var n, a;
|
|
737
|
+
switch (e.type) {
|
|
738
|
+
case "link":
|
|
739
|
+
return (n = t.value.linkModalTips) == null ? void 0 : n.linkTitle;
|
|
740
|
+
case "image":
|
|
741
|
+
return (a = t.value.linkModalTips) == null ? void 0 : a.imageTitle;
|
|
742
|
+
default:
|
|
743
|
+
return "";
|
|
744
|
+
}
|
|
745
|
+
}), r = N({
|
|
746
|
+
desc: "",
|
|
747
|
+
url: ""
|
|
748
|
+
});
|
|
749
|
+
return T(() => e.visible, (n) => {
|
|
750
|
+
n || setTimeout(() => {
|
|
751
|
+
r.desc = "", r.url = "";
|
|
752
|
+
}, 200);
|
|
753
|
+
}), () => i(Te, {
|
|
754
|
+
title: l.value,
|
|
755
|
+
visible: e.visible,
|
|
756
|
+
onClose: e.onCancel
|
|
757
|
+
}, {
|
|
758
|
+
default: () => {
|
|
759
|
+
var n, a, c, m, u;
|
|
760
|
+
return [i("div", {
|
|
761
|
+
class: `${s}-form-item`
|
|
762
|
+
}, [i("label", {
|
|
763
|
+
class: `${s}-label`,
|
|
764
|
+
for: `link-desc-${o}`
|
|
765
|
+
}, [(n = t.value.linkModalTips) == null ? void 0 : n.descLabel]), i("input", {
|
|
766
|
+
placeholder: (a = t.value.linkModalTips) == null ? void 0 : a.descLabelPlaceHolder,
|
|
767
|
+
class: `${s}-input`,
|
|
768
|
+
id: `link-desc-${o}`,
|
|
769
|
+
type: "text",
|
|
770
|
+
value: r.desc,
|
|
771
|
+
onChange: (d) => {
|
|
772
|
+
r.desc = d.target.value;
|
|
773
|
+
},
|
|
774
|
+
autocomplete: "off"
|
|
775
|
+
}, null)]), i("div", {
|
|
776
|
+
class: `${s}-form-item`
|
|
777
|
+
}, [i("label", {
|
|
778
|
+
class: `${s}-label`,
|
|
779
|
+
for: `link-url-${o}`
|
|
780
|
+
}, [(c = t.value.linkModalTips) == null ? void 0 : c.urlLabel]), i("input", {
|
|
781
|
+
placeholder: (m = t.value.linkModalTips) == null ? void 0 : m.urlLabelPlaceHolder,
|
|
782
|
+
class: `${s}-input`,
|
|
783
|
+
id: `link-url-${o}`,
|
|
784
|
+
type: "text",
|
|
785
|
+
value: r.url,
|
|
786
|
+
onChange: (d) => {
|
|
787
|
+
r.url = d.target.value;
|
|
788
|
+
},
|
|
789
|
+
autocomplete: "off"
|
|
790
|
+
}, null)]), i("div", {
|
|
791
|
+
class: `${s}-form-item`
|
|
792
|
+
}, [i("button", {
|
|
793
|
+
class: [`${s}-btn`, `${s}-btn-row`],
|
|
794
|
+
type: "button",
|
|
795
|
+
onClick: () => {
|
|
796
|
+
e.onOk(r), r.desc = "", r.url = "";
|
|
797
|
+
}
|
|
798
|
+
}, [(u = t.value.linkModalTips) == null ? void 0 : u.buttonOK])])];
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
const bl = {
|
|
804
|
+
visible: {
|
|
805
|
+
type: Boolean,
|
|
806
|
+
default: !1
|
|
807
|
+
},
|
|
808
|
+
onCancel: {
|
|
809
|
+
type: Function,
|
|
810
|
+
default: () => {
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
onOk: {
|
|
814
|
+
type: Function,
|
|
815
|
+
default: () => {
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}, kl = /* @__PURE__ */ M({
|
|
819
|
+
props: bl,
|
|
820
|
+
setup(e) {
|
|
821
|
+
var d, f;
|
|
822
|
+
const t = x("usedLanguageText"), o = x("editorId");
|
|
823
|
+
let l = (f = (d = I == null ? void 0 : I.editorExtensions) == null ? void 0 : d.cropper) == null ? void 0 : f.instance;
|
|
824
|
+
const r = F(), n = F(), a = F(), c = N({
|
|
825
|
+
cropperInited: !1,
|
|
826
|
+
imgSelected: !1,
|
|
827
|
+
imgSrc: "",
|
|
828
|
+
// 是否全屏
|
|
829
|
+
isFullscreen: !1
|
|
830
|
+
});
|
|
831
|
+
let m = null;
|
|
832
|
+
T(() => e.visible, () => {
|
|
833
|
+
e.visible && !c.cropperInited && (l = l || window.Cropper, r.value.onchange = () => {
|
|
834
|
+
if (!l) {
|
|
835
|
+
C.emit(o, "errorCatcher", {
|
|
836
|
+
name: "Cropper",
|
|
837
|
+
message: "Cropper is undefined"
|
|
838
|
+
});
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
const h = r.value.files || [];
|
|
842
|
+
if (c.imgSelected = !0, (h == null ? void 0 : h.length) > 0) {
|
|
843
|
+
const v = new FileReader();
|
|
844
|
+
v.onload = (b) => {
|
|
845
|
+
c.imgSrc = b.target.result, q(() => {
|
|
846
|
+
m = new l(n.value, {
|
|
847
|
+
viewMode: 2,
|
|
848
|
+
preview: `.${s}-clip-preview-target`
|
|
849
|
+
// aspectRatio: 16 / 9,
|
|
850
|
+
});
|
|
851
|
+
});
|
|
852
|
+
}, v.readAsDataURL(h[0]);
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}), T(() => [c.imgSelected], () => {
|
|
856
|
+
a.value.style = "";
|
|
857
|
+
}), T(() => c.isFullscreen, () => {
|
|
858
|
+
q(() => {
|
|
859
|
+
m == null || m.destroy(), a.value.style = "", n.value && (m = new l(n.value, {
|
|
860
|
+
viewMode: 2,
|
|
861
|
+
preview: `.${s}-clip-preview-target`
|
|
862
|
+
// aspectRatio: 16 / 9,
|
|
863
|
+
}));
|
|
864
|
+
});
|
|
865
|
+
});
|
|
866
|
+
const u = () => {
|
|
867
|
+
m.clear(), m.destroy(), m = null, r.value.value = "", c.imgSelected = !1;
|
|
868
|
+
};
|
|
869
|
+
return () => {
|
|
870
|
+
var h;
|
|
871
|
+
return i(Te, {
|
|
872
|
+
class: `${s}-modal-clip`,
|
|
873
|
+
title: (h = t.value.clipModalTips) == null ? void 0 : h.title,
|
|
874
|
+
visible: e.visible,
|
|
875
|
+
onClose: e.onCancel,
|
|
876
|
+
showAdjust: !0,
|
|
877
|
+
isFullscreen: c.isFullscreen,
|
|
878
|
+
onAdjust: (v) => {
|
|
879
|
+
c.isFullscreen = v;
|
|
880
|
+
},
|
|
881
|
+
width: "668px",
|
|
882
|
+
height: "421px"
|
|
883
|
+
}, {
|
|
884
|
+
default: () => {
|
|
885
|
+
var v, b;
|
|
886
|
+
return [i("div", {
|
|
887
|
+
class: `${s}-form-item ${s}-clip`
|
|
888
|
+
}, [i("div", {
|
|
889
|
+
class: `${s}-clip-main`
|
|
890
|
+
}, [c.imgSelected ? i("div", {
|
|
891
|
+
class: `${s}-clip-cropper`
|
|
892
|
+
}, [i("img", {
|
|
893
|
+
src: c.imgSrc,
|
|
894
|
+
ref: n,
|
|
895
|
+
style: {
|
|
896
|
+
display: "none"
|
|
897
|
+
},
|
|
898
|
+
alt: ""
|
|
899
|
+
}, null), i("div", {
|
|
900
|
+
class: `${s}-clip-delete`,
|
|
901
|
+
onClick: u
|
|
902
|
+
}, [i("svg", {
|
|
903
|
+
class: `${s}-icon`,
|
|
904
|
+
"aria-hidden": "true"
|
|
905
|
+
}, [i("use", {
|
|
906
|
+
"xlink:href": "#md-editor-icon-delete"
|
|
907
|
+
}, null)])])]) : i("div", {
|
|
908
|
+
class: `${s}-clip-upload`,
|
|
909
|
+
onClick: () => {
|
|
910
|
+
r.value.click();
|
|
911
|
+
}
|
|
912
|
+
}, [i("svg", {
|
|
913
|
+
class: `${s}-icon`,
|
|
914
|
+
"aria-hidden": "true"
|
|
915
|
+
}, [i("use", {
|
|
916
|
+
"xlink:href": "#md-editor-icon-upload"
|
|
917
|
+
}, null)])])]), i("div", {
|
|
918
|
+
class: `${s}-clip-preview`
|
|
919
|
+
}, [i("div", {
|
|
920
|
+
class: `${s}-clip-preview-target`,
|
|
921
|
+
ref: a
|
|
922
|
+
}, null)])]), i("div", {
|
|
923
|
+
class: `${s}-form-item`
|
|
924
|
+
}, [i("button", {
|
|
925
|
+
class: `${s}-btn`,
|
|
926
|
+
type: "button",
|
|
927
|
+
onClick: () => {
|
|
928
|
+
if (m) {
|
|
929
|
+
const k = m.getCroppedCanvas();
|
|
930
|
+
C.emit(o, "uploadImage", [rl(k.toDataURL("image/png"))], e.onOk), u();
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}, [((v = t.value.clipModalTips) == null ? void 0 : v.buttonUpload) || ((b = t.value.linkModalTips) == null ? void 0 : b.buttonOK)])]), i("input", {
|
|
934
|
+
ref: r,
|
|
935
|
+
accept: "image/*",
|
|
936
|
+
type: "file",
|
|
937
|
+
multiple: !1,
|
|
938
|
+
style: {
|
|
939
|
+
display: "none"
|
|
940
|
+
}
|
|
941
|
+
}, null)];
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
}), yl = {
|
|
947
|
+
type: {
|
|
948
|
+
type: String,
|
|
949
|
+
default: "link"
|
|
950
|
+
},
|
|
951
|
+
linkVisible: {
|
|
952
|
+
type: Boolean,
|
|
953
|
+
default: !1
|
|
954
|
+
},
|
|
955
|
+
clipVisible: {
|
|
956
|
+
type: Boolean,
|
|
957
|
+
default: !1
|
|
958
|
+
},
|
|
959
|
+
onCancel: {
|
|
960
|
+
type: Function,
|
|
961
|
+
default: () => {
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
onOk: {
|
|
965
|
+
type: Function,
|
|
966
|
+
default: () => {
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}, Cl = /* @__PURE__ */ M({
|
|
970
|
+
props: yl,
|
|
971
|
+
setup(e) {
|
|
972
|
+
return () => i(Ce, null, [i(pl, {
|
|
973
|
+
type: e.type,
|
|
974
|
+
visible: e.linkVisible,
|
|
975
|
+
onOk: e.onOk,
|
|
976
|
+
onCancel: e.onCancel
|
|
977
|
+
}, null), i(kl, {
|
|
978
|
+
visible: e.clipVisible,
|
|
979
|
+
onOk: e.onOk,
|
|
980
|
+
onCancel: e.onCancel
|
|
981
|
+
}, null)]);
|
|
982
|
+
}
|
|
983
|
+
}), $l = /* @__PURE__ */ M({
|
|
984
|
+
name: "MDEditorToolbar",
|
|
985
|
+
props: dl,
|
|
986
|
+
setup(e) {
|
|
987
|
+
const t = x("editorId"), o = x("usedLanguageText"), {
|
|
988
|
+
fullscreenHandler: l
|
|
989
|
+
} = ml(e), r = `${t}-toolbar-wrapper`, n = N({
|
|
990
|
+
title: !1,
|
|
991
|
+
catalog: !1,
|
|
992
|
+
// 图片上传下拉
|
|
993
|
+
image: !1,
|
|
994
|
+
// 表格预选
|
|
995
|
+
table: !1,
|
|
996
|
+
// mermaid
|
|
997
|
+
mermaid: !1,
|
|
998
|
+
katex: !1
|
|
999
|
+
}), a = (v, b) => {
|
|
1000
|
+
C.emit(t, "replace", v, b);
|
|
1001
|
+
}, c = N({
|
|
1002
|
+
type: "link",
|
|
1003
|
+
linkVisible: !1,
|
|
1004
|
+
clipVisible: !1
|
|
1005
|
+
}), m = F();
|
|
1006
|
+
A(() => {
|
|
1007
|
+
C.on(t, {
|
|
1008
|
+
name: "openModals",
|
|
1009
|
+
callback(v) {
|
|
1010
|
+
c.type = v, c.linkVisible = !0;
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
});
|
|
1014
|
+
const u = D(() => {
|
|
1015
|
+
const v = e.toolbars.filter((y) => !e.toolbarsExclude.includes(y)), b = v.indexOf("="), k = b === -1 ? v : v.slice(0, b + 1), p = b === -1 ? [] : v.slice(b, Number.MAX_SAFE_INTEGER);
|
|
1016
|
+
return [k, p];
|
|
1017
|
+
}), d = F(), f = () => {
|
|
1018
|
+
C.emit(t, "uploadImage", Array.from(d.value.files || [])), d.value.value = "";
|
|
1019
|
+
};
|
|
1020
|
+
A(() => {
|
|
1021
|
+
d.value.addEventListener("change", f);
|
|
1022
|
+
});
|
|
1023
|
+
const h = (v) => {
|
|
1024
|
+
var b, k, p, y, $, w, L, S, B, P, W, ee, Z, K, R, X, j, V, te, re, Se, xe, Ee, Le, He, Ie, Ae, Fe, Me, je, Be, Pe, Re, Oe, De, Ne, _e, Ve, Ue, qe, We, Ge, ze;
|
|
1025
|
+
if ($t.includes(v))
|
|
1026
|
+
switch (v) {
|
|
1027
|
+
case "-":
|
|
1028
|
+
return i(tl, null, null);
|
|
1029
|
+
case "bold":
|
|
1030
|
+
return i("div", {
|
|
1031
|
+
class: `${s}-toolbar-item`,
|
|
1032
|
+
title: (b = o.value.toolbarTips) == null ? void 0 : b.bold,
|
|
1033
|
+
onClick: () => {
|
|
1034
|
+
a("bold");
|
|
1035
|
+
}
|
|
1036
|
+
}, [i("svg", {
|
|
1037
|
+
class: `${s}-icon`,
|
|
1038
|
+
"aria-hidden": "true"
|
|
1039
|
+
}, [i("use", {
|
|
1040
|
+
"xlink:href": "#md-editor-icon-bold"
|
|
1041
|
+
}, null)])]);
|
|
1042
|
+
case "underline":
|
|
1043
|
+
return i("div", {
|
|
1044
|
+
class: `${s}-toolbar-item`,
|
|
1045
|
+
title: (k = o.value.toolbarTips) == null ? void 0 : k.underline,
|
|
1046
|
+
onClick: () => {
|
|
1047
|
+
a("underline");
|
|
1048
|
+
}
|
|
1049
|
+
}, [i("svg", {
|
|
1050
|
+
class: `${s}-icon`,
|
|
1051
|
+
"aria-hidden": "true"
|
|
1052
|
+
}, [i("use", {
|
|
1053
|
+
"xlink:href": "#md-editor-icon-underline"
|
|
1054
|
+
}, null)])]);
|
|
1055
|
+
case "italic":
|
|
1056
|
+
return i("div", {
|
|
1057
|
+
class: `${s}-toolbar-item`,
|
|
1058
|
+
title: (p = o.value.toolbarTips) == null ? void 0 : p.italic,
|
|
1059
|
+
onClick: () => {
|
|
1060
|
+
a("italic");
|
|
1061
|
+
}
|
|
1062
|
+
}, [i("svg", {
|
|
1063
|
+
class: `${s}-icon`,
|
|
1064
|
+
"aria-hidden": "true"
|
|
1065
|
+
}, [i("use", {
|
|
1066
|
+
"xlink:href": "#md-editor-icon-italic"
|
|
1067
|
+
}, null)])]);
|
|
1068
|
+
case "strikeThrough":
|
|
1069
|
+
return i("div", {
|
|
1070
|
+
class: `${s}-toolbar-item`,
|
|
1071
|
+
title: (y = o.value.toolbarTips) == null ? void 0 : y.strikeThrough,
|
|
1072
|
+
onClick: () => {
|
|
1073
|
+
a("strikeThrough");
|
|
1074
|
+
}
|
|
1075
|
+
}, [i("svg", {
|
|
1076
|
+
class: `${s}-icon`,
|
|
1077
|
+
"aria-hidden": "true"
|
|
1078
|
+
}, [i("use", {
|
|
1079
|
+
"xlink:href": "#md-editor-icon-strike-through"
|
|
1080
|
+
}, null)])]);
|
|
1081
|
+
case "title":
|
|
1082
|
+
return i(Y, {
|
|
1083
|
+
relative: `#${r}`,
|
|
1084
|
+
visible: n.title,
|
|
1085
|
+
onChange: (E) => {
|
|
1086
|
+
n.title = E;
|
|
1087
|
+
},
|
|
1088
|
+
overlay: i("ul", {
|
|
1089
|
+
class: `${s}-menu`,
|
|
1090
|
+
onClick: () => {
|
|
1091
|
+
n.title = !1;
|
|
1092
|
+
}
|
|
1093
|
+
}, [i("li", {
|
|
1094
|
+
class: `${s}-menu-item`,
|
|
1095
|
+
onClick: () => {
|
|
1096
|
+
a("h1");
|
|
1097
|
+
}
|
|
1098
|
+
}, [($ = o.value.titleItem) == null ? void 0 : $.h1]), i("li", {
|
|
1099
|
+
class: `${s}-menu-item`,
|
|
1100
|
+
onClick: () => {
|
|
1101
|
+
a("h2");
|
|
1102
|
+
}
|
|
1103
|
+
}, [(w = o.value.titleItem) == null ? void 0 : w.h2]), i("li", {
|
|
1104
|
+
class: `${s}-menu-item`,
|
|
1105
|
+
onClick: () => {
|
|
1106
|
+
a("h3");
|
|
1107
|
+
}
|
|
1108
|
+
}, [(L = o.value.titleItem) == null ? void 0 : L.h3]), i("li", {
|
|
1109
|
+
class: `${s}-menu-item`,
|
|
1110
|
+
onClick: () => {
|
|
1111
|
+
a("h4");
|
|
1112
|
+
}
|
|
1113
|
+
}, [(S = o.value.titleItem) == null ? void 0 : S.h4]), i("li", {
|
|
1114
|
+
class: `${s}-menu-item`,
|
|
1115
|
+
onClick: () => {
|
|
1116
|
+
a("h5");
|
|
1117
|
+
}
|
|
1118
|
+
}, [(B = o.value.titleItem) == null ? void 0 : B.h5]), i("li", {
|
|
1119
|
+
class: `${s}-menu-item`,
|
|
1120
|
+
onClick: () => {
|
|
1121
|
+
a("h6");
|
|
1122
|
+
}
|
|
1123
|
+
}, [(P = o.value.titleItem) == null ? void 0 : P.h6])])
|
|
1124
|
+
}, {
|
|
1125
|
+
default: () => {
|
|
1126
|
+
var E;
|
|
1127
|
+
return [i("div", {
|
|
1128
|
+
class: `${s}-toolbar-item`,
|
|
1129
|
+
title: (E = o.value.toolbarTips) == null ? void 0 : E.title
|
|
1130
|
+
}, [i("svg", {
|
|
1131
|
+
class: `${s}-icon`,
|
|
1132
|
+
"aria-hidden": "true"
|
|
1133
|
+
}, [i("use", {
|
|
1134
|
+
"xlink:href": "#md-editor-icon-title"
|
|
1135
|
+
}, null)])])];
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
case "sub":
|
|
1139
|
+
return i("div", {
|
|
1140
|
+
class: `${s}-toolbar-item`,
|
|
1141
|
+
title: (W = o.value.toolbarTips) == null ? void 0 : W.sub,
|
|
1142
|
+
onClick: () => {
|
|
1143
|
+
a("sub");
|
|
1144
|
+
}
|
|
1145
|
+
}, [i("svg", {
|
|
1146
|
+
class: `${s}-icon`,
|
|
1147
|
+
"aria-hidden": "true"
|
|
1148
|
+
}, [i("use", {
|
|
1149
|
+
"xlink:href": "#md-editor-icon-sub"
|
|
1150
|
+
}, null)])]);
|
|
1151
|
+
case "sup":
|
|
1152
|
+
return i("div", {
|
|
1153
|
+
class: `${s}-toolbar-item`,
|
|
1154
|
+
title: (ee = o.value.toolbarTips) == null ? void 0 : ee.sup,
|
|
1155
|
+
onClick: () => {
|
|
1156
|
+
a("sup");
|
|
1157
|
+
}
|
|
1158
|
+
}, [i("svg", {
|
|
1159
|
+
class: `${s}-icon`,
|
|
1160
|
+
"aria-hidden": "true"
|
|
1161
|
+
}, [i("use", {
|
|
1162
|
+
"xlink:href": "#md-editor-icon-sup"
|
|
1163
|
+
}, null)])]);
|
|
1164
|
+
case "quote":
|
|
1165
|
+
return i("div", {
|
|
1166
|
+
class: `${s}-toolbar-item`,
|
|
1167
|
+
title: (Z = o.value.toolbarTips) == null ? void 0 : Z.quote,
|
|
1168
|
+
onClick: () => {
|
|
1169
|
+
a("quote");
|
|
1170
|
+
}
|
|
1171
|
+
}, [i("svg", {
|
|
1172
|
+
class: `${s}-icon`,
|
|
1173
|
+
"aria-hidden": "true"
|
|
1174
|
+
}, [i("use", {
|
|
1175
|
+
"xlink:href": "#md-editor-icon-quote"
|
|
1176
|
+
}, null)])]);
|
|
1177
|
+
case "unorderedList":
|
|
1178
|
+
return i("div", {
|
|
1179
|
+
class: `${s}-toolbar-item`,
|
|
1180
|
+
title: (K = o.value.toolbarTips) == null ? void 0 : K.unorderedList,
|
|
1181
|
+
onClick: () => {
|
|
1182
|
+
a("unorderedList");
|
|
1183
|
+
}
|
|
1184
|
+
}, [i("svg", {
|
|
1185
|
+
class: `${s}-icon`,
|
|
1186
|
+
"aria-hidden": "true"
|
|
1187
|
+
}, [i("use", {
|
|
1188
|
+
"xlink:href": "#md-editor-icon-unordered-list"
|
|
1189
|
+
}, null)])]);
|
|
1190
|
+
case "orderedList":
|
|
1191
|
+
return i("div", {
|
|
1192
|
+
class: `${s}-toolbar-item`,
|
|
1193
|
+
title: (R = o.value.toolbarTips) == null ? void 0 : R.orderedList,
|
|
1194
|
+
onClick: () => {
|
|
1195
|
+
a("orderedList");
|
|
1196
|
+
}
|
|
1197
|
+
}, [i("svg", {
|
|
1198
|
+
class: `${s}-icon`,
|
|
1199
|
+
"aria-hidden": "true"
|
|
1200
|
+
}, [i("use", {
|
|
1201
|
+
"xlink:href": "#md-editor-icon-ordered-list"
|
|
1202
|
+
}, null)])]);
|
|
1203
|
+
case "task":
|
|
1204
|
+
return i("div", {
|
|
1205
|
+
class: `${s}-toolbar-item`,
|
|
1206
|
+
title: (X = o.value.toolbarTips) == null ? void 0 : X.task,
|
|
1207
|
+
onClick: () => {
|
|
1208
|
+
a("task");
|
|
1209
|
+
}
|
|
1210
|
+
}, [i("svg", {
|
|
1211
|
+
class: `${s}-icon`,
|
|
1212
|
+
"aria-hidden": "true"
|
|
1213
|
+
}, [i("use", {
|
|
1214
|
+
"xlink:href": "#md-editor-icon-task"
|
|
1215
|
+
}, null)])]);
|
|
1216
|
+
case "codeRow":
|
|
1217
|
+
return i("div", {
|
|
1218
|
+
class: `${s}-toolbar-item`,
|
|
1219
|
+
title: (j = o.value.toolbarTips) == null ? void 0 : j.codeRow,
|
|
1220
|
+
onClick: () => {
|
|
1221
|
+
a("codeRow");
|
|
1222
|
+
}
|
|
1223
|
+
}, [i("svg", {
|
|
1224
|
+
class: `${s}-icon`,
|
|
1225
|
+
"aria-hidden": "true"
|
|
1226
|
+
}, [i("use", {
|
|
1227
|
+
"xlink:href": "#md-editor-icon-code-row"
|
|
1228
|
+
}, null)])]);
|
|
1229
|
+
case "code":
|
|
1230
|
+
return i("div", {
|
|
1231
|
+
class: `${s}-toolbar-item`,
|
|
1232
|
+
title: (V = o.value.toolbarTips) == null ? void 0 : V.code,
|
|
1233
|
+
onClick: () => {
|
|
1234
|
+
a("code");
|
|
1235
|
+
}
|
|
1236
|
+
}, [i("svg", {
|
|
1237
|
+
class: `${s}-icon`,
|
|
1238
|
+
"aria-hidden": "true"
|
|
1239
|
+
}, [i("use", {
|
|
1240
|
+
"xlink:href": "#md-editor-icon-code"
|
|
1241
|
+
}, null)])]);
|
|
1242
|
+
case "link":
|
|
1243
|
+
return i("div", {
|
|
1244
|
+
class: `${s}-toolbar-item`,
|
|
1245
|
+
title: (te = o.value.toolbarTips) == null ? void 0 : te.link,
|
|
1246
|
+
onClick: () => {
|
|
1247
|
+
c.type = "link", c.linkVisible = !0;
|
|
1248
|
+
}
|
|
1249
|
+
}, [i("svg", {
|
|
1250
|
+
class: `${s}-icon`,
|
|
1251
|
+
"aria-hidden": "true"
|
|
1252
|
+
}, [i("use", {
|
|
1253
|
+
"xlink:href": "#md-editor-icon-link"
|
|
1254
|
+
}, null)])]);
|
|
1255
|
+
case "image":
|
|
1256
|
+
return e.noUploadImg ? i("div", {
|
|
1257
|
+
class: `${s}-toolbar-item`,
|
|
1258
|
+
title: (re = o.value.toolbarTips) == null ? void 0 : re.image,
|
|
1259
|
+
onClick: () => {
|
|
1260
|
+
c.type = "image", c.linkVisible = !0;
|
|
1261
|
+
}
|
|
1262
|
+
}, [i("svg", {
|
|
1263
|
+
class: `${s}-icon`,
|
|
1264
|
+
"aria-hidden": "true"
|
|
1265
|
+
}, [i("use", {
|
|
1266
|
+
"xlink:href": "#md-editor-icon-image"
|
|
1267
|
+
}, null)])]) : i(Y, {
|
|
1268
|
+
relative: `#${r}`,
|
|
1269
|
+
visible: n.image,
|
|
1270
|
+
onChange: (E) => {
|
|
1271
|
+
n.image = E;
|
|
1272
|
+
},
|
|
1273
|
+
overlay: i("ul", {
|
|
1274
|
+
class: `${s}-menu`,
|
|
1275
|
+
onClick: () => {
|
|
1276
|
+
n.title = !1;
|
|
1277
|
+
}
|
|
1278
|
+
}, [i("li", {
|
|
1279
|
+
class: `${s}-menu-item`,
|
|
1280
|
+
onClick: () => {
|
|
1281
|
+
c.type = "image", c.linkVisible = !0;
|
|
1282
|
+
}
|
|
1283
|
+
}, [(Se = o.value.imgTitleItem) == null ? void 0 : Se.link]), i("li", {
|
|
1284
|
+
class: `${s}-menu-item`,
|
|
1285
|
+
onClick: () => {
|
|
1286
|
+
d.value.click();
|
|
1287
|
+
}
|
|
1288
|
+
}, [(xe = o.value.imgTitleItem) == null ? void 0 : xe.upload]), i("li", {
|
|
1289
|
+
class: `${s}-menu-item`,
|
|
1290
|
+
onClick: () => {
|
|
1291
|
+
c.clipVisible = !0;
|
|
1292
|
+
}
|
|
1293
|
+
}, [(Ee = o.value.imgTitleItem) == null ? void 0 : Ee.clip2upload])])
|
|
1294
|
+
}, {
|
|
1295
|
+
default: () => {
|
|
1296
|
+
var E;
|
|
1297
|
+
return [i("div", {
|
|
1298
|
+
class: `${s}-toolbar-item`,
|
|
1299
|
+
title: (E = o.value.toolbarTips) == null ? void 0 : E.image
|
|
1300
|
+
}, [i("svg", {
|
|
1301
|
+
class: `${s}-icon`,
|
|
1302
|
+
"aria-hidden": "true"
|
|
1303
|
+
}, [i("use", {
|
|
1304
|
+
"xlink:href": "#md-editor-icon-image"
|
|
1305
|
+
}, null)])])];
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
case "table":
|
|
1309
|
+
return i(Y, {
|
|
1310
|
+
relative: `#${r}`,
|
|
1311
|
+
visible: n.table,
|
|
1312
|
+
onChange: (E) => {
|
|
1313
|
+
n.table = E;
|
|
1314
|
+
},
|
|
1315
|
+
key: "bar-table",
|
|
1316
|
+
overlay: i(gl, {
|
|
1317
|
+
tableShape: e.tableShape,
|
|
1318
|
+
onSelected: (E) => {
|
|
1319
|
+
a("table", {
|
|
1320
|
+
selectedShape: E
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
}, null)
|
|
1324
|
+
}, {
|
|
1325
|
+
default: () => {
|
|
1326
|
+
var E;
|
|
1327
|
+
return [i("div", {
|
|
1328
|
+
class: `${s}-toolbar-item`,
|
|
1329
|
+
title: (E = o.value.toolbarTips) == null ? void 0 : E.table
|
|
1330
|
+
}, [i("svg", {
|
|
1331
|
+
class: `${s}-icon`,
|
|
1332
|
+
"aria-hidden": "true"
|
|
1333
|
+
}, [i("use", {
|
|
1334
|
+
"xlink:href": "#md-editor-icon-table"
|
|
1335
|
+
}, null)])])];
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
case "revoke":
|
|
1339
|
+
return i("div", {
|
|
1340
|
+
class: `${s}-toolbar-item`,
|
|
1341
|
+
title: (Le = o.value.toolbarTips) == null ? void 0 : Le.revoke,
|
|
1342
|
+
onClick: () => {
|
|
1343
|
+
C.emit(t, "ctrlZ");
|
|
1344
|
+
}
|
|
1345
|
+
}, [i("svg", {
|
|
1346
|
+
class: `${s}-icon`,
|
|
1347
|
+
"aria-hidden": "true"
|
|
1348
|
+
}, [i("use", {
|
|
1349
|
+
"xlink:href": "#md-editor-icon-revoke"
|
|
1350
|
+
}, null)])]);
|
|
1351
|
+
case "next":
|
|
1352
|
+
return i("div", {
|
|
1353
|
+
class: `${s}-toolbar-item`,
|
|
1354
|
+
title: (He = o.value.toolbarTips) == null ? void 0 : He.next,
|
|
1355
|
+
onClick: () => {
|
|
1356
|
+
C.emit(t, "ctrlShiftZ");
|
|
1357
|
+
}
|
|
1358
|
+
}, [i("svg", {
|
|
1359
|
+
class: `${s}-icon`,
|
|
1360
|
+
"aria-hidden": "true"
|
|
1361
|
+
}, [i("use", {
|
|
1362
|
+
"xlink:href": "#md-editor-icon-next"
|
|
1363
|
+
}, null)])]);
|
|
1364
|
+
case "save":
|
|
1365
|
+
return i("div", {
|
|
1366
|
+
class: `${s}-toolbar-item`,
|
|
1367
|
+
title: (Ie = o.value.toolbarTips) == null ? void 0 : Ie.save,
|
|
1368
|
+
onClick: () => {
|
|
1369
|
+
C.emit(t, me);
|
|
1370
|
+
}
|
|
1371
|
+
}, [i("svg", {
|
|
1372
|
+
class: `${s}-icon`,
|
|
1373
|
+
"aria-hidden": "true"
|
|
1374
|
+
}, [i("use", {
|
|
1375
|
+
"xlink:href": "#md-editor-icon-baocun"
|
|
1376
|
+
}, null)])]);
|
|
1377
|
+
case "prettier":
|
|
1378
|
+
return e.noPrettier ? "" : i("div", {
|
|
1379
|
+
class: `${s}-toolbar-item`,
|
|
1380
|
+
title: (Ae = o.value.toolbarTips) == null ? void 0 : Ae.prettier,
|
|
1381
|
+
onClick: () => {
|
|
1382
|
+
a("prettier");
|
|
1383
|
+
}
|
|
1384
|
+
}, [i("svg", {
|
|
1385
|
+
class: `${s}-icon`,
|
|
1386
|
+
"aria-hidden": "true"
|
|
1387
|
+
}, [i("use", {
|
|
1388
|
+
"xlink:href": "#md-editor-icon-prettier"
|
|
1389
|
+
}, null)])]);
|
|
1390
|
+
case "pageFullscreen":
|
|
1391
|
+
return !e.setting.fullscreen && i("div", {
|
|
1392
|
+
class: `${s}-toolbar-item`,
|
|
1393
|
+
title: (Fe = o.value.toolbarTips) == null ? void 0 : Fe.pageFullscreen,
|
|
1394
|
+
onClick: () => {
|
|
1395
|
+
e.updateSetting("pageFullscreen");
|
|
1396
|
+
}
|
|
1397
|
+
}, [i("svg", {
|
|
1398
|
+
class: `${s}-icon`,
|
|
1399
|
+
"aria-hidden": "true"
|
|
1400
|
+
}, [i("use", {
|
|
1401
|
+
"xlink:href": `#md-editor-icon-${e.setting.pageFullscreen ? "suoxiao" : "fangda"}`
|
|
1402
|
+
}, null)])]);
|
|
1403
|
+
case "fullscreen":
|
|
1404
|
+
return i("div", {
|
|
1405
|
+
class: `${s}-toolbar-item`,
|
|
1406
|
+
title: (Me = o.value.toolbarTips) == null ? void 0 : Me.fullscreen,
|
|
1407
|
+
onClick: () => {
|
|
1408
|
+
l();
|
|
1409
|
+
}
|
|
1410
|
+
}, [i("svg", {
|
|
1411
|
+
class: `${s}-icon`,
|
|
1412
|
+
"aria-hidden": "true"
|
|
1413
|
+
}, [i("use", {
|
|
1414
|
+
"xlink:href": `#md-editor-icon-${e.setting.fullscreen ? "fullscreen-exit" : "fullscreen"}`
|
|
1415
|
+
}, null)])]);
|
|
1416
|
+
case "preview":
|
|
1417
|
+
return i("div", {
|
|
1418
|
+
class: `${s}-toolbar-item`,
|
|
1419
|
+
title: (je = o.value.toolbarTips) == null ? void 0 : je.preview,
|
|
1420
|
+
onClick: () => {
|
|
1421
|
+
e.updateSetting("preview");
|
|
1422
|
+
}
|
|
1423
|
+
}, [i("svg", {
|
|
1424
|
+
class: `${s}-icon`,
|
|
1425
|
+
"aria-hidden": "true"
|
|
1426
|
+
}, [i("use", {
|
|
1427
|
+
"xlink:href": "#md-editor-icon-preview"
|
|
1428
|
+
}, null)])]);
|
|
1429
|
+
case "htmlPreview":
|
|
1430
|
+
return i("div", {
|
|
1431
|
+
class: `${s}-toolbar-item`,
|
|
1432
|
+
title: (Be = o.value.toolbarTips) == null ? void 0 : Be.htmlPreview,
|
|
1433
|
+
onClick: () => {
|
|
1434
|
+
e.updateSetting("htmlPreview");
|
|
1435
|
+
}
|
|
1436
|
+
}, [i("svg", {
|
|
1437
|
+
class: `${s}-icon`,
|
|
1438
|
+
"aria-hidden": "true"
|
|
1439
|
+
}, [i("use", {
|
|
1440
|
+
"xlink:href": "#md-editor-icon-coding"
|
|
1441
|
+
}, null)])]);
|
|
1442
|
+
case "catalog":
|
|
1443
|
+
return i("div", {
|
|
1444
|
+
class: `${s}-toolbar-item`,
|
|
1445
|
+
title: (Pe = o.value.toolbarTips) == null ? void 0 : Pe.catalog,
|
|
1446
|
+
onClick: () => {
|
|
1447
|
+
C.emit(t, we);
|
|
1448
|
+
},
|
|
1449
|
+
key: "bar-catalog"
|
|
1450
|
+
}, [i("svg", {
|
|
1451
|
+
class: `${s}-icon`,
|
|
1452
|
+
"aria-hidden": "true"
|
|
1453
|
+
}, [i("use", {
|
|
1454
|
+
"xlink:href": "#md-editor-icon-catalog"
|
|
1455
|
+
}, null)])]);
|
|
1456
|
+
case "github":
|
|
1457
|
+
return i("div", {
|
|
1458
|
+
class: `${s}-toolbar-item`,
|
|
1459
|
+
title: (Re = o.value.toolbarTips) == null ? void 0 : Re.github,
|
|
1460
|
+
onClick: () => nl("https://github.com/imzbf/md-editor-v3")
|
|
1461
|
+
}, [i("svg", {
|
|
1462
|
+
class: `${s}-icon`,
|
|
1463
|
+
"aria-hidden": "true"
|
|
1464
|
+
}, [i("use", {
|
|
1465
|
+
"xlink:href": "#md-editor-icon-github"
|
|
1466
|
+
}, null)])]);
|
|
1467
|
+
case "mermaid":
|
|
1468
|
+
return i(Y, {
|
|
1469
|
+
relative: `#${r}`,
|
|
1470
|
+
visible: n.mermaid,
|
|
1471
|
+
onChange: (E) => {
|
|
1472
|
+
n.mermaid = E;
|
|
1473
|
+
},
|
|
1474
|
+
overlay: i("ul", {
|
|
1475
|
+
class: `${s}-menu`,
|
|
1476
|
+
onClick: () => {
|
|
1477
|
+
n.mermaid = !1;
|
|
1478
|
+
}
|
|
1479
|
+
}, [i("li", {
|
|
1480
|
+
class: `${s}-menu-item`,
|
|
1481
|
+
onClick: () => {
|
|
1482
|
+
a("flow");
|
|
1483
|
+
}
|
|
1484
|
+
}, [(Oe = o.value.mermaid) == null ? void 0 : Oe.flow]), i("li", {
|
|
1485
|
+
class: `${s}-menu-item`,
|
|
1486
|
+
onClick: () => {
|
|
1487
|
+
a("sequence");
|
|
1488
|
+
}
|
|
1489
|
+
}, [(De = o.value.mermaid) == null ? void 0 : De.sequence]), i("li", {
|
|
1490
|
+
class: `${s}-menu-item`,
|
|
1491
|
+
onClick: () => {
|
|
1492
|
+
a("gantt");
|
|
1493
|
+
}
|
|
1494
|
+
}, [(Ne = o.value.mermaid) == null ? void 0 : Ne.gantt]), i("li", {
|
|
1495
|
+
class: `${s}-menu-item`,
|
|
1496
|
+
onClick: () => {
|
|
1497
|
+
a("class");
|
|
1498
|
+
}
|
|
1499
|
+
}, [(_e = o.value.mermaid) == null ? void 0 : _e.class]), i("li", {
|
|
1500
|
+
class: `${s}-menu-item`,
|
|
1501
|
+
onClick: () => {
|
|
1502
|
+
a("state");
|
|
1503
|
+
}
|
|
1504
|
+
}, [(Ve = o.value.mermaid) == null ? void 0 : Ve.state]), i("li", {
|
|
1505
|
+
class: `${s}-menu-item`,
|
|
1506
|
+
onClick: () => {
|
|
1507
|
+
a("pie");
|
|
1508
|
+
}
|
|
1509
|
+
}, [(Ue = o.value.mermaid) == null ? void 0 : Ue.pie]), i("li", {
|
|
1510
|
+
class: `${s}-menu-item`,
|
|
1511
|
+
onClick: () => {
|
|
1512
|
+
a("relationship");
|
|
1513
|
+
}
|
|
1514
|
+
}, [(qe = o.value.mermaid) == null ? void 0 : qe.relationship]), i("li", {
|
|
1515
|
+
class: `${s}-menu-item`,
|
|
1516
|
+
onClick: () => {
|
|
1517
|
+
a("journey");
|
|
1518
|
+
}
|
|
1519
|
+
}, [(We = o.value.mermaid) == null ? void 0 : We.journey])]),
|
|
1520
|
+
key: "bar-mermaid"
|
|
1521
|
+
}, {
|
|
1522
|
+
default: () => {
|
|
1523
|
+
var E;
|
|
1524
|
+
return [i("div", {
|
|
1525
|
+
class: `${s}-toolbar-item`,
|
|
1526
|
+
title: (E = o.value.toolbarTips) == null ? void 0 : E.mermaid
|
|
1527
|
+
}, [i("svg", {
|
|
1528
|
+
class: `${s}-icon`,
|
|
1529
|
+
"aria-hidden": "true"
|
|
1530
|
+
}, [i("use", {
|
|
1531
|
+
"xlink:href": "#md-editor-icon-mermaid"
|
|
1532
|
+
}, null)])])];
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
case "katex":
|
|
1536
|
+
return i(Y, {
|
|
1537
|
+
relative: `#${r}`,
|
|
1538
|
+
visible: n.katex,
|
|
1539
|
+
onChange: (E) => {
|
|
1540
|
+
n.katex = E;
|
|
1541
|
+
},
|
|
1542
|
+
overlay: i("ul", {
|
|
1543
|
+
class: `${s}-menu`,
|
|
1544
|
+
onClick: () => {
|
|
1545
|
+
n.katex = !1;
|
|
1546
|
+
}
|
|
1547
|
+
}, [i("li", {
|
|
1548
|
+
class: `${s}-menu-item`,
|
|
1549
|
+
onClick: () => {
|
|
1550
|
+
a("katexInline");
|
|
1551
|
+
}
|
|
1552
|
+
}, [(Ge = o.value.katex) == null ? void 0 : Ge.inline]), i("li", {
|
|
1553
|
+
class: `${s}-menu-item`,
|
|
1554
|
+
onClick: () => {
|
|
1555
|
+
a("katexBlock");
|
|
1556
|
+
}
|
|
1557
|
+
}, [(ze = o.value.katex) == null ? void 0 : ze.block])]),
|
|
1558
|
+
key: "bar-katex"
|
|
1559
|
+
}, {
|
|
1560
|
+
default: () => {
|
|
1561
|
+
var E;
|
|
1562
|
+
return [i("div", {
|
|
1563
|
+
class: `${s}-toolbar-item`,
|
|
1564
|
+
title: (E = o.value.toolbarTips) == null ? void 0 : E.katex
|
|
1565
|
+
}, [i("svg", {
|
|
1566
|
+
class: `${s}-icon`,
|
|
1567
|
+
"aria-hidden": "true"
|
|
1568
|
+
}, [i("use", {
|
|
1569
|
+
"xlink:href": "#md-editor-icon-formula"
|
|
1570
|
+
}, null)])])];
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
else
|
|
1575
|
+
return e.defToolbars instanceof Array ? e.defToolbars[v] || "" : e.defToolbars && e.defToolbars.children instanceof Array && e.defToolbars.children[v] || "";
|
|
1576
|
+
};
|
|
1577
|
+
return () => {
|
|
1578
|
+
const v = u.value[0].map((k) => h(k)), b = u.value[1].map((k) => h(k));
|
|
1579
|
+
return i(Ce, null, [e.toolbars.length > 0 && i("div", {
|
|
1580
|
+
class: `${s}-toolbar-wrapper`,
|
|
1581
|
+
id: r
|
|
1582
|
+
}, [i("div", {
|
|
1583
|
+
class: `${s}-toolbar`
|
|
1584
|
+
}, [i("div", {
|
|
1585
|
+
class: `${s}-toolbar-left`,
|
|
1586
|
+
ref: m
|
|
1587
|
+
}, [v]), i("div", {
|
|
1588
|
+
class: `${s}-toolbar-right`
|
|
1589
|
+
}, [b])])]), i("input", {
|
|
1590
|
+
ref: d,
|
|
1591
|
+
accept: "image/*",
|
|
1592
|
+
type: "file",
|
|
1593
|
+
multiple: !0,
|
|
1594
|
+
style: {
|
|
1595
|
+
display: "none"
|
|
1596
|
+
}
|
|
1597
|
+
}, null), i(Cl, {
|
|
1598
|
+
linkVisible: c.linkVisible,
|
|
1599
|
+
clipVisible: c.clipVisible,
|
|
1600
|
+
type: c.type,
|
|
1601
|
+
onCancel: () => {
|
|
1602
|
+
c.linkVisible = !1, c.clipVisible = !1;
|
|
1603
|
+
},
|
|
1604
|
+
onOk: (k) => {
|
|
1605
|
+
k && a(c.type, {
|
|
1606
|
+
desc: k.desc,
|
|
1607
|
+
url: k.url
|
|
1608
|
+
}), c.linkVisible = !1, c.clipVisible = !1;
|
|
1609
|
+
}
|
|
1610
|
+
}, null)]);
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
}), le = (e, t, o) => {
|
|
1614
|
+
let l = e.scrollTop;
|
|
1615
|
+
const r = () => {
|
|
1616
|
+
const n = t - l;
|
|
1617
|
+
l = l + n / 5, Math.abs(n) < 1 ? (e.scrollTo(0, t), o && o()) : (e.scrollTo(0, l), requestAnimationFrame(r));
|
|
1618
|
+
};
|
|
1619
|
+
r();
|
|
1620
|
+
}, ae = (e) => {
|
|
1621
|
+
const { marginTop: t } = getComputedStyle(e);
|
|
1622
|
+
return e.offsetTop - parseFloat(t);
|
|
1623
|
+
}, nt = (e, t) => {
|
|
1624
|
+
const o = Q(() => {
|
|
1625
|
+
e.removeEventListener("scroll", l), e.addEventListener("scroll", l), t.removeEventListener("scroll", l), t.addEventListener("scroll", l);
|
|
1626
|
+
}, 50), l = (r) => {
|
|
1627
|
+
const n = e.clientHeight, a = t.clientHeight, c = e.scrollHeight, m = t.scrollHeight, u = (c - n) / (m - a);
|
|
1628
|
+
r.target === e ? (t.removeEventListener("scroll", l), t.scrollTo({
|
|
1629
|
+
top: e.scrollTop / u
|
|
1630
|
+
// behavior: 'smooth'
|
|
1631
|
+
}), o()) : (e.removeEventListener("scroll", l), e.scrollTo({
|
|
1632
|
+
top: t.scrollTop * u
|
|
1633
|
+
// behavior: 'smooth'
|
|
1634
|
+
}), o());
|
|
1635
|
+
};
|
|
1636
|
+
return [
|
|
1637
|
+
() => {
|
|
1638
|
+
o().finally(() => {
|
|
1639
|
+
e.dispatchEvent(new Event("scroll"));
|
|
1640
|
+
});
|
|
1641
|
+
},
|
|
1642
|
+
() => {
|
|
1643
|
+
e.removeEventListener("scroll", l), t.removeEventListener("scroll", l);
|
|
1644
|
+
}
|
|
1645
|
+
];
|
|
1646
|
+
}, rt = (e, t, o, l) => {
|
|
1647
|
+
const { view: r } = o;
|
|
1648
|
+
let n = 0;
|
|
1649
|
+
const a = Q(() => {
|
|
1650
|
+
e.removeEventListener("scroll", u), e.addEventListener("scroll", u), t.removeEventListener("scroll", u), t.addEventListener("scroll", u);
|
|
1651
|
+
}, 50);
|
|
1652
|
+
let c = [];
|
|
1653
|
+
const m = () => {
|
|
1654
|
+
c = [];
|
|
1655
|
+
const { width: d, lineHeight: f, fontFamily: h, fontSize: v, whiteSpace: b } = getComputedStyle(
|
|
1656
|
+
document.querySelector(".cm-content")
|
|
1657
|
+
), k = document.createElement("div");
|
|
1658
|
+
k.style.visibility = "none", k.style.zIndex = "-1", k.style.width = d, k.style.lineHeight = f, k.style.fontFamily = h, k.style.fontSize = v, k.style.whiteSpace = b, document.body.appendChild(k);
|
|
1659
|
+
let p = 0;
|
|
1660
|
+
l.split(`
|
|
1661
|
+
`).forEach((y) => {
|
|
1662
|
+
k.innerText = y || "-", p += k.offsetHeight;
|
|
1663
|
+
const $ = {
|
|
1664
|
+
lineHeight: k.offsetHeight,
|
|
1665
|
+
scrollHeight: p
|
|
1666
|
+
};
|
|
1667
|
+
c.push($);
|
|
1668
|
+
}), k.remove();
|
|
1669
|
+
}, u = Q((d) => {
|
|
1670
|
+
var b, k;
|
|
1671
|
+
n++;
|
|
1672
|
+
const f = r.lineBlockAtHeight(r.scrollDOM.scrollTop), h = r.state.doc.lineAt(f.from), v = Array.from(t.children[0].children).filter(
|
|
1673
|
+
(p) => p.hasAttribute("data-line")
|
|
1674
|
+
);
|
|
1675
|
+
if (d.target === e) {
|
|
1676
|
+
if (t.removeEventListener("scroll", u), e.scrollTop + e.clientHeight >= e.scrollHeight) {
|
|
1677
|
+
le(t, t.scrollHeight - t.clientHeight, () => {
|
|
1678
|
+
--n === 0 && a();
|
|
1679
|
+
});
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
const { number: p } = h;
|
|
1683
|
+
let y = (b = t.firstElementChild) == null ? void 0 : b.firstElementChild, $ = 1, w = v.length === 0 ? (k = t.firstElementChild) == null ? void 0 : k.lastElementChild : v[0], L = v.length === 0 ? 0 : Number(v[0].dataset.line);
|
|
1684
|
+
for (let R = 0; R < v.length; R++) {
|
|
1685
|
+
const X = Number(v[R].dataset.line) + 1, j = Number(
|
|
1686
|
+
R + 1 >= v.length ? -2 : v[R + 1].dataset.line
|
|
1687
|
+
);
|
|
1688
|
+
if (p >= X && p <= j) {
|
|
1689
|
+
y = v[R], w = v[R + 1], $ = X, L = j;
|
|
1690
|
+
break;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
if (!y) {
|
|
1694
|
+
n--;
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
const S = (r.scrollDOM.scrollTop - c[$ - 1].scrollHeight + c[$ - 1].lineHeight) / (c[L - 1].scrollHeight - c[$ - 1].scrollHeight + c[$ - 1].lineHeight), { marginTop: B } = getComputedStyle(y), P = y.offsetTop - parseFloat(B), { marginTop: W } = getComputedStyle(w), Z = w.offsetTop - parseFloat(W) - P, K = P + Z * S;
|
|
1698
|
+
le(t, K, () => {
|
|
1699
|
+
--n === 0 && a();
|
|
1700
|
+
});
|
|
1701
|
+
} else {
|
|
1702
|
+
if (e.removeEventListener("scroll", u), t.scrollTop === 0) {
|
|
1703
|
+
le(e, 0, () => {
|
|
1704
|
+
--n === 0 && a();
|
|
1705
|
+
});
|
|
1706
|
+
return;
|
|
1707
|
+
} else if (t.scrollTop + t.clientHeight >= t.scrollHeight) {
|
|
1708
|
+
le(e, e.scrollHeight - e.clientHeight, () => {
|
|
1709
|
+
--n === 0 && a();
|
|
1710
|
+
});
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
const p = t.scrollTop, y = t.scrollHeight;
|
|
1714
|
+
let $ = Math.floor(
|
|
1715
|
+
Number(v[v.length - 1].dataset.line) * (p / y)
|
|
1716
|
+
), w;
|
|
1717
|
+
for (let j = $; j >= 0; j--) {
|
|
1718
|
+
const V = t.querySelector(`[data-line="${j}"]`);
|
|
1719
|
+
if (V) {
|
|
1720
|
+
w = V, $ = j;
|
|
1721
|
+
break;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (!w) {
|
|
1725
|
+
n--;
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
let L, S;
|
|
1729
|
+
for (; ; ) {
|
|
1730
|
+
const j = v.indexOf(w), V = v[j + 1], te = ae(w);
|
|
1731
|
+
if (te > p) {
|
|
1732
|
+
if (j === 0) {
|
|
1733
|
+
L = w, S = V;
|
|
1734
|
+
break;
|
|
1735
|
+
}
|
|
1736
|
+
w = v[j - 1];
|
|
1737
|
+
continue;
|
|
1738
|
+
}
|
|
1739
|
+
const re = ae(V);
|
|
1740
|
+
if (te <= p && re > p) {
|
|
1741
|
+
L = w, S = V;
|
|
1742
|
+
break;
|
|
1743
|
+
}
|
|
1744
|
+
w = V;
|
|
1745
|
+
}
|
|
1746
|
+
const B = ae(L), P = ae(S), W = (p - B) / (P - B), ee = Number(L.dataset.line), Z = Number(S.dataset.line), K = c[ee].scrollHeight, X = c[Z].scrollHeight - K;
|
|
1747
|
+
le(e, K + X * W, () => {
|
|
1748
|
+
--n === 0 && a();
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
}, 6);
|
|
1752
|
+
return [
|
|
1753
|
+
() => {
|
|
1754
|
+
m(), a().finally(() => {
|
|
1755
|
+
e.dispatchEvent(new Event("scroll"));
|
|
1756
|
+
});
|
|
1757
|
+
},
|
|
1758
|
+
() => {
|
|
1759
|
+
n = 0, e.removeEventListener("scroll", u), t.removeEventListener("scroll", u);
|
|
1760
|
+
}
|
|
1761
|
+
];
|
|
1762
|
+
}, wl = (e, t, o, l, r) => {
|
|
1763
|
+
const n = x("previewOnly");
|
|
1764
|
+
let a = () => {
|
|
1765
|
+
}, c = () => {
|
|
1766
|
+
};
|
|
1767
|
+
const m = () => {
|
|
1768
|
+
q(() => {
|
|
1769
|
+
(e.setting.preview || e.setting.htmlPreview) && !n && e.scrollAuto && (a(), c());
|
|
1770
|
+
});
|
|
1771
|
+
}, u = (d) => {
|
|
1772
|
+
d && !n && q(() => {
|
|
1773
|
+
a();
|
|
1774
|
+
const f = document.querySelector(".cm-scroller");
|
|
1775
|
+
[c, a] = (o.value ? rt : nt)(
|
|
1776
|
+
f,
|
|
1777
|
+
o.value || l.value,
|
|
1778
|
+
r.value,
|
|
1779
|
+
e.value
|
|
1780
|
+
), c();
|
|
1781
|
+
});
|
|
1782
|
+
};
|
|
1783
|
+
T(() => t.value, m), T(() => e.setting.preview, u), T(() => e.setting.htmlPreview, u), T(
|
|
1784
|
+
[ce(e.setting, "fullscreen"), ce(e.setting, "pageFullscreen")],
|
|
1785
|
+
m
|
|
1786
|
+
), T(
|
|
1787
|
+
() => e.scrollAuto,
|
|
1788
|
+
(d) => {
|
|
1789
|
+
d ? c() : a();
|
|
1790
|
+
}
|
|
1791
|
+
), A(() => {
|
|
1792
|
+
const d = document.querySelector(".cm-scroller");
|
|
1793
|
+
!n && (o.value || l.value) && ([c, a] = (o.value ? rt : nt)(
|
|
1794
|
+
d,
|
|
1795
|
+
o.value || l.value,
|
|
1796
|
+
r.value,
|
|
1797
|
+
e.value
|
|
1798
|
+
)), e.scrollAuto && c();
|
|
1799
|
+
});
|
|
1800
|
+
}, Tl = (e, t, o) => {
|
|
1801
|
+
var d, f, h, v, b, k;
|
|
1802
|
+
let l = "", r = 0, n = 0, a = !0, c = !1;
|
|
1803
|
+
const m = t.getSelectedText(), u = (d = I.editorConfig) == null ? void 0 : d.mermaidTemplate;
|
|
1804
|
+
if (/^h[1-6]{1}$/.test(e)) {
|
|
1805
|
+
const p = e.replace(/^h(\d)/, (y, $) => new Array(Number($)).fill("#", 0, $).join(""));
|
|
1806
|
+
l = `${p} ${m}`, r = p.length + 1;
|
|
1807
|
+
} else if (e === "prettier") {
|
|
1808
|
+
const p = window.prettier || ((h = (f = I.editorExtensions) == null ? void 0 : f.prettier) == null ? void 0 : h.prettierInstance), y = [
|
|
1809
|
+
((v = window.prettierPlugins) == null ? void 0 : v.markdown) || ((k = (b = I.editorExtensions) == null ? void 0 : b.prettier) == null ? void 0 : k.parserMarkdownInstance)
|
|
1810
|
+
];
|
|
1811
|
+
!p || y[0] === void 0 ? (C.emit(o.editorId, "errorCatcher", {
|
|
1812
|
+
name: "prettier",
|
|
1813
|
+
message: "prettier is undefined"
|
|
1814
|
+
}), l = t.getValue()) : l = p.format(t.getValue(), {
|
|
1815
|
+
parser: "markdown",
|
|
1816
|
+
plugins: y
|
|
1817
|
+
}), a = !1, c = !0;
|
|
1818
|
+
} else
|
|
1819
|
+
switch (e) {
|
|
1820
|
+
case "bold": {
|
|
1821
|
+
l = `**${m}**`, r = 2, n = -2;
|
|
1822
|
+
break;
|
|
1823
|
+
}
|
|
1824
|
+
case "underline": {
|
|
1825
|
+
l = `<u>${m}</u>`, r = 3, n = -4;
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
case "italic": {
|
|
1829
|
+
l = `*${m}*`, r = 1, n = -1;
|
|
1830
|
+
break;
|
|
1831
|
+
}
|
|
1832
|
+
case "strikeThrough": {
|
|
1833
|
+
l = `~${m}~`, r = 1, n = -1;
|
|
1834
|
+
break;
|
|
1835
|
+
}
|
|
1836
|
+
case "sub": {
|
|
1837
|
+
l = `<sub>${m}</sub>`, r = 5, n = -6;
|
|
1838
|
+
break;
|
|
1839
|
+
}
|
|
1840
|
+
case "sup": {
|
|
1841
|
+
l = `<sup>${m}</sup>`, r = 5, n = -6;
|
|
1842
|
+
break;
|
|
1843
|
+
}
|
|
1844
|
+
case "codeRow": {
|
|
1845
|
+
l = "`" + m + "`", r = 1, n = -1;
|
|
1846
|
+
break;
|
|
1847
|
+
}
|
|
1848
|
+
case "quote": {
|
|
1849
|
+
l = `> ${m}`, r = 2;
|
|
1850
|
+
break;
|
|
1851
|
+
}
|
|
1852
|
+
case "orderedList": {
|
|
1853
|
+
l = `1. ${m}`, r = 3;
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1856
|
+
case "unorderedList": {
|
|
1857
|
+
l = `- ${m}`, r = 2;
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
case "task": {
|
|
1861
|
+
l = `- [ ] ${m}`, r = 6;
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
case "code": {
|
|
1865
|
+
const p = o.text || m || "", y = o.mode || "language";
|
|
1866
|
+
l = `\`\`\`${y}
|
|
1867
|
+
${p}
|
|
1868
|
+
\`\`\`
|
|
1869
|
+
`, r = 3, n = 3 + y.length - l.length;
|
|
1870
|
+
break;
|
|
1871
|
+
}
|
|
1872
|
+
case "table": {
|
|
1873
|
+
l = "|";
|
|
1874
|
+
const { selectedShape: p = { x: 1, y: 1 } } = o, { x: y, y: $ } = p;
|
|
1875
|
+
for (let w = 0; w <= $; w++)
|
|
1876
|
+
l += " col |";
|
|
1877
|
+
l += `
|
|
1878
|
+
|`;
|
|
1879
|
+
for (let w = 0; w <= $; w++)
|
|
1880
|
+
l += " - |";
|
|
1881
|
+
for (let w = 0; w <= y; w++) {
|
|
1882
|
+
l += `
|
|
1883
|
+
|`;
|
|
1884
|
+
for (let L = 0; L <= $; L++)
|
|
1885
|
+
l += " content |";
|
|
1886
|
+
}
|
|
1887
|
+
r = 2, n = 5 - l.length;
|
|
1888
|
+
break;
|
|
1889
|
+
}
|
|
1890
|
+
case "link": {
|
|
1891
|
+
const { desc: p, url: y } = o;
|
|
1892
|
+
l = `[${p}](${y})`, a = !1;
|
|
1893
|
+
break;
|
|
1894
|
+
}
|
|
1895
|
+
case "image": {
|
|
1896
|
+
const { desc: p, url: y, urls: $ } = o;
|
|
1897
|
+
$ instanceof Array ? l = $.reduce((w, L) => w + `
|
|
1898
|
+
`, "") : l = `
|
|
1899
|
+
`, a = !1;
|
|
1900
|
+
break;
|
|
1901
|
+
}
|
|
1902
|
+
case "flow": {
|
|
1903
|
+
l = `\`\`\`mermaid
|
|
1904
|
+
${(u == null ? void 0 : u.flow) || `flowchart TD
|
|
1905
|
+
Start --> Stop`}
|
|
1906
|
+
\`\`\`
|
|
1907
|
+
`, r = 3, n = 10 - l.length;
|
|
1908
|
+
break;
|
|
1909
|
+
}
|
|
1910
|
+
case "sequence": {
|
|
1911
|
+
l = `\`\`\`mermaid
|
|
1912
|
+
${(u == null ? void 0 : u.sequence) || `sequenceDiagram
|
|
1913
|
+
A->>B: hello!
|
|
1914
|
+
B-->>A: hi!
|
|
1915
|
+
A-)B: bye!`}
|
|
1916
|
+
\`\`\`
|
|
1917
|
+
`, r = 3, n = 10 - l.length;
|
|
1918
|
+
break;
|
|
1919
|
+
}
|
|
1920
|
+
case "gantt": {
|
|
1921
|
+
l = `\`\`\`mermaid
|
|
1922
|
+
${(u == null ? void 0 : u.gantt) || `gantt
|
|
1923
|
+
title A Gantt Diagram
|
|
1924
|
+
dateFormat YYYY-MM-DD
|
|
1925
|
+
section Section
|
|
1926
|
+
A task :a1, 2014-01-01, 30d
|
|
1927
|
+
Another task :after a1, 20d`}
|
|
1928
|
+
\`\`\`
|
|
1929
|
+
`, r = 3, n = 10 - l.length;
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1932
|
+
case "class": {
|
|
1933
|
+
l = `\`\`\`mermaid
|
|
1934
|
+
${(u == null ? void 0 : u.class) || `classDiagram
|
|
1935
|
+
class Animal
|
|
1936
|
+
Vehicle <|-- Car`}
|
|
1937
|
+
\`\`\`
|
|
1938
|
+
`, r = 3, n = 10 - l.length;
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
case "state": {
|
|
1942
|
+
l = `\`\`\`mermaid
|
|
1943
|
+
${(u == null ? void 0 : u.state) || `stateDiagram-v2
|
|
1944
|
+
s1 --> s2`}
|
|
1945
|
+
\`\`\`
|
|
1946
|
+
`, r = 3, n = 10 - l.length;
|
|
1947
|
+
break;
|
|
1948
|
+
}
|
|
1949
|
+
case "pie": {
|
|
1950
|
+
l = `\`\`\`mermaid
|
|
1951
|
+
${(u == null ? void 0 : u.pie) || `pie title Pets adopted by volunteers
|
|
1952
|
+
"Dogs" : 386
|
|
1953
|
+
"Cats" : 85
|
|
1954
|
+
"Rats" : 15`}
|
|
1955
|
+
\`\`\`
|
|
1956
|
+
`, r = 3, n = 10 - l.length;
|
|
1957
|
+
break;
|
|
1958
|
+
}
|
|
1959
|
+
case "relationship": {
|
|
1960
|
+
l = `\`\`\`mermaid
|
|
1961
|
+
${(u == null ? void 0 : u.relationship) || `erDiagram
|
|
1962
|
+
CAR ||--o{ NAMED-DRIVER : allows
|
|
1963
|
+
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
1964
|
+
\`\`\`
|
|
1965
|
+
`, r = 3, n = 10 - l.length;
|
|
1966
|
+
break;
|
|
1967
|
+
}
|
|
1968
|
+
case "journey": {
|
|
1969
|
+
l = `\`\`\`mermaid
|
|
1970
|
+
${(u == null ? void 0 : u.journey) || `journey
|
|
1971
|
+
title My working day
|
|
1972
|
+
section Go to work
|
|
1973
|
+
Make tea: 5: Me
|
|
1974
|
+
Go upstairs: 3: Me
|
|
1975
|
+
Do work: 1: Me, Cat
|
|
1976
|
+
section Go home
|
|
1977
|
+
Go downstairs: 5: Me
|
|
1978
|
+
Sit down: 5: Me`}
|
|
1979
|
+
\`\`\`
|
|
1980
|
+
`, r = 3, n = 10 - l.length;
|
|
1981
|
+
break;
|
|
1982
|
+
}
|
|
1983
|
+
case "katexInline": {
|
|
1984
|
+
l = "$$", r = 1, n = -1;
|
|
1985
|
+
break;
|
|
1986
|
+
}
|
|
1987
|
+
case "katexBlock": {
|
|
1988
|
+
l = `$$
|
|
1989
|
+
|
|
1990
|
+
$$
|
|
1991
|
+
`, r = 3, n = -4;
|
|
1992
|
+
break;
|
|
1993
|
+
}
|
|
1994
|
+
case "universal": {
|
|
1995
|
+
const { generate: p } = o, y = p(m);
|
|
1996
|
+
l = y.targetValue, a = y.select, r = y.deviationStart, n = y.deviationEnd;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
return {
|
|
2000
|
+
text: l,
|
|
2001
|
+
options: {
|
|
2002
|
+
// 是否选中
|
|
2003
|
+
select: a,
|
|
2004
|
+
// 选中时,开始位置的偏移量
|
|
2005
|
+
deviationStart: r,
|
|
2006
|
+
// 结束的偏移量
|
|
2007
|
+
deviationEnd: n,
|
|
2008
|
+
// 是否整个替换
|
|
2009
|
+
replaceAll: c
|
|
2010
|
+
}
|
|
2011
|
+
};
|
|
2012
|
+
}, Sl = "#e5c07b", it = "var(--md-color)", xl = "#56b6c2", El = "#ffffff", oe = "var(--md-color)", at = "#e5c07b", Ll = "#e5c07b", Hl = "var(--md-color)", st = "#d19a66", Il = "#c678dd", Al = "#21252b", ct = "#2c313a", dt = "#000", ge = "#353a42", Fl = "#ceedfa33", ut = "#528bff", Ml = $e.theme(
|
|
2013
|
+
{
|
|
2014
|
+
"&": {
|
|
2015
|
+
color: oe,
|
|
2016
|
+
backgroundColor: dt
|
|
2017
|
+
},
|
|
2018
|
+
".cm-content": {
|
|
2019
|
+
caretColor: ut
|
|
2020
|
+
},
|
|
2021
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: ut },
|
|
2022
|
+
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: Fl },
|
|
2023
|
+
".cm-panels": { backgroundColor: Al, color: oe },
|
|
2024
|
+
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
2025
|
+
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
2026
|
+
".cm-searchMatch": {
|
|
2027
|
+
backgroundColor: "#72a1ff59",
|
|
2028
|
+
outline: "1px solid #457dff"
|
|
2029
|
+
},
|
|
2030
|
+
".cm-searchMatch.cm-searchMatch-selected": {
|
|
2031
|
+
backgroundColor: "#6199ff2f"
|
|
2032
|
+
},
|
|
2033
|
+
".cm-activeLine": { backgroundColor: "#ceedfa33" },
|
|
2034
|
+
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
|
|
2035
|
+
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
|
|
2036
|
+
backgroundColor: "#bad0f847"
|
|
2037
|
+
},
|
|
2038
|
+
".cm-gutters": {
|
|
2039
|
+
backgroundColor: dt,
|
|
2040
|
+
color: oe,
|
|
2041
|
+
borderRight: "1px solid",
|
|
2042
|
+
borderColor: "var(--md-border-color)"
|
|
2043
|
+
},
|
|
2044
|
+
".cm-activeLineGutter": {
|
|
2045
|
+
backgroundColor: ct
|
|
2046
|
+
},
|
|
2047
|
+
".cm-foldPlaceholder": {
|
|
2048
|
+
backgroundColor: "transparent",
|
|
2049
|
+
border: "none",
|
|
2050
|
+
color: "#ddd"
|
|
2051
|
+
},
|
|
2052
|
+
".cm-tooltip": {
|
|
2053
|
+
border: "none",
|
|
2054
|
+
backgroundColor: ge
|
|
2055
|
+
},
|
|
2056
|
+
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
2057
|
+
borderTopColor: "transparent",
|
|
2058
|
+
borderBottomColor: "transparent"
|
|
2059
|
+
},
|
|
2060
|
+
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
2061
|
+
borderTopColor: ge,
|
|
2062
|
+
borderBottomColor: ge
|
|
2063
|
+
},
|
|
2064
|
+
".cm-tooltip-autocomplete": {
|
|
2065
|
+
"& > ul > li[aria-selected]": {
|
|
2066
|
+
backgroundColor: ct,
|
|
2067
|
+
color: oe
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
},
|
|
2071
|
+
{ dark: !0 }
|
|
2072
|
+
), jl = yt.define([
|
|
2073
|
+
{ tag: g.keyword, color: Il },
|
|
2074
|
+
{ tag: [g.name, g.deleted, g.character, g.propertyName, g.macroName], color: it },
|
|
2075
|
+
{ tag: [g.function(g.variableName), g.labelName], color: Ll },
|
|
2076
|
+
{ tag: [g.color, g.constant(g.name), g.standard(g.name)], color: st },
|
|
2077
|
+
{ tag: [g.definition(g.name), g.separator], color: oe },
|
|
2078
|
+
{
|
|
2079
|
+
tag: [
|
|
2080
|
+
g.typeName,
|
|
2081
|
+
g.className,
|
|
2082
|
+
g.number,
|
|
2083
|
+
g.changed,
|
|
2084
|
+
g.annotation,
|
|
2085
|
+
g.modifier,
|
|
2086
|
+
g.self,
|
|
2087
|
+
g.namespace
|
|
2088
|
+
],
|
|
2089
|
+
color: Sl
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
tag: [
|
|
2093
|
+
g.operator,
|
|
2094
|
+
g.operatorKeyword,
|
|
2095
|
+
g.url,
|
|
2096
|
+
g.escape,
|
|
2097
|
+
g.regexp,
|
|
2098
|
+
g.link,
|
|
2099
|
+
g.special(g.string)
|
|
2100
|
+
],
|
|
2101
|
+
color: xl
|
|
2102
|
+
},
|
|
2103
|
+
{ tag: [g.meta, g.comment], color: at },
|
|
2104
|
+
{ tag: g.strong, fontWeight: "bold" },
|
|
2105
|
+
{ tag: g.emphasis, fontStyle: "italic" },
|
|
2106
|
+
{ tag: g.strikethrough, textDecoration: "line-through" },
|
|
2107
|
+
{ tag: g.link, color: at, textDecoration: "underline" },
|
|
2108
|
+
{ tag: g.heading, fontWeight: "bold", color: it },
|
|
2109
|
+
{ tag: [g.atom, g.bool, g.special(g.variableName)], color: st },
|
|
2110
|
+
{ tag: [g.processingInstruction, g.string, g.inserted], color: Hl },
|
|
2111
|
+
{ tag: g.invalid, color: El }
|
|
2112
|
+
]), Bl = [
|
|
2113
|
+
Ml,
|
|
2114
|
+
Ct(jl)
|
|
2115
|
+
], Pl = "#e5c07b", mt = "#3f4a54", Rl = "#56b6c2", Ol = "#fff", ne = "#3f4a54", ft = "#2d8cf0", Dl = "#2d8cf0", Nl = "#3f4a54", gt = "#d19a66", _l = "#c678dd", Vl = "#21252b", ht = "#2c313a", vt = "#fff", he = "#353a42", Ul = "#bad5fa", pt = "#3f4a54", ql = $e.theme(
|
|
2116
|
+
{
|
|
2117
|
+
"&": {
|
|
2118
|
+
color: ne,
|
|
2119
|
+
backgroundColor: vt
|
|
2120
|
+
},
|
|
2121
|
+
".cm-content": {
|
|
2122
|
+
caretColor: pt
|
|
2123
|
+
},
|
|
2124
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: pt },
|
|
2125
|
+
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: Ul },
|
|
2126
|
+
".cm-panels": { backgroundColor: Vl, color: ne },
|
|
2127
|
+
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
2128
|
+
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
2129
|
+
".cm-searchMatch": {
|
|
2130
|
+
backgroundColor: "#72a1ff59",
|
|
2131
|
+
outline: "1px solid #457dff"
|
|
2132
|
+
},
|
|
2133
|
+
".cm-searchMatch.cm-searchMatch-selected": {
|
|
2134
|
+
backgroundColor: "#6199ff2f"
|
|
2135
|
+
},
|
|
2136
|
+
".cm-activeLine": { backgroundColor: "#ceedfa33" },
|
|
2137
|
+
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
|
|
2138
|
+
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
|
|
2139
|
+
backgroundColor: "#bad0f847"
|
|
2140
|
+
},
|
|
2141
|
+
".cm-gutters": {
|
|
2142
|
+
backgroundColor: vt,
|
|
2143
|
+
color: ne,
|
|
2144
|
+
borderRight: "1px solid",
|
|
2145
|
+
borderColor: "var(--md-border-color)"
|
|
2146
|
+
},
|
|
2147
|
+
".cm-activeLineGutter": {
|
|
2148
|
+
backgroundColor: ht
|
|
2149
|
+
},
|
|
2150
|
+
".cm-foldPlaceholder": {
|
|
2151
|
+
backgroundColor: "transparent",
|
|
2152
|
+
border: "none",
|
|
2153
|
+
color: "#ddd"
|
|
2154
|
+
},
|
|
2155
|
+
".cm-tooltip": {
|
|
2156
|
+
border: "none",
|
|
2157
|
+
backgroundColor: he
|
|
2158
|
+
},
|
|
2159
|
+
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
2160
|
+
borderTopColor: "transparent",
|
|
2161
|
+
borderBottomColor: "transparent"
|
|
2162
|
+
},
|
|
2163
|
+
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
2164
|
+
borderTopColor: he,
|
|
2165
|
+
borderBottomColor: he
|
|
2166
|
+
},
|
|
2167
|
+
".cm-tooltip-autocomplete": {
|
|
2168
|
+
"& > ul > li[aria-selected]": {
|
|
2169
|
+
backgroundColor: ht,
|
|
2170
|
+
color: ne
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
},
|
|
2174
|
+
{ dark: !0 }
|
|
2175
|
+
), Wl = yt.define([
|
|
2176
|
+
{ tag: g.keyword, color: _l },
|
|
2177
|
+
{ tag: [g.name, g.deleted, g.character, g.propertyName, g.macroName], color: mt },
|
|
2178
|
+
{ tag: [g.function(g.variableName), g.labelName], color: Dl },
|
|
2179
|
+
{ tag: [g.color, g.constant(g.name), g.standard(g.name)], color: gt },
|
|
2180
|
+
{ tag: [g.definition(g.name), g.separator], color: ne },
|
|
2181
|
+
{
|
|
2182
|
+
tag: [
|
|
2183
|
+
g.typeName,
|
|
2184
|
+
g.className,
|
|
2185
|
+
g.number,
|
|
2186
|
+
g.changed,
|
|
2187
|
+
g.annotation,
|
|
2188
|
+
g.modifier,
|
|
2189
|
+
g.self,
|
|
2190
|
+
g.namespace
|
|
2191
|
+
],
|
|
2192
|
+
color: Pl
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
tag: [
|
|
2196
|
+
g.operator,
|
|
2197
|
+
g.operatorKeyword,
|
|
2198
|
+
g.url,
|
|
2199
|
+
g.escape,
|
|
2200
|
+
g.regexp,
|
|
2201
|
+
g.link,
|
|
2202
|
+
g.special(g.string)
|
|
2203
|
+
],
|
|
2204
|
+
color: Rl
|
|
2205
|
+
},
|
|
2206
|
+
{ tag: [g.meta, g.comment], color: ft },
|
|
2207
|
+
{ tag: g.strong, fontWeight: "bold" },
|
|
2208
|
+
{ tag: g.emphasis, fontStyle: "italic" },
|
|
2209
|
+
{ tag: g.strikethrough, textDecoration: "line-through" },
|
|
2210
|
+
{ tag: g.link, color: ft, textDecoration: "underline" },
|
|
2211
|
+
{ tag: g.heading, fontWeight: "bold", color: mt },
|
|
2212
|
+
{ tag: [g.atom, g.bool, g.special(g.variableName)], color: gt },
|
|
2213
|
+
{ tag: [g.processingInstruction, g.string, g.inserted], color: Nl },
|
|
2214
|
+
{ tag: g.invalid, color: Ol }
|
|
2215
|
+
]), Gl = [
|
|
2216
|
+
ql,
|
|
2217
|
+
Ct(Wl)
|
|
2218
|
+
], J = (e) => {
|
|
2219
|
+
const t = new Ft();
|
|
2220
|
+
return (l) => (t.get(e.state) ? e.dispatch({ effects: t.reconfigure(l) }) : e.dispatch({
|
|
2221
|
+
effects: Mt.appendConfig.of(t.of(l))
|
|
2222
|
+
}), !0);
|
|
2223
|
+
};
|
|
2224
|
+
class zl {
|
|
2225
|
+
constructor(t) {
|
|
2226
|
+
U(this, "view");
|
|
2227
|
+
// 切换tabSize的执行方法。切换时,Compartment实例需要相同
|
|
2228
|
+
U(this, "toggleTabSize");
|
|
2229
|
+
U(this, "togglePlaceholder");
|
|
2230
|
+
/**
|
|
2231
|
+
* 设置全部的扩展
|
|
2232
|
+
*/
|
|
2233
|
+
U(this, "setExtensions");
|
|
2234
|
+
U(this, "toggleDisabled");
|
|
2235
|
+
U(this, "toggleReadOnly");
|
|
2236
|
+
U(this, "toggleMaxlength");
|
|
2237
|
+
this.view = t, this.toggleTabSize = J(this.view), this.togglePlaceholder = J(this.view), this.setExtensions = J(this.view), this.toggleDisabled = J(this.view), this.toggleReadOnly = J(this.view), this.toggleMaxlength = J(this.view);
|
|
2238
|
+
}
|
|
2239
|
+
getValue() {
|
|
2240
|
+
return this.view.state.doc.toString();
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* 设置内容
|
|
2244
|
+
*
|
|
2245
|
+
* @param insert 待插入内容
|
|
2246
|
+
* @param from 插入开始位置
|
|
2247
|
+
* @param to 插入结束位置
|
|
2248
|
+
*/
|
|
2249
|
+
setValue(t, o = 0, l = this.view.state.doc.length) {
|
|
2250
|
+
this.view.dispatch({
|
|
2251
|
+
changes: {
|
|
2252
|
+
from: o,
|
|
2253
|
+
to: l,
|
|
2254
|
+
insert: t
|
|
2255
|
+
}
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* 获取选中的文本
|
|
2260
|
+
*/
|
|
2261
|
+
getSelectedText() {
|
|
2262
|
+
const { from: t, to: o } = this.view.state.selection.main;
|
|
2263
|
+
return this.view.state.sliceDoc(t, o);
|
|
2264
|
+
}
|
|
2265
|
+
/**
|
|
2266
|
+
* 使用新的内容替换选中的内容
|
|
2267
|
+
*
|
|
2268
|
+
* @param text 待替换内容
|
|
2269
|
+
* @param options 替换后是否选中
|
|
2270
|
+
*/
|
|
2271
|
+
replaceSelectedText(t, o = {
|
|
2272
|
+
// 是否选中
|
|
2273
|
+
select: !0,
|
|
2274
|
+
// 选中时,开始位置的偏移量
|
|
2275
|
+
deviationStart: 0,
|
|
2276
|
+
// 结束的偏移量
|
|
2277
|
+
deviationEnd: 0,
|
|
2278
|
+
// 直接替换所有文本
|
|
2279
|
+
replaceAll: !1
|
|
2280
|
+
}) {
|
|
2281
|
+
if (o.replaceAll) {
|
|
2282
|
+
this.setValue(t);
|
|
2283
|
+
return;
|
|
2284
|
+
}
|
|
2285
|
+
const { from: l } = this.view.state.selection.main;
|
|
2286
|
+
if (this.view.dispatch(this.view.state.replaceSelection(t)), o.select) {
|
|
2287
|
+
const r = l + t.length + o.deviationEnd;
|
|
2288
|
+
this.view.dispatch({
|
|
2289
|
+
selection: fe.create(
|
|
2290
|
+
[
|
|
2291
|
+
fe.range(l + o.deviationStart, r),
|
|
2292
|
+
fe.cursor(r)
|
|
2293
|
+
],
|
|
2294
|
+
1
|
|
2295
|
+
)
|
|
2296
|
+
}), this.view.focus();
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
/**
|
|
2300
|
+
* 设置tabSize
|
|
2301
|
+
*
|
|
2302
|
+
* @param tabSize 需要切换的大小
|
|
2303
|
+
*/
|
|
2304
|
+
setTabSize(t) {
|
|
2305
|
+
this.toggleTabSize([
|
|
2306
|
+
se.tabSize.of(t),
|
|
2307
|
+
Vt.of(" ".repeat(t))
|
|
2308
|
+
]);
|
|
2309
|
+
}
|
|
2310
|
+
/**
|
|
2311
|
+
* 设置placeholder
|
|
2312
|
+
*
|
|
2313
|
+
* @param t 目标内容
|
|
2314
|
+
*/
|
|
2315
|
+
setPlaceholder(t) {
|
|
2316
|
+
this.togglePlaceholder(jt(t));
|
|
2317
|
+
}
|
|
2318
|
+
foucs() {
|
|
2319
|
+
this.view.focus();
|
|
2320
|
+
}
|
|
2321
|
+
setDisabled(t) {
|
|
2322
|
+
this.toggleDisabled([$e.editable.of(!t)]);
|
|
2323
|
+
}
|
|
2324
|
+
setReadOnly(t) {
|
|
2325
|
+
this.toggleReadOnly([se.readOnly.of(t)]);
|
|
2326
|
+
}
|
|
2327
|
+
setMaxLength(t) {
|
|
2328
|
+
this.toggleMaxlength([
|
|
2329
|
+
se.changeFilter.of((o) => o.newDoc.length <= t)
|
|
2330
|
+
]);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
const Kl = (e) => {
|
|
2334
|
+
const t = x("editorId");
|
|
2335
|
+
return (l) => {
|
|
2336
|
+
if (l.clipboardData) {
|
|
2337
|
+
if (l.clipboardData.files.length > 0) {
|
|
2338
|
+
const { files: r } = l.clipboardData;
|
|
2339
|
+
C.emit(
|
|
2340
|
+
t,
|
|
2341
|
+
"uploadImage",
|
|
2342
|
+
Array.from(r).filter((n) => /image\/.*/.test(n.type))
|
|
2343
|
+
), l.preventDefault();
|
|
2344
|
+
}
|
|
2345
|
+
if (e.autoDetectCode && l.clipboardData.types.includes("vscode-editor-data")) {
|
|
2346
|
+
const r = JSON.parse(l.clipboardData.getData("vscode-editor-data"));
|
|
2347
|
+
C.emit(t, "replace", "code", {
|
|
2348
|
+
mode: r.mode,
|
|
2349
|
+
text: l.clipboardData.getData("text/plain")
|
|
2350
|
+
}), l.preventDefault();
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
}, Xl = (e) => {
|
|
2355
|
+
const t = x("editorId");
|
|
2356
|
+
A(() => {
|
|
2357
|
+
C.on(t, {
|
|
2358
|
+
name: St,
|
|
2359
|
+
callback() {
|
|
2360
|
+
var o;
|
|
2361
|
+
(o = e.value) == null || o.foucs();
|
|
2362
|
+
}
|
|
2363
|
+
});
|
|
2364
|
+
});
|
|
2365
|
+
}, Zl = (e, t) => [
|
|
2366
|
+
{
|
|
2367
|
+
key: "Ctrl-b",
|
|
2368
|
+
mac: "Cmd-b",
|
|
2369
|
+
run: () => (C.emit(e, "replace", "bold"), !0)
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
key: "Ctrl-d",
|
|
2373
|
+
mac: "Cmd-d",
|
|
2374
|
+
run: Ot,
|
|
2375
|
+
preventDefault: !0
|
|
2376
|
+
},
|
|
2377
|
+
{
|
|
2378
|
+
key: "Ctrl-s",
|
|
2379
|
+
mac: "Cmd-s",
|
|
2380
|
+
run: (L) => (C.emit(e, me, L.state.doc.toString()), !0),
|
|
2381
|
+
shift: () => (C.emit(e, "replace", "strikeThrough"), !0)
|
|
2382
|
+
},
|
|
2383
|
+
{
|
|
2384
|
+
key: "Ctrl-u",
|
|
2385
|
+
mac: "Cmd-u",
|
|
2386
|
+
run: () => (C.emit(e, "replace", "underline"), !0),
|
|
2387
|
+
shift: () => (C.emit(e, "replace", "unorderedList"), !0)
|
|
2388
|
+
},
|
|
2389
|
+
{
|
|
2390
|
+
key: "Ctrl-i",
|
|
2391
|
+
mac: "Cmd-i",
|
|
2392
|
+
run: () => (C.emit(e, "replace", "italic"), !0),
|
|
2393
|
+
shift: () => (C.emit(e, "openModals", "image"), !0)
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
key: "Ctrl-1",
|
|
2397
|
+
mac: "Cmd-1",
|
|
2398
|
+
run: () => (C.emit(e, "replace", "h1"), !0)
|
|
2399
|
+
},
|
|
2400
|
+
{
|
|
2401
|
+
key: "Ctrl-2",
|
|
2402
|
+
mac: "Cmd-2",
|
|
2403
|
+
run: () => (C.emit(e, "replace", "h2"), !0)
|
|
2404
|
+
},
|
|
2405
|
+
{
|
|
2406
|
+
key: "Ctrl-3",
|
|
2407
|
+
mac: "Cmd-3",
|
|
2408
|
+
run: () => (C.emit(e, "replace", "h3"), !0)
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
key: "Ctrl-4",
|
|
2412
|
+
mac: "Cmd-4",
|
|
2413
|
+
run: () => (C.emit(e, "replace", "h4"), !0)
|
|
2414
|
+
},
|
|
2415
|
+
{
|
|
2416
|
+
key: "Ctrl-5",
|
|
2417
|
+
mac: "Cmd-5",
|
|
2418
|
+
run: () => (C.emit(e, "replace", "h5"), !0)
|
|
2419
|
+
},
|
|
2420
|
+
{
|
|
2421
|
+
key: "Ctrl-6",
|
|
2422
|
+
mac: "Cmd-6",
|
|
2423
|
+
run: () => (C.emit(e, "replace", "h6"), !0)
|
|
2424
|
+
},
|
|
2425
|
+
{
|
|
2426
|
+
key: "Ctrl-ArrowUp",
|
|
2427
|
+
mac: "Cmd-ArrowUp",
|
|
2428
|
+
run: () => (C.emit(e, "replace", "sup"), !0)
|
|
2429
|
+
},
|
|
2430
|
+
{
|
|
2431
|
+
key: "Ctrl-ArrowDown",
|
|
2432
|
+
mac: "Cmd-ArrowDown",
|
|
2433
|
+
run: () => (C.emit(e, "replace", "sub"), !0)
|
|
2434
|
+
},
|
|
2435
|
+
{
|
|
2436
|
+
key: "Ctrl-o",
|
|
2437
|
+
mac: "Cmd-o",
|
|
2438
|
+
run: () => (C.emit(e, "replace", "orderedList"), !0)
|
|
2439
|
+
},
|
|
2440
|
+
{
|
|
2441
|
+
key: "Ctrl-c",
|
|
2442
|
+
mac: "Cmd-c",
|
|
2443
|
+
shift: () => (C.emit(e, "replace", "code"), !0),
|
|
2444
|
+
any(L, S) {
|
|
2445
|
+
return (S.ctrlKey || S.metaKey) && S.altKey && S.code === "KeyC" ? (C.emit(e, "replace", "codeRow"), !0) : !1;
|
|
2446
|
+
}
|
|
2447
|
+
},
|
|
2448
|
+
{
|
|
2449
|
+
key: "Ctrl-l",
|
|
2450
|
+
mac: "Cmd-l",
|
|
2451
|
+
run: () => (C.emit(e, "openModals", "link"), !0)
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
key: "Ctrl-f",
|
|
2455
|
+
mac: "Cmd-f",
|
|
2456
|
+
shift: () => t.noPrettier ? !1 : (C.emit(e, "replace", "prettier"), !0)
|
|
2457
|
+
},
|
|
2458
|
+
{
|
|
2459
|
+
any: (L, S) => (S.ctrlKey || S.metaKey) && S.altKey && S.shiftKey && S.code === "KeyT" ? (C.emit(e, "replace", "table"), !0) : !1
|
|
2460
|
+
}
|
|
2461
|
+
], Jl = (e) => {
|
|
2462
|
+
const t = x("tabWidth"), o = x("editorId"), l = x("theme"), r = F(), n = F(), a = Zl(o, e), c = Kl(e), m = [
|
|
2463
|
+
Bt.of([...a, Dt]),
|
|
2464
|
+
At,
|
|
2465
|
+
Rt({ codeLanguages: Pt }),
|
|
2466
|
+
// 横向换行
|
|
2467
|
+
ie.lineWrapping,
|
|
2468
|
+
ie.updateListener.of((d) => {
|
|
2469
|
+
e.onChange(d.state.doc.toString());
|
|
2470
|
+
}),
|
|
2471
|
+
ie.domEventHandlers({
|
|
2472
|
+
paste: c,
|
|
2473
|
+
blur: e.onBlur,
|
|
2474
|
+
focus: e.onFocus
|
|
2475
|
+
})
|
|
2476
|
+
], u = () => l.value === "light" ? I.codeMirrorExtensions(
|
|
2477
|
+
l.value,
|
|
2478
|
+
[...m, Gl],
|
|
2479
|
+
a
|
|
2480
|
+
) : I.codeMirrorExtensions(
|
|
2481
|
+
l.value,
|
|
2482
|
+
[...m, Bl],
|
|
2483
|
+
a
|
|
2484
|
+
);
|
|
2485
|
+
return A(() => {
|
|
2486
|
+
const d = se.create({
|
|
2487
|
+
doc: e.value
|
|
2488
|
+
}), f = new ie({
|
|
2489
|
+
state: d,
|
|
2490
|
+
parent: r.value
|
|
2491
|
+
});
|
|
2492
|
+
n.value = new zl(f), n.value.setTabSize(t), n.value.setExtensions(u()), n.value.setPlaceholder(e.placeholder), n.value.setDisabled(e.disabled), n.value.setReadOnly(e.readonly), e.autofocus && f.focus(), e.maxlength && n.value.setMaxLength(e.maxlength), C.on(o, {
|
|
2493
|
+
name: "ctrlZ",
|
|
2494
|
+
callback() {
|
|
2495
|
+
Nt(f);
|
|
2496
|
+
}
|
|
2497
|
+
}), C.on(o, {
|
|
2498
|
+
name: "ctrlShiftZ",
|
|
2499
|
+
callback() {
|
|
2500
|
+
_t(f);
|
|
2501
|
+
}
|
|
2502
|
+
}), C.on(o, {
|
|
2503
|
+
name: "replace",
|
|
2504
|
+
callback(h, v = {}) {
|
|
2505
|
+
var p;
|
|
2506
|
+
const { text: b, options: k } = Tl(h, n.value, v);
|
|
2507
|
+
(p = n.value) == null || p.replaceSelectedText(b, k);
|
|
2508
|
+
}
|
|
2509
|
+
});
|
|
2510
|
+
}), T(
|
|
2511
|
+
() => l.value,
|
|
2512
|
+
() => {
|
|
2513
|
+
var d, f;
|
|
2514
|
+
l.value === "dark" ? (d = n.value) == null || d.setExtensions(u()) : (f = n.value) == null || f.setExtensions(u());
|
|
2515
|
+
}
|
|
2516
|
+
), T(
|
|
2517
|
+
() => e.value,
|
|
2518
|
+
() => {
|
|
2519
|
+
var d, f;
|
|
2520
|
+
((d = n.value) == null ? void 0 : d.getValue()) !== e.value && ((f = n.value) == null || f.setValue(e.value));
|
|
2521
|
+
}
|
|
2522
|
+
), T(
|
|
2523
|
+
() => e.value,
|
|
2524
|
+
() => {
|
|
2525
|
+
var d;
|
|
2526
|
+
(d = n.value) == null || d.setPlaceholder(e.placeholder);
|
|
2527
|
+
}
|
|
2528
|
+
), T(
|
|
2529
|
+
() => e.disabled,
|
|
2530
|
+
() => {
|
|
2531
|
+
var d;
|
|
2532
|
+
(d = n.value) == null || d.setDisabled(e.disabled);
|
|
2533
|
+
}
|
|
2534
|
+
), T(
|
|
2535
|
+
() => e.readonly,
|
|
2536
|
+
() => {
|
|
2537
|
+
var d;
|
|
2538
|
+
(d = n.value) == null || d.setDisabled(e.readonly);
|
|
2539
|
+
}
|
|
2540
|
+
), T(
|
|
2541
|
+
() => e.maxlength,
|
|
2542
|
+
() => {
|
|
2543
|
+
var d;
|
|
2544
|
+
e.maxlength && ((d = n.value) == null || d.setMaxLength(e.maxlength));
|
|
2545
|
+
}
|
|
2546
|
+
), Xl(n), {
|
|
2547
|
+
inputWrapperRef: r,
|
|
2548
|
+
codeMirrorUt: n
|
|
2549
|
+
};
|
|
2550
|
+
}, Yl = (e, t) => {
|
|
2551
|
+
const o = x("editorId"), l = Q(() => {
|
|
2552
|
+
const r = document.querySelectorAll(`#${o}-preview img`);
|
|
2553
|
+
r.length !== 0 && Ut(r, {
|
|
2554
|
+
background: "#00000073"
|
|
2555
|
+
});
|
|
2556
|
+
});
|
|
2557
|
+
A(l), T([t, ce(e.setting, "preview")], l);
|
|
2558
|
+
}, Ql = (e, t) => {
|
|
2559
|
+
const o = x("editorId"), l = x("usedLanguageText"), r = () => {
|
|
2560
|
+
document.querySelectorAll(`#${o}-preview pre`).forEach((c) => {
|
|
2561
|
+
var f, h;
|
|
2562
|
+
let m = -1;
|
|
2563
|
+
(f = c.querySelector(".copy-button")) == null || f.remove();
|
|
2564
|
+
const u = ((h = l.value.copyCode) == null ? void 0 : h.text) || "复制代码", d = document.createElement("span");
|
|
2565
|
+
d.setAttribute("class", "copy-button"), d.dataset.tips = u, d.innerHTML = `<svg class="${s}-icon" aria-hidden="true"><use xlink:href="#${s}-icon-copy"></use></svg>`, d.addEventListener("click", () => {
|
|
2566
|
+
var y, $;
|
|
2567
|
+
clearTimeout(m);
|
|
2568
|
+
const v = c.querySelector("code").innerText, b = qt(e.formatCopiedText(v)), k = ((y = l.value.copyCode) == null ? void 0 : y.successTips) || "已复制!", p = (($ = l.value.copyCode) == null ? void 0 : $.failTips) || "已复制!";
|
|
2569
|
+
d.dataset.tips = b ? k : p, m = window.setTimeout(() => {
|
|
2570
|
+
d.dataset.tips = u;
|
|
2571
|
+
}, 1500);
|
|
2572
|
+
}), c.appendChild(d);
|
|
2573
|
+
});
|
|
2574
|
+
}, n = () => {
|
|
2575
|
+
q(r);
|
|
2576
|
+
}, a = (c) => {
|
|
2577
|
+
c && q(r);
|
|
2578
|
+
};
|
|
2579
|
+
T(() => t.value, n), T(() => e.setting.preview, a), T(() => e.setting.htmlPreview, a), T(() => l.value, r), A(r);
|
|
2580
|
+
}, eo = (e) => {
|
|
2581
|
+
var n;
|
|
2582
|
+
const t = (n = I.editorExtensions) == null ? void 0 : n.highlight, o = t == null ? void 0 : t.instance, l = x("highlight"), r = de(o);
|
|
2583
|
+
return A(() => {
|
|
2584
|
+
if (e.noHighlight)
|
|
2585
|
+
return;
|
|
2586
|
+
if (!r.value) {
|
|
2587
|
+
const c = document.createElement("script");
|
|
2588
|
+
c.src = l.value.js, c.onload = () => {
|
|
2589
|
+
r.value = window.hljs;
|
|
2590
|
+
}, c.id = `${s}-hljs`, O(c, "hljs");
|
|
2591
|
+
}
|
|
2592
|
+
const a = document.createElement("link");
|
|
2593
|
+
a.rel = "stylesheet", a.href = l.value.css, a.id = `${s}-hlCss`, O(a);
|
|
2594
|
+
}), T(
|
|
2595
|
+
() => l.value.css,
|
|
2596
|
+
(a) => {
|
|
2597
|
+
ul(`${s}-hlCss`, "href", a);
|
|
2598
|
+
}
|
|
2599
|
+
), r;
|
|
2600
|
+
}, to = (e) => {
|
|
2601
|
+
const t = x("theme"), { editorExtensions: o } = I, l = o == null ? void 0 : o.mermaid, r = de(l == null ? void 0 : l.instance), n = de(!1), a = new Kt({
|
|
2602
|
+
max: 1e3,
|
|
2603
|
+
// 缓存10分钟
|
|
2604
|
+
ttl: 6e5
|
|
2605
|
+
}), c = () => {
|
|
2606
|
+
const u = (l == null ? void 0 : l.instance) || window.mermaid;
|
|
2607
|
+
!e.noMermaid && u && (u.initialize({
|
|
2608
|
+
startOnLoad: !1,
|
|
2609
|
+
theme: t.value === "dark" ? "dark" : "default"
|
|
2610
|
+
}), n.value = !n.value);
|
|
2611
|
+
};
|
|
2612
|
+
return T(
|
|
2613
|
+
() => t.value,
|
|
2614
|
+
() => {
|
|
2615
|
+
a.clear(), c();
|
|
2616
|
+
}
|
|
2617
|
+
), A(() => {
|
|
2618
|
+
if (!e.noMermaid && !(l != null && l.instance)) {
|
|
2619
|
+
const u = document.createElement("script");
|
|
2620
|
+
u.id = `${s}-mermaid`;
|
|
2621
|
+
const d = (l == null ? void 0 : l.js) || Qt;
|
|
2622
|
+
/\.mjs/.test(d) ? (u.setAttribute("type", "module"), u.innerHTML = `import mermaid from "${d}";window.mermaid=mermaid;document.getElementById('${s}-mermaid').dispatchEvent(new Event('load'));`) : u.src = d, u.onload = () => {
|
|
2623
|
+
r.value = window.mermaid, c();
|
|
2624
|
+
}, O(u, "mermaid");
|
|
2625
|
+
}
|
|
2626
|
+
}), { mermaidRef: r, reRenderRef: n, replaceMermaid: () => {
|
|
2627
|
+
q(() => {
|
|
2628
|
+
!e.noMermaid && r.value && document.querySelectorAll(
|
|
2629
|
+
`div.${s}-mermaid`
|
|
2630
|
+
).forEach(async (d) => {
|
|
2631
|
+
let f = a.get(d.innerText);
|
|
2632
|
+
if (!f) {
|
|
2633
|
+
const v = cl(), k = await (r.value.renderAsync || r.value.render)(v, d.innerText);
|
|
2634
|
+
f = typeof k == "string" ? k : k.svg, a.set(d.innerText, f);
|
|
2635
|
+
}
|
|
2636
|
+
const h = document.createElement("p");
|
|
2637
|
+
h.className = `${s}-mermaid`, h.setAttribute("data-processed", ""), h.innerHTML = f, d.replaceWith(h);
|
|
2638
|
+
});
|
|
2639
|
+
});
|
|
2640
|
+
} };
|
|
2641
|
+
}, lo = (e) => {
|
|
2642
|
+
var r;
|
|
2643
|
+
const t = (r = I.editorExtensions) == null ? void 0 : r.katex, o = t == null ? void 0 : t.instance, l = de(o);
|
|
2644
|
+
return A(() => {
|
|
2645
|
+
if (!e.noKatex && !l.value) {
|
|
2646
|
+
const n = document.createElement("script");
|
|
2647
|
+
n.src = (t == null ? void 0 : t.js) || Je.js, n.onload = () => {
|
|
2648
|
+
l.value = window.katex;
|
|
2649
|
+
}, n.id = `${s}-katex`;
|
|
2650
|
+
const a = document.createElement("link");
|
|
2651
|
+
a.rel = "stylesheet", a.href = (t == null ? void 0 : t.css) || Je.css, a.id = `${s}-katexCss`, O(n, "katex"), O(a);
|
|
2652
|
+
}
|
|
2653
|
+
}), l;
|
|
2654
|
+
}, oo = (e, t) => {
|
|
2655
|
+
const o = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
2656
|
+
e.renderer.rules.fence = (l, r, n, a, c) => {
|
|
2657
|
+
const m = l[r], u = m.content.trim();
|
|
2658
|
+
return m.info === "mermaid" ? `<div class="${s}-mermaid" data-mermaid-theme=${t.themeRef.value}>${u}</div>` : o(l, r, n, a, c);
|
|
2659
|
+
};
|
|
2660
|
+
}, bt = (e, t) => {
|
|
2661
|
+
let o = !0, l = !0;
|
|
2662
|
+
const r = e.posMax, n = t > 0 ? e.src.charCodeAt(t - 1) : -1, a = t + 1 <= r ? e.src.charCodeAt(t + 1) : -1;
|
|
2663
|
+
return (n === 32 || n === 9 || a >= 48 && a <= 57) && (l = !1), (a === 32 || a === 9) && (o = !1), {
|
|
2664
|
+
can_open: o,
|
|
2665
|
+
can_close: l
|
|
2666
|
+
};
|
|
2667
|
+
}, no = (e, t) => {
|
|
2668
|
+
let o, l, r, n;
|
|
2669
|
+
if (e.src[e.pos] !== "$")
|
|
2670
|
+
return !1;
|
|
2671
|
+
if (r = bt(e, e.pos), !r.can_open)
|
|
2672
|
+
return t || (e.pending += "$"), e.pos += 1, !0;
|
|
2673
|
+
const a = e.pos + 1;
|
|
2674
|
+
for (o = a; (o = e.src.indexOf("$", o)) !== -1; ) {
|
|
2675
|
+
for (n = o - 1; e.src[n] === "\\"; )
|
|
2676
|
+
n -= 1;
|
|
2677
|
+
if ((o - n) % 2 == 1)
|
|
2678
|
+
break;
|
|
2679
|
+
o += 1;
|
|
2680
|
+
}
|
|
2681
|
+
return o === -1 ? (t || (e.pending += "$"), e.pos = a, !0) : o - a === 0 ? (t || (e.pending += "$$"), e.pos = a + 1, !0) : (r = bt(e, o), r.can_close ? (t || (l = e.push("math_inline", "math", 0), l.markup = "$", l.content = e.src.slice(a, o)), e.pos = o + 1, !0) : (t || (e.pending += "$"), e.pos = a, !0));
|
|
2682
|
+
}, ro = (e, t, o, l) => {
|
|
2683
|
+
let r, n, a, c, m = !1, u = e.bMarks[t] + e.tShift[t], d = e.eMarks[t];
|
|
2684
|
+
if (u + 2 > d || e.src.slice(u, u + 2) !== "$$")
|
|
2685
|
+
return !1;
|
|
2686
|
+
if (u += 2, r = e.src.slice(u, d), l)
|
|
2687
|
+
return !0;
|
|
2688
|
+
for (r.trim().slice(-2) === "$$" && (r = r.trim().slice(0, -2), m = !0), a = t; !m && (a++, !(a >= o || (u = e.bMarks[a] + e.tShift[a], d = e.eMarks[a], u < d && e.tShift[a] < e.blkIndent))); )
|
|
2689
|
+
e.src.slice(u, d).trim().slice(-2) === "$$" && (c = e.src.slice(0, d).lastIndexOf("$$"), n = e.src.slice(u, c), m = !0);
|
|
2690
|
+
e.line = a + 1;
|
|
2691
|
+
const f = e.push("math_block", "math", 0);
|
|
2692
|
+
return f.block = !0, f.content = (r && r.trim() ? r + `
|
|
2693
|
+
` : "") + e.getLines(t + 1, a, e.tShift[t], !0) + (n && n.trim() ? n : ""), f.map = [t, e.line], f.markup = "$$", !0;
|
|
2694
|
+
}, io = (e, t) => {
|
|
2695
|
+
const o = (r) => {
|
|
2696
|
+
if (t.katexRef.value) {
|
|
2697
|
+
const n = t.katexRef.value.renderToString(r, {
|
|
2698
|
+
throwOnError: !1
|
|
2699
|
+
});
|
|
2700
|
+
return `<span class="${s}-katex-inline" data-processed>${n}</span>`;
|
|
2701
|
+
} else
|
|
2702
|
+
return `<span class="${s}-katex-inline">${r}</span>`;
|
|
2703
|
+
}, l = (r, n) => {
|
|
2704
|
+
if (t.katexRef.value) {
|
|
2705
|
+
const a = t.katexRef.value.renderToString(r, {
|
|
2706
|
+
throwOnError: !1,
|
|
2707
|
+
displayMode: !0
|
|
2708
|
+
});
|
|
2709
|
+
return `<p class="${s}-katex-block" data-line=${n} data-processed>${a}</p>`;
|
|
2710
|
+
} else
|
|
2711
|
+
return `<p class="${s}-katex-block" data-line=${n}>${r}</p>`;
|
|
2712
|
+
};
|
|
2713
|
+
e.inline.ruler.after("escape", "math_inline", no), e.block.ruler.after("blockquote", "math_block", ro, {
|
|
2714
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
2715
|
+
}), e.renderer.rules.math_inline = (r, n) => o(r[n].content), e.renderer.rules.math_block = (r, n) => l(r[n].content, r[n].map[0]) + `
|
|
2716
|
+
`;
|
|
2717
|
+
}, ao = (e, t) => {
|
|
2718
|
+
t = t || {};
|
|
2719
|
+
const o = 3, l = t.marker || "!", r = l.charCodeAt(0), n = l.length;
|
|
2720
|
+
let a = "", c = "";
|
|
2721
|
+
const m = (d, f, h, v, b) => {
|
|
2722
|
+
const k = d[f];
|
|
2723
|
+
return k.type === "admonition_open" ? (d[f].attrPush([
|
|
2724
|
+
"class",
|
|
2725
|
+
`${s}-admonition ${s}-admonition-${k.info}`
|
|
2726
|
+
]), d[f].attrSet("data-line", String(d[f].map[0]))) : k.type === "admonition_title_open" && d[f].attrPush(["class", `${s}-admonition-title`]), b.renderToken(d, f, h);
|
|
2727
|
+
}, u = (d) => {
|
|
2728
|
+
const f = d.trim().split(" ", 2);
|
|
2729
|
+
c = "", a = f[0], f.length > 1 && (c = d.substring(a.length + 2)), (c === "" || !c) && (c = a);
|
|
2730
|
+
};
|
|
2731
|
+
e.block.ruler.before(
|
|
2732
|
+
"code",
|
|
2733
|
+
"admonition",
|
|
2734
|
+
(d, f, h, v) => {
|
|
2735
|
+
let b, k, p, y = !1, $ = d.bMarks[f] + d.tShift[f], w = d.eMarks[f];
|
|
2736
|
+
if (r !== d.src.charCodeAt($))
|
|
2737
|
+
return !1;
|
|
2738
|
+
for (b = $ + 1; b <= w && l[(b - $) % n] === d.src[b]; b++)
|
|
2739
|
+
;
|
|
2740
|
+
const L = Math.floor((b - $) / n);
|
|
2741
|
+
if (L !== o)
|
|
2742
|
+
return !1;
|
|
2743
|
+
b -= (b - $) % n;
|
|
2744
|
+
const S = d.src.slice($, b), B = d.src.slice(b, w);
|
|
2745
|
+
if (u(B), v)
|
|
2746
|
+
return !0;
|
|
2747
|
+
for (k = f; k++, !(k >= h || ($ = d.bMarks[k] + d.tShift[k], w = d.eMarks[k], $ < w && d.sCount[k] < d.blkIndent)); )
|
|
2748
|
+
if (r === d.src.charCodeAt($) && !(d.sCount[k] - d.blkIndent >= 4)) {
|
|
2749
|
+
for (b = $ + 1; b <= w && l[(b - $) % n] === d.src[b]; b++)
|
|
2750
|
+
;
|
|
2751
|
+
if (!(Math.floor((b - $) / n) < L) && (b -= (b - $) % n, b = d.skipSpaces(b), !(b < w))) {
|
|
2752
|
+
y = !0;
|
|
2753
|
+
break;
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
const P = d.parentType, W = d.lineMax;
|
|
2757
|
+
return d.parentType = "root", d.lineMax = k, p = d.push("admonition_open", "div", 1), p.markup = S, p.block = !0, p.info = a, p.map = [f, k], p = d.push("admonition_title_open", "p", 1), p.markup = S + " " + a, p.map = [f, k], p = d.push("inline", "", 0), p.content = c, p.map = [f, d.line - 1], p.children = [], p = d.push("admonition_title_close", "p", -1), p.markup = S + " " + a, d.md.block.tokenize(d, f + 1, k), p = d.push("admonition_close", "div", -1), p.markup = d.src.slice($, b), p.block = !0, d.parentType = P, d.lineMax = W, d.line = k + (y ? 1 : 0), !0;
|
|
2758
|
+
},
|
|
2759
|
+
{
|
|
2760
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
2761
|
+
}
|
|
2762
|
+
), e.renderer.rules.admonition_open = m, e.renderer.rules.admonition_title_open = m, e.renderer.rules.admonition_title_close = m, e.renderer.rules.admonition_close = m;
|
|
2763
|
+
}, so = (e, t) => {
|
|
2764
|
+
let o;
|
|
2765
|
+
e.core.ruler.push("headingLinks", (l) => {
|
|
2766
|
+
o || (o = l.Token);
|
|
2767
|
+
}), e.renderer.rules.heading_open = (l, r) => {
|
|
2768
|
+
const n = l[r], a = l[r + 1].content, c = n.markup.length;
|
|
2769
|
+
return t.headsRef.value.push({
|
|
2770
|
+
text: a,
|
|
2771
|
+
level: c
|
|
2772
|
+
}), n.map && n.level === 0 && (n.attrSet("data-line", String(n.map[0])), n.attrSet(
|
|
2773
|
+
"id",
|
|
2774
|
+
t.mdHeadingId(a, c, t.headsRef.value.length)
|
|
2775
|
+
)), e.renderer.renderToken(l, r, t);
|
|
2776
|
+
}, e.renderer.rules.heading_close = (l, r, n, a, c) => c.renderToken(l, r, n);
|
|
2777
|
+
}, kt = (e) => e.replace(
|
|
2778
|
+
/<pre><code\sclass="language-([^>]*)">/g,
|
|
2779
|
+
'<pre><code class="language-$1" language="$1">'
|
|
2780
|
+
), co = (e) => {
|
|
2781
|
+
const { editorConfig: t, markdownItConfig: o } = I, l = x("editorId"), r = x("showCodeRowNumber"), n = x("previewOnly"), a = x("theme"), c = F([]), m = eo(e), u = lo(e), { reRenderRef: d, replaceMermaid: f } = to(e), h = Wt({
|
|
2782
|
+
html: !0,
|
|
2783
|
+
breaks: !0
|
|
2784
|
+
});
|
|
2785
|
+
h.use(oo, { themeRef: a }), h.use(io, { katexRef: u }), h.use(Gt, { figcaption: !0 }), h.use(ao), h.use(zt), h.use(so, { mdHeadingId: e.mdHeadingId, headsRef: c }), h.renderer.rules.paragraph_open = h.renderer.rules.table_open = (p, y, $, w, L) => {
|
|
2786
|
+
let S;
|
|
2787
|
+
return p[y].map && p[y].level === 0 && (S = p[y].map[0], p[y].attrSet("data-line", String(S))), L.renderToken(p, y, $);
|
|
2788
|
+
}, h.set({
|
|
2789
|
+
highlight: (p, y) => {
|
|
2790
|
+
if (e.noHighlight || !m.value)
|
|
2791
|
+
return p;
|
|
2792
|
+
const $ = m.value.getLanguage(y);
|
|
2793
|
+
let w;
|
|
2794
|
+
return $ ? w = m.value.highlight(p, {
|
|
2795
|
+
language: y,
|
|
2796
|
+
ignoreIllegals: !0
|
|
2797
|
+
}).value : w = m.value.highlightAuto(p).value, r ? il(w.trim()) : `<span class="code-block">${w.trim()}</span>`;
|
|
2798
|
+
}
|
|
2799
|
+
}), o(h);
|
|
2800
|
+
const v = F(e.sanitize(kt(h.render(e.value)))), b = Q(
|
|
2801
|
+
async () => {
|
|
2802
|
+
c.value = [], v.value = e.sanitize(kt(h.render(e.value))), C.emit(l, "buildFinished", v.value), e.onHtmlChanged(v.value), f();
|
|
2803
|
+
},
|
|
2804
|
+
(t == null ? void 0 : t.renderDelay) !== void 0 ? t == null ? void 0 : t.renderDelay : n ? 0 : 500
|
|
2805
|
+
), k = D(() => e.noHighlight || m.value);
|
|
2806
|
+
return T([ce(e, "value"), k, d], b), T(
|
|
2807
|
+
() => c.value,
|
|
2808
|
+
(p) => {
|
|
2809
|
+
e.onGetCatalog(p), C.emit(l, "catalogChanged", p);
|
|
2810
|
+
}
|
|
2811
|
+
), A(() => {
|
|
2812
|
+
C.on(l, {
|
|
2813
|
+
name: "pushCatalog",
|
|
2814
|
+
callback() {
|
|
2815
|
+
C.emit(l, "catalogChanged", c.value);
|
|
2816
|
+
}
|
|
2817
|
+
});
|
|
2818
|
+
}), { html: v };
|
|
2819
|
+
}, uo = {
|
|
2820
|
+
value: {
|
|
2821
|
+
type: String,
|
|
2822
|
+
default: ""
|
|
2823
|
+
},
|
|
2824
|
+
onChange: {
|
|
2825
|
+
type: Function,
|
|
2826
|
+
default: () => {
|
|
2827
|
+
}
|
|
2828
|
+
},
|
|
2829
|
+
setting: {
|
|
2830
|
+
type: Object,
|
|
2831
|
+
default: () => ({})
|
|
2832
|
+
},
|
|
2833
|
+
onHtmlChanged: {
|
|
2834
|
+
type: Function,
|
|
2835
|
+
default: () => {
|
|
2836
|
+
}
|
|
2837
|
+
},
|
|
2838
|
+
onGetCatalog: {
|
|
2839
|
+
type: Function,
|
|
2840
|
+
default: () => {
|
|
2841
|
+
}
|
|
2842
|
+
},
|
|
2843
|
+
mdHeadingId: {
|
|
2844
|
+
type: Function,
|
|
2845
|
+
default: () => ""
|
|
2846
|
+
},
|
|
2847
|
+
noMermaid: {
|
|
2848
|
+
type: Boolean,
|
|
2849
|
+
default: !1
|
|
2850
|
+
},
|
|
2851
|
+
sanitize: {
|
|
2852
|
+
type: Function,
|
|
2853
|
+
default: (e) => e
|
|
2854
|
+
},
|
|
2855
|
+
placeholder: {
|
|
2856
|
+
type: String,
|
|
2857
|
+
default: ""
|
|
2858
|
+
},
|
|
2859
|
+
// 不使用该函数功能
|
|
2860
|
+
noKatex: {
|
|
2861
|
+
type: Boolean,
|
|
2862
|
+
default: !1
|
|
2863
|
+
},
|
|
2864
|
+
scrollAuto: {
|
|
2865
|
+
type: Boolean
|
|
2866
|
+
},
|
|
2867
|
+
formatCopiedText: {
|
|
2868
|
+
type: Function,
|
|
2869
|
+
default: (e) => e
|
|
2870
|
+
},
|
|
2871
|
+
autofocus: {
|
|
2872
|
+
type: Boolean
|
|
2873
|
+
},
|
|
2874
|
+
disabled: {
|
|
2875
|
+
type: Boolean
|
|
2876
|
+
},
|
|
2877
|
+
readonly: {
|
|
2878
|
+
type: Boolean
|
|
2879
|
+
},
|
|
2880
|
+
maxlength: {
|
|
2881
|
+
type: Number
|
|
2882
|
+
},
|
|
2883
|
+
autoDetectCode: {
|
|
2884
|
+
type: Boolean
|
|
2885
|
+
},
|
|
2886
|
+
/**
|
|
2887
|
+
* 输入框失去焦点时触发事件
|
|
2888
|
+
*/
|
|
2889
|
+
onBlur: {
|
|
2890
|
+
type: Function,
|
|
2891
|
+
default: () => {
|
|
2892
|
+
}
|
|
2893
|
+
},
|
|
2894
|
+
/**
|
|
2895
|
+
* 输入框获得焦点时触发事件
|
|
2896
|
+
*/
|
|
2897
|
+
onFocus: {
|
|
2898
|
+
type: Function,
|
|
2899
|
+
default: () => {
|
|
2900
|
+
}
|
|
2901
|
+
},
|
|
2902
|
+
noPrettier: {
|
|
2903
|
+
type: Boolean
|
|
2904
|
+
},
|
|
2905
|
+
noHighlight: {
|
|
2906
|
+
type: Boolean,
|
|
2907
|
+
default: !1
|
|
2908
|
+
}
|
|
2909
|
+
}, mo = /* @__PURE__ */ M({
|
|
2910
|
+
name: "MDEditorContent",
|
|
2911
|
+
props: uo,
|
|
2912
|
+
setup(e) {
|
|
2913
|
+
const t = x("previewOnly"), o = x("showCodeRowNumber"), l = x("previewTheme"), r = x("editorId"), n = F(), a = F(), {
|
|
2914
|
+
inputWrapperRef: c,
|
|
2915
|
+
codeMirrorUt: m
|
|
2916
|
+
} = Jl(e), {
|
|
2917
|
+
html: u
|
|
2918
|
+
} = co(e);
|
|
2919
|
+
return wl(e, u, n, a, m), Ql(e, u), Yl(e, u), () => i("div", {
|
|
2920
|
+
class: `${s}-content`
|
|
2921
|
+
}, [!t && i("div", {
|
|
2922
|
+
class: `${s}-input-wrapper`,
|
|
2923
|
+
ref: c
|
|
2924
|
+
}, null), e.setting.preview && i("div", {
|
|
2925
|
+
id: `${r}-preview-wrapper`,
|
|
2926
|
+
class: `${s}-preview-wrapper`,
|
|
2927
|
+
ref: n,
|
|
2928
|
+
key: "content-preview-wrapper"
|
|
2929
|
+
}, [i("article", {
|
|
2930
|
+
id: `${r}-preview`,
|
|
2931
|
+
class: [`${s}-preview`, `${l == null ? void 0 : l.value}-theme`, o && `${s}-scrn`],
|
|
2932
|
+
innerHTML: u.value
|
|
2933
|
+
}, null)]), e.setting.htmlPreview && i("div", {
|
|
2934
|
+
class: `${s}-preview-wrapper`,
|
|
2935
|
+
ref: a,
|
|
2936
|
+
key: "html-preview-wrapper"
|
|
2937
|
+
}, [i("div", {
|
|
2938
|
+
class: `${s}-html`
|
|
2939
|
+
}, [u.value])])]);
|
|
2940
|
+
}
|
|
2941
|
+
}), fo = /* @__PURE__ */ M({
|
|
2942
|
+
props: {
|
|
2943
|
+
modelValue: {
|
|
2944
|
+
type: String,
|
|
2945
|
+
default: ""
|
|
2946
|
+
}
|
|
2947
|
+
},
|
|
2948
|
+
setup(e) {
|
|
2949
|
+
const t = x("usedLanguageText");
|
|
2950
|
+
return () => {
|
|
2951
|
+
var o, l;
|
|
2952
|
+
return i("div", {
|
|
2953
|
+
class: `${s}-footer-item`
|
|
2954
|
+
}, [i("label", {
|
|
2955
|
+
class: `${s}-footer-label`
|
|
2956
|
+
}, [`${(o = t.value.footer) == null ? void 0 : o.markdownTotal}:`]), i("span", null, [((l = e.modelValue) == null ? void 0 : l.length) || 0])]);
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
});
|
|
2960
|
+
const go = {
|
|
2961
|
+
checked: {
|
|
2962
|
+
type: Boolean,
|
|
2963
|
+
default: !1
|
|
2964
|
+
},
|
|
2965
|
+
onChange: {
|
|
2966
|
+
type: Function,
|
|
2967
|
+
default: () => {
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
}, ho = /* @__PURE__ */ M({
|
|
2971
|
+
props: go,
|
|
2972
|
+
setup(e) {
|
|
2973
|
+
return () => i("div", {
|
|
2974
|
+
class: [`${s}-checkbox`, e.checked && `${s}-checkbox-checked`],
|
|
2975
|
+
onClick: () => {
|
|
2976
|
+
e.onChange(!e.checked);
|
|
2977
|
+
}
|
|
2978
|
+
}, null);
|
|
2979
|
+
}
|
|
2980
|
+
}), vo = {
|
|
2981
|
+
scrollAuto: {
|
|
2982
|
+
type: Boolean
|
|
2983
|
+
},
|
|
2984
|
+
onScrollAutoChange: {
|
|
2985
|
+
type: Function,
|
|
2986
|
+
default: () => {
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
}, po = /* @__PURE__ */ M({
|
|
2990
|
+
props: vo,
|
|
2991
|
+
setup(e) {
|
|
2992
|
+
const t = x("usedLanguageText");
|
|
2993
|
+
return () => {
|
|
2994
|
+
var o;
|
|
2995
|
+
return i("div", {
|
|
2996
|
+
class: `${s}-footer-item`
|
|
2997
|
+
}, [i("label", {
|
|
2998
|
+
class: `${s}-footer-label`,
|
|
2999
|
+
onClick: () => {
|
|
3000
|
+
e.onScrollAutoChange(!e.scrollAuto);
|
|
3001
|
+
}
|
|
3002
|
+
}, [(o = t.value.footer) == null ? void 0 : o.scrollAuto]), i(ho, {
|
|
3003
|
+
checked: e.scrollAuto,
|
|
3004
|
+
onChange: e.onScrollAutoChange
|
|
3005
|
+
}, null)]);
|
|
3006
|
+
};
|
|
3007
|
+
}
|
|
3008
|
+
}), bo = {
|
|
3009
|
+
modelValue: {
|
|
3010
|
+
type: String,
|
|
3011
|
+
default: ""
|
|
3012
|
+
},
|
|
3013
|
+
footers: {
|
|
3014
|
+
type: Array,
|
|
3015
|
+
default: []
|
|
3016
|
+
},
|
|
3017
|
+
scrollAuto: {
|
|
3018
|
+
type: Boolean
|
|
3019
|
+
},
|
|
3020
|
+
onScrollAutoChange: {
|
|
3021
|
+
type: Function,
|
|
3022
|
+
default: () => {
|
|
3023
|
+
}
|
|
3024
|
+
},
|
|
3025
|
+
defFooters: {
|
|
3026
|
+
type: Object
|
|
3027
|
+
}
|
|
3028
|
+
}, ko = /* @__PURE__ */ M({
|
|
3029
|
+
name: "MDEditorFooter",
|
|
3030
|
+
props: bo,
|
|
3031
|
+
setup(e) {
|
|
3032
|
+
const t = D(() => {
|
|
3033
|
+
const l = e.footers.indexOf("="), r = l === -1 ? e.footers : e.footers.slice(0, l), n = l === -1 ? [] : e.footers.slice(l, Number.MAX_SAFE_INTEGER);
|
|
3034
|
+
return [r, n];
|
|
3035
|
+
}), o = (l) => {
|
|
3036
|
+
if (wt.includes(l))
|
|
3037
|
+
switch (l) {
|
|
3038
|
+
case "markdownTotal":
|
|
3039
|
+
return i(fo, {
|
|
3040
|
+
modelValue: e.modelValue
|
|
3041
|
+
}, null);
|
|
3042
|
+
case "scrollSwitch":
|
|
3043
|
+
return i(po, {
|
|
3044
|
+
scrollAuto: e.scrollAuto,
|
|
3045
|
+
onScrollAutoChange: e.onScrollAutoChange
|
|
3046
|
+
}, null);
|
|
3047
|
+
}
|
|
3048
|
+
else
|
|
3049
|
+
return e.defFooters instanceof Array ? e.defFooters[l] || "" : e.defFooters && e.defFooters.children instanceof Array && e.defFooters.children[l] || "";
|
|
3050
|
+
};
|
|
3051
|
+
return () => {
|
|
3052
|
+
const l = t.value[0].map((n) => o(n)), r = t.value[1].map((n) => o(n));
|
|
3053
|
+
return i("div", {
|
|
3054
|
+
class: `${s}-footer`
|
|
3055
|
+
}, [i("div", {
|
|
3056
|
+
class: `${s}-footer-left`
|
|
3057
|
+
}, [l]), i("div", {
|
|
3058
|
+
class: `${s}-footer-right`
|
|
3059
|
+
}, [r])]);
|
|
3060
|
+
};
|
|
3061
|
+
}
|
|
3062
|
+
}), yo = {
|
|
3063
|
+
tocItem: {
|
|
3064
|
+
type: Object,
|
|
3065
|
+
default: () => ({})
|
|
3066
|
+
},
|
|
3067
|
+
mdHeadingId: {
|
|
3068
|
+
type: Function,
|
|
3069
|
+
default: () => {
|
|
3070
|
+
}
|
|
3071
|
+
},
|
|
3072
|
+
scrollElement: {
|
|
3073
|
+
type: [String, Object],
|
|
3074
|
+
default: ""
|
|
3075
|
+
},
|
|
3076
|
+
onClick: {
|
|
3077
|
+
type: Function,
|
|
3078
|
+
default: () => {
|
|
3079
|
+
}
|
|
3080
|
+
},
|
|
3081
|
+
scrollElementOffsetTop: {
|
|
3082
|
+
type: Number,
|
|
3083
|
+
default: 0
|
|
3084
|
+
}
|
|
3085
|
+
}, xt = /* @__PURE__ */ M({
|
|
3086
|
+
props: yo,
|
|
3087
|
+
setup(e) {
|
|
3088
|
+
return () => {
|
|
3089
|
+
const {
|
|
3090
|
+
tocItem: t,
|
|
3091
|
+
mdHeadingId: o,
|
|
3092
|
+
scrollElement: l,
|
|
3093
|
+
onClick: r,
|
|
3094
|
+
scrollElementOffsetTop: n
|
|
3095
|
+
} = e;
|
|
3096
|
+
return i("div", {
|
|
3097
|
+
class: [`${s}-catalog-link`, t.active && `${s}-catalog-active`],
|
|
3098
|
+
onClick: (a) => {
|
|
3099
|
+
r(a, t), a.stopPropagation();
|
|
3100
|
+
const c = o(t.text, t.level, t.index), m = document.getElementById(c), u = l instanceof Element ? l : document.querySelector(l);
|
|
3101
|
+
if (m && u) {
|
|
3102
|
+
let d = m.offsetParent, f = m.offsetTop;
|
|
3103
|
+
if (u.contains(d))
|
|
3104
|
+
for (; d && u != d; )
|
|
3105
|
+
f += d == null ? void 0 : d.offsetTop, d = d == null ? void 0 : d.offsetParent;
|
|
3106
|
+
u == null || u.scrollTo({
|
|
3107
|
+
top: f - n,
|
|
3108
|
+
behavior: "smooth"
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
}, [i("span", {
|
|
3113
|
+
title: t.text
|
|
3114
|
+
}, [t.text]), i("div", {
|
|
3115
|
+
class: `${s}-catalog-wrapper`
|
|
3116
|
+
}, [t.children && t.children.map((a) => i(xt, {
|
|
3117
|
+
mdHeadingId: o,
|
|
3118
|
+
key: `${t.text}-link-${a.level}-${a.text}`,
|
|
3119
|
+
tocItem: a,
|
|
3120
|
+
scrollElement: l,
|
|
3121
|
+
onClick: r,
|
|
3122
|
+
scrollElementOffsetTop: n
|
|
3123
|
+
}, null))])]);
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
const Co = {
|
|
3128
|
+
/**
|
|
3129
|
+
* 编辑器的Id,务必与需要绑定的编辑器Id相同
|
|
3130
|
+
*/
|
|
3131
|
+
editorId: {
|
|
3132
|
+
type: String
|
|
3133
|
+
},
|
|
3134
|
+
class: {
|
|
3135
|
+
type: String,
|
|
3136
|
+
default: ""
|
|
3137
|
+
},
|
|
3138
|
+
mdHeadingId: {
|
|
3139
|
+
type: Function,
|
|
3140
|
+
default: (e) => e
|
|
3141
|
+
},
|
|
3142
|
+
/**
|
|
3143
|
+
* 指定滚动的容器,选择器需带上对应的符号,默认预览框
|
|
3144
|
+
* 元素必须定位!!!!!!
|
|
3145
|
+
*
|
|
3146
|
+
* 默认:#md-editor-preview-wrapper
|
|
3147
|
+
*/
|
|
3148
|
+
scrollElement: {
|
|
3149
|
+
type: [String, Object]
|
|
3150
|
+
},
|
|
3151
|
+
theme: {
|
|
3152
|
+
type: String,
|
|
3153
|
+
default: "light"
|
|
3154
|
+
},
|
|
3155
|
+
/**
|
|
3156
|
+
* 高亮标题相对滚动容器顶部偏移量,即距离该值时,高亮当前目录菜单项
|
|
3157
|
+
*
|
|
3158
|
+
* 默认:20px
|
|
3159
|
+
*/
|
|
3160
|
+
offsetTop: {
|
|
3161
|
+
type: Number,
|
|
3162
|
+
default: 20
|
|
3163
|
+
},
|
|
3164
|
+
/**
|
|
3165
|
+
* 滚动区域的固定顶部高度
|
|
3166
|
+
*
|
|
3167
|
+
* 默认:0
|
|
3168
|
+
*/
|
|
3169
|
+
scrollElementOffsetTop: {
|
|
3170
|
+
type: Number,
|
|
3171
|
+
default: 0
|
|
3172
|
+
},
|
|
3173
|
+
onClick: {
|
|
3174
|
+
type: Function
|
|
3175
|
+
}
|
|
3176
|
+
}, ue = /* @__PURE__ */ M({
|
|
3177
|
+
name: "MdCatalog",
|
|
3178
|
+
props: Co,
|
|
3179
|
+
emits: ["onClick"],
|
|
3180
|
+
setup(e, t) {
|
|
3181
|
+
const o = e.editorId, l = N({
|
|
3182
|
+
list: [],
|
|
3183
|
+
show: !1,
|
|
3184
|
+
scrollElement: e.scrollElement || `#${o}-preview-wrapper`
|
|
3185
|
+
}), r = D(() => {
|
|
3186
|
+
const a = [];
|
|
3187
|
+
return l.list.forEach(({
|
|
3188
|
+
text: c,
|
|
3189
|
+
level: m,
|
|
3190
|
+
active: u
|
|
3191
|
+
}, d) => {
|
|
3192
|
+
const f = {
|
|
3193
|
+
level: m,
|
|
3194
|
+
text: c,
|
|
3195
|
+
index: d + 1,
|
|
3196
|
+
active: !!u
|
|
3197
|
+
};
|
|
3198
|
+
if (a.length === 0)
|
|
3199
|
+
a.push(f);
|
|
3200
|
+
else {
|
|
3201
|
+
let h = a[a.length - 1];
|
|
3202
|
+
if (f.level > h.level)
|
|
3203
|
+
for (let v = h.level + 1; v <= 6; v++) {
|
|
3204
|
+
const {
|
|
3205
|
+
children: b
|
|
3206
|
+
} = h;
|
|
3207
|
+
if (!b) {
|
|
3208
|
+
h.children = [f];
|
|
3209
|
+
break;
|
|
3210
|
+
}
|
|
3211
|
+
if (h = b[b.length - 1], f.level <= h.level) {
|
|
3212
|
+
b.push(f);
|
|
3213
|
+
break;
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
else
|
|
3217
|
+
a.push(f);
|
|
3218
|
+
}
|
|
3219
|
+
}), a;
|
|
3220
|
+
});
|
|
3221
|
+
A(() => {
|
|
3222
|
+
C.on(o, {
|
|
3223
|
+
name: "catalogChanged",
|
|
3224
|
+
callback: (a) => {
|
|
3225
|
+
l.list = a.map((c, m) => m === 0 ? {
|
|
3226
|
+
...c,
|
|
3227
|
+
active: !0
|
|
3228
|
+
} : {
|
|
3229
|
+
...c
|
|
3230
|
+
});
|
|
3231
|
+
}
|
|
3232
|
+
}), C.emit(o, "pushCatalog");
|
|
3233
|
+
});
|
|
3234
|
+
const n = () => {
|
|
3235
|
+
var c;
|
|
3236
|
+
const a = l.scrollElement instanceof HTMLElement ? l.scrollElement : document.querySelector(l.scrollElement);
|
|
3237
|
+
(c = a === document.documentElement ? window : a) == null || c.addEventListener("scroll", al(() => {
|
|
3238
|
+
if (l.list.length === 0)
|
|
3239
|
+
return !1;
|
|
3240
|
+
const {
|
|
3241
|
+
activeHead: m
|
|
3242
|
+
} = l.list.reduce((u, d, f) => {
|
|
3243
|
+
const h = document.getElementById(e.mdHeadingId(d.text, d.level, f + 1));
|
|
3244
|
+
if (h instanceof HTMLElement) {
|
|
3245
|
+
const v = sl(h, a);
|
|
3246
|
+
if (v < e.offsetTop && v > u.minTop)
|
|
3247
|
+
return {
|
|
3248
|
+
activeHead: d,
|
|
3249
|
+
minTop: v
|
|
3250
|
+
};
|
|
3251
|
+
}
|
|
3252
|
+
return u;
|
|
3253
|
+
}, {
|
|
3254
|
+
activeHead: l.list[0],
|
|
3255
|
+
minTop: Number.MIN_SAFE_INTEGER
|
|
3256
|
+
});
|
|
3257
|
+
l.list = l.list.map((u) => u === m ? {
|
|
3258
|
+
...u,
|
|
3259
|
+
active: !0
|
|
3260
|
+
} : {
|
|
3261
|
+
...u,
|
|
3262
|
+
active: !1
|
|
3263
|
+
});
|
|
3264
|
+
}));
|
|
3265
|
+
};
|
|
3266
|
+
return A(() => {
|
|
3267
|
+
n(), C.on(o, {
|
|
3268
|
+
name: ve,
|
|
3269
|
+
callback(a) {
|
|
3270
|
+
a && q(n);
|
|
3271
|
+
}
|
|
3272
|
+
});
|
|
3273
|
+
}), () => i("div", {
|
|
3274
|
+
class: `${s}-catalog${e.theme === "dark" ? "-dark" : ""} ${e.class}`
|
|
3275
|
+
}, [r.value.map((a) => i(xt, {
|
|
3276
|
+
mdHeadingId: e.mdHeadingId,
|
|
3277
|
+
tocItem: a,
|
|
3278
|
+
key: `link-${a.level}-${a.text}`,
|
|
3279
|
+
scrollElement: l.scrollElement,
|
|
3280
|
+
onClick: (c, m) => {
|
|
3281
|
+
e.onClick ? e.onClick(c, m) : t.emit("onClick", c, m);
|
|
3282
|
+
},
|
|
3283
|
+
scrollElementOffsetTop: e.scrollElementOffsetTop
|
|
3284
|
+
}, null))]);
|
|
3285
|
+
}
|
|
3286
|
+
}), $o = (e, t) => {
|
|
3287
|
+
const { editorId: o, previewOnly: l } = e, r = N({
|
|
3288
|
+
// 是否已编译成html
|
|
3289
|
+
buildFinished: !1,
|
|
3290
|
+
// 存储当前最新的html
|
|
3291
|
+
html: ""
|
|
3292
|
+
});
|
|
3293
|
+
T(
|
|
3294
|
+
() => e.modelValue,
|
|
3295
|
+
() => {
|
|
3296
|
+
r.buildFinished = !1;
|
|
3297
|
+
}
|
|
3298
|
+
), A(() => {
|
|
3299
|
+
l || (C.on(o, {
|
|
3300
|
+
name: "buildFinished",
|
|
3301
|
+
callback(n) {
|
|
3302
|
+
r.buildFinished = !0, r.html = n;
|
|
3303
|
+
}
|
|
3304
|
+
}), C.on(o, {
|
|
3305
|
+
name: me,
|
|
3306
|
+
callback() {
|
|
3307
|
+
const n = new Promise((a) => {
|
|
3308
|
+
if (r.buildFinished)
|
|
3309
|
+
a(r.html);
|
|
3310
|
+
else {
|
|
3311
|
+
const c = (m) => {
|
|
3312
|
+
a(m), C.remove(o, "buildFinished", c);
|
|
3313
|
+
};
|
|
3314
|
+
C.on(o, {
|
|
3315
|
+
name: "buildFinished",
|
|
3316
|
+
callback: c
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
});
|
|
3320
|
+
e.onSave ? e.onSave(e.modelValue, n) : t.emit("onSave", e.modelValue, n);
|
|
3321
|
+
}
|
|
3322
|
+
}));
|
|
3323
|
+
});
|
|
3324
|
+
}, wo = (e) => {
|
|
3325
|
+
var n;
|
|
3326
|
+
const { editorId: t, previewOnly: o } = e, l = (n = I == null ? void 0 : I.editorExtensions) == null ? void 0 : n.highlight;
|
|
3327
|
+
G("editorId", t), G("tabWidth", e.tabWidth), G(
|
|
3328
|
+
"theme",
|
|
3329
|
+
D(() => e.theme)
|
|
3330
|
+
), G(
|
|
3331
|
+
"highlight",
|
|
3332
|
+
D(() => {
|
|
3333
|
+
const a = {
|
|
3334
|
+
...Ye,
|
|
3335
|
+
...l == null ? void 0 : l.css
|
|
3336
|
+
}, c = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme;
|
|
3337
|
+
return {
|
|
3338
|
+
js: (l == null ? void 0 : l.js) || Jt,
|
|
3339
|
+
css: a[e.codeTheme] ? a[e.codeTheme][c] : Ye.atom[c]
|
|
3340
|
+
};
|
|
3341
|
+
})
|
|
3342
|
+
), G("previewOnly", o), G("showCodeRowNumber", e.showCodeRowNumber);
|
|
3343
|
+
const r = D(() => {
|
|
3344
|
+
var c;
|
|
3345
|
+
const a = {
|
|
3346
|
+
...Ze,
|
|
3347
|
+
...(c = I == null ? void 0 : I.editorConfig) == null ? void 0 : c.languageUserDefined
|
|
3348
|
+
};
|
|
3349
|
+
return a[e.language] ? a[e.language] : Ze["zh-CN"];
|
|
3350
|
+
});
|
|
3351
|
+
G("usedLanguageText", r), G(
|
|
3352
|
+
"previewTheme",
|
|
3353
|
+
D(() => e.previewTheme)
|
|
3354
|
+
);
|
|
3355
|
+
}, To = (e) => {
|
|
3356
|
+
var u, d, f, h, v, b;
|
|
3357
|
+
const { noPrettier: t, previewOnly: o, noIconfont: l, noUploadImg: r } = e, { editorExtensions: n } = I, a = t || !!((d = (u = I.editorExtensions) == null ? void 0 : u.prettier) != null && d.prettierInstance), c = t || !!((h = (f = I.editorExtensions) == null ? void 0 : f.prettier) != null && h.parserMarkdownInstance), m = r || !!((b = (v = I.editorExtensions) == null ? void 0 : v.cropper) != null && b.instance);
|
|
3358
|
+
A(() => {
|
|
3359
|
+
var L, S, B, P;
|
|
3360
|
+
const k = document.createElement("script");
|
|
3361
|
+
k.src = (n == null ? void 0 : n.iconfont) || Zt, k.id = `${s}-icon`;
|
|
3362
|
+
const p = document.createElement("script"), y = document.createElement("script");
|
|
3363
|
+
p.src = ((L = n == null ? void 0 : n.prettier) == null ? void 0 : L.standaloneJs) || Ke.main, p.id = `${s}-prettier`, y.src = ((S = n == null ? void 0 : n.prettier) == null ? void 0 : S.parserMarkdownJs) || Ke.markdown, y.id = `${s}-prettierMD`;
|
|
3364
|
+
const $ = document.createElement("link");
|
|
3365
|
+
$.rel = "stylesheet", $.href = ((B = n == null ? void 0 : n.cropper) == null ? void 0 : B.css) || Xe.css, $.id = `${s}-cropperCss`;
|
|
3366
|
+
const w = document.createElement("script");
|
|
3367
|
+
w.src = ((P = n == null ? void 0 : n.cropper) == null ? void 0 : P.js) || Xe.js, w.id = `${s}-cropper`, l || O(k), o || (m || (O($), O(w)), a || O(p), c || O(y));
|
|
3368
|
+
});
|
|
3369
|
+
}, So = (e, t) => {
|
|
3370
|
+
const { editorId: o, previewOnly: l } = e, r = N({
|
|
3371
|
+
pageFullscreen: e.pageFullscreen,
|
|
3372
|
+
fullscreen: !1,
|
|
3373
|
+
preview: e.preview,
|
|
3374
|
+
htmlPreview: e.preview ? !1 : e.htmlPreview
|
|
3375
|
+
}), n = (m, u) => {
|
|
3376
|
+
r[m] = u === void 0 ? !r[m] : u, m === "preview" && r.preview ? r.htmlPreview = !1 : m === "htmlPreview" && r.htmlPreview && (r.preview = !1);
|
|
3377
|
+
};
|
|
3378
|
+
let a = "";
|
|
3379
|
+
const c = () => {
|
|
3380
|
+
r.pageFullscreen || r.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = a;
|
|
3381
|
+
};
|
|
3382
|
+
return T(() => [r.pageFullscreen, r.fullscreen], c), A(() => {
|
|
3383
|
+
l || C.on(o, {
|
|
3384
|
+
name: "uploadImage",
|
|
3385
|
+
callback(m, u) {
|
|
3386
|
+
const d = (f) => {
|
|
3387
|
+
C.emit(o, "replace", "image", {
|
|
3388
|
+
desc: "",
|
|
3389
|
+
urls: f
|
|
3390
|
+
}), u && u();
|
|
3391
|
+
};
|
|
3392
|
+
e.onUploadImg ? e.onUploadImg(m, d) : t.emit("onUploadImg", m, d);
|
|
3393
|
+
}
|
|
3394
|
+
}), a = document.body.style.overflow, c();
|
|
3395
|
+
}), [r, n];
|
|
3396
|
+
}, xo = (e) => {
|
|
3397
|
+
const { editorId: t } = e, o = F(!1);
|
|
3398
|
+
A(() => {
|
|
3399
|
+
C.on(t, {
|
|
3400
|
+
name: we,
|
|
3401
|
+
callback: (r) => {
|
|
3402
|
+
r === void 0 ? o.value = !o.value : o.value = r;
|
|
3403
|
+
}
|
|
3404
|
+
});
|
|
3405
|
+
});
|
|
3406
|
+
const l = D(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog"));
|
|
3407
|
+
return [o, l];
|
|
3408
|
+
}, Eo = (e, t, o, l, r) => {
|
|
3409
|
+
const { editorId: n } = e;
|
|
3410
|
+
T(
|
|
3411
|
+
() => l.pageFullscreen,
|
|
3412
|
+
(c) => {
|
|
3413
|
+
C.emit(n, Qe, c);
|
|
3414
|
+
}
|
|
3415
|
+
), T(
|
|
3416
|
+
() => l.fullscreen,
|
|
3417
|
+
(c) => {
|
|
3418
|
+
C.emit(n, et, c);
|
|
3419
|
+
}
|
|
3420
|
+
), T(
|
|
3421
|
+
() => l.preview,
|
|
3422
|
+
(c) => {
|
|
3423
|
+
C.emit(n, ve, c);
|
|
3424
|
+
}
|
|
3425
|
+
), T(
|
|
3426
|
+
() => l.htmlPreview,
|
|
3427
|
+
(c) => {
|
|
3428
|
+
C.emit(n, tt, c);
|
|
3429
|
+
}
|
|
3430
|
+
), T(o, (c) => {
|
|
3431
|
+
C.emit(n, lt, c);
|
|
3432
|
+
});
|
|
3433
|
+
const a = {
|
|
3434
|
+
on(c, m) {
|
|
3435
|
+
switch (c) {
|
|
3436
|
+
case "pageFullscreen": {
|
|
3437
|
+
C.on(n, {
|
|
3438
|
+
name: Qe,
|
|
3439
|
+
callback(u) {
|
|
3440
|
+
m(u);
|
|
3441
|
+
}
|
|
3442
|
+
});
|
|
3443
|
+
break;
|
|
3444
|
+
}
|
|
3445
|
+
case "fullscreen": {
|
|
3446
|
+
C.on(n, {
|
|
3447
|
+
name: et,
|
|
3448
|
+
callback(u) {
|
|
3449
|
+
m(u);
|
|
3450
|
+
}
|
|
3451
|
+
});
|
|
3452
|
+
break;
|
|
3453
|
+
}
|
|
3454
|
+
case "preview": {
|
|
3455
|
+
C.on(n, {
|
|
3456
|
+
name: ve,
|
|
3457
|
+
callback(u) {
|
|
3458
|
+
m(u);
|
|
3459
|
+
}
|
|
3460
|
+
});
|
|
3461
|
+
break;
|
|
3462
|
+
}
|
|
3463
|
+
case "htmlPreview": {
|
|
3464
|
+
C.on(n, {
|
|
3465
|
+
name: tt,
|
|
3466
|
+
callback(u) {
|
|
3467
|
+
m(u);
|
|
3468
|
+
}
|
|
3469
|
+
});
|
|
3470
|
+
break;
|
|
3471
|
+
}
|
|
3472
|
+
case "catalog": {
|
|
3473
|
+
C.on(n, {
|
|
3474
|
+
name: lt,
|
|
3475
|
+
callback(u) {
|
|
3476
|
+
m(u);
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
break;
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
},
|
|
3483
|
+
togglePageFullscreen(c) {
|
|
3484
|
+
r("pageFullscreen", c);
|
|
3485
|
+
},
|
|
3486
|
+
toggleFullscreen(c) {
|
|
3487
|
+
C.emit(n, Tt, c);
|
|
3488
|
+
},
|
|
3489
|
+
togglePreview(c) {
|
|
3490
|
+
r("preview", c);
|
|
3491
|
+
},
|
|
3492
|
+
toggleHtmlPreview(c) {
|
|
3493
|
+
r("htmlPreview", c);
|
|
3494
|
+
},
|
|
3495
|
+
toggleCatalog(c) {
|
|
3496
|
+
C.emit(n, we, c);
|
|
3497
|
+
},
|
|
3498
|
+
triggerSave() {
|
|
3499
|
+
C.emit(n, me);
|
|
3500
|
+
},
|
|
3501
|
+
insert(c) {
|
|
3502
|
+
C.emit(n, "replace", "universal", { generate: c });
|
|
3503
|
+
},
|
|
3504
|
+
focus() {
|
|
3505
|
+
C.emit(n, St);
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3508
|
+
t.expose(a);
|
|
3509
|
+
}, Lo = (e) => e, Ho = {
|
|
3510
|
+
/**
|
|
3511
|
+
* 主题
|
|
3512
|
+
*
|
|
3513
|
+
* @default 'light'
|
|
3514
|
+
*/
|
|
3515
|
+
modelValue: {
|
|
3516
|
+
type: String,
|
|
3517
|
+
default: ""
|
|
3518
|
+
},
|
|
3519
|
+
/**
|
|
3520
|
+
* 主题,支持light和dark
|
|
3521
|
+
*
|
|
3522
|
+
* @default 'light'
|
|
3523
|
+
*/
|
|
3524
|
+
theme: {
|
|
3525
|
+
type: String,
|
|
3526
|
+
default: "light"
|
|
3527
|
+
},
|
|
3528
|
+
/**
|
|
3529
|
+
* 外层类名
|
|
3530
|
+
*
|
|
3531
|
+
* @default ''
|
|
3532
|
+
*/
|
|
3533
|
+
class: {
|
|
3534
|
+
type: String,
|
|
3535
|
+
default: ""
|
|
3536
|
+
},
|
|
3537
|
+
/**
|
|
3538
|
+
* input回调事件
|
|
3539
|
+
*/
|
|
3540
|
+
onChange: {
|
|
3541
|
+
type: Function
|
|
3542
|
+
},
|
|
3543
|
+
/**
|
|
3544
|
+
* input回调事件
|
|
3545
|
+
*/
|
|
3546
|
+
onSave: {
|
|
3547
|
+
type: Function
|
|
3548
|
+
},
|
|
3549
|
+
/**
|
|
3550
|
+
* 上传图片事件
|
|
3551
|
+
*/
|
|
3552
|
+
onUploadImg: {
|
|
3553
|
+
type: Function
|
|
3554
|
+
},
|
|
3555
|
+
/**
|
|
3556
|
+
* 是否页面内全屏
|
|
3557
|
+
*
|
|
3558
|
+
* @default false
|
|
3559
|
+
*/
|
|
3560
|
+
pageFullscreen: {
|
|
3561
|
+
type: Boolean,
|
|
3562
|
+
default: !1
|
|
3563
|
+
},
|
|
3564
|
+
/**
|
|
3565
|
+
* 是否展开预览
|
|
3566
|
+
*
|
|
3567
|
+
* @default true
|
|
3568
|
+
*/
|
|
3569
|
+
preview: {
|
|
3570
|
+
type: Boolean,
|
|
3571
|
+
default: !0
|
|
3572
|
+
},
|
|
3573
|
+
/**
|
|
3574
|
+
* 是否展开html预览
|
|
3575
|
+
*
|
|
3576
|
+
* @default false
|
|
3577
|
+
*/
|
|
3578
|
+
htmlPreview: {
|
|
3579
|
+
type: Boolean,
|
|
3580
|
+
default: !1
|
|
3581
|
+
},
|
|
3582
|
+
/**
|
|
3583
|
+
* 仅预览模式,不显示toolbar和编辑框
|
|
3584
|
+
*
|
|
3585
|
+
* @default false
|
|
3586
|
+
*/
|
|
3587
|
+
previewOnly: {
|
|
3588
|
+
type: Boolean,
|
|
3589
|
+
default: !1
|
|
3590
|
+
},
|
|
3591
|
+
/**
|
|
3592
|
+
* 预设语言名称
|
|
3593
|
+
*
|
|
3594
|
+
* @default 'zh-CN'
|
|
3595
|
+
*/
|
|
3596
|
+
language: {
|
|
3597
|
+
type: String,
|
|
3598
|
+
default: "zh-CN"
|
|
3599
|
+
},
|
|
3600
|
+
/**
|
|
3601
|
+
* 工具栏选择显示
|
|
3602
|
+
*
|
|
3603
|
+
* @default allToolbar
|
|
3604
|
+
*/
|
|
3605
|
+
toolbars: {
|
|
3606
|
+
type: Array,
|
|
3607
|
+
default: $t
|
|
3608
|
+
},
|
|
3609
|
+
/**
|
|
3610
|
+
* 工具栏选择不显示
|
|
3611
|
+
*
|
|
3612
|
+
* @default []
|
|
3613
|
+
*/
|
|
3614
|
+
toolbarsExclude: {
|
|
3615
|
+
type: Array,
|
|
3616
|
+
default: []
|
|
3617
|
+
},
|
|
3618
|
+
/**
|
|
3619
|
+
* 格式化md
|
|
3620
|
+
*
|
|
3621
|
+
* @default true
|
|
3622
|
+
*/
|
|
3623
|
+
noPrettier: {
|
|
3624
|
+
type: Boolean,
|
|
3625
|
+
default: !1
|
|
3626
|
+
},
|
|
3627
|
+
/**
|
|
3628
|
+
* html变化事件
|
|
3629
|
+
*/
|
|
3630
|
+
onHtmlChanged: {
|
|
3631
|
+
type: Function
|
|
3632
|
+
},
|
|
3633
|
+
/**
|
|
3634
|
+
* 获取目录结构
|
|
3635
|
+
*/
|
|
3636
|
+
onGetCatalog: {
|
|
3637
|
+
type: Function
|
|
3638
|
+
},
|
|
3639
|
+
/**
|
|
3640
|
+
* 编辑器唯一标识
|
|
3641
|
+
*
|
|
3642
|
+
* @default 'md-editor-v3'
|
|
3643
|
+
*/
|
|
3644
|
+
editorId: {
|
|
3645
|
+
type: String,
|
|
3646
|
+
default: Xt
|
|
3647
|
+
},
|
|
3648
|
+
/**
|
|
3649
|
+
* 一个tab等于空格数
|
|
3650
|
+
*
|
|
3651
|
+
* @default 2
|
|
3652
|
+
*/
|
|
3653
|
+
tabWidth: {
|
|
3654
|
+
type: Number,
|
|
3655
|
+
default: 2
|
|
3656
|
+
},
|
|
3657
|
+
/**
|
|
3658
|
+
* 预览中代码是否显示行号
|
|
3659
|
+
*
|
|
3660
|
+
* @default false
|
|
3661
|
+
*/
|
|
3662
|
+
showCodeRowNumber: {
|
|
3663
|
+
type: Boolean,
|
|
3664
|
+
default: !1
|
|
3665
|
+
},
|
|
3666
|
+
/**
|
|
3667
|
+
* 预览内容样式
|
|
3668
|
+
*
|
|
3669
|
+
* @default 'default'
|
|
3670
|
+
*/
|
|
3671
|
+
previewTheme: {
|
|
3672
|
+
type: String,
|
|
3673
|
+
default: "default"
|
|
3674
|
+
},
|
|
3675
|
+
/**
|
|
3676
|
+
* 编辑器样式
|
|
3677
|
+
*/
|
|
3678
|
+
style: {
|
|
3679
|
+
type: Object,
|
|
3680
|
+
default: () => ({})
|
|
3681
|
+
},
|
|
3682
|
+
/**
|
|
3683
|
+
* 标题的id生成方式
|
|
3684
|
+
*
|
|
3685
|
+
* @default (text: string) => text
|
|
3686
|
+
*/
|
|
3687
|
+
mdHeadingId: {
|
|
3688
|
+
type: Function,
|
|
3689
|
+
default: Lo
|
|
3690
|
+
},
|
|
3691
|
+
/**
|
|
3692
|
+
* 表格预设格子数
|
|
3693
|
+
*
|
|
3694
|
+
* @default [6, 4]
|
|
3695
|
+
*/
|
|
3696
|
+
tableShape: {
|
|
3697
|
+
type: Array,
|
|
3698
|
+
default: () => [6, 4]
|
|
3699
|
+
},
|
|
3700
|
+
/**
|
|
3701
|
+
* 不使用该mermaid
|
|
3702
|
+
*
|
|
3703
|
+
* @default false
|
|
3704
|
+
*/
|
|
3705
|
+
noMermaid: {
|
|
3706
|
+
type: Boolean,
|
|
3707
|
+
default: !1
|
|
3708
|
+
},
|
|
3709
|
+
/**
|
|
3710
|
+
*
|
|
3711
|
+
* 不能保证文本正确的情况,在marked编译md文本后通过该方法处理
|
|
3712
|
+
* 推荐DOMPurify、sanitize-html
|
|
3713
|
+
*
|
|
3714
|
+
* @default (text: string) => text
|
|
3715
|
+
*/
|
|
3716
|
+
sanitize: {
|
|
3717
|
+
type: Function,
|
|
3718
|
+
default: (e) => e
|
|
3719
|
+
},
|
|
3720
|
+
/**
|
|
3721
|
+
* 空提示
|
|
3722
|
+
*
|
|
3723
|
+
* @default ''
|
|
3724
|
+
*/
|
|
3725
|
+
placeholder: {
|
|
3726
|
+
type: String,
|
|
3727
|
+
default: ""
|
|
3728
|
+
},
|
|
3729
|
+
/**
|
|
3730
|
+
* 不使用katex
|
|
3731
|
+
*
|
|
3732
|
+
* @default false
|
|
3733
|
+
*/
|
|
3734
|
+
noKatex: {
|
|
3735
|
+
type: Boolean,
|
|
3736
|
+
default: !1
|
|
3737
|
+
},
|
|
3738
|
+
/**
|
|
3739
|
+
* 自定义的工具栏列表
|
|
3740
|
+
*/
|
|
3741
|
+
defToolbars: {
|
|
3742
|
+
type: [String, Object]
|
|
3743
|
+
},
|
|
3744
|
+
/**
|
|
3745
|
+
* 内部错误捕获
|
|
3746
|
+
*/
|
|
3747
|
+
onError: {
|
|
3748
|
+
type: Function
|
|
3749
|
+
},
|
|
3750
|
+
/**
|
|
3751
|
+
* 代码主题
|
|
3752
|
+
*
|
|
3753
|
+
* @default 'atom'
|
|
3754
|
+
*/
|
|
3755
|
+
codeTheme: {
|
|
3756
|
+
type: String,
|
|
3757
|
+
default: "atom"
|
|
3758
|
+
},
|
|
3759
|
+
/**
|
|
3760
|
+
* 页脚列表显示顺序
|
|
3761
|
+
*/
|
|
3762
|
+
footers: {
|
|
3763
|
+
type: Array,
|
|
3764
|
+
default: wt
|
|
3765
|
+
},
|
|
3766
|
+
/**
|
|
3767
|
+
* 是否默认激活输入框和预览框同步滚动
|
|
3768
|
+
*
|
|
3769
|
+
* @default true
|
|
3770
|
+
*/
|
|
3771
|
+
scrollAuto: {
|
|
3772
|
+
type: Boolean,
|
|
3773
|
+
default: !0
|
|
3774
|
+
},
|
|
3775
|
+
/**
|
|
3776
|
+
* 自定义的也叫工具组件列表
|
|
3777
|
+
*/
|
|
3778
|
+
defFooters: {
|
|
3779
|
+
type: [String, Object]
|
|
3780
|
+
},
|
|
3781
|
+
/**
|
|
3782
|
+
* 不插入iconfont链接
|
|
3783
|
+
*
|
|
3784
|
+
* @default false
|
|
3785
|
+
*/
|
|
3786
|
+
noIconfont: {
|
|
3787
|
+
type: Boolean
|
|
3788
|
+
},
|
|
3789
|
+
/**
|
|
3790
|
+
* 复制代码格式化方法
|
|
3791
|
+
*
|
|
3792
|
+
* @default (text) => text
|
|
3793
|
+
*/
|
|
3794
|
+
formatCopiedText: {
|
|
3795
|
+
type: Function,
|
|
3796
|
+
default: (e) => e
|
|
3797
|
+
},
|
|
3798
|
+
/**
|
|
3799
|
+
* 是否禁用上传图片
|
|
3800
|
+
*
|
|
3801
|
+
* @default false
|
|
3802
|
+
*/
|
|
3803
|
+
noUploadImg: {
|
|
3804
|
+
type: Boolean
|
|
3805
|
+
},
|
|
3806
|
+
/**
|
|
3807
|
+
* 某些预览主题的代码模块背景是暗色系
|
|
3808
|
+
* 将这个属性设置为true,会自动在该主题下的light模式下使用暗色系的代码风格
|
|
3809
|
+
*
|
|
3810
|
+
* @default true
|
|
3811
|
+
*/
|
|
3812
|
+
codeStyleReverse: {
|
|
3813
|
+
type: Boolean,
|
|
3814
|
+
default: !0
|
|
3815
|
+
},
|
|
3816
|
+
/**
|
|
3817
|
+
* 需要自动调整的预览主题
|
|
3818
|
+
*
|
|
3819
|
+
* @default ['default', 'mk-cute']
|
|
3820
|
+
*/
|
|
3821
|
+
codeStyleReverseList: {
|
|
3822
|
+
type: Array,
|
|
3823
|
+
default: ["default", "mk-cute"]
|
|
3824
|
+
},
|
|
3825
|
+
/**
|
|
3826
|
+
* 文本区域自动获得焦点
|
|
3827
|
+
*
|
|
3828
|
+
* @default false
|
|
3829
|
+
*/
|
|
3830
|
+
autoFocus: {
|
|
3831
|
+
type: Boolean
|
|
3832
|
+
},
|
|
3833
|
+
/**
|
|
3834
|
+
* 禁用文本区域
|
|
3835
|
+
*
|
|
3836
|
+
* @default false
|
|
3837
|
+
*/
|
|
3838
|
+
disabled: {
|
|
3839
|
+
type: Boolean
|
|
3840
|
+
},
|
|
3841
|
+
/**
|
|
3842
|
+
* 文本区域为只读
|
|
3843
|
+
*
|
|
3844
|
+
* @default false
|
|
3845
|
+
*/
|
|
3846
|
+
readOnly: {
|
|
3847
|
+
type: Boolean
|
|
3848
|
+
},
|
|
3849
|
+
/**
|
|
3850
|
+
* 文本区域允许的最大字符数
|
|
3851
|
+
*/
|
|
3852
|
+
maxLength: {
|
|
3853
|
+
type: Number
|
|
3854
|
+
},
|
|
3855
|
+
/**
|
|
3856
|
+
* 是否启用自动识别粘贴代码类别
|
|
3857
|
+
* 目前支持 vscode 复制的代码识别
|
|
3858
|
+
*
|
|
3859
|
+
* @default false
|
|
3860
|
+
*/
|
|
3861
|
+
autoDetectCode: {
|
|
3862
|
+
type: Boolean
|
|
3863
|
+
},
|
|
3864
|
+
/**
|
|
3865
|
+
* 输入框失去焦点时触发事件
|
|
3866
|
+
*/
|
|
3867
|
+
onBlur: {
|
|
3868
|
+
type: Function
|
|
3869
|
+
},
|
|
3870
|
+
/**
|
|
3871
|
+
* 输入框获得焦点时触发事件
|
|
3872
|
+
*/
|
|
3873
|
+
onFocus: {
|
|
3874
|
+
type: Function
|
|
3875
|
+
},
|
|
3876
|
+
noHighlight: {
|
|
3877
|
+
type: Boolean,
|
|
3878
|
+
default: !1
|
|
3879
|
+
}
|
|
3880
|
+
}, Io = [
|
|
3881
|
+
"onChange",
|
|
3882
|
+
"onSave",
|
|
3883
|
+
"onUploadImg",
|
|
3884
|
+
"onHtmlChanged",
|
|
3885
|
+
"onGetCatalog",
|
|
3886
|
+
"onError",
|
|
3887
|
+
"update:modelValue",
|
|
3888
|
+
"onBlur",
|
|
3889
|
+
"onFocus"
|
|
3890
|
+
];
|
|
3891
|
+
const z = /* @__PURE__ */ M({
|
|
3892
|
+
name: "MdEditorV3",
|
|
3893
|
+
props: Ho,
|
|
3894
|
+
emits: Io,
|
|
3895
|
+
setup(e, t) {
|
|
3896
|
+
const {
|
|
3897
|
+
editorId: o,
|
|
3898
|
+
previewOnly: l,
|
|
3899
|
+
noKatex: r,
|
|
3900
|
+
noMermaid: n,
|
|
3901
|
+
noPrettier: a,
|
|
3902
|
+
noUploadImg: c,
|
|
3903
|
+
noHighlight: m
|
|
3904
|
+
} = e, u = N({
|
|
3905
|
+
scrollAuto: e.scrollAuto
|
|
3906
|
+
});
|
|
3907
|
+
$o(e, t), wo(e), To(e);
|
|
3908
|
+
const [d, f] = So(e, t), [h, v] = xo(e);
|
|
3909
|
+
return ye(() => {
|
|
3910
|
+
C.clear(o);
|
|
3911
|
+
}), Eo(e, t, h, d, f), () => {
|
|
3912
|
+
var p;
|
|
3913
|
+
const b = _({
|
|
3914
|
+
props: e,
|
|
3915
|
+
ctx: t
|
|
3916
|
+
}, "defToolbars"), k = _({
|
|
3917
|
+
props: e,
|
|
3918
|
+
ctx: t
|
|
3919
|
+
}, "defFooters");
|
|
3920
|
+
return i("div", {
|
|
3921
|
+
id: o,
|
|
3922
|
+
class: [s, e.class, e.theme === "dark" && `${s}-dark`, d.fullscreen || d.pageFullscreen ? `${s}-fullscreen` : "", l && `${s}-previewOnly`],
|
|
3923
|
+
style: e.style
|
|
3924
|
+
}, [!l && i($l, {
|
|
3925
|
+
noPrettier: a,
|
|
3926
|
+
toolbars: e.toolbars,
|
|
3927
|
+
toolbarsExclude: e.toolbarsExclude,
|
|
3928
|
+
setting: d,
|
|
3929
|
+
updateSetting: f,
|
|
3930
|
+
tableShape: e.tableShape,
|
|
3931
|
+
defToolbars: b,
|
|
3932
|
+
noUploadImg: c
|
|
3933
|
+
}, null), i(mo, {
|
|
3934
|
+
value: e.modelValue,
|
|
3935
|
+
setting: d,
|
|
3936
|
+
mdHeadingId: e.mdHeadingId,
|
|
3937
|
+
noMermaid: n,
|
|
3938
|
+
noPrettier: a,
|
|
3939
|
+
sanitize: e.sanitize,
|
|
3940
|
+
placeholder: e.placeholder,
|
|
3941
|
+
noKatex: r,
|
|
3942
|
+
scrollAuto: u.scrollAuto,
|
|
3943
|
+
formatCopiedText: e.formatCopiedText,
|
|
3944
|
+
autofocus: e.autoFocus,
|
|
3945
|
+
disabled: e.disabled,
|
|
3946
|
+
readonly: e.readOnly,
|
|
3947
|
+
maxlength: e.maxLength,
|
|
3948
|
+
autoDetectCode: e.autoDetectCode,
|
|
3949
|
+
noHighlight: m,
|
|
3950
|
+
onChange: (y) => {
|
|
3951
|
+
e.onChange ? e.onChange(y) : (t.emit("update:modelValue", y), t.emit("onChange", y));
|
|
3952
|
+
},
|
|
3953
|
+
onHtmlChanged: (y) => {
|
|
3954
|
+
e.onHtmlChanged ? e.onHtmlChanged(y) : t.emit("onHtmlChanged", y);
|
|
3955
|
+
},
|
|
3956
|
+
onGetCatalog: (y) => {
|
|
3957
|
+
e.onGetCatalog ? e.onGetCatalog(y) : t.emit("onGetCatalog", y);
|
|
3958
|
+
},
|
|
3959
|
+
onBlur: (y) => {
|
|
3960
|
+
e.onBlur ? e.onBlur(y) : t.emit("onBlur", y);
|
|
3961
|
+
},
|
|
3962
|
+
onFocus: (y) => {
|
|
3963
|
+
e.onFocus ? e.onFocus(y) : t.emit("onFocus", y);
|
|
3964
|
+
}
|
|
3965
|
+
}, null), !l && ((p = e.footers) == null ? void 0 : p.length) > 0 && i(ko, {
|
|
3966
|
+
modelValue: e.modelValue,
|
|
3967
|
+
footers: e.footers,
|
|
3968
|
+
defFooters: k,
|
|
3969
|
+
scrollAuto: u.scrollAuto,
|
|
3970
|
+
onScrollAutoChange: (y) => u.scrollAuto = y
|
|
3971
|
+
}, null), v.value && !l && i(ue, {
|
|
3972
|
+
theme: e.theme,
|
|
3973
|
+
style: {
|
|
3974
|
+
display: h.value ? "block" : "none"
|
|
3975
|
+
},
|
|
3976
|
+
class: `${s}-catalog-editor`,
|
|
3977
|
+
editorId: o,
|
|
3978
|
+
mdHeadingId: e.mdHeadingId
|
|
3979
|
+
}, null)]);
|
|
3980
|
+
};
|
|
3981
|
+
}
|
|
3982
|
+
}), Ao = {
|
|
3983
|
+
title: {
|
|
3984
|
+
type: String,
|
|
3985
|
+
default: ""
|
|
3986
|
+
},
|
|
3987
|
+
// 展示在工具栏的内容,通常是个图标
|
|
3988
|
+
trigger: {
|
|
3989
|
+
type: [String, Object]
|
|
3990
|
+
},
|
|
3991
|
+
onClick: {
|
|
3992
|
+
type: Function
|
|
3993
|
+
}
|
|
3994
|
+
}, pe = /* @__PURE__ */ M({
|
|
3995
|
+
name: "NormalToolbar",
|
|
3996
|
+
props: Ao,
|
|
3997
|
+
emits: ["onClick"],
|
|
3998
|
+
setup(e, t) {
|
|
3999
|
+
return () => {
|
|
4000
|
+
const o = _({
|
|
4001
|
+
props: e,
|
|
4002
|
+
ctx: t
|
|
4003
|
+
}, "trigger");
|
|
4004
|
+
return i("div", {
|
|
4005
|
+
class: `${s}-toolbar-item`,
|
|
4006
|
+
title: e.title,
|
|
4007
|
+
onClick: (l) => {
|
|
4008
|
+
e.onClick instanceof Function ? e.onClick(l) : t.emit("onClick", l);
|
|
4009
|
+
}
|
|
4010
|
+
}, [o]);
|
|
4011
|
+
};
|
|
4012
|
+
}
|
|
4013
|
+
}), Fo = {
|
|
4014
|
+
title: {
|
|
4015
|
+
type: String,
|
|
4016
|
+
default: ""
|
|
4017
|
+
},
|
|
4018
|
+
visible: {
|
|
4019
|
+
type: Boolean
|
|
4020
|
+
},
|
|
4021
|
+
// 展示在工具栏的内容,通常是个图标
|
|
4022
|
+
trigger: {
|
|
4023
|
+
type: [String, Object]
|
|
4024
|
+
},
|
|
4025
|
+
onChange: {
|
|
4026
|
+
type: Function
|
|
4027
|
+
},
|
|
4028
|
+
// 下拉框中的内容
|
|
4029
|
+
overlay: {
|
|
4030
|
+
type: [String, Object]
|
|
4031
|
+
}
|
|
4032
|
+
}, be = /* @__PURE__ */ M({
|
|
4033
|
+
name: "DropdownToolbar",
|
|
4034
|
+
props: Fo,
|
|
4035
|
+
emits: ["onChange"],
|
|
4036
|
+
setup(e, t) {
|
|
4037
|
+
const o = x("editorId");
|
|
4038
|
+
return () => {
|
|
4039
|
+
const l = _({
|
|
4040
|
+
props: e,
|
|
4041
|
+
ctx: t
|
|
4042
|
+
}, "trigger"), r = _({
|
|
4043
|
+
props: e,
|
|
4044
|
+
ctx: t
|
|
4045
|
+
}, "overlay");
|
|
4046
|
+
return i(Y, {
|
|
4047
|
+
relative: `#${o}-toolbar-wrapper`,
|
|
4048
|
+
visible: e.visible,
|
|
4049
|
+
onChange: (n) => {
|
|
4050
|
+
e.onChange instanceof Function ? e.onChange(n) : t.emit("onChange", n);
|
|
4051
|
+
},
|
|
4052
|
+
overlay: r
|
|
4053
|
+
}, {
|
|
4054
|
+
default: () => [i("div", {
|
|
4055
|
+
class: `${s}-toolbar-item`,
|
|
4056
|
+
title: e.title || ""
|
|
4057
|
+
}, [l])]
|
|
4058
|
+
});
|
|
4059
|
+
};
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
function Mo(e) {
|
|
4063
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !It(e);
|
|
4064
|
+
}
|
|
4065
|
+
const jo = {
|
|
4066
|
+
title: {
|
|
4067
|
+
type: String,
|
|
4068
|
+
default: ""
|
|
4069
|
+
},
|
|
4070
|
+
modalTitle: {
|
|
4071
|
+
type: String,
|
|
4072
|
+
default: ""
|
|
4073
|
+
},
|
|
4074
|
+
visible: {
|
|
4075
|
+
type: Boolean
|
|
4076
|
+
},
|
|
4077
|
+
width: {
|
|
4078
|
+
type: String,
|
|
4079
|
+
default: "auto"
|
|
4080
|
+
},
|
|
4081
|
+
height: {
|
|
4082
|
+
type: String,
|
|
4083
|
+
default: "auto"
|
|
4084
|
+
},
|
|
4085
|
+
// 展示在工具栏的内容,通常是个图标
|
|
4086
|
+
trigger: {
|
|
4087
|
+
type: [String, Object]
|
|
4088
|
+
},
|
|
4089
|
+
onClick: {
|
|
4090
|
+
type: Function
|
|
4091
|
+
},
|
|
4092
|
+
onClose: {
|
|
4093
|
+
type: Function
|
|
4094
|
+
},
|
|
4095
|
+
/**
|
|
4096
|
+
* 显示全屏按钮
|
|
4097
|
+
*/
|
|
4098
|
+
showAdjust: {
|
|
4099
|
+
type: Boolean,
|
|
4100
|
+
default: !1
|
|
4101
|
+
},
|
|
4102
|
+
isFullscreen: {
|
|
4103
|
+
type: Boolean,
|
|
4104
|
+
default: !1
|
|
4105
|
+
},
|
|
4106
|
+
onAdjust: {
|
|
4107
|
+
type: Function
|
|
4108
|
+
}
|
|
4109
|
+
}, ke = /* @__PURE__ */ M({
|
|
4110
|
+
name: "ModalToolbar",
|
|
4111
|
+
props: jo,
|
|
4112
|
+
emits: ["onClick", "onClose", "onAdjust"],
|
|
4113
|
+
setup(e, t) {
|
|
4114
|
+
return () => {
|
|
4115
|
+
const o = _({
|
|
4116
|
+
props: e,
|
|
4117
|
+
ctx: t
|
|
4118
|
+
}, "trigger"), l = _({
|
|
4119
|
+
props: e,
|
|
4120
|
+
ctx: t
|
|
4121
|
+
}, "default");
|
|
4122
|
+
return i(Ce, null, [i("div", {
|
|
4123
|
+
class: `${s}-toolbar-item`,
|
|
4124
|
+
title: e.title,
|
|
4125
|
+
onClick: () => {
|
|
4126
|
+
e.onClick instanceof Function ? e.onClick() : t.emit("onClick");
|
|
4127
|
+
}
|
|
4128
|
+
}, [o]), i(Te, {
|
|
4129
|
+
width: e.width,
|
|
4130
|
+
height: e.height,
|
|
4131
|
+
title: e.modalTitle,
|
|
4132
|
+
visible: e.visible,
|
|
4133
|
+
onClose: () => {
|
|
4134
|
+
e.onClose instanceof Function ? e.onClose() : t.emit("onClose");
|
|
4135
|
+
},
|
|
4136
|
+
showAdjust: e.showAdjust,
|
|
4137
|
+
isFullscreen: e.isFullscreen,
|
|
4138
|
+
onAdjust: (r) => {
|
|
4139
|
+
e.onAdjust instanceof Function ? e.onAdjust(r) : t.emit("onAdjust", r);
|
|
4140
|
+
}
|
|
4141
|
+
}, Mo(l) ? l : {
|
|
4142
|
+
default: () => [l]
|
|
4143
|
+
})]);
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4146
|
+
});
|
|
4147
|
+
z.install = (e) => (e.component(z.name, z), e.component(pe.name, pe), e.component(be.name, be), e.component(ue.name, ue), e.component(ke.name, ke), e);
|
|
4148
|
+
z.NormalToolbar = pe;
|
|
4149
|
+
z.DropdownToolbar = be;
|
|
4150
|
+
z.MdCatalog = ue;
|
|
4151
|
+
z.ModalToolbar = ke;
|
|
4152
|
+
z.config = el;
|
|
4153
|
+
export {
|
|
4154
|
+
z as default
|
|
4155
|
+
};
|