md-editor-v3 3.0.0 → 4.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 +131 -95
- package/lib/cjs/DropdownToolbar.cjs +1 -0
- package/lib/cjs/MdCatalog.cjs +1 -0
- package/lib/cjs/MdEditor.cjs +60 -0
- package/lib/cjs/MdPreview.cjs +1 -0
- package/lib/cjs/ModalToolbar.cjs +1 -0
- package/lib/cjs/NormalToolbar.cjs +1 -0
- package/lib/cjs/chunks/config.cjs +1 -0
- package/lib/cjs/chunks/dom.cjs +1 -0
- package/lib/cjs/chunks/event-bus.cjs +1 -0
- package/lib/cjs/chunks/index.cjs +8 -0
- package/lib/cjs/chunks/index2.cjs +1 -0
- package/lib/cjs/chunks/index3.cjs +1 -0
- package/lib/cjs/chunks/index4.cjs +2 -0
- package/lib/cjs/chunks/vue-tsx.cjs +1 -0
- package/lib/cjs/config.cjs +1 -0
- package/lib/cjs/index.cjs +1 -0
- package/lib/es/DropdownToolbar.mjs +7 -0
- package/lib/es/MdCatalog.mjs +215 -0
- package/lib/es/MdEditor.mjs +2286 -0
- package/lib/es/MdPreview.mjs +15 -0
- package/lib/es/ModalToolbar.mjs +9 -0
- package/lib/es/NormalToolbar.mjs +39 -0
- package/lib/es/chunks/config.mjs +271 -0
- package/lib/es/chunks/dom.mjs +32 -0
- package/lib/es/chunks/event-bus.mjs +38 -0
- package/lib/es/chunks/index.mjs +1061 -0
- package/lib/es/chunks/index2.mjs +135 -0
- package/lib/es/chunks/index3.mjs +229 -0
- package/lib/es/chunks/index4.mjs +57 -0
- package/lib/es/chunks/vue-tsx.mjs +11 -0
- package/lib/es/config.mjs +4 -0
- package/lib/es/index.mjs +35 -0
- package/lib/preview.css +1 -0
- package/lib/style.css +1 -1
- package/lib/types/DropdownToolbar/index.d.ts +129 -0
- package/lib/{MdEditor/extensions → types}/MdCatalog/CatalogLink.d.ts +4 -4
- package/lib/{MdEditor/extensions/MdCatalog/index.d.ts → types/MdCatalog/MdCatalog.d.ts} +3 -3
- package/lib/types/MdCatalog/index.d.ts +193 -0
- package/lib/{MdEditor → types/MdEditor}/Editor.d.ts +153 -162
- package/lib/types/MdEditor/components/Checkbox/index.d.ts +24 -0
- package/lib/types/MdEditor/components/Divider/index.d.ts +2 -0
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +53 -0
- package/lib/types/MdEditor/components/Modal/index.d.ts +84 -0
- package/lib/types/MdEditor/composition.d.ts +66 -0
- package/lib/{MdEditor → types/MdEditor}/index.d.ts +343 -388
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +154 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/commands.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/index.d.ts +56 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/themeLight.d.ts +23 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/themeOneDark.d.ts +26 -0
- package/lib/types/MdEditor/layouts/Content/composition/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/composition/useAttach.d.ts +7 -0
- package/lib/types/MdEditor/layouts/Content/composition/useAutoScroll.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/composition/useCodeMirror.d.ts +13 -0
- package/lib/types/MdEditor/layouts/Content/composition/useCopyCode.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/composition/useHighlight.d.ts +8 -0
- package/lib/types/MdEditor/layouts/Content/composition/useKatex.d.ts +8 -0
- package/lib/types/MdEditor/layouts/Content/composition/useMarkdownIt.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +11 -0
- package/lib/types/MdEditor/layouts/Content/composition/usePasteUpload.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/composition/userZoom.d.ts +10 -0
- package/lib/types/MdEditor/layouts/Content/index.d.ts +173 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/admonition/index.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/codetabs/index.d.ts +14 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/heading/index.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/katex/index.d.ts +10 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/mermaid/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +89 -0
- package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +15 -0
- package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +21 -0
- package/lib/types/MdEditor/layouts/Footer/index.d.ts +50 -0
- package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +33 -0
- package/lib/types/MdEditor/layouts/Modals/Link.d.ts +42 -0
- package/lib/types/MdEditor/layouts/Modals/index.d.ts +51 -0
- package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +28 -0
- package/lib/types/MdEditor/layouts/Toolbar/composition.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +91 -0
- package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +45 -0
- package/lib/types/MdEditor/props.d.ts +546 -0
- package/lib/types/MdEditor/static/event-name.d.ts +9 -0
- package/lib/{MdEditor → types/MdEditor}/type.d.ts +2 -1
- package/lib/types/MdEditor/utils/content-help.d.ts +19 -0
- package/lib/types/MdEditor/utils/dom.d.ts +22 -0
- package/lib/types/MdEditor/utils/event-bus.d.ts +17 -0
- package/lib/types/MdEditor/utils/index.d.ts +66 -0
- package/lib/types/MdEditor/utils/scroll-auto.d.ts +18 -0
- package/lib/types/MdEditor/utils/smooth-scroll.d.ts +8 -0
- package/lib/types/MdEditor/utils/vue-tsx.d.ts +23 -0
- package/lib/types/MdPreview/MdPreview.d.ts +186 -0
- package/lib/types/MdPreview/index.d.ts +453 -0
- package/lib/types/ModalToolbar/index.d.ts +244 -0
- package/lib/types/NormalToolbar/index.d.ts +105 -0
- package/lib/types/config.d.ts +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/{md-editor-v3.umd.js → umd/index.js} +38 -38
- package/package.json +16 -20
- package/lib/md-editor-v3.cjs +0 -63
- package/lib/md-editor-v3.mjs +0 -4146
- /package/lib/{MdEditor/extensions → types/DropdownToolbar}/DropdownToolbar.d.ts +0 -0
- /package/lib/{MdEditor → types/MdEditor}/config.d.ts +0 -0
- /package/lib/{MdEditor/extensions → types/ModalToolbar}/ModalToolbar.d.ts +0 -0
- /package/lib/{MdEditor/extensions → types/NormalToolbar}/NormalToolbar.d.ts +0 -0
|
@@ -0,0 +1,2286 @@
|
|
|
1
|
+
var Ze = Object.defineProperty;
|
|
2
|
+
var Je = (e, o, n) => o in e ? Ze(e, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[o] = n;
|
|
3
|
+
var U = (e, o, n) => (Je(e, typeof o != "symbol" ? o + "" : o, n), n);
|
|
4
|
+
import { defineComponent as I, createVNode as t, inject as S, ref as q, onMounted as W, reactive as Y, computed as me, watch as F, nextTick as ue, Fragment as Ke, toRef as ae, shallowRef as Xe, onBeforeUnmount as Qe } from "vue";
|
|
5
|
+
import { p as a, a as G, s as et, b as tt, d as lt } from "./chunks/config.mjs";
|
|
6
|
+
import { a as Q, D as ot } from "./chunks/index2.mjs";
|
|
7
|
+
import { b as h } from "./chunks/event-bus.mjs";
|
|
8
|
+
import { b as at, g as nt, d as rt } from "./chunks/index4.mjs";
|
|
9
|
+
import { C as it, a as st, O as je, T as ct, b as dt, e as ut, c as mt, u as ft, d as gt, f as ht, g as bt, h as vt, i as kt, M as pt } from "./chunks/index.mjs";
|
|
10
|
+
import { a as Ct } from "./chunks/dom.mjs";
|
|
11
|
+
import { a as _e, M as $t } from "./chunks/index3.mjs";
|
|
12
|
+
import { minimalSetup as yt, EditorView as ne } from "codemirror";
|
|
13
|
+
import { EditorView as fe, placeholder as xt, keymap as wt } from "@codemirror/view";
|
|
14
|
+
import { languages as Tt } from "@codemirror/language-data";
|
|
15
|
+
import { markdown as St } from "@codemirror/lang-markdown";
|
|
16
|
+
import { deleteLine as At, indentWithTab as Mt, undo as Lt, redo as Dt } from "@codemirror/commands";
|
|
17
|
+
import { HighlightStyle as We, syntaxHighlighting as ze, indentUnit as Et } from "@codemirror/language";
|
|
18
|
+
import { tags as i } from "@lezer/highlight";
|
|
19
|
+
import { EditorSelection as re, EditorState as ie, Compartment as Ht, StateEffect as Ft } from "@codemirror/state";
|
|
20
|
+
import { g as De } from "./chunks/vue-tsx.mjs";
|
|
21
|
+
import Ye from "./MdCatalog.mjs";
|
|
22
|
+
import It from "./NormalToolbar.mjs";
|
|
23
|
+
import "medium-zoom";
|
|
24
|
+
import "copy-to-clipboard";
|
|
25
|
+
import "markdown-it";
|
|
26
|
+
import "markdown-it-image-figures";
|
|
27
|
+
import "markdown-it-task-lists";
|
|
28
|
+
import "lru-cache";
|
|
29
|
+
const Bt = /* @__PURE__ */ I({
|
|
30
|
+
setup() {
|
|
31
|
+
return () => t("div", {
|
|
32
|
+
class: `${a}-divider`
|
|
33
|
+
}, null);
|
|
34
|
+
}
|
|
35
|
+
}), Ot = {
|
|
36
|
+
noPrettier: {
|
|
37
|
+
type: Boolean
|
|
38
|
+
},
|
|
39
|
+
// 工具栏选择显示
|
|
40
|
+
toolbars: {
|
|
41
|
+
type: Array,
|
|
42
|
+
default: () => []
|
|
43
|
+
},
|
|
44
|
+
// 工具栏选择不显示
|
|
45
|
+
toolbarsExclude: {
|
|
46
|
+
type: Array,
|
|
47
|
+
default: () => []
|
|
48
|
+
},
|
|
49
|
+
setting: {
|
|
50
|
+
type: Object,
|
|
51
|
+
default: () => ({})
|
|
52
|
+
},
|
|
53
|
+
screenfull: {
|
|
54
|
+
type: Object,
|
|
55
|
+
default: null
|
|
56
|
+
},
|
|
57
|
+
screenfullJs: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: ""
|
|
60
|
+
},
|
|
61
|
+
updateSetting: {
|
|
62
|
+
type: Function,
|
|
63
|
+
default: () => {
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
tableShape: {
|
|
67
|
+
type: Array,
|
|
68
|
+
default: () => [6, 4]
|
|
69
|
+
},
|
|
70
|
+
defToolbars: {
|
|
71
|
+
type: Object
|
|
72
|
+
},
|
|
73
|
+
noUploadImg: {
|
|
74
|
+
type: Boolean
|
|
75
|
+
}
|
|
76
|
+
}, Vt = (e) => {
|
|
77
|
+
var f, d, u, k;
|
|
78
|
+
const o = S("editorId");
|
|
79
|
+
let n = (d = (f = G.editorExtensions) == null ? void 0 : f.screenfull) == null ? void 0 : d.instance;
|
|
80
|
+
const l = (k = (u = G.editorExtensions) == null ? void 0 : u.screenfull) == null ? void 0 : k.js, s = q(!1), r = ($) => {
|
|
81
|
+
if (!n) {
|
|
82
|
+
h.emit(o, "errorCatcher", {
|
|
83
|
+
name: "fullscreen",
|
|
84
|
+
message: "fullscreen is undefined"
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
n.isEnabled ? (s.value = !0, ($ === void 0 ? !n.isFullscreen : $) ? n.request() : n.exit()) : console.error("browser does not support screenfull!");
|
|
89
|
+
}, c = () => {
|
|
90
|
+
n && n.isEnabled && n.on("change", () => {
|
|
91
|
+
(s.value || e.setting.fullscreen) && (s.value = !1, e.updateSetting("fullscreen"));
|
|
92
|
+
});
|
|
93
|
+
}, g = () => {
|
|
94
|
+
n = window.screenfull, c();
|
|
95
|
+
};
|
|
96
|
+
return W(() => {
|
|
97
|
+
if (c(), !n) {
|
|
98
|
+
const $ = document.createElement("script");
|
|
99
|
+
$.src = l || et, $.onload = g, $.id = `${a}-screenfull`, Ct($, "screenfull");
|
|
100
|
+
}
|
|
101
|
+
}), W(() => {
|
|
102
|
+
h.on(o, {
|
|
103
|
+
name: it,
|
|
104
|
+
callback: r
|
|
105
|
+
});
|
|
106
|
+
}), { fullscreenHandler: r };
|
|
107
|
+
}, Rt = {
|
|
108
|
+
tableShape: {
|
|
109
|
+
type: Array,
|
|
110
|
+
default: () => [6, 4]
|
|
111
|
+
},
|
|
112
|
+
onSelected: {
|
|
113
|
+
type: Function,
|
|
114
|
+
default: () => {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, Nt = /* @__PURE__ */ I({
|
|
118
|
+
name: "TableShape",
|
|
119
|
+
props: Rt,
|
|
120
|
+
setup(e) {
|
|
121
|
+
const o = Y({
|
|
122
|
+
x: -1,
|
|
123
|
+
y: -1
|
|
124
|
+
});
|
|
125
|
+
return () => t("div", {
|
|
126
|
+
class: `${a}-table-shape`,
|
|
127
|
+
onMouseleave: () => {
|
|
128
|
+
o.x = -1, o.y = -1;
|
|
129
|
+
}
|
|
130
|
+
}, [new Array(e.tableShape[1]).fill("").map((n, l) => t("div", {
|
|
131
|
+
class: `${a}-table-shape-row`,
|
|
132
|
+
key: `table-shape-row-${l}`
|
|
133
|
+
}, [new Array(e.tableShape[0]).fill("").map((s, r) => t("div", {
|
|
134
|
+
class: `${a}-table-shape-col`,
|
|
135
|
+
key: `table-shape-col-${r}`,
|
|
136
|
+
onMouseenter: () => {
|
|
137
|
+
o.x = l, o.y = r;
|
|
138
|
+
},
|
|
139
|
+
onClick: () => {
|
|
140
|
+
e.onSelected(o);
|
|
141
|
+
}
|
|
142
|
+
}, [t("div", {
|
|
143
|
+
class: [`${a}-table-shape-col-default`, l <= o.x && r <= o.y && `${a}-table-shape-col-include`]
|
|
144
|
+
}, null)]))]))]);
|
|
145
|
+
}
|
|
146
|
+
}), Pt = Nt, Ut = {
|
|
147
|
+
type: {
|
|
148
|
+
type: String,
|
|
149
|
+
default: "link"
|
|
150
|
+
},
|
|
151
|
+
visible: {
|
|
152
|
+
type: Boolean,
|
|
153
|
+
default: !1
|
|
154
|
+
},
|
|
155
|
+
onCancel: {
|
|
156
|
+
type: Function,
|
|
157
|
+
default: () => {
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
onOk: {
|
|
161
|
+
type: Function,
|
|
162
|
+
default: () => {
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, qt = /* @__PURE__ */ I({
|
|
166
|
+
props: Ut,
|
|
167
|
+
setup(e) {
|
|
168
|
+
const o = S("usedLanguageText"), n = S("editorId"), l = me(() => {
|
|
169
|
+
var r, c;
|
|
170
|
+
switch (e.type) {
|
|
171
|
+
case "link":
|
|
172
|
+
return (r = o.value.linkModalTips) == null ? void 0 : r.linkTitle;
|
|
173
|
+
case "image":
|
|
174
|
+
return (c = o.value.linkModalTips) == null ? void 0 : c.imageTitle;
|
|
175
|
+
default:
|
|
176
|
+
return "";
|
|
177
|
+
}
|
|
178
|
+
}), s = Y({
|
|
179
|
+
desc: "",
|
|
180
|
+
url: ""
|
|
181
|
+
});
|
|
182
|
+
return F(() => e.visible, (r) => {
|
|
183
|
+
r || setTimeout(() => {
|
|
184
|
+
s.desc = "", s.url = "";
|
|
185
|
+
}, 200);
|
|
186
|
+
}), () => t(_e, {
|
|
187
|
+
title: l.value,
|
|
188
|
+
visible: e.visible,
|
|
189
|
+
onClose: e.onCancel
|
|
190
|
+
}, {
|
|
191
|
+
default: () => {
|
|
192
|
+
var r, c, g, f, d;
|
|
193
|
+
return [t("div", {
|
|
194
|
+
class: `${a}-form-item`
|
|
195
|
+
}, [t("label", {
|
|
196
|
+
class: `${a}-label`,
|
|
197
|
+
for: `link-desc-${n}`
|
|
198
|
+
}, [(r = o.value.linkModalTips) == null ? void 0 : r.descLabel]), t("input", {
|
|
199
|
+
placeholder: (c = o.value.linkModalTips) == null ? void 0 : c.descLabelPlaceHolder,
|
|
200
|
+
class: `${a}-input`,
|
|
201
|
+
id: `link-desc-${n}`,
|
|
202
|
+
type: "text",
|
|
203
|
+
value: s.desc,
|
|
204
|
+
onChange: (u) => {
|
|
205
|
+
s.desc = u.target.value;
|
|
206
|
+
},
|
|
207
|
+
autocomplete: "off"
|
|
208
|
+
}, null)]), t("div", {
|
|
209
|
+
class: `${a}-form-item`
|
|
210
|
+
}, [t("label", {
|
|
211
|
+
class: `${a}-label`,
|
|
212
|
+
for: `link-url-${n}`
|
|
213
|
+
}, [(g = o.value.linkModalTips) == null ? void 0 : g.urlLabel]), t("input", {
|
|
214
|
+
placeholder: (f = o.value.linkModalTips) == null ? void 0 : f.urlLabelPlaceHolder,
|
|
215
|
+
class: `${a}-input`,
|
|
216
|
+
id: `link-url-${n}`,
|
|
217
|
+
type: "text",
|
|
218
|
+
value: s.url,
|
|
219
|
+
onChange: (u) => {
|
|
220
|
+
s.url = u.target.value;
|
|
221
|
+
},
|
|
222
|
+
autocomplete: "off"
|
|
223
|
+
}, null)]), t("div", {
|
|
224
|
+
class: `${a}-form-item`
|
|
225
|
+
}, [t("button", {
|
|
226
|
+
class: [`${a}-btn`, `${a}-btn-row`],
|
|
227
|
+
type: "button",
|
|
228
|
+
onClick: () => {
|
|
229
|
+
e.onOk(s), s.desc = "", s.url = "";
|
|
230
|
+
}
|
|
231
|
+
}, [(d = o.value.linkModalTips) == null ? void 0 : d.buttonOK])])];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}), Gt = {
|
|
236
|
+
visible: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default: !1
|
|
239
|
+
},
|
|
240
|
+
onCancel: {
|
|
241
|
+
type: Function,
|
|
242
|
+
default: () => {
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
onOk: {
|
|
246
|
+
type: Function,
|
|
247
|
+
default: () => {
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}, Kt = /* @__PURE__ */ I({
|
|
251
|
+
props: Gt,
|
|
252
|
+
setup(e) {
|
|
253
|
+
var u, k, $;
|
|
254
|
+
const o = S("usedLanguageText"), n = S("editorId");
|
|
255
|
+
let l = ($ = (k = (u = G) == null ? void 0 : u.editorExtensions) == null ? void 0 : k.cropper) == null ? void 0 : $.instance;
|
|
256
|
+
const s = q(), r = q(), c = q(), g = Y({
|
|
257
|
+
cropperInited: !1,
|
|
258
|
+
imgSelected: !1,
|
|
259
|
+
imgSrc: "",
|
|
260
|
+
// 是否全屏
|
|
261
|
+
isFullscreen: !1
|
|
262
|
+
});
|
|
263
|
+
let f = null;
|
|
264
|
+
F(() => e.visible, () => {
|
|
265
|
+
e.visible && !g.cropperInited && (l = l || window.Cropper, s.value.onchange = () => {
|
|
266
|
+
if (!l) {
|
|
267
|
+
h.emit(n, "errorCatcher", {
|
|
268
|
+
name: "Cropper",
|
|
269
|
+
message: "Cropper is undefined"
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const b = s.value.files || [];
|
|
274
|
+
if (g.imgSelected = !0, (b == null ? void 0 : b.length) > 0) {
|
|
275
|
+
const v = new FileReader();
|
|
276
|
+
v.onload = (m) => {
|
|
277
|
+
g.imgSrc = m.target.result, ue(() => {
|
|
278
|
+
f = new l(r.value, {
|
|
279
|
+
viewMode: 2,
|
|
280
|
+
preview: `.${a}-clip-preview-target`
|
|
281
|
+
// aspectRatio: 16 / 9,
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}, v.readAsDataURL(b[0]);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}), F(() => [g.imgSelected], () => {
|
|
288
|
+
c.value.style = "";
|
|
289
|
+
}), F(() => g.isFullscreen, () => {
|
|
290
|
+
ue(() => {
|
|
291
|
+
f == null || f.destroy(), c.value.style = "", r.value && (f = new l(r.value, {
|
|
292
|
+
viewMode: 2,
|
|
293
|
+
preview: `.${a}-clip-preview-target`
|
|
294
|
+
// aspectRatio: 16 / 9,
|
|
295
|
+
}));
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
const d = () => {
|
|
299
|
+
f.clear(), f.destroy(), f = null, s.value.value = "", g.imgSelected = !1;
|
|
300
|
+
};
|
|
301
|
+
return () => {
|
|
302
|
+
var b;
|
|
303
|
+
return t(_e, {
|
|
304
|
+
class: `${a}-modal-clip`,
|
|
305
|
+
title: (b = o.value.clipModalTips) == null ? void 0 : b.title,
|
|
306
|
+
visible: e.visible,
|
|
307
|
+
onClose: e.onCancel,
|
|
308
|
+
showAdjust: !0,
|
|
309
|
+
isFullscreen: g.isFullscreen,
|
|
310
|
+
onAdjust: (v) => {
|
|
311
|
+
g.isFullscreen = v;
|
|
312
|
+
},
|
|
313
|
+
width: "668px",
|
|
314
|
+
height: "421px"
|
|
315
|
+
}, {
|
|
316
|
+
default: () => {
|
|
317
|
+
var v, m;
|
|
318
|
+
return [t("div", {
|
|
319
|
+
class: `${a}-form-item ${a}-clip`
|
|
320
|
+
}, [t("div", {
|
|
321
|
+
class: `${a}-clip-main`
|
|
322
|
+
}, [g.imgSelected ? t("div", {
|
|
323
|
+
class: `${a}-clip-cropper`
|
|
324
|
+
}, [t("img", {
|
|
325
|
+
src: g.imgSrc,
|
|
326
|
+
ref: r,
|
|
327
|
+
style: {
|
|
328
|
+
display: "none"
|
|
329
|
+
},
|
|
330
|
+
alt: ""
|
|
331
|
+
}, null), t("div", {
|
|
332
|
+
class: `${a}-clip-delete`,
|
|
333
|
+
onClick: d
|
|
334
|
+
}, [t("svg", {
|
|
335
|
+
class: `${a}-icon`,
|
|
336
|
+
"aria-hidden": "true"
|
|
337
|
+
}, [t("use", {
|
|
338
|
+
"xlink:href": "#md-editor-icon-delete"
|
|
339
|
+
}, null)])])]) : t("div", {
|
|
340
|
+
class: `${a}-clip-upload`,
|
|
341
|
+
onClick: () => {
|
|
342
|
+
s.value.click();
|
|
343
|
+
}
|
|
344
|
+
}, [t("svg", {
|
|
345
|
+
class: `${a}-icon`,
|
|
346
|
+
"aria-hidden": "true"
|
|
347
|
+
}, [t("use", {
|
|
348
|
+
"xlink:href": "#md-editor-icon-upload"
|
|
349
|
+
}, null)])])]), t("div", {
|
|
350
|
+
class: `${a}-clip-preview`
|
|
351
|
+
}, [t("div", {
|
|
352
|
+
class: `${a}-clip-preview-target`,
|
|
353
|
+
ref: c
|
|
354
|
+
}, null)])]), t("div", {
|
|
355
|
+
class: `${a}-form-item`
|
|
356
|
+
}, [t("button", {
|
|
357
|
+
class: `${a}-btn`,
|
|
358
|
+
type: "button",
|
|
359
|
+
onClick: () => {
|
|
360
|
+
if (f) {
|
|
361
|
+
const y = f.getCroppedCanvas();
|
|
362
|
+
h.emit(n, "uploadImage", [at(y.toDataURL("image/png"))], e.onOk), d();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}, [((v = o.value.clipModalTips) == null ? void 0 : v.buttonUpload) || ((m = o.value.linkModalTips) == null ? void 0 : m.buttonOK)])]), t("input", {
|
|
366
|
+
ref: s,
|
|
367
|
+
accept: "image/*",
|
|
368
|
+
type: "file",
|
|
369
|
+
multiple: !1,
|
|
370
|
+
style: {
|
|
371
|
+
display: "none"
|
|
372
|
+
}
|
|
373
|
+
}, null)];
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}), jt = {
|
|
379
|
+
type: {
|
|
380
|
+
type: String,
|
|
381
|
+
default: "link"
|
|
382
|
+
},
|
|
383
|
+
linkVisible: {
|
|
384
|
+
type: Boolean,
|
|
385
|
+
default: !1
|
|
386
|
+
},
|
|
387
|
+
clipVisible: {
|
|
388
|
+
type: Boolean,
|
|
389
|
+
default: !1
|
|
390
|
+
},
|
|
391
|
+
onCancel: {
|
|
392
|
+
type: Function,
|
|
393
|
+
default: () => {
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
onOk: {
|
|
397
|
+
type: Function,
|
|
398
|
+
default: () => {
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}, _t = /* @__PURE__ */ I({
|
|
402
|
+
props: jt,
|
|
403
|
+
setup(e) {
|
|
404
|
+
return () => t(Ke, null, [t(qt, {
|
|
405
|
+
type: e.type,
|
|
406
|
+
visible: e.linkVisible,
|
|
407
|
+
onOk: e.onOk,
|
|
408
|
+
onCancel: e.onCancel
|
|
409
|
+
}, null), t(Kt, {
|
|
410
|
+
visible: e.clipVisible,
|
|
411
|
+
onOk: e.onOk,
|
|
412
|
+
onCancel: e.onCancel
|
|
413
|
+
}, null)]);
|
|
414
|
+
}
|
|
415
|
+
}), Wt = /* @__PURE__ */ I({
|
|
416
|
+
name: "MDEditorToolbar",
|
|
417
|
+
props: Ot,
|
|
418
|
+
setup(e) {
|
|
419
|
+
const o = S("editorId"), n = S("usedLanguageText"), {
|
|
420
|
+
fullscreenHandler: l
|
|
421
|
+
} = Vt(e), s = `${o}-toolbar-wrapper`, r = Y({
|
|
422
|
+
title: !1,
|
|
423
|
+
catalog: !1,
|
|
424
|
+
// 图片上传下拉
|
|
425
|
+
image: !1,
|
|
426
|
+
// 表格预选
|
|
427
|
+
table: !1,
|
|
428
|
+
// mermaid
|
|
429
|
+
mermaid: !1,
|
|
430
|
+
katex: !1
|
|
431
|
+
}), c = (b, v) => {
|
|
432
|
+
h.emit(o, "replace", b, v);
|
|
433
|
+
}, g = Y({
|
|
434
|
+
type: "link",
|
|
435
|
+
linkVisible: !1,
|
|
436
|
+
clipVisible: !1
|
|
437
|
+
}), f = q();
|
|
438
|
+
W(() => {
|
|
439
|
+
h.on(o, {
|
|
440
|
+
name: "openModals",
|
|
441
|
+
callback(b) {
|
|
442
|
+
g.type = b, g.linkVisible = !0;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
const d = me(() => {
|
|
447
|
+
const b = e.toolbars.filter((x) => !e.toolbarsExclude.includes(x)), v = b.indexOf("="), m = v === -1 ? b : b.slice(0, v + 1), y = v === -1 ? [] : b.slice(v, Number.MAX_SAFE_INTEGER);
|
|
448
|
+
return [m, y];
|
|
449
|
+
}), u = q(), k = () => {
|
|
450
|
+
h.emit(o, "uploadImage", Array.from(u.value.files || [])), u.value.value = "";
|
|
451
|
+
};
|
|
452
|
+
W(() => {
|
|
453
|
+
u.value.addEventListener("change", k);
|
|
454
|
+
});
|
|
455
|
+
const $ = (b) => {
|
|
456
|
+
var v, m, y, x, T, w, A, p, M, R, L, D, B, O, E, K, N, le, Z, j, P, J, _, H, V, X, oe, ge, he, be, ve, ke, pe, Ce, $e, ye, xe, we, Te, Se, Ae, Me, Le;
|
|
457
|
+
if (tt.includes(b))
|
|
458
|
+
switch (b) {
|
|
459
|
+
case "-":
|
|
460
|
+
return t(Bt, null, null);
|
|
461
|
+
case "bold":
|
|
462
|
+
return t("div", {
|
|
463
|
+
class: `${a}-toolbar-item`,
|
|
464
|
+
title: (v = n.value.toolbarTips) == null ? void 0 : v.bold,
|
|
465
|
+
onClick: () => {
|
|
466
|
+
c("bold");
|
|
467
|
+
}
|
|
468
|
+
}, [t("svg", {
|
|
469
|
+
class: `${a}-icon`,
|
|
470
|
+
"aria-hidden": "true"
|
|
471
|
+
}, [t("use", {
|
|
472
|
+
"xlink:href": "#md-editor-icon-bold"
|
|
473
|
+
}, null)])]);
|
|
474
|
+
case "underline":
|
|
475
|
+
return t("div", {
|
|
476
|
+
class: `${a}-toolbar-item`,
|
|
477
|
+
title: (m = n.value.toolbarTips) == null ? void 0 : m.underline,
|
|
478
|
+
onClick: () => {
|
|
479
|
+
c("underline");
|
|
480
|
+
}
|
|
481
|
+
}, [t("svg", {
|
|
482
|
+
class: `${a}-icon`,
|
|
483
|
+
"aria-hidden": "true"
|
|
484
|
+
}, [t("use", {
|
|
485
|
+
"xlink:href": "#md-editor-icon-underline"
|
|
486
|
+
}, null)])]);
|
|
487
|
+
case "italic":
|
|
488
|
+
return t("div", {
|
|
489
|
+
class: `${a}-toolbar-item`,
|
|
490
|
+
title: (y = n.value.toolbarTips) == null ? void 0 : y.italic,
|
|
491
|
+
onClick: () => {
|
|
492
|
+
c("italic");
|
|
493
|
+
}
|
|
494
|
+
}, [t("svg", {
|
|
495
|
+
class: `${a}-icon`,
|
|
496
|
+
"aria-hidden": "true"
|
|
497
|
+
}, [t("use", {
|
|
498
|
+
"xlink:href": "#md-editor-icon-italic"
|
|
499
|
+
}, null)])]);
|
|
500
|
+
case "strikeThrough":
|
|
501
|
+
return t("div", {
|
|
502
|
+
class: `${a}-toolbar-item`,
|
|
503
|
+
title: (x = n.value.toolbarTips) == null ? void 0 : x.strikeThrough,
|
|
504
|
+
onClick: () => {
|
|
505
|
+
c("strikeThrough");
|
|
506
|
+
}
|
|
507
|
+
}, [t("svg", {
|
|
508
|
+
class: `${a}-icon`,
|
|
509
|
+
"aria-hidden": "true"
|
|
510
|
+
}, [t("use", {
|
|
511
|
+
"xlink:href": "#md-editor-icon-strike-through"
|
|
512
|
+
}, null)])]);
|
|
513
|
+
case "title":
|
|
514
|
+
return t(Q, {
|
|
515
|
+
relative: `#${s}`,
|
|
516
|
+
visible: r.title,
|
|
517
|
+
onChange: (C) => {
|
|
518
|
+
r.title = C;
|
|
519
|
+
},
|
|
520
|
+
overlay: t("ul", {
|
|
521
|
+
class: `${a}-menu`,
|
|
522
|
+
onClick: () => {
|
|
523
|
+
r.title = !1;
|
|
524
|
+
}
|
|
525
|
+
}, [t("li", {
|
|
526
|
+
class: `${a}-menu-item`,
|
|
527
|
+
onClick: () => {
|
|
528
|
+
c("h1");
|
|
529
|
+
}
|
|
530
|
+
}, [(T = n.value.titleItem) == null ? void 0 : T.h1]), t("li", {
|
|
531
|
+
class: `${a}-menu-item`,
|
|
532
|
+
onClick: () => {
|
|
533
|
+
c("h2");
|
|
534
|
+
}
|
|
535
|
+
}, [(w = n.value.titleItem) == null ? void 0 : w.h2]), t("li", {
|
|
536
|
+
class: `${a}-menu-item`,
|
|
537
|
+
onClick: () => {
|
|
538
|
+
c("h3");
|
|
539
|
+
}
|
|
540
|
+
}, [(A = n.value.titleItem) == null ? void 0 : A.h3]), t("li", {
|
|
541
|
+
class: `${a}-menu-item`,
|
|
542
|
+
onClick: () => {
|
|
543
|
+
c("h4");
|
|
544
|
+
}
|
|
545
|
+
}, [(p = n.value.titleItem) == null ? void 0 : p.h4]), t("li", {
|
|
546
|
+
class: `${a}-menu-item`,
|
|
547
|
+
onClick: () => {
|
|
548
|
+
c("h5");
|
|
549
|
+
}
|
|
550
|
+
}, [(M = n.value.titleItem) == null ? void 0 : M.h5]), t("li", {
|
|
551
|
+
class: `${a}-menu-item`,
|
|
552
|
+
onClick: () => {
|
|
553
|
+
c("h6");
|
|
554
|
+
}
|
|
555
|
+
}, [(R = n.value.titleItem) == null ? void 0 : R.h6])])
|
|
556
|
+
}, {
|
|
557
|
+
default: () => {
|
|
558
|
+
var C;
|
|
559
|
+
return [t("div", {
|
|
560
|
+
class: `${a}-toolbar-item`,
|
|
561
|
+
title: (C = n.value.toolbarTips) == null ? void 0 : C.title
|
|
562
|
+
}, [t("svg", {
|
|
563
|
+
class: `${a}-icon`,
|
|
564
|
+
"aria-hidden": "true"
|
|
565
|
+
}, [t("use", {
|
|
566
|
+
"xlink:href": "#md-editor-icon-title"
|
|
567
|
+
}, null)])])];
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
case "sub":
|
|
571
|
+
return t("div", {
|
|
572
|
+
class: `${a}-toolbar-item`,
|
|
573
|
+
title: (L = n.value.toolbarTips) == null ? void 0 : L.sub,
|
|
574
|
+
onClick: () => {
|
|
575
|
+
c("sub");
|
|
576
|
+
}
|
|
577
|
+
}, [t("svg", {
|
|
578
|
+
class: `${a}-icon`,
|
|
579
|
+
"aria-hidden": "true"
|
|
580
|
+
}, [t("use", {
|
|
581
|
+
"xlink:href": "#md-editor-icon-sub"
|
|
582
|
+
}, null)])]);
|
|
583
|
+
case "sup":
|
|
584
|
+
return t("div", {
|
|
585
|
+
class: `${a}-toolbar-item`,
|
|
586
|
+
title: (D = n.value.toolbarTips) == null ? void 0 : D.sup,
|
|
587
|
+
onClick: () => {
|
|
588
|
+
c("sup");
|
|
589
|
+
}
|
|
590
|
+
}, [t("svg", {
|
|
591
|
+
class: `${a}-icon`,
|
|
592
|
+
"aria-hidden": "true"
|
|
593
|
+
}, [t("use", {
|
|
594
|
+
"xlink:href": "#md-editor-icon-sup"
|
|
595
|
+
}, null)])]);
|
|
596
|
+
case "quote":
|
|
597
|
+
return t("div", {
|
|
598
|
+
class: `${a}-toolbar-item`,
|
|
599
|
+
title: (B = n.value.toolbarTips) == null ? void 0 : B.quote,
|
|
600
|
+
onClick: () => {
|
|
601
|
+
c("quote");
|
|
602
|
+
}
|
|
603
|
+
}, [t("svg", {
|
|
604
|
+
class: `${a}-icon`,
|
|
605
|
+
"aria-hidden": "true"
|
|
606
|
+
}, [t("use", {
|
|
607
|
+
"xlink:href": "#md-editor-icon-quote"
|
|
608
|
+
}, null)])]);
|
|
609
|
+
case "unorderedList":
|
|
610
|
+
return t("div", {
|
|
611
|
+
class: `${a}-toolbar-item`,
|
|
612
|
+
title: (O = n.value.toolbarTips) == null ? void 0 : O.unorderedList,
|
|
613
|
+
onClick: () => {
|
|
614
|
+
c("unorderedList");
|
|
615
|
+
}
|
|
616
|
+
}, [t("svg", {
|
|
617
|
+
class: `${a}-icon`,
|
|
618
|
+
"aria-hidden": "true"
|
|
619
|
+
}, [t("use", {
|
|
620
|
+
"xlink:href": "#md-editor-icon-unordered-list"
|
|
621
|
+
}, null)])]);
|
|
622
|
+
case "orderedList":
|
|
623
|
+
return t("div", {
|
|
624
|
+
class: `${a}-toolbar-item`,
|
|
625
|
+
title: (E = n.value.toolbarTips) == null ? void 0 : E.orderedList,
|
|
626
|
+
onClick: () => {
|
|
627
|
+
c("orderedList");
|
|
628
|
+
}
|
|
629
|
+
}, [t("svg", {
|
|
630
|
+
class: `${a}-icon`,
|
|
631
|
+
"aria-hidden": "true"
|
|
632
|
+
}, [t("use", {
|
|
633
|
+
"xlink:href": "#md-editor-icon-ordered-list"
|
|
634
|
+
}, null)])]);
|
|
635
|
+
case "task":
|
|
636
|
+
return t("div", {
|
|
637
|
+
class: `${a}-toolbar-item`,
|
|
638
|
+
title: (K = n.value.toolbarTips) == null ? void 0 : K.task,
|
|
639
|
+
onClick: () => {
|
|
640
|
+
c("task");
|
|
641
|
+
}
|
|
642
|
+
}, [t("svg", {
|
|
643
|
+
class: `${a}-icon`,
|
|
644
|
+
"aria-hidden": "true"
|
|
645
|
+
}, [t("use", {
|
|
646
|
+
"xlink:href": "#md-editor-icon-task"
|
|
647
|
+
}, null)])]);
|
|
648
|
+
case "codeRow":
|
|
649
|
+
return t("div", {
|
|
650
|
+
class: `${a}-toolbar-item`,
|
|
651
|
+
title: (N = n.value.toolbarTips) == null ? void 0 : N.codeRow,
|
|
652
|
+
onClick: () => {
|
|
653
|
+
c("codeRow");
|
|
654
|
+
}
|
|
655
|
+
}, [t("svg", {
|
|
656
|
+
class: `${a}-icon`,
|
|
657
|
+
"aria-hidden": "true"
|
|
658
|
+
}, [t("use", {
|
|
659
|
+
"xlink:href": "#md-editor-icon-code-row"
|
|
660
|
+
}, null)])]);
|
|
661
|
+
case "code":
|
|
662
|
+
return t("div", {
|
|
663
|
+
class: `${a}-toolbar-item`,
|
|
664
|
+
title: (le = n.value.toolbarTips) == null ? void 0 : le.code,
|
|
665
|
+
onClick: () => {
|
|
666
|
+
c("code");
|
|
667
|
+
}
|
|
668
|
+
}, [t("svg", {
|
|
669
|
+
class: `${a}-icon`,
|
|
670
|
+
"aria-hidden": "true"
|
|
671
|
+
}, [t("use", {
|
|
672
|
+
"xlink:href": "#md-editor-icon-code"
|
|
673
|
+
}, null)])]);
|
|
674
|
+
case "link":
|
|
675
|
+
return t("div", {
|
|
676
|
+
class: `${a}-toolbar-item`,
|
|
677
|
+
title: (Z = n.value.toolbarTips) == null ? void 0 : Z.link,
|
|
678
|
+
onClick: () => {
|
|
679
|
+
g.type = "link", g.linkVisible = !0;
|
|
680
|
+
}
|
|
681
|
+
}, [t("svg", {
|
|
682
|
+
class: `${a}-icon`,
|
|
683
|
+
"aria-hidden": "true"
|
|
684
|
+
}, [t("use", {
|
|
685
|
+
"xlink:href": "#md-editor-icon-link"
|
|
686
|
+
}, null)])]);
|
|
687
|
+
case "image":
|
|
688
|
+
return e.noUploadImg ? t("div", {
|
|
689
|
+
class: `${a}-toolbar-item`,
|
|
690
|
+
title: (j = n.value.toolbarTips) == null ? void 0 : j.image,
|
|
691
|
+
onClick: () => {
|
|
692
|
+
g.type = "image", g.linkVisible = !0;
|
|
693
|
+
}
|
|
694
|
+
}, [t("svg", {
|
|
695
|
+
class: `${a}-icon`,
|
|
696
|
+
"aria-hidden": "true"
|
|
697
|
+
}, [t("use", {
|
|
698
|
+
"xlink:href": "#md-editor-icon-image"
|
|
699
|
+
}, null)])]) : t(Q, {
|
|
700
|
+
relative: `#${s}`,
|
|
701
|
+
visible: r.image,
|
|
702
|
+
onChange: (C) => {
|
|
703
|
+
r.image = C;
|
|
704
|
+
},
|
|
705
|
+
overlay: t("ul", {
|
|
706
|
+
class: `${a}-menu`,
|
|
707
|
+
onClick: () => {
|
|
708
|
+
r.title = !1;
|
|
709
|
+
}
|
|
710
|
+
}, [t("li", {
|
|
711
|
+
class: `${a}-menu-item`,
|
|
712
|
+
onClick: () => {
|
|
713
|
+
g.type = "image", g.linkVisible = !0;
|
|
714
|
+
}
|
|
715
|
+
}, [(P = n.value.imgTitleItem) == null ? void 0 : P.link]), t("li", {
|
|
716
|
+
class: `${a}-menu-item`,
|
|
717
|
+
onClick: () => {
|
|
718
|
+
u.value.click();
|
|
719
|
+
}
|
|
720
|
+
}, [(J = n.value.imgTitleItem) == null ? void 0 : J.upload]), t("li", {
|
|
721
|
+
class: `${a}-menu-item`,
|
|
722
|
+
onClick: () => {
|
|
723
|
+
g.clipVisible = !0;
|
|
724
|
+
}
|
|
725
|
+
}, [(_ = n.value.imgTitleItem) == null ? void 0 : _.clip2upload])])
|
|
726
|
+
}, {
|
|
727
|
+
default: () => {
|
|
728
|
+
var C;
|
|
729
|
+
return [t("div", {
|
|
730
|
+
class: `${a}-toolbar-item`,
|
|
731
|
+
title: (C = n.value.toolbarTips) == null ? void 0 : C.image
|
|
732
|
+
}, [t("svg", {
|
|
733
|
+
class: `${a}-icon`,
|
|
734
|
+
"aria-hidden": "true"
|
|
735
|
+
}, [t("use", {
|
|
736
|
+
"xlink:href": "#md-editor-icon-image"
|
|
737
|
+
}, null)])])];
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
case "table":
|
|
741
|
+
return t(Q, {
|
|
742
|
+
relative: `#${s}`,
|
|
743
|
+
visible: r.table,
|
|
744
|
+
onChange: (C) => {
|
|
745
|
+
r.table = C;
|
|
746
|
+
},
|
|
747
|
+
key: "bar-table",
|
|
748
|
+
overlay: t(Pt, {
|
|
749
|
+
tableShape: e.tableShape,
|
|
750
|
+
onSelected: (C) => {
|
|
751
|
+
c("table", {
|
|
752
|
+
selectedShape: C
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}, null)
|
|
756
|
+
}, {
|
|
757
|
+
default: () => {
|
|
758
|
+
var C;
|
|
759
|
+
return [t("div", {
|
|
760
|
+
class: `${a}-toolbar-item`,
|
|
761
|
+
title: (C = n.value.toolbarTips) == null ? void 0 : C.table
|
|
762
|
+
}, [t("svg", {
|
|
763
|
+
class: `${a}-icon`,
|
|
764
|
+
"aria-hidden": "true"
|
|
765
|
+
}, [t("use", {
|
|
766
|
+
"xlink:href": "#md-editor-icon-table"
|
|
767
|
+
}, null)])])];
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
case "revoke":
|
|
771
|
+
return t("div", {
|
|
772
|
+
class: `${a}-toolbar-item`,
|
|
773
|
+
title: (H = n.value.toolbarTips) == null ? void 0 : H.revoke,
|
|
774
|
+
onClick: () => {
|
|
775
|
+
h.emit(o, "ctrlZ");
|
|
776
|
+
}
|
|
777
|
+
}, [t("svg", {
|
|
778
|
+
class: `${a}-icon`,
|
|
779
|
+
"aria-hidden": "true"
|
|
780
|
+
}, [t("use", {
|
|
781
|
+
"xlink:href": "#md-editor-icon-revoke"
|
|
782
|
+
}, null)])]);
|
|
783
|
+
case "next":
|
|
784
|
+
return t("div", {
|
|
785
|
+
class: `${a}-toolbar-item`,
|
|
786
|
+
title: (V = n.value.toolbarTips) == null ? void 0 : V.next,
|
|
787
|
+
onClick: () => {
|
|
788
|
+
h.emit(o, "ctrlShiftZ");
|
|
789
|
+
}
|
|
790
|
+
}, [t("svg", {
|
|
791
|
+
class: `${a}-icon`,
|
|
792
|
+
"aria-hidden": "true"
|
|
793
|
+
}, [t("use", {
|
|
794
|
+
"xlink:href": "#md-editor-icon-next"
|
|
795
|
+
}, null)])]);
|
|
796
|
+
case "save":
|
|
797
|
+
return t("div", {
|
|
798
|
+
class: `${a}-toolbar-item`,
|
|
799
|
+
title: (X = n.value.toolbarTips) == null ? void 0 : X.save,
|
|
800
|
+
onClick: () => {
|
|
801
|
+
h.emit(o, je);
|
|
802
|
+
}
|
|
803
|
+
}, [t("svg", {
|
|
804
|
+
class: `${a}-icon`,
|
|
805
|
+
"aria-hidden": "true"
|
|
806
|
+
}, [t("use", {
|
|
807
|
+
"xlink:href": "#md-editor-icon-baocun"
|
|
808
|
+
}, null)])]);
|
|
809
|
+
case "prettier":
|
|
810
|
+
return e.noPrettier ? "" : t("div", {
|
|
811
|
+
class: `${a}-toolbar-item`,
|
|
812
|
+
title: (oe = n.value.toolbarTips) == null ? void 0 : oe.prettier,
|
|
813
|
+
onClick: () => {
|
|
814
|
+
c("prettier");
|
|
815
|
+
}
|
|
816
|
+
}, [t("svg", {
|
|
817
|
+
class: `${a}-icon`,
|
|
818
|
+
"aria-hidden": "true"
|
|
819
|
+
}, [t("use", {
|
|
820
|
+
"xlink:href": "#md-editor-icon-prettier"
|
|
821
|
+
}, null)])]);
|
|
822
|
+
case "pageFullscreen":
|
|
823
|
+
return !e.setting.fullscreen && t("div", {
|
|
824
|
+
class: `${a}-toolbar-item`,
|
|
825
|
+
title: (ge = n.value.toolbarTips) == null ? void 0 : ge.pageFullscreen,
|
|
826
|
+
onClick: () => {
|
|
827
|
+
e.updateSetting("pageFullscreen");
|
|
828
|
+
}
|
|
829
|
+
}, [t("svg", {
|
|
830
|
+
class: `${a}-icon`,
|
|
831
|
+
"aria-hidden": "true"
|
|
832
|
+
}, [t("use", {
|
|
833
|
+
"xlink:href": `#md-editor-icon-${e.setting.pageFullscreen ? "suoxiao" : "fangda"}`
|
|
834
|
+
}, null)])]);
|
|
835
|
+
case "fullscreen":
|
|
836
|
+
return t("div", {
|
|
837
|
+
class: `${a}-toolbar-item`,
|
|
838
|
+
title: (he = n.value.toolbarTips) == null ? void 0 : he.fullscreen,
|
|
839
|
+
onClick: () => {
|
|
840
|
+
l();
|
|
841
|
+
}
|
|
842
|
+
}, [t("svg", {
|
|
843
|
+
class: `${a}-icon`,
|
|
844
|
+
"aria-hidden": "true"
|
|
845
|
+
}, [t("use", {
|
|
846
|
+
"xlink:href": `#md-editor-icon-${e.setting.fullscreen ? "fullscreen-exit" : "fullscreen"}`
|
|
847
|
+
}, null)])]);
|
|
848
|
+
case "preview":
|
|
849
|
+
return t("div", {
|
|
850
|
+
class: `${a}-toolbar-item`,
|
|
851
|
+
title: (be = n.value.toolbarTips) == null ? void 0 : be.preview,
|
|
852
|
+
onClick: () => {
|
|
853
|
+
e.updateSetting("preview");
|
|
854
|
+
}
|
|
855
|
+
}, [t("svg", {
|
|
856
|
+
class: `${a}-icon`,
|
|
857
|
+
"aria-hidden": "true"
|
|
858
|
+
}, [t("use", {
|
|
859
|
+
"xlink:href": "#md-editor-icon-preview"
|
|
860
|
+
}, null)])]);
|
|
861
|
+
case "htmlPreview":
|
|
862
|
+
return t("div", {
|
|
863
|
+
class: `${a}-toolbar-item`,
|
|
864
|
+
title: (ve = n.value.toolbarTips) == null ? void 0 : ve.htmlPreview,
|
|
865
|
+
onClick: () => {
|
|
866
|
+
e.updateSetting("htmlPreview");
|
|
867
|
+
}
|
|
868
|
+
}, [t("svg", {
|
|
869
|
+
class: `${a}-icon`,
|
|
870
|
+
"aria-hidden": "true"
|
|
871
|
+
}, [t("use", {
|
|
872
|
+
"xlink:href": "#md-editor-icon-coding"
|
|
873
|
+
}, null)])]);
|
|
874
|
+
case "catalog":
|
|
875
|
+
return t("div", {
|
|
876
|
+
class: `${a}-toolbar-item`,
|
|
877
|
+
title: (ke = n.value.toolbarTips) == null ? void 0 : ke.catalog,
|
|
878
|
+
onClick: () => {
|
|
879
|
+
h.emit(o, st);
|
|
880
|
+
},
|
|
881
|
+
key: "bar-catalog"
|
|
882
|
+
}, [t("svg", {
|
|
883
|
+
class: `${a}-icon`,
|
|
884
|
+
"aria-hidden": "true"
|
|
885
|
+
}, [t("use", {
|
|
886
|
+
"xlink:href": "#md-editor-icon-catalog"
|
|
887
|
+
}, null)])]);
|
|
888
|
+
case "github":
|
|
889
|
+
return t("div", {
|
|
890
|
+
class: `${a}-toolbar-item`,
|
|
891
|
+
title: (pe = n.value.toolbarTips) == null ? void 0 : pe.github,
|
|
892
|
+
onClick: () => nt("https://github.com/imzbf/md-editor-v3")
|
|
893
|
+
}, [t("svg", {
|
|
894
|
+
class: `${a}-icon`,
|
|
895
|
+
"aria-hidden": "true"
|
|
896
|
+
}, [t("use", {
|
|
897
|
+
"xlink:href": "#md-editor-icon-github"
|
|
898
|
+
}, null)])]);
|
|
899
|
+
case "mermaid":
|
|
900
|
+
return t(Q, {
|
|
901
|
+
relative: `#${s}`,
|
|
902
|
+
visible: r.mermaid,
|
|
903
|
+
onChange: (C) => {
|
|
904
|
+
r.mermaid = C;
|
|
905
|
+
},
|
|
906
|
+
overlay: t("ul", {
|
|
907
|
+
class: `${a}-menu`,
|
|
908
|
+
onClick: () => {
|
|
909
|
+
r.mermaid = !1;
|
|
910
|
+
}
|
|
911
|
+
}, [t("li", {
|
|
912
|
+
class: `${a}-menu-item`,
|
|
913
|
+
onClick: () => {
|
|
914
|
+
c("flow");
|
|
915
|
+
}
|
|
916
|
+
}, [(Ce = n.value.mermaid) == null ? void 0 : Ce.flow]), t("li", {
|
|
917
|
+
class: `${a}-menu-item`,
|
|
918
|
+
onClick: () => {
|
|
919
|
+
c("sequence");
|
|
920
|
+
}
|
|
921
|
+
}, [($e = n.value.mermaid) == null ? void 0 : $e.sequence]), t("li", {
|
|
922
|
+
class: `${a}-menu-item`,
|
|
923
|
+
onClick: () => {
|
|
924
|
+
c("gantt");
|
|
925
|
+
}
|
|
926
|
+
}, [(ye = n.value.mermaid) == null ? void 0 : ye.gantt]), t("li", {
|
|
927
|
+
class: `${a}-menu-item`,
|
|
928
|
+
onClick: () => {
|
|
929
|
+
c("class");
|
|
930
|
+
}
|
|
931
|
+
}, [(xe = n.value.mermaid) == null ? void 0 : xe.class]), t("li", {
|
|
932
|
+
class: `${a}-menu-item`,
|
|
933
|
+
onClick: () => {
|
|
934
|
+
c("state");
|
|
935
|
+
}
|
|
936
|
+
}, [(we = n.value.mermaid) == null ? void 0 : we.state]), t("li", {
|
|
937
|
+
class: `${a}-menu-item`,
|
|
938
|
+
onClick: () => {
|
|
939
|
+
c("pie");
|
|
940
|
+
}
|
|
941
|
+
}, [(Te = n.value.mermaid) == null ? void 0 : Te.pie]), t("li", {
|
|
942
|
+
class: `${a}-menu-item`,
|
|
943
|
+
onClick: () => {
|
|
944
|
+
c("relationship");
|
|
945
|
+
}
|
|
946
|
+
}, [(Se = n.value.mermaid) == null ? void 0 : Se.relationship]), t("li", {
|
|
947
|
+
class: `${a}-menu-item`,
|
|
948
|
+
onClick: () => {
|
|
949
|
+
c("journey");
|
|
950
|
+
}
|
|
951
|
+
}, [(Ae = n.value.mermaid) == null ? void 0 : Ae.journey])]),
|
|
952
|
+
key: "bar-mermaid"
|
|
953
|
+
}, {
|
|
954
|
+
default: () => {
|
|
955
|
+
var C;
|
|
956
|
+
return [t("div", {
|
|
957
|
+
class: `${a}-toolbar-item`,
|
|
958
|
+
title: (C = n.value.toolbarTips) == null ? void 0 : C.mermaid
|
|
959
|
+
}, [t("svg", {
|
|
960
|
+
class: `${a}-icon`,
|
|
961
|
+
"aria-hidden": "true"
|
|
962
|
+
}, [t("use", {
|
|
963
|
+
"xlink:href": "#md-editor-icon-mermaid"
|
|
964
|
+
}, null)])])];
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
case "katex":
|
|
968
|
+
return t(Q, {
|
|
969
|
+
relative: `#${s}`,
|
|
970
|
+
visible: r.katex,
|
|
971
|
+
onChange: (C) => {
|
|
972
|
+
r.katex = C;
|
|
973
|
+
},
|
|
974
|
+
overlay: t("ul", {
|
|
975
|
+
class: `${a}-menu`,
|
|
976
|
+
onClick: () => {
|
|
977
|
+
r.katex = !1;
|
|
978
|
+
}
|
|
979
|
+
}, [t("li", {
|
|
980
|
+
class: `${a}-menu-item`,
|
|
981
|
+
onClick: () => {
|
|
982
|
+
c("katexInline");
|
|
983
|
+
}
|
|
984
|
+
}, [(Me = n.value.katex) == null ? void 0 : Me.inline]), t("li", {
|
|
985
|
+
class: `${a}-menu-item`,
|
|
986
|
+
onClick: () => {
|
|
987
|
+
c("katexBlock");
|
|
988
|
+
}
|
|
989
|
+
}, [(Le = n.value.katex) == null ? void 0 : Le.block])]),
|
|
990
|
+
key: "bar-katex"
|
|
991
|
+
}, {
|
|
992
|
+
default: () => {
|
|
993
|
+
var C;
|
|
994
|
+
return [t("div", {
|
|
995
|
+
class: `${a}-toolbar-item`,
|
|
996
|
+
title: (C = n.value.toolbarTips) == null ? void 0 : C.katex
|
|
997
|
+
}, [t("svg", {
|
|
998
|
+
class: `${a}-icon`,
|
|
999
|
+
"aria-hidden": "true"
|
|
1000
|
+
}, [t("use", {
|
|
1001
|
+
"xlink:href": "#md-editor-icon-formula"
|
|
1002
|
+
}, null)])])];
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
else
|
|
1007
|
+
return e.defToolbars instanceof Array ? e.defToolbars[b] || "" : e.defToolbars && e.defToolbars.children instanceof Array && e.defToolbars.children[b] || "";
|
|
1008
|
+
};
|
|
1009
|
+
return () => {
|
|
1010
|
+
const b = d.value[0].map((m) => $(m)), v = d.value[1].map((m) => $(m));
|
|
1011
|
+
return t(Ke, null, [e.toolbars.length > 0 && t("div", {
|
|
1012
|
+
class: `${a}-toolbar-wrapper`,
|
|
1013
|
+
id: s
|
|
1014
|
+
}, [t("div", {
|
|
1015
|
+
class: `${a}-toolbar`
|
|
1016
|
+
}, [t("div", {
|
|
1017
|
+
class: `${a}-toolbar-left`,
|
|
1018
|
+
ref: f
|
|
1019
|
+
}, [b]), t("div", {
|
|
1020
|
+
class: `${a}-toolbar-right`
|
|
1021
|
+
}, [v])])]), t("input", {
|
|
1022
|
+
ref: u,
|
|
1023
|
+
accept: "image/*",
|
|
1024
|
+
type: "file",
|
|
1025
|
+
multiple: !0,
|
|
1026
|
+
style: {
|
|
1027
|
+
display: "none"
|
|
1028
|
+
}
|
|
1029
|
+
}, null), t(_t, {
|
|
1030
|
+
linkVisible: g.linkVisible,
|
|
1031
|
+
clipVisible: g.clipVisible,
|
|
1032
|
+
type: g.type,
|
|
1033
|
+
onCancel: () => {
|
|
1034
|
+
g.linkVisible = !1, g.clipVisible = !1;
|
|
1035
|
+
},
|
|
1036
|
+
onOk: (m) => {
|
|
1037
|
+
m && c(g.type, {
|
|
1038
|
+
desc: m.desc,
|
|
1039
|
+
url: m.url
|
|
1040
|
+
}), g.linkVisible = !1, g.clipVisible = !1;
|
|
1041
|
+
}
|
|
1042
|
+
}, null)]);
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
}), zt = (e, o, n) => {
|
|
1046
|
+
let l = e.scrollTop;
|
|
1047
|
+
const s = () => {
|
|
1048
|
+
const r = o - l;
|
|
1049
|
+
l = l + r / 5, Math.abs(r) < 1 ? (e.scrollTo(0, o), n && setTimeout(n, 100)) : (e.scrollTo(0, l), requestAnimationFrame(s));
|
|
1050
|
+
};
|
|
1051
|
+
s();
|
|
1052
|
+
}, Ee = zt, Yt = (e, o) => {
|
|
1053
|
+
const n = rt(() => {
|
|
1054
|
+
e.removeEventListener("scroll", l), e.addEventListener("scroll", l), o.removeEventListener("scroll", l), o.addEventListener("scroll", l);
|
|
1055
|
+
}, 50), l = (s) => {
|
|
1056
|
+
const r = e.clientHeight, c = o.clientHeight, g = e.scrollHeight, f = o.scrollHeight, d = (g - r) / (f - c);
|
|
1057
|
+
s.target === e ? (o.removeEventListener("scroll", l), o.scrollTo({
|
|
1058
|
+
top: e.scrollTop / d
|
|
1059
|
+
// behavior: 'smooth'
|
|
1060
|
+
}), n()) : (e.removeEventListener("scroll", l), e.scrollTo({
|
|
1061
|
+
top: o.scrollTop * d
|
|
1062
|
+
// behavior: 'smooth'
|
|
1063
|
+
}), n());
|
|
1064
|
+
};
|
|
1065
|
+
return [
|
|
1066
|
+
() => {
|
|
1067
|
+
n().finally(() => {
|
|
1068
|
+
e.dispatchEvent(new Event("scroll"));
|
|
1069
|
+
});
|
|
1070
|
+
},
|
|
1071
|
+
() => {
|
|
1072
|
+
e.removeEventListener("scroll", l), o.removeEventListener("scroll", l);
|
|
1073
|
+
}
|
|
1074
|
+
];
|
|
1075
|
+
}, Zt = (e, o, n) => {
|
|
1076
|
+
const { view: l } = n, s = (k) => l.lineBlockAt(l.state.doc.line(k).from).top, r = (k) => l.lineBlockAt(l.state.doc.line(k).from).height;
|
|
1077
|
+
let c = [];
|
|
1078
|
+
const g = () => {
|
|
1079
|
+
c = [];
|
|
1080
|
+
const k = Array.from(o.querySelectorAll("[data-line]")).map(
|
|
1081
|
+
(m) => Number(m.dataset.line) + 1
|
|
1082
|
+
), { lines: $ } = l.state.doc;
|
|
1083
|
+
let b = 1, v = k.shift() ?? $;
|
|
1084
|
+
for (let m = 1; m <= $; m++)
|
|
1085
|
+
m === v && (b = m, v = k.shift() || $ + 1), c.push({
|
|
1086
|
+
start: b,
|
|
1087
|
+
end: v - 1
|
|
1088
|
+
});
|
|
1089
|
+
};
|
|
1090
|
+
let f = 0, d = 0;
|
|
1091
|
+
const u = (k) => {
|
|
1092
|
+
var v, m, y, x, T, w, A;
|
|
1093
|
+
if (!((v = o.firstElementChild) != null && v.firstElementChild))
|
|
1094
|
+
return;
|
|
1095
|
+
const $ = l.lineBlockAtHeight(l.scrollDOM.scrollTop), { number: b } = l.state.doc.lineAt($.from);
|
|
1096
|
+
if (!(b > c.length) && !(l.state.doc.lines < c[c.length - 1].end))
|
|
1097
|
+
if (k.target === e) {
|
|
1098
|
+
if (d !== 0)
|
|
1099
|
+
return;
|
|
1100
|
+
f++;
|
|
1101
|
+
const p = c[b - 1], M = s(p.end) + r(p.end);
|
|
1102
|
+
let R = 0;
|
|
1103
|
+
const L = s(p.start), D = o.querySelector(`[data-line="${p.start - 1}"]`) || ((m = o.firstElementChild) == null ? void 0 : m.firstElementChild), B = o.querySelector(`[data-line="${p.end}"]`) || ((y = o.lastElementChild) == null ? void 0 : y.lastElementChild);
|
|
1104
|
+
let O = 0, E = 0;
|
|
1105
|
+
L === 0 ? (R = (l.scrollDOM.scrollTop - L) / (M - L), O = B.offsetTop) : M > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (R = (l.scrollDOM.scrollTop - L) / (l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight - L), E = D.offsetTop, O = o.scrollHeight - o.clientHeight - E + 10) : (R = (l.scrollDOM.scrollTop - L) / (M - L), E = D.offsetTop, O = B.offsetTop - E);
|
|
1106
|
+
const K = E - 10 + O * R;
|
|
1107
|
+
Ee(o, K, () => {
|
|
1108
|
+
f--;
|
|
1109
|
+
});
|
|
1110
|
+
} else {
|
|
1111
|
+
if (f !== 0)
|
|
1112
|
+
return;
|
|
1113
|
+
d++;
|
|
1114
|
+
const p = Array.from(
|
|
1115
|
+
o.querySelectorAll("[data-line]")
|
|
1116
|
+
), M = o.scrollTop, R = o.scrollHeight;
|
|
1117
|
+
let L = p.length === 0 ? 1 : Math.ceil(
|
|
1118
|
+
Number(p[p.length - 1].dataset.line) * (M / R)
|
|
1119
|
+
), D = (x = o.firstElementChild) == null ? void 0 : x.firstElementChild;
|
|
1120
|
+
for (let H = L; H >= 0; H--) {
|
|
1121
|
+
const V = o.querySelector(`[data-line="${H}"]`);
|
|
1122
|
+
if (V) {
|
|
1123
|
+
D = V, L = H;
|
|
1124
|
+
break;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
let B = (T = o.firstElementChild) == null ? void 0 : T.firstElementChild, O = (w = o.firstElementChild) == null ? void 0 : w.lastElementChild;
|
|
1128
|
+
for (; p.length > 0; ) {
|
|
1129
|
+
const H = p.indexOf(D);
|
|
1130
|
+
if (H + 1 >= p.length)
|
|
1131
|
+
break;
|
|
1132
|
+
const V = p[H + 1], X = D.offsetTop;
|
|
1133
|
+
if (X > M) {
|
|
1134
|
+
if (H === 0) {
|
|
1135
|
+
B = D, O = V;
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
D = p[H - 1];
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
const oe = V.offsetTop;
|
|
1142
|
+
if (X <= M && oe > M) {
|
|
1143
|
+
B = D, O = V;
|
|
1144
|
+
break;
|
|
1145
|
+
}
|
|
1146
|
+
D = V;
|
|
1147
|
+
}
|
|
1148
|
+
const E = B.offsetTop, K = O.offsetTop;
|
|
1149
|
+
let N = 0;
|
|
1150
|
+
const { start: le, end: Z } = c[Number(B.dataset.line || 0)], j = s(le);
|
|
1151
|
+
let P = s(Z);
|
|
1152
|
+
const J = r(Z);
|
|
1153
|
+
let _ = 0;
|
|
1154
|
+
B === ((A = o.firstElementChild) == null ? void 0 : A.firstElementChild) ? (N = Math.max(M / K, 0), _ = P + J - j) : P > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (N = Math.max(
|
|
1155
|
+
(M - E) / (o.scrollHeight - E - o.clientHeight),
|
|
1156
|
+
0
|
|
1157
|
+
), P = s(l.state.doc.lines) + r(l.state.doc.lines), _ = 8 + P - j - e.clientHeight) : (N = Math.max(
|
|
1158
|
+
(M - E) / (K - E),
|
|
1159
|
+
0
|
|
1160
|
+
), _ = P + J - j), Ee(e, j + _ * N, () => {
|
|
1161
|
+
d--;
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
return [
|
|
1166
|
+
() => {
|
|
1167
|
+
g(), e.addEventListener("scroll", u), o.addEventListener("scroll", u), e.dispatchEvent(new Event("scroll"));
|
|
1168
|
+
},
|
|
1169
|
+
() => {
|
|
1170
|
+
c = [], e.removeEventListener("scroll", u), o.removeEventListener("scroll", u);
|
|
1171
|
+
}
|
|
1172
|
+
];
|
|
1173
|
+
}, Jt = (e, o, n) => {
|
|
1174
|
+
const l = S("editorId");
|
|
1175
|
+
let s = () => {
|
|
1176
|
+
}, r = () => {
|
|
1177
|
+
};
|
|
1178
|
+
const c = () => {
|
|
1179
|
+
s();
|
|
1180
|
+
const g = document.querySelector(".cm-scroller"), f = document.querySelector(
|
|
1181
|
+
`[id="${l}-preview-wrapper"][data-show="true"]`
|
|
1182
|
+
), d = document.querySelector(
|
|
1183
|
+
`[id="${l}-html-wrapper"][data-show="true"]`
|
|
1184
|
+
);
|
|
1185
|
+
(f || d) && ([r, s] = (f ? Zt : Yt)(
|
|
1186
|
+
g,
|
|
1187
|
+
f || d,
|
|
1188
|
+
n.value
|
|
1189
|
+
)), e.scrollAuto && r();
|
|
1190
|
+
};
|
|
1191
|
+
F(
|
|
1192
|
+
[
|
|
1193
|
+
o,
|
|
1194
|
+
ae(e.setting, "preview"),
|
|
1195
|
+
ae(e.setting, "htmlPreview"),
|
|
1196
|
+
ae(e.setting, "fullscreen"),
|
|
1197
|
+
ae(e.setting, "pageFullscreen")
|
|
1198
|
+
],
|
|
1199
|
+
() => {
|
|
1200
|
+
ue(c);
|
|
1201
|
+
}
|
|
1202
|
+
), F(
|
|
1203
|
+
() => e.scrollAuto,
|
|
1204
|
+
(g) => {
|
|
1205
|
+
g ? r() : s();
|
|
1206
|
+
}
|
|
1207
|
+
), W(c);
|
|
1208
|
+
}, Xt = Jt, Qt = (e, o, n) => {
|
|
1209
|
+
var u, k, $, b, v, m;
|
|
1210
|
+
let l = "", s = 0, r = 0, c = !0, g = !1;
|
|
1211
|
+
const f = o.getSelectedText(), d = (u = G.editorConfig) == null ? void 0 : u.mermaidTemplate;
|
|
1212
|
+
if (/^h[1-6]{1}$/.test(e)) {
|
|
1213
|
+
const y = e.replace(/^h(\d)/, (x, T) => new Array(Number(T)).fill("#", 0, T).join(""));
|
|
1214
|
+
l = `${y} ${f}`, s = y.length + 1;
|
|
1215
|
+
} else if (e === "prettier") {
|
|
1216
|
+
const y = window.prettier || (($ = (k = G.editorExtensions) == null ? void 0 : k.prettier) == null ? void 0 : $.prettierInstance), x = [
|
|
1217
|
+
((b = window.prettierPlugins) == null ? void 0 : b.markdown) || ((m = (v = G.editorExtensions) == null ? void 0 : v.prettier) == null ? void 0 : m.parserMarkdownInstance)
|
|
1218
|
+
];
|
|
1219
|
+
!y || x[0] === void 0 ? (h.emit(n.editorId, "errorCatcher", {
|
|
1220
|
+
name: "prettier",
|
|
1221
|
+
message: "prettier is undefined"
|
|
1222
|
+
}), l = o.getValue()) : l = y.format(o.getValue(), {
|
|
1223
|
+
parser: "markdown",
|
|
1224
|
+
plugins: x
|
|
1225
|
+
}), c = !1, g = !0;
|
|
1226
|
+
} else
|
|
1227
|
+
switch (e) {
|
|
1228
|
+
case "bold": {
|
|
1229
|
+
l = `**${f}**`, s = 2, r = -2;
|
|
1230
|
+
break;
|
|
1231
|
+
}
|
|
1232
|
+
case "underline": {
|
|
1233
|
+
l = `<u>${f}</u>`, s = 3, r = -4;
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
case "italic": {
|
|
1237
|
+
l = `*${f}*`, s = 1, r = -1;
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
case "strikeThrough": {
|
|
1241
|
+
l = `~~${f}~~`, s = 2, r = -2;
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
case "sub": {
|
|
1245
|
+
l = `<sub>${f}</sub>`, s = 5, r = -6;
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1248
|
+
case "sup": {
|
|
1249
|
+
l = `<sup>${f}</sup>`, s = 5, r = -6;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
case "codeRow": {
|
|
1253
|
+
l = "`" + f + "`", s = 1, r = -1;
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
case "quote": {
|
|
1257
|
+
l = `> ${f}`, s = 2;
|
|
1258
|
+
break;
|
|
1259
|
+
}
|
|
1260
|
+
case "orderedList": {
|
|
1261
|
+
l = `1. ${f}`, s = 3;
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
case "unorderedList": {
|
|
1265
|
+
l = `- ${f}`, s = 2;
|
|
1266
|
+
break;
|
|
1267
|
+
}
|
|
1268
|
+
case "task": {
|
|
1269
|
+
l = `- [ ] ${f}`, s = 6;
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
case "code": {
|
|
1273
|
+
const y = n.text || f || "", x = n.mode || "language";
|
|
1274
|
+
l = `\`\`\`${x}
|
|
1275
|
+
${y}
|
|
1276
|
+
\`\`\`
|
|
1277
|
+
`, s = 3, r = 3 + x.length - l.length;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
case "table": {
|
|
1281
|
+
l = "|";
|
|
1282
|
+
const { selectedShape: y = { x: 1, y: 1 } } = n, { x, y: T } = y;
|
|
1283
|
+
for (let w = 0; w <= T; w++)
|
|
1284
|
+
l += " col |";
|
|
1285
|
+
l += `
|
|
1286
|
+
|`;
|
|
1287
|
+
for (let w = 0; w <= T; w++)
|
|
1288
|
+
l += " - |";
|
|
1289
|
+
for (let w = 0; w <= x; w++) {
|
|
1290
|
+
l += `
|
|
1291
|
+
|`;
|
|
1292
|
+
for (let A = 0; A <= T; A++)
|
|
1293
|
+
l += " content |";
|
|
1294
|
+
}
|
|
1295
|
+
s = 2, r = 5 - l.length;
|
|
1296
|
+
break;
|
|
1297
|
+
}
|
|
1298
|
+
case "link": {
|
|
1299
|
+
const { desc: y, url: x } = n;
|
|
1300
|
+
l = `[${y}](${x})`, c = !1;
|
|
1301
|
+
break;
|
|
1302
|
+
}
|
|
1303
|
+
case "image": {
|
|
1304
|
+
const { desc: y, url: x, urls: T } = n;
|
|
1305
|
+
T instanceof Array ? l = T.reduce((w, A) => w + `
|
|
1306
|
+
`, "") : l = `
|
|
1307
|
+
`, c = !1;
|
|
1308
|
+
break;
|
|
1309
|
+
}
|
|
1310
|
+
case "flow": {
|
|
1311
|
+
l = `\`\`\`mermaid
|
|
1312
|
+
${(d == null ? void 0 : d.flow) || `flowchart TD
|
|
1313
|
+
Start --> Stop`}
|
|
1314
|
+
\`\`\`
|
|
1315
|
+
`, s = 3, r = 10 - l.length;
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
case "sequence": {
|
|
1319
|
+
l = `\`\`\`mermaid
|
|
1320
|
+
${(d == null ? void 0 : d.sequence) || `sequenceDiagram
|
|
1321
|
+
A->>B: hello!
|
|
1322
|
+
B-->>A: hi!
|
|
1323
|
+
A-)B: bye!`}
|
|
1324
|
+
\`\`\`
|
|
1325
|
+
`, s = 3, r = 10 - l.length;
|
|
1326
|
+
break;
|
|
1327
|
+
}
|
|
1328
|
+
case "gantt": {
|
|
1329
|
+
l = `\`\`\`mermaid
|
|
1330
|
+
${(d == null ? void 0 : d.gantt) || `gantt
|
|
1331
|
+
title A Gantt Diagram
|
|
1332
|
+
dateFormat YYYY-MM-DD
|
|
1333
|
+
section Section
|
|
1334
|
+
A task :a1, 2014-01-01, 30d
|
|
1335
|
+
Another task :after a1, 20d`}
|
|
1336
|
+
\`\`\`
|
|
1337
|
+
`, s = 3, r = 10 - l.length;
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
case "class": {
|
|
1341
|
+
l = `\`\`\`mermaid
|
|
1342
|
+
${(d == null ? void 0 : d.class) || `classDiagram
|
|
1343
|
+
class Animal
|
|
1344
|
+
Vehicle <|-- Car`}
|
|
1345
|
+
\`\`\`
|
|
1346
|
+
`, s = 3, r = 10 - l.length;
|
|
1347
|
+
break;
|
|
1348
|
+
}
|
|
1349
|
+
case "state": {
|
|
1350
|
+
l = `\`\`\`mermaid
|
|
1351
|
+
${(d == null ? void 0 : d.state) || `stateDiagram-v2
|
|
1352
|
+
s1 --> s2`}
|
|
1353
|
+
\`\`\`
|
|
1354
|
+
`, s = 3, r = 10 - l.length;
|
|
1355
|
+
break;
|
|
1356
|
+
}
|
|
1357
|
+
case "pie": {
|
|
1358
|
+
l = `\`\`\`mermaid
|
|
1359
|
+
${(d == null ? void 0 : d.pie) || `pie title Pets adopted by volunteers
|
|
1360
|
+
"Dogs" : 386
|
|
1361
|
+
"Cats" : 85
|
|
1362
|
+
"Rats" : 15`}
|
|
1363
|
+
\`\`\`
|
|
1364
|
+
`, s = 3, r = 10 - l.length;
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
case "relationship": {
|
|
1368
|
+
l = `\`\`\`mermaid
|
|
1369
|
+
${(d == null ? void 0 : d.relationship) || `erDiagram
|
|
1370
|
+
CAR ||--o{ NAMED-DRIVER : allows
|
|
1371
|
+
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
1372
|
+
\`\`\`
|
|
1373
|
+
`, s = 3, r = 10 - l.length;
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
case "journey": {
|
|
1377
|
+
l = `\`\`\`mermaid
|
|
1378
|
+
${(d == null ? void 0 : d.journey) || `journey
|
|
1379
|
+
title My working day
|
|
1380
|
+
section Go to work
|
|
1381
|
+
Make tea: 5: Me
|
|
1382
|
+
Go upstairs: 3: Me
|
|
1383
|
+
Do work: 1: Me, Cat
|
|
1384
|
+
section Go home
|
|
1385
|
+
Go downstairs: 5: Me
|
|
1386
|
+
Sit down: 5: Me`}
|
|
1387
|
+
\`\`\`
|
|
1388
|
+
`, s = 3, r = 10 - l.length;
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
case "katexInline": {
|
|
1392
|
+
l = "$$", s = 1, r = -1;
|
|
1393
|
+
break;
|
|
1394
|
+
}
|
|
1395
|
+
case "katexBlock": {
|
|
1396
|
+
l = `$$
|
|
1397
|
+
|
|
1398
|
+
$$
|
|
1399
|
+
`, s = 3, r = -4;
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
case "universal": {
|
|
1403
|
+
const { generate: y } = n, x = y(f);
|
|
1404
|
+
l = x.targetValue, c = x.select, s = x.deviationStart, r = x.deviationEnd;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
return {
|
|
1408
|
+
text: l,
|
|
1409
|
+
options: {
|
|
1410
|
+
// 是否选中
|
|
1411
|
+
select: c,
|
|
1412
|
+
// 选中时,开始位置的偏移量
|
|
1413
|
+
deviationStart: s,
|
|
1414
|
+
// 结束的偏移量
|
|
1415
|
+
deviationEnd: r,
|
|
1416
|
+
// 是否整个替换
|
|
1417
|
+
replaceAll: g
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
}, el = "#e5c07b", He = "var(--md-color)", tl = "#56b6c2", ll = "#ffffff", ee = "var(--md-color)", Fe = "#e5c07b", ol = "#e5c07b", al = "var(--md-color)", Ie = "#d19a66", nl = "#c678dd", rl = "#21252b", Be = "#2c313a", Oe = "#000", se = "#353a42", il = "#ceedfa33", Ve = "#528bff", sl = fe.theme(
|
|
1421
|
+
{
|
|
1422
|
+
"&": {
|
|
1423
|
+
color: ee,
|
|
1424
|
+
backgroundColor: Oe
|
|
1425
|
+
},
|
|
1426
|
+
".cm-content": {
|
|
1427
|
+
caretColor: Ve
|
|
1428
|
+
},
|
|
1429
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: Ve },
|
|
1430
|
+
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: il },
|
|
1431
|
+
".cm-panels": { backgroundColor: rl, color: ee },
|
|
1432
|
+
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
1433
|
+
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
1434
|
+
".cm-searchMatch": {
|
|
1435
|
+
backgroundColor: "#72a1ff59",
|
|
1436
|
+
outline: "1px solid #457dff"
|
|
1437
|
+
},
|
|
1438
|
+
".cm-searchMatch.cm-searchMatch-selected": {
|
|
1439
|
+
backgroundColor: "#6199ff2f"
|
|
1440
|
+
},
|
|
1441
|
+
".cm-activeLine": { backgroundColor: "#ceedfa33" },
|
|
1442
|
+
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
|
|
1443
|
+
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
|
|
1444
|
+
backgroundColor: "#bad0f847"
|
|
1445
|
+
},
|
|
1446
|
+
".cm-gutters": {
|
|
1447
|
+
backgroundColor: Oe,
|
|
1448
|
+
color: ee,
|
|
1449
|
+
borderRight: "1px solid",
|
|
1450
|
+
borderColor: "var(--md-border-color)"
|
|
1451
|
+
},
|
|
1452
|
+
".cm-activeLineGutter": {
|
|
1453
|
+
backgroundColor: Be
|
|
1454
|
+
},
|
|
1455
|
+
".cm-foldPlaceholder": {
|
|
1456
|
+
backgroundColor: "transparent",
|
|
1457
|
+
border: "none",
|
|
1458
|
+
color: "#ddd"
|
|
1459
|
+
},
|
|
1460
|
+
".cm-tooltip": {
|
|
1461
|
+
border: "none",
|
|
1462
|
+
backgroundColor: se
|
|
1463
|
+
},
|
|
1464
|
+
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
1465
|
+
borderTopColor: "transparent",
|
|
1466
|
+
borderBottomColor: "transparent"
|
|
1467
|
+
},
|
|
1468
|
+
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
1469
|
+
borderTopColor: se,
|
|
1470
|
+
borderBottomColor: se
|
|
1471
|
+
},
|
|
1472
|
+
".cm-tooltip-autocomplete": {
|
|
1473
|
+
"& > ul > li[aria-selected]": {
|
|
1474
|
+
backgroundColor: Be,
|
|
1475
|
+
color: ee
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
},
|
|
1479
|
+
{ dark: !0 }
|
|
1480
|
+
), cl = We.define([
|
|
1481
|
+
{ tag: i.keyword, color: nl },
|
|
1482
|
+
{ tag: [i.name, i.deleted, i.character, i.propertyName, i.macroName], color: He },
|
|
1483
|
+
{ tag: [i.function(i.variableName), i.labelName], color: ol },
|
|
1484
|
+
{ tag: [i.color, i.constant(i.name), i.standard(i.name)], color: Ie },
|
|
1485
|
+
{ tag: [i.definition(i.name), i.separator], color: ee },
|
|
1486
|
+
{
|
|
1487
|
+
tag: [
|
|
1488
|
+
i.typeName,
|
|
1489
|
+
i.className,
|
|
1490
|
+
i.number,
|
|
1491
|
+
i.changed,
|
|
1492
|
+
i.annotation,
|
|
1493
|
+
i.modifier,
|
|
1494
|
+
i.self,
|
|
1495
|
+
i.namespace
|
|
1496
|
+
],
|
|
1497
|
+
color: el
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
tag: [
|
|
1501
|
+
i.operator,
|
|
1502
|
+
i.operatorKeyword,
|
|
1503
|
+
i.url,
|
|
1504
|
+
i.escape,
|
|
1505
|
+
i.regexp,
|
|
1506
|
+
i.link,
|
|
1507
|
+
i.special(i.string)
|
|
1508
|
+
],
|
|
1509
|
+
color: tl
|
|
1510
|
+
},
|
|
1511
|
+
{ tag: [i.meta, i.comment], color: Fe },
|
|
1512
|
+
{ tag: i.strong, fontWeight: "bold" },
|
|
1513
|
+
{ tag: i.emphasis, fontStyle: "italic" },
|
|
1514
|
+
{ tag: i.strikethrough, textDecoration: "line-through" },
|
|
1515
|
+
{ tag: i.link, color: Fe, textDecoration: "underline" },
|
|
1516
|
+
{ tag: i.heading, fontWeight: "bold", color: He },
|
|
1517
|
+
{ tag: [i.atom, i.bool, i.special(i.variableName)], color: Ie },
|
|
1518
|
+
{ tag: [i.processingInstruction, i.string, i.inserted], color: al },
|
|
1519
|
+
{ tag: i.invalid, color: ll }
|
|
1520
|
+
]), dl = [
|
|
1521
|
+
sl,
|
|
1522
|
+
ze(cl)
|
|
1523
|
+
], ul = "#e5c07b", Re = "#3f4a54", ml = "#56b6c2", fl = "#fff", te = "#3f4a54", Ne = "#2d8cf0", gl = "#2d8cf0", hl = "#3f4a54", Pe = "#d19a66", bl = "#c678dd", vl = "#21252b", Ue = "#ceedfa33", qe = "#fff", ce = "#353a42", kl = "#bad5fa", Ge = "#3f4a54", pl = fe.theme(
|
|
1524
|
+
{
|
|
1525
|
+
"&": {
|
|
1526
|
+
color: te,
|
|
1527
|
+
backgroundColor: qe
|
|
1528
|
+
},
|
|
1529
|
+
".cm-content": {
|
|
1530
|
+
caretColor: Ge
|
|
1531
|
+
},
|
|
1532
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: Ge },
|
|
1533
|
+
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: kl },
|
|
1534
|
+
".cm-panels": { backgroundColor: vl, color: te },
|
|
1535
|
+
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
1536
|
+
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
1537
|
+
".cm-searchMatch": {
|
|
1538
|
+
backgroundColor: "#72a1ff59",
|
|
1539
|
+
outline: "1px solid #457dff"
|
|
1540
|
+
},
|
|
1541
|
+
".cm-searchMatch.cm-searchMatch-selected": {
|
|
1542
|
+
backgroundColor: "#6199ff2f"
|
|
1543
|
+
},
|
|
1544
|
+
".cm-activeLine": { backgroundColor: "#ceedfa33" },
|
|
1545
|
+
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
|
|
1546
|
+
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
|
|
1547
|
+
backgroundColor: "#bad0f847"
|
|
1548
|
+
},
|
|
1549
|
+
".cm-gutters": {
|
|
1550
|
+
backgroundColor: qe,
|
|
1551
|
+
color: te,
|
|
1552
|
+
borderRight: "1px solid",
|
|
1553
|
+
borderColor: "var(--md-border-color)"
|
|
1554
|
+
},
|
|
1555
|
+
".cm-activeLineGutter": {
|
|
1556
|
+
backgroundColor: Ue
|
|
1557
|
+
},
|
|
1558
|
+
".cm-foldPlaceholder": {
|
|
1559
|
+
backgroundColor: "transparent",
|
|
1560
|
+
border: "none",
|
|
1561
|
+
color: "#ddd"
|
|
1562
|
+
},
|
|
1563
|
+
".cm-tooltip": {
|
|
1564
|
+
border: "none",
|
|
1565
|
+
backgroundColor: ce
|
|
1566
|
+
},
|
|
1567
|
+
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
1568
|
+
borderTopColor: "transparent",
|
|
1569
|
+
borderBottomColor: "transparent"
|
|
1570
|
+
},
|
|
1571
|
+
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
1572
|
+
borderTopColor: ce,
|
|
1573
|
+
borderBottomColor: ce
|
|
1574
|
+
},
|
|
1575
|
+
".cm-tooltip-autocomplete": {
|
|
1576
|
+
"& > ul > li[aria-selected]": {
|
|
1577
|
+
backgroundColor: Ue,
|
|
1578
|
+
color: te
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
{ dark: !0 }
|
|
1583
|
+
), Cl = We.define([
|
|
1584
|
+
{ tag: i.keyword, color: bl },
|
|
1585
|
+
{ tag: [i.name, i.deleted, i.character, i.propertyName, i.macroName], color: Re },
|
|
1586
|
+
{ tag: [i.function(i.variableName), i.labelName], color: gl },
|
|
1587
|
+
{ tag: [i.color, i.constant(i.name), i.standard(i.name)], color: Pe },
|
|
1588
|
+
{ tag: [i.definition(i.name), i.separator], color: te },
|
|
1589
|
+
{
|
|
1590
|
+
tag: [
|
|
1591
|
+
i.typeName,
|
|
1592
|
+
i.className,
|
|
1593
|
+
i.number,
|
|
1594
|
+
i.changed,
|
|
1595
|
+
i.annotation,
|
|
1596
|
+
i.modifier,
|
|
1597
|
+
i.self,
|
|
1598
|
+
i.namespace
|
|
1599
|
+
],
|
|
1600
|
+
color: ul
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
tag: [
|
|
1604
|
+
i.operator,
|
|
1605
|
+
i.operatorKeyword,
|
|
1606
|
+
i.url,
|
|
1607
|
+
i.escape,
|
|
1608
|
+
i.regexp,
|
|
1609
|
+
i.link,
|
|
1610
|
+
i.special(i.string)
|
|
1611
|
+
],
|
|
1612
|
+
color: ml
|
|
1613
|
+
},
|
|
1614
|
+
{ tag: [i.meta, i.comment], color: Ne },
|
|
1615
|
+
{ tag: i.strong, fontWeight: "bold" },
|
|
1616
|
+
{ tag: i.emphasis, fontStyle: "italic" },
|
|
1617
|
+
{ tag: i.strikethrough, textDecoration: "line-through" },
|
|
1618
|
+
{ tag: i.link, color: Ne, textDecoration: "underline" },
|
|
1619
|
+
{ tag: i.heading, fontWeight: "bold", color: Re },
|
|
1620
|
+
{ tag: [i.atom, i.bool, i.special(i.variableName)], color: Pe },
|
|
1621
|
+
{ tag: [i.processingInstruction, i.string, i.inserted], color: hl },
|
|
1622
|
+
{ tag: i.invalid, color: fl }
|
|
1623
|
+
]), $l = [
|
|
1624
|
+
pl,
|
|
1625
|
+
ze(Cl)
|
|
1626
|
+
], z = (e) => {
|
|
1627
|
+
const o = new Ht();
|
|
1628
|
+
return (l) => (o.get(e.state) ? e.dispatch({ effects: o.reconfigure(l) }) : e.dispatch({
|
|
1629
|
+
effects: Ft.appendConfig.of(o.of(l))
|
|
1630
|
+
}), !0);
|
|
1631
|
+
};
|
|
1632
|
+
class yl {
|
|
1633
|
+
constructor(o) {
|
|
1634
|
+
U(this, "view");
|
|
1635
|
+
// 切换tabSize的执行方法。切换时,Compartment实例需要相同
|
|
1636
|
+
U(this, "toggleTabSize");
|
|
1637
|
+
U(this, "togglePlaceholder");
|
|
1638
|
+
/**
|
|
1639
|
+
* 设置全部的扩展
|
|
1640
|
+
*/
|
|
1641
|
+
U(this, "setExtensions");
|
|
1642
|
+
U(this, "toggleDisabled");
|
|
1643
|
+
U(this, "toggleReadOnly");
|
|
1644
|
+
U(this, "toggleMaxlength");
|
|
1645
|
+
this.view = o, this.toggleTabSize = z(this.view), this.togglePlaceholder = z(this.view), this.setExtensions = z(this.view), this.toggleDisabled = z(this.view), this.toggleReadOnly = z(this.view), this.toggleMaxlength = z(this.view);
|
|
1646
|
+
}
|
|
1647
|
+
getValue() {
|
|
1648
|
+
return this.view.state.doc.toString();
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* 设置内容
|
|
1652
|
+
*
|
|
1653
|
+
* @param insert 待插入内容
|
|
1654
|
+
* @param from 插入开始位置
|
|
1655
|
+
* @param to 插入结束位置
|
|
1656
|
+
*/
|
|
1657
|
+
setValue(o, n = 0, l = this.view.state.doc.length) {
|
|
1658
|
+
this.view.dispatch({
|
|
1659
|
+
changes: {
|
|
1660
|
+
from: n,
|
|
1661
|
+
to: l,
|
|
1662
|
+
insert: o
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* 获取选中的文本
|
|
1668
|
+
*/
|
|
1669
|
+
getSelectedText() {
|
|
1670
|
+
const { from: o, to: n } = this.view.state.selection.main;
|
|
1671
|
+
return this.view.state.sliceDoc(o, n);
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* 使用新的内容替换选中的内容
|
|
1675
|
+
*
|
|
1676
|
+
* @param text 待替换内容
|
|
1677
|
+
* @param options 替换后是否选中
|
|
1678
|
+
*/
|
|
1679
|
+
replaceSelectedText(o, n = {
|
|
1680
|
+
// 是否选中
|
|
1681
|
+
select: !0,
|
|
1682
|
+
// 选中时,开始位置的偏移量
|
|
1683
|
+
deviationStart: 0,
|
|
1684
|
+
// 结束的偏移量
|
|
1685
|
+
deviationEnd: 0,
|
|
1686
|
+
// 直接替换所有文本
|
|
1687
|
+
replaceAll: !1
|
|
1688
|
+
}) {
|
|
1689
|
+
if (n.replaceAll) {
|
|
1690
|
+
this.setValue(o);
|
|
1691
|
+
return;
|
|
1692
|
+
}
|
|
1693
|
+
const { from: l } = this.view.state.selection.main;
|
|
1694
|
+
if (this.view.dispatch(this.view.state.replaceSelection(o)), n.select) {
|
|
1695
|
+
const s = l + o.length + n.deviationEnd;
|
|
1696
|
+
this.view.dispatch({
|
|
1697
|
+
selection: re.create(
|
|
1698
|
+
[
|
|
1699
|
+
re.range(l + n.deviationStart, s),
|
|
1700
|
+
re.cursor(s)
|
|
1701
|
+
],
|
|
1702
|
+
1
|
|
1703
|
+
)
|
|
1704
|
+
}), this.view.focus();
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* 设置tabSize
|
|
1709
|
+
*
|
|
1710
|
+
* @param tabSize 需要切换的大小
|
|
1711
|
+
*/
|
|
1712
|
+
setTabSize(o) {
|
|
1713
|
+
this.toggleTabSize([
|
|
1714
|
+
ie.tabSize.of(o),
|
|
1715
|
+
Et.of(" ".repeat(o))
|
|
1716
|
+
]);
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* 设置placeholder
|
|
1720
|
+
*
|
|
1721
|
+
* @param t 目标内容
|
|
1722
|
+
*/
|
|
1723
|
+
setPlaceholder(o) {
|
|
1724
|
+
this.togglePlaceholder(xt(o));
|
|
1725
|
+
}
|
|
1726
|
+
focus() {
|
|
1727
|
+
this.view.focus();
|
|
1728
|
+
}
|
|
1729
|
+
setDisabled(o) {
|
|
1730
|
+
this.toggleDisabled([fe.editable.of(!o)]);
|
|
1731
|
+
}
|
|
1732
|
+
setReadOnly(o) {
|
|
1733
|
+
this.toggleReadOnly([ie.readOnly.of(o)]);
|
|
1734
|
+
}
|
|
1735
|
+
setMaxLength(o) {
|
|
1736
|
+
this.toggleMaxlength([
|
|
1737
|
+
ie.changeFilter.of((n) => n.newDoc.length <= o)
|
|
1738
|
+
]);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
const xl = (e) => {
|
|
1742
|
+
const o = S("editorId");
|
|
1743
|
+
return (l) => {
|
|
1744
|
+
if (l.clipboardData) {
|
|
1745
|
+
if (l.clipboardData.files.length > 0) {
|
|
1746
|
+
const { files: s } = l.clipboardData;
|
|
1747
|
+
h.emit(
|
|
1748
|
+
o,
|
|
1749
|
+
"uploadImage",
|
|
1750
|
+
Array.from(s).filter((r) => /image\/.*/.test(r.type))
|
|
1751
|
+
), l.preventDefault();
|
|
1752
|
+
}
|
|
1753
|
+
if (e.autoDetectCode && l.clipboardData.types.includes("vscode-editor-data")) {
|
|
1754
|
+
const s = JSON.parse(l.clipboardData.getData("vscode-editor-data"));
|
|
1755
|
+
h.emit(o, "replace", "code", {
|
|
1756
|
+
mode: s.mode,
|
|
1757
|
+
text: l.clipboardData.getData("text/plain")
|
|
1758
|
+
}), l.preventDefault();
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
}, wl = xl, Tl = (e) => {
|
|
1763
|
+
const o = S("editorId");
|
|
1764
|
+
W(() => {
|
|
1765
|
+
h.on(o, {
|
|
1766
|
+
name: ct,
|
|
1767
|
+
callback() {
|
|
1768
|
+
var n;
|
|
1769
|
+
(n = e.value) == null || n.focus();
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
});
|
|
1773
|
+
}, Sl = Tl, Al = (e, o) => [
|
|
1774
|
+
{
|
|
1775
|
+
key: "Ctrl-b",
|
|
1776
|
+
mac: "Cmd-b",
|
|
1777
|
+
run: () => (h.emit(e, "replace", "bold"), !0)
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
key: "Ctrl-d",
|
|
1781
|
+
mac: "Cmd-d",
|
|
1782
|
+
run: At,
|
|
1783
|
+
preventDefault: !0
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
key: "Ctrl-s",
|
|
1787
|
+
mac: "Cmd-s",
|
|
1788
|
+
run: (A) => (h.emit(e, je, A.state.doc.toString()), !0),
|
|
1789
|
+
shift: () => (h.emit(e, "replace", "strikeThrough"), !0)
|
|
1790
|
+
},
|
|
1791
|
+
{
|
|
1792
|
+
key: "Ctrl-u",
|
|
1793
|
+
mac: "Cmd-u",
|
|
1794
|
+
run: () => (h.emit(e, "replace", "underline"), !0),
|
|
1795
|
+
shift: () => (h.emit(e, "replace", "unorderedList"), !0)
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
key: "Ctrl-i",
|
|
1799
|
+
mac: "Cmd-i",
|
|
1800
|
+
run: () => (h.emit(e, "replace", "italic"), !0),
|
|
1801
|
+
shift: () => (h.emit(e, "openModals", "image"), !0)
|
|
1802
|
+
},
|
|
1803
|
+
{
|
|
1804
|
+
key: "Ctrl-1",
|
|
1805
|
+
mac: "Cmd-1",
|
|
1806
|
+
run: () => (h.emit(e, "replace", "h1"), !0)
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
key: "Ctrl-2",
|
|
1810
|
+
mac: "Cmd-2",
|
|
1811
|
+
run: () => (h.emit(e, "replace", "h2"), !0)
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
key: "Ctrl-3",
|
|
1815
|
+
mac: "Cmd-3",
|
|
1816
|
+
run: () => (h.emit(e, "replace", "h3"), !0)
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
key: "Ctrl-4",
|
|
1820
|
+
mac: "Cmd-4",
|
|
1821
|
+
run: () => (h.emit(e, "replace", "h4"), !0)
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
key: "Ctrl-5",
|
|
1825
|
+
mac: "Cmd-5",
|
|
1826
|
+
run: () => (h.emit(e, "replace", "h5"), !0)
|
|
1827
|
+
},
|
|
1828
|
+
{
|
|
1829
|
+
key: "Ctrl-6",
|
|
1830
|
+
mac: "Cmd-6",
|
|
1831
|
+
run: () => (h.emit(e, "replace", "h6"), !0)
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
key: "Ctrl-ArrowUp",
|
|
1835
|
+
mac: "Cmd-ArrowUp",
|
|
1836
|
+
run: () => (h.emit(e, "replace", "sup"), !0)
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
key: "Ctrl-ArrowDown",
|
|
1840
|
+
mac: "Cmd-ArrowDown",
|
|
1841
|
+
run: () => (h.emit(e, "replace", "sub"), !0)
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
key: "Ctrl-o",
|
|
1845
|
+
mac: "Cmd-o",
|
|
1846
|
+
run: () => (h.emit(e, "replace", "orderedList"), !0)
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
key: "Ctrl-c",
|
|
1850
|
+
mac: "Cmd-c",
|
|
1851
|
+
shift: () => (h.emit(e, "replace", "code"), !0),
|
|
1852
|
+
any(A, p) {
|
|
1853
|
+
return (p.ctrlKey || p.metaKey) && p.altKey && p.code === "KeyC" ? (h.emit(e, "replace", "codeRow"), !0) : !1;
|
|
1854
|
+
}
|
|
1855
|
+
},
|
|
1856
|
+
{
|
|
1857
|
+
key: "Ctrl-l",
|
|
1858
|
+
mac: "Cmd-l",
|
|
1859
|
+
run: () => (h.emit(e, "openModals", "link"), !0)
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
key: "Ctrl-f",
|
|
1863
|
+
mac: "Cmd-f",
|
|
1864
|
+
shift: () => o.noPrettier ? !1 : (h.emit(e, "replace", "prettier"), !0)
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
any: (A, p) => (p.ctrlKey || p.metaKey) && p.altKey && p.shiftKey && p.code === "KeyT" ? (h.emit(e, "replace", "table"), !0) : !1
|
|
1868
|
+
}
|
|
1869
|
+
], Ml = Al, Ll = (e) => {
|
|
1870
|
+
const o = S("tabWidth"), n = S("editorId"), l = S("theme"), s = q(), r = Xe(), c = Ml(n, e), g = wl(e), f = [
|
|
1871
|
+
wt.of([...c, Mt]),
|
|
1872
|
+
yt,
|
|
1873
|
+
St({ codeLanguages: Tt }),
|
|
1874
|
+
// 横向换行
|
|
1875
|
+
ne.lineWrapping,
|
|
1876
|
+
ne.updateListener.of((u) => {
|
|
1877
|
+
u.docChanged && e.onChange(u.state.doc.toString());
|
|
1878
|
+
}),
|
|
1879
|
+
ne.domEventHandlers({
|
|
1880
|
+
paste: g,
|
|
1881
|
+
blur: e.onBlur,
|
|
1882
|
+
focus: e.onFocus
|
|
1883
|
+
})
|
|
1884
|
+
], d = () => l.value === "light" ? G.codeMirrorExtensions(
|
|
1885
|
+
l.value,
|
|
1886
|
+
[...f, $l],
|
|
1887
|
+
[...c]
|
|
1888
|
+
) : G.codeMirrorExtensions(
|
|
1889
|
+
l.value,
|
|
1890
|
+
[...f, dl],
|
|
1891
|
+
[...c]
|
|
1892
|
+
);
|
|
1893
|
+
return W(() => {
|
|
1894
|
+
const u = new ne({
|
|
1895
|
+
doc: e.value,
|
|
1896
|
+
parent: s.value
|
|
1897
|
+
});
|
|
1898
|
+
r.value = new yl(u), r.value.setTabSize(o), r.value.setExtensions(d()), r.value.setDisabled(e.disabled), r.value.setReadOnly(e.readonly), e.placeholder && r.value.setPlaceholder(e.placeholder), e.autofocus && u.focus(), e.maxlength && r.value.setMaxLength(e.maxlength), h.on(n, {
|
|
1899
|
+
name: "ctrlZ",
|
|
1900
|
+
callback() {
|
|
1901
|
+
Lt(u);
|
|
1902
|
+
}
|
|
1903
|
+
}), h.on(n, {
|
|
1904
|
+
name: "ctrlShiftZ",
|
|
1905
|
+
callback() {
|
|
1906
|
+
Dt(u);
|
|
1907
|
+
}
|
|
1908
|
+
}), h.on(n, {
|
|
1909
|
+
name: "replace",
|
|
1910
|
+
callback(k, $ = {}) {
|
|
1911
|
+
var m;
|
|
1912
|
+
const { text: b, options: v } = Qt(k, r.value, $);
|
|
1913
|
+
(m = r.value) == null || m.replaceSelectedText(b, v);
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
}), F(
|
|
1917
|
+
() => l.value,
|
|
1918
|
+
() => {
|
|
1919
|
+
var u, k;
|
|
1920
|
+
l.value === "dark" ? (u = r.value) == null || u.setExtensions(d()) : (k = r.value) == null || k.setExtensions(d());
|
|
1921
|
+
}
|
|
1922
|
+
), F(
|
|
1923
|
+
() => e.value,
|
|
1924
|
+
() => {
|
|
1925
|
+
var u, k;
|
|
1926
|
+
((u = r.value) == null ? void 0 : u.getValue()) !== e.value && ((k = r.value) == null || k.setValue(e.value));
|
|
1927
|
+
}
|
|
1928
|
+
), F(
|
|
1929
|
+
() => e.placeholder,
|
|
1930
|
+
() => {
|
|
1931
|
+
var u;
|
|
1932
|
+
(u = r.value) == null || u.setPlaceholder(e.placeholder);
|
|
1933
|
+
}
|
|
1934
|
+
), F(
|
|
1935
|
+
() => e.disabled,
|
|
1936
|
+
() => {
|
|
1937
|
+
var u;
|
|
1938
|
+
(u = r.value) == null || u.setDisabled(e.disabled);
|
|
1939
|
+
}
|
|
1940
|
+
), F(
|
|
1941
|
+
() => e.readonly,
|
|
1942
|
+
() => {
|
|
1943
|
+
var u;
|
|
1944
|
+
(u = r.value) == null || u.setDisabled(e.readonly);
|
|
1945
|
+
}
|
|
1946
|
+
), F(
|
|
1947
|
+
() => e.maxlength,
|
|
1948
|
+
() => {
|
|
1949
|
+
var u;
|
|
1950
|
+
e.maxlength && ((u = r.value) == null || u.setMaxLength(e.maxlength));
|
|
1951
|
+
}
|
|
1952
|
+
), Sl(r), {
|
|
1953
|
+
inputWrapperRef: s,
|
|
1954
|
+
codeMirrorUt: r
|
|
1955
|
+
};
|
|
1956
|
+
}, Dl = Ll, El = {
|
|
1957
|
+
value: {
|
|
1958
|
+
type: String,
|
|
1959
|
+
default: ""
|
|
1960
|
+
},
|
|
1961
|
+
onChange: {
|
|
1962
|
+
type: Function,
|
|
1963
|
+
default: () => {
|
|
1964
|
+
}
|
|
1965
|
+
},
|
|
1966
|
+
setting: {
|
|
1967
|
+
type: Object,
|
|
1968
|
+
default: () => ({})
|
|
1969
|
+
},
|
|
1970
|
+
onHtmlChanged: {
|
|
1971
|
+
type: Function,
|
|
1972
|
+
default: () => {
|
|
1973
|
+
}
|
|
1974
|
+
},
|
|
1975
|
+
onGetCatalog: {
|
|
1976
|
+
type: Function,
|
|
1977
|
+
default: () => {
|
|
1978
|
+
}
|
|
1979
|
+
},
|
|
1980
|
+
mdHeadingId: {
|
|
1981
|
+
type: Function,
|
|
1982
|
+
default: () => ""
|
|
1983
|
+
},
|
|
1984
|
+
noMermaid: {
|
|
1985
|
+
type: Boolean,
|
|
1986
|
+
default: !1
|
|
1987
|
+
},
|
|
1988
|
+
sanitize: {
|
|
1989
|
+
type: Function,
|
|
1990
|
+
default: (e) => e
|
|
1991
|
+
},
|
|
1992
|
+
placeholder: {
|
|
1993
|
+
type: String,
|
|
1994
|
+
default: ""
|
|
1995
|
+
},
|
|
1996
|
+
// 不使用该函数功能
|
|
1997
|
+
noKatex: {
|
|
1998
|
+
type: Boolean,
|
|
1999
|
+
default: !1
|
|
2000
|
+
},
|
|
2001
|
+
scrollAuto: {
|
|
2002
|
+
type: Boolean
|
|
2003
|
+
},
|
|
2004
|
+
formatCopiedText: {
|
|
2005
|
+
type: Function,
|
|
2006
|
+
default: (e) => e
|
|
2007
|
+
},
|
|
2008
|
+
autofocus: {
|
|
2009
|
+
type: Boolean
|
|
2010
|
+
},
|
|
2011
|
+
disabled: {
|
|
2012
|
+
type: Boolean
|
|
2013
|
+
},
|
|
2014
|
+
readonly: {
|
|
2015
|
+
type: Boolean
|
|
2016
|
+
},
|
|
2017
|
+
maxlength: {
|
|
2018
|
+
type: Number
|
|
2019
|
+
},
|
|
2020
|
+
autoDetectCode: {
|
|
2021
|
+
type: Boolean
|
|
2022
|
+
},
|
|
2023
|
+
/**
|
|
2024
|
+
* 输入框失去焦点时触发事件
|
|
2025
|
+
*/
|
|
2026
|
+
onBlur: {
|
|
2027
|
+
type: Function,
|
|
2028
|
+
default: () => {
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
/**
|
|
2032
|
+
* 输入框获得焦点时触发事件
|
|
2033
|
+
*/
|
|
2034
|
+
onFocus: {
|
|
2035
|
+
type: Function,
|
|
2036
|
+
default: () => {
|
|
2037
|
+
}
|
|
2038
|
+
},
|
|
2039
|
+
noPrettier: {
|
|
2040
|
+
type: Boolean
|
|
2041
|
+
},
|
|
2042
|
+
noHighlight: {
|
|
2043
|
+
type: Boolean,
|
|
2044
|
+
default: !1
|
|
2045
|
+
}
|
|
2046
|
+
}, Hl = /* @__PURE__ */ I({
|
|
2047
|
+
name: "MDEditorContent",
|
|
2048
|
+
props: El,
|
|
2049
|
+
setup(e) {
|
|
2050
|
+
const o = q(""), {
|
|
2051
|
+
inputWrapperRef: n,
|
|
2052
|
+
codeMirrorUt: l
|
|
2053
|
+
} = Dl(e);
|
|
2054
|
+
return Xt(e, o, l), () => t("div", {
|
|
2055
|
+
class: `${a}-content`
|
|
2056
|
+
}, [t("div", {
|
|
2057
|
+
class: `${a}-input-wrapper`,
|
|
2058
|
+
ref: n
|
|
2059
|
+
}, null), t(dt, {
|
|
2060
|
+
modelValue: e.value,
|
|
2061
|
+
setting: e.setting,
|
|
2062
|
+
onHtmlChanged: (s) => {
|
|
2063
|
+
o.value = s, e.onHtmlChanged(s);
|
|
2064
|
+
},
|
|
2065
|
+
onGetCatalog: e.onGetCatalog,
|
|
2066
|
+
mdHeadingId: e.mdHeadingId,
|
|
2067
|
+
noMermaid: e.noMermaid,
|
|
2068
|
+
sanitize: e.sanitize,
|
|
2069
|
+
noKatex: e.noKatex,
|
|
2070
|
+
formatCopiedText: e.formatCopiedText,
|
|
2071
|
+
noHighlight: e.noHighlight
|
|
2072
|
+
}, null)]);
|
|
2073
|
+
}
|
|
2074
|
+
}), Fl = /* @__PURE__ */ I({
|
|
2075
|
+
props: {
|
|
2076
|
+
modelValue: {
|
|
2077
|
+
type: String,
|
|
2078
|
+
default: ""
|
|
2079
|
+
}
|
|
2080
|
+
},
|
|
2081
|
+
setup(e) {
|
|
2082
|
+
const o = S("usedLanguageText");
|
|
2083
|
+
return () => {
|
|
2084
|
+
var n, l;
|
|
2085
|
+
return t("div", {
|
|
2086
|
+
class: `${a}-footer-item`
|
|
2087
|
+
}, [t("label", {
|
|
2088
|
+
class: `${a}-footer-label`
|
|
2089
|
+
}, [`${(n = o.value.footer) == null ? void 0 : n.markdownTotal}:`]), t("span", null, [((l = e.modelValue) == null ? void 0 : l.length) || 0])]);
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
}), Il = {
|
|
2093
|
+
checked: {
|
|
2094
|
+
type: Boolean,
|
|
2095
|
+
default: !1
|
|
2096
|
+
},
|
|
2097
|
+
onChange: {
|
|
2098
|
+
type: Function,
|
|
2099
|
+
default: () => {
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}, Bl = /* @__PURE__ */ I({
|
|
2103
|
+
props: Il,
|
|
2104
|
+
setup(e) {
|
|
2105
|
+
return () => t("div", {
|
|
2106
|
+
class: [`${a}-checkbox`, e.checked && `${a}-checkbox-checked`],
|
|
2107
|
+
onClick: () => {
|
|
2108
|
+
e.onChange(!e.checked);
|
|
2109
|
+
}
|
|
2110
|
+
}, null);
|
|
2111
|
+
}
|
|
2112
|
+
}), Ol = {
|
|
2113
|
+
scrollAuto: {
|
|
2114
|
+
type: Boolean
|
|
2115
|
+
},
|
|
2116
|
+
onScrollAutoChange: {
|
|
2117
|
+
type: Function,
|
|
2118
|
+
default: () => {
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}, Vl = /* @__PURE__ */ I({
|
|
2122
|
+
props: Ol,
|
|
2123
|
+
setup(e) {
|
|
2124
|
+
const o = S("usedLanguageText");
|
|
2125
|
+
return () => {
|
|
2126
|
+
var n;
|
|
2127
|
+
return t("div", {
|
|
2128
|
+
class: `${a}-footer-item`
|
|
2129
|
+
}, [t("label", {
|
|
2130
|
+
class: `${a}-footer-label`,
|
|
2131
|
+
onClick: () => {
|
|
2132
|
+
e.onScrollAutoChange(!e.scrollAuto);
|
|
2133
|
+
}
|
|
2134
|
+
}, [(n = o.value.footer) == null ? void 0 : n.scrollAuto]), t(Bl, {
|
|
2135
|
+
checked: e.scrollAuto,
|
|
2136
|
+
onChange: e.onScrollAutoChange
|
|
2137
|
+
}, null)]);
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
}), Rl = {
|
|
2141
|
+
modelValue: {
|
|
2142
|
+
type: String,
|
|
2143
|
+
default: ""
|
|
2144
|
+
},
|
|
2145
|
+
footers: {
|
|
2146
|
+
type: Array,
|
|
2147
|
+
default: []
|
|
2148
|
+
},
|
|
2149
|
+
scrollAuto: {
|
|
2150
|
+
type: Boolean
|
|
2151
|
+
},
|
|
2152
|
+
onScrollAutoChange: {
|
|
2153
|
+
type: Function,
|
|
2154
|
+
default: () => {
|
|
2155
|
+
}
|
|
2156
|
+
},
|
|
2157
|
+
defFooters: {
|
|
2158
|
+
type: Object
|
|
2159
|
+
}
|
|
2160
|
+
}, Nl = /* @__PURE__ */ I({
|
|
2161
|
+
name: "MDEditorFooter",
|
|
2162
|
+
props: Rl,
|
|
2163
|
+
setup(e) {
|
|
2164
|
+
const o = me(() => {
|
|
2165
|
+
const l = e.footers.indexOf("="), s = l === -1 ? e.footers : e.footers.slice(0, l), r = l === -1 ? [] : e.footers.slice(l, Number.MAX_SAFE_INTEGER);
|
|
2166
|
+
return [s, r];
|
|
2167
|
+
}), n = (l) => {
|
|
2168
|
+
if (lt.includes(l))
|
|
2169
|
+
switch (l) {
|
|
2170
|
+
case "markdownTotal":
|
|
2171
|
+
return t(Fl, {
|
|
2172
|
+
modelValue: e.modelValue
|
|
2173
|
+
}, null);
|
|
2174
|
+
case "scrollSwitch":
|
|
2175
|
+
return t(Vl, {
|
|
2176
|
+
scrollAuto: e.scrollAuto,
|
|
2177
|
+
onScrollAutoChange: e.onScrollAutoChange
|
|
2178
|
+
}, null);
|
|
2179
|
+
}
|
|
2180
|
+
else
|
|
2181
|
+
return e.defFooters instanceof Array ? e.defFooters[l] || "" : e.defFooters && e.defFooters.children instanceof Array && e.defFooters.children[l] || "";
|
|
2182
|
+
};
|
|
2183
|
+
return () => {
|
|
2184
|
+
const l = o.value[0].map((r) => n(r)), s = o.value[1].map((r) => n(r));
|
|
2185
|
+
return t("div", {
|
|
2186
|
+
class: `${a}-footer`
|
|
2187
|
+
}, [t("div", {
|
|
2188
|
+
class: `${a}-footer-left`
|
|
2189
|
+
}, [l]), t("div", {
|
|
2190
|
+
class: `${a}-footer-right`
|
|
2191
|
+
}, [s])]);
|
|
2192
|
+
};
|
|
2193
|
+
}
|
|
2194
|
+
}), Pl = /* @__PURE__ */ I({
|
|
2195
|
+
name: "MdEditorV3",
|
|
2196
|
+
props: ut,
|
|
2197
|
+
emits: mt,
|
|
2198
|
+
setup(e, o) {
|
|
2199
|
+
const {
|
|
2200
|
+
editorId: n,
|
|
2201
|
+
noKatex: l,
|
|
2202
|
+
noMermaid: s,
|
|
2203
|
+
noPrettier: r,
|
|
2204
|
+
noUploadImg: c,
|
|
2205
|
+
noHighlight: g
|
|
2206
|
+
} = e, f = Y({
|
|
2207
|
+
scrollAuto: e.scrollAuto
|
|
2208
|
+
});
|
|
2209
|
+
ft(e, o), gt(e), ht(e);
|
|
2210
|
+
const [d, u] = bt(e, o), k = vt(e);
|
|
2211
|
+
return Qe(() => {
|
|
2212
|
+
h.clear(n);
|
|
2213
|
+
}), kt(e, o, k, d, u), () => {
|
|
2214
|
+
var v;
|
|
2215
|
+
const $ = De({
|
|
2216
|
+
props: e,
|
|
2217
|
+
ctx: o
|
|
2218
|
+
}, "defToolbars"), b = De({
|
|
2219
|
+
props: e,
|
|
2220
|
+
ctx: o
|
|
2221
|
+
}, "defFooters");
|
|
2222
|
+
return t("div", {
|
|
2223
|
+
id: n,
|
|
2224
|
+
class: [a, e.class, e.theme === "dark" && `${a}-dark`, d.fullscreen || d.pageFullscreen ? `${a}-fullscreen` : ""],
|
|
2225
|
+
style: e.style
|
|
2226
|
+
}, [t(Wt, {
|
|
2227
|
+
noPrettier: r,
|
|
2228
|
+
toolbars: e.toolbars,
|
|
2229
|
+
toolbarsExclude: e.toolbarsExclude,
|
|
2230
|
+
setting: d,
|
|
2231
|
+
updateSetting: u,
|
|
2232
|
+
tableShape: e.tableShape,
|
|
2233
|
+
defToolbars: $,
|
|
2234
|
+
noUploadImg: c
|
|
2235
|
+
}, null), t(Hl, {
|
|
2236
|
+
value: e.modelValue,
|
|
2237
|
+
setting: d,
|
|
2238
|
+
mdHeadingId: e.mdHeadingId,
|
|
2239
|
+
noMermaid: s,
|
|
2240
|
+
noPrettier: r,
|
|
2241
|
+
sanitize: e.sanitize,
|
|
2242
|
+
placeholder: e.placeholder,
|
|
2243
|
+
noKatex: l,
|
|
2244
|
+
scrollAuto: f.scrollAuto,
|
|
2245
|
+
formatCopiedText: e.formatCopiedText,
|
|
2246
|
+
autofocus: e.autoFocus,
|
|
2247
|
+
disabled: e.disabled,
|
|
2248
|
+
readonly: e.readOnly,
|
|
2249
|
+
maxlength: e.maxLength,
|
|
2250
|
+
autoDetectCode: e.autoDetectCode,
|
|
2251
|
+
noHighlight: g,
|
|
2252
|
+
onChange: (m) => {
|
|
2253
|
+
e.onChange ? e.onChange(m) : (o.emit("update:modelValue", m), o.emit("onChange", m));
|
|
2254
|
+
},
|
|
2255
|
+
onHtmlChanged: (m) => {
|
|
2256
|
+
e.onHtmlChanged ? e.onHtmlChanged(m) : o.emit("onHtmlChanged", m);
|
|
2257
|
+
},
|
|
2258
|
+
onGetCatalog: (m) => {
|
|
2259
|
+
e.onGetCatalog ? e.onGetCatalog(m) : o.emit("onGetCatalog", m);
|
|
2260
|
+
},
|
|
2261
|
+
onBlur: (m) => {
|
|
2262
|
+
e.onBlur ? e.onBlur(m) : o.emit("onBlur", m);
|
|
2263
|
+
},
|
|
2264
|
+
onFocus: (m) => {
|
|
2265
|
+
e.onFocus ? e.onFocus(m) : o.emit("onFocus", m);
|
|
2266
|
+
}
|
|
2267
|
+
}, null), ((v = e.footers) == null ? void 0 : v.length) > 0 && t(Nl, {
|
|
2268
|
+
modelValue: e.modelValue,
|
|
2269
|
+
footers: e.footers,
|
|
2270
|
+
defFooters: b,
|
|
2271
|
+
scrollAuto: f.scrollAuto,
|
|
2272
|
+
onScrollAutoChange: (m) => f.scrollAuto = m
|
|
2273
|
+
}, null), k.value && t(Ye, {
|
|
2274
|
+
theme: e.theme,
|
|
2275
|
+
class: `${a}-catalog-editor`,
|
|
2276
|
+
editorId: n,
|
|
2277
|
+
mdHeadingId: e.mdHeadingId,
|
|
2278
|
+
key: "internal-catalog"
|
|
2279
|
+
}, null)]);
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
}), de = Pl;
|
|
2283
|
+
de.install = (e) => (e.component(de.name, de), e.use(It).use(ot).use($t).use(Ye).use(pt), e);
|
|
2284
|
+
export {
|
|
2285
|
+
de as default
|
|
2286
|
+
};
|