md-editor-v3 4.12.0 → 4.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/DropdownToolbar.cjs +3 -1
- package/lib/cjs/MdCatalog.cjs +270 -1
- package/lib/cjs/MdEditor.cjs +3101 -58
- package/lib/cjs/MdModal.cjs +3 -1
- package/lib/cjs/MdPreview.cjs +3 -1
- package/lib/cjs/ModalToolbar.cjs +124 -1
- package/lib/cjs/NormalToolbar.cjs +61 -1
- package/lib/cjs/chunks/config.cjs +290 -1
- package/lib/cjs/chunks/dom.cjs +64 -1
- package/lib/cjs/chunks/index.cjs +1863 -8
- package/lib/cjs/chunks/index2.cjs +198 -1
- package/lib/cjs/chunks/index3.cjs +270 -1
- package/lib/cjs/chunks/index4.cjs +141 -2
- package/lib/cjs/chunks/vue-tsx.cjs +10 -1
- package/lib/cjs/config.cjs +12 -1
- package/lib/cjs/index.cjs +25 -1
- package/lib/es/DropdownToolbar.mjs +2 -2
- package/lib/es/MdCatalog.mjs +164 -114
- package/lib/es/MdEditor.mjs +2292 -1677
- package/lib/es/MdModal.mjs +2 -2
- package/lib/es/MdPreview.mjs +2 -2
- package/lib/es/ModalToolbar.mjs +55 -38
- package/lib/es/NormalToolbar.mjs +26 -18
- package/lib/es/chunks/config.mjs +73 -54
- package/lib/es/chunks/dom.mjs +57 -24
- package/lib/es/chunks/index.mjs +1093 -611
- package/lib/es/chunks/index2.mjs +126 -78
- package/lib/es/chunks/index3.mjs +185 -111
- package/lib/es/chunks/index4.mjs +124 -73
- package/lib/es/chunks/vue-tsx.mjs +8 -8
- package/lib/es/config.mjs +11 -10
- package/lib/es/index.mjs +23 -23
- package/lib/preview.css +200 -1
- package/lib/style.css +592 -1
- package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +1 -1
- package/lib/types/DropdownToolbar/index.d.ts +39 -61
- package/lib/types/MdCatalog/CatalogLink.d.ts +1 -1
- package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
- package/lib/types/MdCatalog/index.d.ts +47 -60
- package/lib/types/MdEditor/Editor.d.ts +1 -1
- package/lib/types/MdEditor/components/Checkbox/index.d.ts +1 -1
- package/lib/types/MdEditor/components/Divider/index.d.ts +1 -1
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +1 -1
- package/lib/types/MdEditor/components/Icon/Icon.d.ts +1 -1
- package/lib/types/MdEditor/components/Icon/index.d.ts +1 -1
- package/lib/types/MdEditor/components/Modal/Modal.d.ts +2 -2
- package/lib/types/MdEditor/components/Modal/index.d.ts +59 -63
- package/lib/types/MdEditor/components/Popper/index.d.ts +1 -1
- package/lib/types/MdEditor/index.d.ts +238 -104
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Content/index.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Footer/index.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Modals/Link.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Modals/index.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +1 -1
- package/lib/types/MdEditor/utils/vue-tsx.d.ts +1 -1
- package/lib/types/MdPreview/MdPreview.d.ts +1 -1
- package/lib/types/MdPreview/index.d.ts +119 -73
- package/lib/types/ModalToolbar/ModalToolbar.d.ts +1 -1
- package/lib/types/ModalToolbar/index.d.ts +64 -66
- package/lib/types/NormalToolbar/NormalToolbar.d.ts +1 -1
- package/lib/types/NormalToolbar/index.d.ts +30 -58
- package/lib/umd/index.js +42 -42
- package/package.json +4 -4
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { defineComponent, createVNode, inject, ref, onMounted, reactive, computed, watch, nextTick, Fragment, cloneVNode, toRef, shallowRef, onBeforeUnmount } from "vue";
|
|
8
|
+
import { p as prefix, e as configOption, l as screenfullUrl, b as allToolbar, M as MinInputBoxWidth, d as allFooter } from "./chunks/config.mjs";
|
|
9
|
+
import { draggingScroll, linkTo, debounce, createSmoothScroll, throttle } from "@vavt/util";
|
|
10
|
+
import { a as Dropdown, D as DropdownToolbar } from "./chunks/index2.mjs";
|
|
11
|
+
import { b as bus, i as CHANGE_FULL_SCREEN, E as ERROR_CATCHER, U as UPLOAD_IMAGE, l as base642File, m as OPEN_MODALS, h as REPLACE, c as CHANGE_CATALOG_VISIBLE, O as ON_SAVE, n as CTRL_SHIFT_Z, o as CTRL_Z, j as EVENT_LISTENER } from "./chunks/index4.mjs";
|
|
12
|
+
import { a as appendHandler } from "./chunks/dom.mjs";
|
|
13
|
+
import { M as MdModal, I as Icon } from "./chunks/index3.mjs";
|
|
14
|
+
import { EditorView as EditorView$1 } from "codemirror";
|
|
15
|
+
import { EditorView, placeholder, keymap } from "@codemirror/view";
|
|
16
|
+
import { languages } from "@codemirror/language-data";
|
|
17
|
+
import { markdown } from "@codemirror/lang-markdown";
|
|
18
|
+
import { EditorSelection, EditorState, Compartment, StateEffect } from "@codemirror/state";
|
|
19
|
+
import { deleteLine, defaultKeymap, historyKeymap, indentWithTab, history, undo, redo } from "@codemirror/commands";
|
|
20
|
+
import { HighlightStyle, syntaxHighlighting, indentUnit } from "@codemirror/language";
|
|
21
|
+
import { tags } from "@lezer/highlight";
|
|
22
|
+
import { autocompletion } from "@codemirror/autocomplete";
|
|
23
|
+
import { c as contentProps, C as ContentPreview, e as editorProps, a as editorEmits, u as useOnSave, b as useProvide, d as useExpansion, f as useErrorCatcher, g as useConfig, h as useCatalog, i as useExpose, M as MdPreview } from "./chunks/index.mjs";
|
|
24
|
+
import MdCatalog from "./MdCatalog.mjs";
|
|
25
|
+
import { g as getSlot } from "./chunks/vue-tsx.mjs";
|
|
26
|
+
import NormalToolbar from "./NormalToolbar.mjs";
|
|
27
|
+
import ModalToolbar from "./ModalToolbar.mjs";
|
|
28
|
+
const Divider = /* @__PURE__ */ defineComponent({
|
|
26
29
|
setup() {
|
|
27
|
-
return () =>
|
|
28
|
-
class: `${
|
|
30
|
+
return () => createVNode("div", {
|
|
31
|
+
"class": `${prefix}-divider`
|
|
29
32
|
}, null);
|
|
30
33
|
}
|
|
31
|
-
})
|
|
34
|
+
});
|
|
35
|
+
const toolbarProps = {
|
|
32
36
|
noPrettier: {
|
|
33
37
|
type: Boolean
|
|
34
38
|
},
|
|
@@ -77,38 +81,66 @@ const El = /* @__PURE__ */ z({
|
|
|
77
81
|
showToolbarName: {
|
|
78
82
|
type: Boolean
|
|
79
83
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
};
|
|
85
|
+
const useSreenfull = (props2) => {
|
|
86
|
+
var _a, _b, _c, _d;
|
|
87
|
+
const editorId = inject("editorId");
|
|
88
|
+
let screenfull = (_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.screenfull) == null ? void 0 : _b.instance;
|
|
89
|
+
const screenfullJs = (_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.screenfull) == null ? void 0 : _d.js;
|
|
90
|
+
const screenfullMe = ref(false);
|
|
91
|
+
const fullscreenHandler = (status) => {
|
|
92
|
+
if (!screenfull) {
|
|
93
|
+
bus.emit(editorId, ERROR_CATCHER, {
|
|
87
94
|
name: "fullscreen",
|
|
88
95
|
message: "fullscreen is undefined"
|
|
89
96
|
});
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
if (screenfull.isEnabled) {
|
|
100
|
+
screenfullMe.value = true;
|
|
101
|
+
const targetStatus = status === void 0 ? !screenfull.isFullscreen : status;
|
|
102
|
+
if (targetStatus) {
|
|
103
|
+
screenfull.request();
|
|
104
|
+
} else {
|
|
105
|
+
screenfull.exit();
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
console.error("browser does not support screenfull!");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const onScreenfullEvent = () => {
|
|
112
|
+
if (screenfull && screenfull.isEnabled) {
|
|
113
|
+
screenfull.on("change", () => {
|
|
114
|
+
if (screenfullMe.value || props2.setting.fullscreen) {
|
|
115
|
+
screenfullMe.value = false;
|
|
116
|
+
props2.updateSetting("fullscreen");
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const screenfullLoad = () => {
|
|
122
|
+
screenfull = window.screenfull;
|
|
123
|
+
onScreenfullEvent();
|
|
99
124
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
125
|
+
onMounted(() => {
|
|
126
|
+
onScreenfullEvent();
|
|
127
|
+
if (!screenfull) {
|
|
128
|
+
const screenScript = document.createElement("script");
|
|
129
|
+
screenScript.src = screenfullJs || screenfullUrl;
|
|
130
|
+
screenScript.onload = screenfullLoad;
|
|
131
|
+
screenScript.id = `${prefix}-screenfull`;
|
|
132
|
+
appendHandler(screenScript, "screenfull");
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
onMounted(() => {
|
|
136
|
+
bus.on(editorId, {
|
|
137
|
+
name: CHANGE_FULL_SCREEN,
|
|
138
|
+
callback: fullscreenHandler
|
|
109
139
|
});
|
|
110
|
-
})
|
|
111
|
-
|
|
140
|
+
});
|
|
141
|
+
return { fullscreenHandler };
|
|
142
|
+
};
|
|
143
|
+
const props$6 = {
|
|
112
144
|
tableShape: {
|
|
113
145
|
type: Array,
|
|
114
146
|
default: () => [6, 4]
|
|
@@ -118,43 +150,48 @@ const El = /* @__PURE__ */ z({
|
|
|
118
150
|
default: () => {
|
|
119
151
|
}
|
|
120
152
|
}
|
|
121
|
-
}
|
|
153
|
+
};
|
|
154
|
+
const TableShape = /* @__PURE__ */ defineComponent({
|
|
122
155
|
name: "TableShape",
|
|
123
|
-
props:
|
|
124
|
-
setup(
|
|
125
|
-
const
|
|
156
|
+
props: props$6,
|
|
157
|
+
setup(props2) {
|
|
158
|
+
const hoverPosition = reactive({
|
|
126
159
|
x: -1,
|
|
127
160
|
y: -1
|
|
128
161
|
});
|
|
129
|
-
return () =>
|
|
130
|
-
class: `${
|
|
131
|
-
onMouseleave: () => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
162
|
+
return () => createVNode("div", {
|
|
163
|
+
"class": `${prefix}-table-shape`,
|
|
164
|
+
"onMouseleave": () => {
|
|
165
|
+
hoverPosition.x = -1;
|
|
166
|
+
hoverPosition.y = -1;
|
|
167
|
+
}
|
|
168
|
+
}, [new Array(props2.tableShape[1]).fill("").map((_, rowIndex) => createVNode("div", {
|
|
169
|
+
"class": `${prefix}-table-shape-row`,
|
|
170
|
+
"key": `table-shape-row-${rowIndex}`
|
|
171
|
+
}, [new Array(props2.tableShape[0]).fill("").map((_2, colIndex) => createVNode("div", {
|
|
172
|
+
"class": `${prefix}-table-shape-col`,
|
|
173
|
+
"key": `table-shape-col-${colIndex}`,
|
|
174
|
+
"onMouseenter": () => {
|
|
175
|
+
hoverPosition.x = rowIndex;
|
|
176
|
+
hoverPosition.y = colIndex;
|
|
142
177
|
},
|
|
143
|
-
onClick: () => {
|
|
144
|
-
|
|
178
|
+
"onClick": () => {
|
|
179
|
+
props2.onSelected(hoverPosition);
|
|
145
180
|
}
|
|
146
|
-
}, [
|
|
147
|
-
class: [`${
|
|
181
|
+
}, [createVNode("div", {
|
|
182
|
+
"class": [`${prefix}-table-shape-col-default`, rowIndex <= hoverPosition.x && colIndex <= hoverPosition.y && `${prefix}-table-shape-col-include`]
|
|
148
183
|
}, null)]))]))]);
|
|
149
184
|
}
|
|
150
|
-
})
|
|
185
|
+
});
|
|
186
|
+
const TableShape$1 = TableShape;
|
|
187
|
+
const props$5 = {
|
|
151
188
|
type: {
|
|
152
189
|
type: String,
|
|
153
190
|
default: "link"
|
|
154
191
|
},
|
|
155
192
|
visible: {
|
|
156
193
|
type: Boolean,
|
|
157
|
-
default:
|
|
194
|
+
default: false
|
|
158
195
|
},
|
|
159
196
|
onCancel: {
|
|
160
197
|
type: Function,
|
|
@@ -166,80 +203,94 @@ const El = /* @__PURE__ */ z({
|
|
|
166
203
|
default: () => {
|
|
167
204
|
}
|
|
168
205
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
206
|
+
};
|
|
207
|
+
const LinkModal = /* @__PURE__ */ defineComponent({
|
|
208
|
+
props: props$5,
|
|
209
|
+
setup(props2) {
|
|
210
|
+
const ult = inject("usedLanguageText");
|
|
211
|
+
const editorId = inject("editorId");
|
|
212
|
+
const title = computed(() => {
|
|
213
|
+
var _a, _b;
|
|
214
|
+
switch (props2.type) {
|
|
215
|
+
case "link": {
|
|
216
|
+
return (_a = ult.value.linkModalTips) == null ? void 0 : _a.linkTitle;
|
|
217
|
+
}
|
|
218
|
+
case "image": {
|
|
219
|
+
return (_b = ult.value.linkModalTips) == null ? void 0 : _b.imageTitle;
|
|
220
|
+
}
|
|
221
|
+
default: {
|
|
180
222
|
return "";
|
|
223
|
+
}
|
|
181
224
|
}
|
|
182
|
-
})
|
|
225
|
+
});
|
|
226
|
+
const linkData = reactive({
|
|
183
227
|
desc: "",
|
|
184
228
|
url: ""
|
|
185
229
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
230
|
+
watch(() => props2.visible, (nVal) => {
|
|
231
|
+
if (!nVal) {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
linkData.desc = "";
|
|
234
|
+
linkData.url = "";
|
|
235
|
+
}, 200);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return () => createVNode(MdModal, {
|
|
239
|
+
"title": title.value,
|
|
240
|
+
"visible": props2.visible,
|
|
241
|
+
"onClose": props2.onCancel
|
|
194
242
|
}, {
|
|
195
243
|
default: () => {
|
|
196
|
-
var
|
|
197
|
-
return [
|
|
198
|
-
class: `${
|
|
199
|
-
}, [
|
|
200
|
-
class: `${
|
|
201
|
-
for: `link-desc-${
|
|
202
|
-
}, [(
|
|
203
|
-
placeholder: (
|
|
204
|
-
class: `${
|
|
205
|
-
id: `link-desc-${
|
|
206
|
-
type: "text",
|
|
207
|
-
value:
|
|
208
|
-
onChange: (
|
|
209
|
-
|
|
244
|
+
var _a, _b, _c, _d, _e;
|
|
245
|
+
return [createVNode("div", {
|
|
246
|
+
"class": `${prefix}-form-item`
|
|
247
|
+
}, [createVNode("label", {
|
|
248
|
+
"class": `${prefix}-label`,
|
|
249
|
+
"for": `link-desc-${editorId}`
|
|
250
|
+
}, [(_a = ult.value.linkModalTips) == null ? void 0 : _a.descLabel]), createVNode("input", {
|
|
251
|
+
"placeholder": (_b = ult.value.linkModalTips) == null ? void 0 : _b.descLabelPlaceHolder,
|
|
252
|
+
"class": `${prefix}-input`,
|
|
253
|
+
"id": `link-desc-${editorId}`,
|
|
254
|
+
"type": "text",
|
|
255
|
+
"value": linkData.desc,
|
|
256
|
+
"onChange": (e) => {
|
|
257
|
+
linkData.desc = e.target.value;
|
|
210
258
|
},
|
|
211
|
-
autocomplete: "off"
|
|
212
|
-
}, null)]),
|
|
213
|
-
class: `${
|
|
214
|
-
}, [
|
|
215
|
-
class: `${
|
|
216
|
-
for: `link-url-${
|
|
217
|
-
}, [(
|
|
218
|
-
placeholder: (
|
|
219
|
-
class: `${
|
|
220
|
-
id: `link-url-${
|
|
221
|
-
type: "text",
|
|
222
|
-
value:
|
|
223
|
-
onChange: (
|
|
224
|
-
|
|
259
|
+
"autocomplete": "off"
|
|
260
|
+
}, null)]), createVNode("div", {
|
|
261
|
+
"class": `${prefix}-form-item`
|
|
262
|
+
}, [createVNode("label", {
|
|
263
|
+
"class": `${prefix}-label`,
|
|
264
|
+
"for": `link-url-${editorId}`
|
|
265
|
+
}, [(_c = ult.value.linkModalTips) == null ? void 0 : _c.urlLabel]), createVNode("input", {
|
|
266
|
+
"placeholder": (_d = ult.value.linkModalTips) == null ? void 0 : _d.urlLabelPlaceHolder,
|
|
267
|
+
"class": `${prefix}-input`,
|
|
268
|
+
"id": `link-url-${editorId}`,
|
|
269
|
+
"type": "text",
|
|
270
|
+
"value": linkData.url,
|
|
271
|
+
"onChange": (e) => {
|
|
272
|
+
linkData.url = e.target.value;
|
|
225
273
|
},
|
|
226
|
-
autocomplete: "off"
|
|
227
|
-
}, null)]),
|
|
228
|
-
class: `${
|
|
229
|
-
}, [
|
|
230
|
-
class: [`${
|
|
231
|
-
type: "button",
|
|
232
|
-
onClick: () => {
|
|
233
|
-
|
|
274
|
+
"autocomplete": "off"
|
|
275
|
+
}, null)]), createVNode("div", {
|
|
276
|
+
"class": `${prefix}-form-item`
|
|
277
|
+
}, [createVNode("button", {
|
|
278
|
+
"class": [`${prefix}-btn`, `${prefix}-btn-row`],
|
|
279
|
+
"type": "button",
|
|
280
|
+
"onClick": () => {
|
|
281
|
+
props2.onOk(linkData);
|
|
282
|
+
linkData.desc = "";
|
|
283
|
+
linkData.url = "";
|
|
234
284
|
}
|
|
235
|
-
}, [(
|
|
285
|
+
}, [(_e = ult.value.linkModalTips) == null ? void 0 : _e.buttonOK])])];
|
|
236
286
|
}
|
|
237
287
|
});
|
|
238
288
|
}
|
|
239
|
-
})
|
|
289
|
+
});
|
|
290
|
+
const props$4 = {
|
|
240
291
|
visible: {
|
|
241
292
|
type: Boolean,
|
|
242
|
-
default:
|
|
293
|
+
default: false
|
|
243
294
|
},
|
|
244
295
|
onCancel: {
|
|
245
296
|
type: Function,
|
|
@@ -251,121 +302,143 @@ const El = /* @__PURE__ */ z({
|
|
|
251
302
|
default: () => {
|
|
252
303
|
}
|
|
253
304
|
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
305
|
+
};
|
|
306
|
+
const ClipModal = /* @__PURE__ */ defineComponent({
|
|
307
|
+
props: props$4,
|
|
308
|
+
setup(props2) {
|
|
309
|
+
var _a, _b, _c;
|
|
310
|
+
const ult = inject("usedLanguageText");
|
|
311
|
+
const editorId = inject("editorId");
|
|
312
|
+
let Cropper = (_c = (_b = (_a = configOption) == null ? void 0 : _a.editorExtensions) == null ? void 0 : _b.cropper) == null ? void 0 : _c.instance;
|
|
313
|
+
const uploadRef = ref();
|
|
314
|
+
const uploadImgRef = ref();
|
|
315
|
+
const previewTargetRef = ref();
|
|
316
|
+
const data = reactive({
|
|
317
|
+
cropperInited: false,
|
|
318
|
+
imgSelected: false,
|
|
263
319
|
imgSrc: "",
|
|
264
320
|
// 是否全屏
|
|
265
|
-
isFullscreen:
|
|
321
|
+
isFullscreen: false
|
|
266
322
|
});
|
|
267
|
-
let
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
const x = r.value.files || [];
|
|
278
|
-
if (f.imgSelected = !0, (x == null ? void 0 : x.length) > 0) {
|
|
279
|
-
const S = new FileReader();
|
|
280
|
-
S.onload = (L) => {
|
|
281
|
-
f.imgSrc = L.target.result, de(() => {
|
|
282
|
-
m = new n(i.value, {
|
|
283
|
-
viewMode: 2,
|
|
284
|
-
preview: `.${a}-clip-preview-target`
|
|
285
|
-
// aspectRatio: 16 / 9,
|
|
286
|
-
});
|
|
323
|
+
let cropper = null;
|
|
324
|
+
watch(() => props2.visible, () => {
|
|
325
|
+
if (props2.visible && !data.cropperInited) {
|
|
326
|
+
Cropper = Cropper || window.Cropper;
|
|
327
|
+
uploadRef.value.onchange = () => {
|
|
328
|
+
if (!Cropper) {
|
|
329
|
+
bus.emit(editorId, ERROR_CATCHER, {
|
|
330
|
+
name: "Cropper",
|
|
331
|
+
message: "Cropper is undefined"
|
|
287
332
|
});
|
|
288
|
-
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const fileList = uploadRef.value.files || [];
|
|
336
|
+
data.imgSelected = true;
|
|
337
|
+
if ((fileList == null ? void 0 : fileList.length) > 0) {
|
|
338
|
+
const fileReader = new FileReader();
|
|
339
|
+
fileReader.onload = (e) => {
|
|
340
|
+
data.imgSrc = e.target.result;
|
|
341
|
+
nextTick(() => {
|
|
342
|
+
cropper = new Cropper(uploadImgRef.value, {
|
|
343
|
+
viewMode: 2,
|
|
344
|
+
preview: `.${prefix}-clip-preview-target`
|
|
345
|
+
// aspectRatio: 16 / 9,
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
fileReader.readAsDataURL(fileList[0]);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
watch(() => [data.imgSelected], () => {
|
|
355
|
+
previewTargetRef.value.style = "";
|
|
356
|
+
});
|
|
357
|
+
watch(() => data.isFullscreen, () => {
|
|
358
|
+
nextTick(() => {
|
|
359
|
+
cropper == null ? void 0 : cropper.destroy();
|
|
360
|
+
previewTargetRef.value.style = "";
|
|
361
|
+
if (uploadImgRef.value) {
|
|
362
|
+
cropper = new Cropper(uploadImgRef.value, {
|
|
363
|
+
viewMode: 2,
|
|
364
|
+
preview: `.${prefix}-clip-preview-target`
|
|
365
|
+
// aspectRatio: 16 / 9,
|
|
366
|
+
});
|
|
289
367
|
}
|
|
290
368
|
});
|
|
291
|
-
}), B(() => [f.imgSelected], () => {
|
|
292
|
-
h.value.style = "";
|
|
293
|
-
}), B(() => f.isFullscreen, () => {
|
|
294
|
-
de(() => {
|
|
295
|
-
m == null || m.destroy(), h.value.style = "", i.value && (m = new n(i.value, {
|
|
296
|
-
viewMode: 2,
|
|
297
|
-
preview: `.${a}-clip-preview-target`
|
|
298
|
-
// aspectRatio: 16 / 9,
|
|
299
|
-
}));
|
|
300
|
-
});
|
|
301
369
|
});
|
|
302
|
-
const
|
|
303
|
-
|
|
370
|
+
const reset = () => {
|
|
371
|
+
cropper.clear();
|
|
372
|
+
cropper.destroy();
|
|
373
|
+
cropper = null;
|
|
374
|
+
uploadRef.value.value = "";
|
|
375
|
+
data.imgSelected = false;
|
|
304
376
|
};
|
|
305
377
|
return () => {
|
|
306
|
-
var
|
|
307
|
-
return
|
|
308
|
-
class: `${
|
|
309
|
-
title: (
|
|
310
|
-
visible:
|
|
311
|
-
onClose:
|
|
312
|
-
showAdjust:
|
|
313
|
-
isFullscreen:
|
|
314
|
-
onAdjust: (
|
|
315
|
-
|
|
378
|
+
var _a2;
|
|
379
|
+
return createVNode(MdModal, {
|
|
380
|
+
"class": `${prefix}-modal-clip`,
|
|
381
|
+
"title": (_a2 = ult.value.clipModalTips) == null ? void 0 : _a2.title,
|
|
382
|
+
"visible": props2.visible,
|
|
383
|
+
"onClose": props2.onCancel,
|
|
384
|
+
"showAdjust": true,
|
|
385
|
+
"isFullscreen": data.isFullscreen,
|
|
386
|
+
"onAdjust": (val) => {
|
|
387
|
+
data.isFullscreen = val;
|
|
316
388
|
},
|
|
317
|
-
width: "668px",
|
|
318
|
-
height: "421px"
|
|
389
|
+
"width": "668px",
|
|
390
|
+
"height": "421px"
|
|
319
391
|
}, {
|
|
320
392
|
default: () => {
|
|
321
|
-
var
|
|
322
|
-
return [
|
|
323
|
-
class: `${
|
|
324
|
-
}, [
|
|
325
|
-
class: `${
|
|
326
|
-
}, [
|
|
327
|
-
class: `${
|
|
328
|
-
}, [
|
|
329
|
-
src:
|
|
330
|
-
ref:
|
|
331
|
-
style: {
|
|
393
|
+
var _a3, _b2;
|
|
394
|
+
return [createVNode("div", {
|
|
395
|
+
"class": `${prefix}-form-item ${prefix}-clip`
|
|
396
|
+
}, [createVNode("div", {
|
|
397
|
+
"class": `${prefix}-clip-main`
|
|
398
|
+
}, [data.imgSelected ? createVNode("div", {
|
|
399
|
+
"class": `${prefix}-clip-cropper`
|
|
400
|
+
}, [createVNode("img", {
|
|
401
|
+
"src": data.imgSrc,
|
|
402
|
+
"ref": uploadImgRef,
|
|
403
|
+
"style": {
|
|
332
404
|
display: "none"
|
|
333
405
|
},
|
|
334
|
-
alt: ""
|
|
335
|
-
}, null),
|
|
336
|
-
class: `${
|
|
337
|
-
onClick:
|
|
338
|
-
}, [
|
|
339
|
-
name: "delete"
|
|
340
|
-
}, null)])]) :
|
|
341
|
-
class: `${
|
|
342
|
-
onClick: () => {
|
|
343
|
-
|
|
406
|
+
"alt": ""
|
|
407
|
+
}, null), createVNode("div", {
|
|
408
|
+
"class": `${prefix}-clip-delete`,
|
|
409
|
+
"onClick": reset
|
|
410
|
+
}, [createVNode(Icon, {
|
|
411
|
+
"name": "delete"
|
|
412
|
+
}, null)])]) : createVNode("div", {
|
|
413
|
+
"class": `${prefix}-clip-upload`,
|
|
414
|
+
"onClick": () => {
|
|
415
|
+
uploadRef.value.click();
|
|
344
416
|
}
|
|
345
|
-
}, [
|
|
346
|
-
name: "upload"
|
|
347
|
-
}, null)])]),
|
|
348
|
-
class: `${
|
|
349
|
-
}, [
|
|
350
|
-
class: `${
|
|
351
|
-
ref:
|
|
352
|
-
}, null)])]),
|
|
353
|
-
class: `${
|
|
354
|
-
}, [
|
|
355
|
-
class: `${
|
|
356
|
-
type: "button",
|
|
357
|
-
onClick: () => {
|
|
358
|
-
if (
|
|
359
|
-
const
|
|
360
|
-
|
|
417
|
+
}, [createVNode(Icon, {
|
|
418
|
+
"name": "upload"
|
|
419
|
+
}, null)])]), createVNode("div", {
|
|
420
|
+
"class": `${prefix}-clip-preview`
|
|
421
|
+
}, [createVNode("div", {
|
|
422
|
+
"class": `${prefix}-clip-preview-target`,
|
|
423
|
+
"ref": previewTargetRef
|
|
424
|
+
}, null)])]), createVNode("div", {
|
|
425
|
+
"class": `${prefix}-form-item`
|
|
426
|
+
}, [createVNode("button", {
|
|
427
|
+
"class": `${prefix}-btn`,
|
|
428
|
+
"type": "button",
|
|
429
|
+
"onClick": () => {
|
|
430
|
+
if (cropper) {
|
|
431
|
+
const cvs = cropper.getCroppedCanvas();
|
|
432
|
+
bus.emit(editorId, UPLOAD_IMAGE, [base642File(cvs.toDataURL("image/png"))], props2.onOk);
|
|
433
|
+
reset();
|
|
361
434
|
}
|
|
362
435
|
}
|
|
363
|
-
}, [((
|
|
364
|
-
ref:
|
|
365
|
-
accept: "image/*",
|
|
366
|
-
type: "file",
|
|
367
|
-
multiple:
|
|
368
|
-
style: {
|
|
436
|
+
}, [((_a3 = ult.value.clipModalTips) == null ? void 0 : _a3.buttonUpload) || ((_b2 = ult.value.linkModalTips) == null ? void 0 : _b2.buttonOK)])]), createVNode("input", {
|
|
437
|
+
"ref": uploadRef,
|
|
438
|
+
"accept": "image/*",
|
|
439
|
+
"type": "file",
|
|
440
|
+
"multiple": false,
|
|
441
|
+
"style": {
|
|
369
442
|
display: "none"
|
|
370
443
|
}
|
|
371
444
|
}, null)];
|
|
@@ -373,18 +446,19 @@ const El = /* @__PURE__ */ z({
|
|
|
373
446
|
});
|
|
374
447
|
};
|
|
375
448
|
}
|
|
376
|
-
})
|
|
449
|
+
});
|
|
450
|
+
const props$3 = {
|
|
377
451
|
type: {
|
|
378
452
|
type: String,
|
|
379
453
|
default: "link"
|
|
380
454
|
},
|
|
381
455
|
linkVisible: {
|
|
382
456
|
type: Boolean,
|
|
383
|
-
default:
|
|
457
|
+
default: false
|
|
384
458
|
},
|
|
385
459
|
clipVisible: {
|
|
386
460
|
type: Boolean,
|
|
387
|
-
default:
|
|
461
|
+
default: false
|
|
388
462
|
},
|
|
389
463
|
onCancel: {
|
|
390
464
|
type: Function,
|
|
@@ -396,1046 +470,1291 @@ const El = /* @__PURE__ */ z({
|
|
|
396
470
|
default: () => {
|
|
397
471
|
}
|
|
398
472
|
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
473
|
+
};
|
|
474
|
+
const Modals = /* @__PURE__ */ defineComponent({
|
|
475
|
+
props: props$3,
|
|
476
|
+
setup(props2) {
|
|
477
|
+
return () => createVNode(Fragment, null, [createVNode(LinkModal, {
|
|
478
|
+
"type": props2.type,
|
|
479
|
+
"visible": props2.linkVisible,
|
|
480
|
+
"onOk": props2.onOk,
|
|
481
|
+
"onCancel": props2.onCancel
|
|
482
|
+
}, null), createVNode(ClipModal, {
|
|
483
|
+
"visible": props2.clipVisible,
|
|
484
|
+
"onOk": props2.onOk,
|
|
485
|
+
"onCancel": props2.onCancel
|
|
411
486
|
}, null)]);
|
|
412
487
|
}
|
|
413
|
-
})
|
|
488
|
+
});
|
|
489
|
+
const ToolBar = /* @__PURE__ */ defineComponent({
|
|
414
490
|
name: "MDEditorToolbar",
|
|
415
|
-
props:
|
|
416
|
-
setup(
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
491
|
+
props: toolbarProps,
|
|
492
|
+
setup(props2) {
|
|
493
|
+
const editorId = inject("editorId");
|
|
494
|
+
const ult = inject("usedLanguageText");
|
|
495
|
+
const theme = inject("theme");
|
|
496
|
+
const language = inject("language");
|
|
497
|
+
const {
|
|
498
|
+
fullscreenHandler
|
|
499
|
+
} = useSreenfull(props2);
|
|
500
|
+
const wrapperId = `${editorId}-toolbar-wrapper`;
|
|
501
|
+
const wrapperRef = ref();
|
|
502
|
+
const visible = reactive({
|
|
503
|
+
title: false,
|
|
504
|
+
catalog: false,
|
|
422
505
|
// 图片上传下拉
|
|
423
|
-
image:
|
|
506
|
+
image: false,
|
|
424
507
|
// 表格预选
|
|
425
|
-
table:
|
|
508
|
+
table: false,
|
|
426
509
|
// mermaid
|
|
427
|
-
mermaid:
|
|
428
|
-
katex:
|
|
429
|
-
})
|
|
430
|
-
|
|
431
|
-
|
|
510
|
+
mermaid: false,
|
|
511
|
+
katex: false
|
|
512
|
+
});
|
|
513
|
+
const emitHandler = (direct, params) => {
|
|
514
|
+
bus.emit(editorId, REPLACE, direct, params);
|
|
515
|
+
};
|
|
516
|
+
const modalData = reactive({
|
|
432
517
|
type: "link",
|
|
433
|
-
linkVisible:
|
|
434
|
-
clipVisible:
|
|
435
|
-
})
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
518
|
+
linkVisible: false,
|
|
519
|
+
clipVisible: false
|
|
520
|
+
});
|
|
521
|
+
const toolbarLeftRef = ref();
|
|
522
|
+
onMounted(() => {
|
|
523
|
+
bus.on(editorId, {
|
|
524
|
+
name: OPEN_MODALS,
|
|
525
|
+
callback(type) {
|
|
526
|
+
modalData.type = type;
|
|
527
|
+
modalData.linkVisible = true;
|
|
441
528
|
}
|
|
442
529
|
});
|
|
443
530
|
});
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
531
|
+
const splitedbar = computed(() => {
|
|
532
|
+
const excluedBars = props2.toolbars.filter((barItem) => !props2.toolbarsExclude.includes(barItem));
|
|
533
|
+
const moduleSplitIndex = excluedBars.indexOf("=");
|
|
534
|
+
const barLeft = moduleSplitIndex === -1 ? excluedBars : excluedBars.slice(0, moduleSplitIndex + 1);
|
|
535
|
+
const barRight = moduleSplitIndex === -1 ? [] : excluedBars.slice(moduleSplitIndex, Number.MAX_SAFE_INTEGER);
|
|
536
|
+
return [barLeft, barRight];
|
|
537
|
+
});
|
|
538
|
+
const uploadRef = ref();
|
|
539
|
+
const uploadHandler = () => {
|
|
540
|
+
bus.emit(editorId, UPLOAD_IMAGE, Array.from(uploadRef.value.files || []));
|
|
541
|
+
uploadRef.value.value = "";
|
|
449
542
|
};
|
|
450
|
-
|
|
451
|
-
|
|
543
|
+
onMounted(() => {
|
|
544
|
+
uploadRef.value.addEventListener("change", uploadHandler);
|
|
452
545
|
});
|
|
453
|
-
const
|
|
454
|
-
var
|
|
455
|
-
if (
|
|
456
|
-
switch (
|
|
457
|
-
case "-":
|
|
458
|
-
return
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
546
|
+
const barRender = (barItem) => {
|
|
547
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma;
|
|
548
|
+
if (allToolbar.includes(barItem)) {
|
|
549
|
+
switch (barItem) {
|
|
550
|
+
case "-": {
|
|
551
|
+
return createVNode(Divider, null, null);
|
|
552
|
+
}
|
|
553
|
+
case "bold": {
|
|
554
|
+
return createVNode("div", {
|
|
555
|
+
"class": `${prefix}-toolbar-item`,
|
|
556
|
+
"title": (_a = ult.value.toolbarTips) == null ? void 0 : _a.bold,
|
|
557
|
+
"onClick": () => {
|
|
558
|
+
emitHandler("bold");
|
|
465
559
|
}
|
|
466
|
-
}, [
|
|
467
|
-
name: "bold"
|
|
468
|
-
}, null),
|
|
469
|
-
class: `${
|
|
470
|
-
}, [(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
560
|
+
}, [createVNode(Icon, {
|
|
561
|
+
"name": "bold"
|
|
562
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
563
|
+
"class": `${prefix}-toolbar-item-name`
|
|
564
|
+
}, [(_b = ult.value.toolbarTips) == null ? void 0 : _b.bold])]);
|
|
565
|
+
}
|
|
566
|
+
case "underline": {
|
|
567
|
+
return createVNode("div", {
|
|
568
|
+
"class": `${prefix}-toolbar-item`,
|
|
569
|
+
"title": (_c = ult.value.toolbarTips) == null ? void 0 : _c.underline,
|
|
570
|
+
"onClick": () => {
|
|
571
|
+
emitHandler("underline");
|
|
477
572
|
}
|
|
478
|
-
}, [
|
|
479
|
-
name: "underline"
|
|
480
|
-
}, null),
|
|
481
|
-
class: `${
|
|
482
|
-
}, [(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
573
|
+
}, [createVNode(Icon, {
|
|
574
|
+
"name": "underline"
|
|
575
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
576
|
+
"class": `${prefix}-toolbar-item-name`
|
|
577
|
+
}, [(_d = ult.value.toolbarTips) == null ? void 0 : _d.underline])]);
|
|
578
|
+
}
|
|
579
|
+
case "italic": {
|
|
580
|
+
return createVNode("div", {
|
|
581
|
+
"class": `${prefix}-toolbar-item`,
|
|
582
|
+
"title": (_e = ult.value.toolbarTips) == null ? void 0 : _e.italic,
|
|
583
|
+
"onClick": () => {
|
|
584
|
+
emitHandler("italic");
|
|
489
585
|
}
|
|
490
|
-
}, [
|
|
491
|
-
name: "italic"
|
|
492
|
-
}, null),
|
|
493
|
-
class: `${
|
|
494
|
-
}, [(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
586
|
+
}, [createVNode(Icon, {
|
|
587
|
+
"name": "italic"
|
|
588
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
589
|
+
"class": `${prefix}-toolbar-item-name`
|
|
590
|
+
}, [(_f = ult.value.toolbarTips) == null ? void 0 : _f.italic])]);
|
|
591
|
+
}
|
|
592
|
+
case "strikeThrough": {
|
|
593
|
+
return createVNode("div", {
|
|
594
|
+
"class": `${prefix}-toolbar-item`,
|
|
595
|
+
"title": (_g = ult.value.toolbarTips) == null ? void 0 : _g.strikeThrough,
|
|
596
|
+
"onClick": () => {
|
|
597
|
+
emitHandler("strikeThrough");
|
|
501
598
|
}
|
|
502
|
-
}, [
|
|
503
|
-
name: "strike-through"
|
|
504
|
-
}, null),
|
|
505
|
-
class: `${
|
|
506
|
-
}, [(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
599
|
+
}, [createVNode(Icon, {
|
|
600
|
+
"name": "strike-through"
|
|
601
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
602
|
+
"class": `${prefix}-toolbar-item-name`
|
|
603
|
+
}, [(_h = ult.value.toolbarTips) == null ? void 0 : _h.strikeThrough])]);
|
|
604
|
+
}
|
|
605
|
+
case "title": {
|
|
606
|
+
return createVNode(Dropdown, {
|
|
607
|
+
"relative": `#${wrapperId}`,
|
|
608
|
+
"visible": visible.title,
|
|
609
|
+
"onChange": (v) => {
|
|
610
|
+
visible.title = v;
|
|
513
611
|
},
|
|
514
|
-
overlay:
|
|
515
|
-
class: `${
|
|
516
|
-
onClick: () => {
|
|
517
|
-
|
|
612
|
+
"overlay": createVNode("ul", {
|
|
613
|
+
"class": `${prefix}-menu`,
|
|
614
|
+
"onClick": () => {
|
|
615
|
+
visible.title = false;
|
|
518
616
|
}
|
|
519
|
-
}, [
|
|
520
|
-
class: `${
|
|
521
|
-
onClick: () => {
|
|
522
|
-
|
|
617
|
+
}, [createVNode("li", {
|
|
618
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-title`,
|
|
619
|
+
"onClick": () => {
|
|
620
|
+
emitHandler("h1");
|
|
523
621
|
}
|
|
524
|
-
}, [(
|
|
525
|
-
class: `${
|
|
526
|
-
onClick: () => {
|
|
527
|
-
|
|
622
|
+
}, [(_i = ult.value.titleItem) == null ? void 0 : _i.h1]), createVNode("li", {
|
|
623
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-title`,
|
|
624
|
+
"onClick": () => {
|
|
625
|
+
emitHandler("h2");
|
|
528
626
|
}
|
|
529
|
-
}, [(
|
|
530
|
-
class: `${
|
|
531
|
-
onClick: () => {
|
|
532
|
-
|
|
627
|
+
}, [(_j = ult.value.titleItem) == null ? void 0 : _j.h2]), createVNode("li", {
|
|
628
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-title`,
|
|
629
|
+
"onClick": () => {
|
|
630
|
+
emitHandler("h3");
|
|
533
631
|
}
|
|
534
|
-
}, [(
|
|
535
|
-
class: `${
|
|
536
|
-
onClick: () => {
|
|
537
|
-
|
|
632
|
+
}, [(_k = ult.value.titleItem) == null ? void 0 : _k.h3]), createVNode("li", {
|
|
633
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-title`,
|
|
634
|
+
"onClick": () => {
|
|
635
|
+
emitHandler("h4");
|
|
538
636
|
}
|
|
539
|
-
}, [(
|
|
540
|
-
class: `${
|
|
541
|
-
onClick: () => {
|
|
542
|
-
|
|
637
|
+
}, [(_l = ult.value.titleItem) == null ? void 0 : _l.h4]), createVNode("li", {
|
|
638
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-title`,
|
|
639
|
+
"onClick": () => {
|
|
640
|
+
emitHandler("h5");
|
|
543
641
|
}
|
|
544
|
-
}, [(
|
|
545
|
-
class: `${
|
|
546
|
-
onClick: () => {
|
|
547
|
-
|
|
642
|
+
}, [(_m = ult.value.titleItem) == null ? void 0 : _m.h5]), createVNode("li", {
|
|
643
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-title`,
|
|
644
|
+
"onClick": () => {
|
|
645
|
+
emitHandler("h6");
|
|
548
646
|
}
|
|
549
|
-
}, [(
|
|
647
|
+
}, [(_n = ult.value.titleItem) == null ? void 0 : _n.h6])])
|
|
550
648
|
}, {
|
|
551
649
|
default: () => {
|
|
552
|
-
var
|
|
553
|
-
return [
|
|
554
|
-
class: `${
|
|
555
|
-
title: (
|
|
556
|
-
}, [
|
|
557
|
-
name: "title"
|
|
558
|
-
}, null),
|
|
559
|
-
class: `${
|
|
560
|
-
}, [(
|
|
650
|
+
var _a2, _b2;
|
|
651
|
+
return [createVNode("div", {
|
|
652
|
+
"class": `${prefix}-toolbar-item`,
|
|
653
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.title
|
|
654
|
+
}, [createVNode(Icon, {
|
|
655
|
+
"name": "title"
|
|
656
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
657
|
+
"class": `${prefix}-toolbar-item-name`
|
|
658
|
+
}, [(_b2 = ult.value.toolbarTips) == null ? void 0 : _b2.title])])];
|
|
561
659
|
}
|
|
562
660
|
});
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
661
|
+
}
|
|
662
|
+
case "sub": {
|
|
663
|
+
return createVNode("div", {
|
|
664
|
+
"class": `${prefix}-toolbar-item`,
|
|
665
|
+
"title": (_o = ult.value.toolbarTips) == null ? void 0 : _o.sub,
|
|
666
|
+
"onClick": () => {
|
|
667
|
+
emitHandler("sub");
|
|
569
668
|
}
|
|
570
|
-
}, [
|
|
571
|
-
name: "sub"
|
|
572
|
-
}, null),
|
|
573
|
-
class: `${
|
|
574
|
-
}, [(
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
669
|
+
}, [createVNode(Icon, {
|
|
670
|
+
"name": "sub"
|
|
671
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
672
|
+
"class": `${prefix}-toolbar-item-name`
|
|
673
|
+
}, [(_p = ult.value.toolbarTips) == null ? void 0 : _p.sub])]);
|
|
674
|
+
}
|
|
675
|
+
case "sup": {
|
|
676
|
+
return createVNode("div", {
|
|
677
|
+
"class": `${prefix}-toolbar-item`,
|
|
678
|
+
"title": (_q = ult.value.toolbarTips) == null ? void 0 : _q.sup,
|
|
679
|
+
"onClick": () => {
|
|
680
|
+
emitHandler("sup");
|
|
581
681
|
}
|
|
582
|
-
}, [
|
|
583
|
-
name: "sup"
|
|
584
|
-
}, null),
|
|
585
|
-
class: `${
|
|
586
|
-
}, [(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
682
|
+
}, [createVNode(Icon, {
|
|
683
|
+
"name": "sup"
|
|
684
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
685
|
+
"class": `${prefix}-toolbar-item-name`
|
|
686
|
+
}, [(_r = ult.value.toolbarTips) == null ? void 0 : _r.sup])]);
|
|
687
|
+
}
|
|
688
|
+
case "quote": {
|
|
689
|
+
return createVNode("div", {
|
|
690
|
+
"class": `${prefix}-toolbar-item`,
|
|
691
|
+
"title": (_s = ult.value.toolbarTips) == null ? void 0 : _s.quote,
|
|
692
|
+
"onClick": () => {
|
|
693
|
+
emitHandler("quote");
|
|
593
694
|
}
|
|
594
|
-
}, [
|
|
595
|
-
name: "quote"
|
|
596
|
-
}, null),
|
|
597
|
-
class: `${
|
|
598
|
-
}, [(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
695
|
+
}, [createVNode(Icon, {
|
|
696
|
+
"name": "quote"
|
|
697
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
698
|
+
"class": `${prefix}-toolbar-item-name`
|
|
699
|
+
}, [(_t = ult.value.toolbarTips) == null ? void 0 : _t.quote])]);
|
|
700
|
+
}
|
|
701
|
+
case "unorderedList": {
|
|
702
|
+
return createVNode("div", {
|
|
703
|
+
"class": `${prefix}-toolbar-item`,
|
|
704
|
+
"title": (_u = ult.value.toolbarTips) == null ? void 0 : _u.unorderedList,
|
|
705
|
+
"onClick": () => {
|
|
706
|
+
emitHandler("unorderedList");
|
|
605
707
|
}
|
|
606
|
-
}, [
|
|
607
|
-
name: "unordered-list"
|
|
608
|
-
}, null),
|
|
609
|
-
class: `${
|
|
610
|
-
}, [(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
708
|
+
}, [createVNode(Icon, {
|
|
709
|
+
"name": "unordered-list"
|
|
710
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
711
|
+
"class": `${prefix}-toolbar-item-name`
|
|
712
|
+
}, [(_v = ult.value.toolbarTips) == null ? void 0 : _v.unorderedList])]);
|
|
713
|
+
}
|
|
714
|
+
case "orderedList": {
|
|
715
|
+
return createVNode("div", {
|
|
716
|
+
"class": `${prefix}-toolbar-item`,
|
|
717
|
+
"title": (_w = ult.value.toolbarTips) == null ? void 0 : _w.orderedList,
|
|
718
|
+
"onClick": () => {
|
|
719
|
+
emitHandler("orderedList");
|
|
617
720
|
}
|
|
618
|
-
}, [
|
|
619
|
-
name: "ordered-list"
|
|
620
|
-
}, null),
|
|
621
|
-
class: `${
|
|
622
|
-
}, [(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
721
|
+
}, [createVNode(Icon, {
|
|
722
|
+
"name": "ordered-list"
|
|
723
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
724
|
+
"class": `${prefix}-toolbar-item-name`
|
|
725
|
+
}, [(_x = ult.value.toolbarTips) == null ? void 0 : _x.orderedList])]);
|
|
726
|
+
}
|
|
727
|
+
case "task": {
|
|
728
|
+
return createVNode("div", {
|
|
729
|
+
"class": `${prefix}-toolbar-item`,
|
|
730
|
+
"title": (_y = ult.value.toolbarTips) == null ? void 0 : _y.task,
|
|
731
|
+
"onClick": () => {
|
|
732
|
+
emitHandler("task");
|
|
629
733
|
}
|
|
630
|
-
}, [
|
|
631
|
-
name: "task"
|
|
632
|
-
}, null),
|
|
633
|
-
class: `${
|
|
634
|
-
}, [(
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
734
|
+
}, [createVNode(Icon, {
|
|
735
|
+
"name": "task"
|
|
736
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
737
|
+
"class": `${prefix}-toolbar-item-name`
|
|
738
|
+
}, [(_z = ult.value.toolbarTips) == null ? void 0 : _z.task])]);
|
|
739
|
+
}
|
|
740
|
+
case "codeRow": {
|
|
741
|
+
return createVNode("div", {
|
|
742
|
+
"class": `${prefix}-toolbar-item`,
|
|
743
|
+
"title": (_A = ult.value.toolbarTips) == null ? void 0 : _A.codeRow,
|
|
744
|
+
"onClick": () => {
|
|
745
|
+
emitHandler("codeRow");
|
|
641
746
|
}
|
|
642
|
-
}, [
|
|
643
|
-
name: "code-row"
|
|
644
|
-
}, null),
|
|
645
|
-
class: `${
|
|
646
|
-
}, [(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
747
|
+
}, [createVNode(Icon, {
|
|
748
|
+
"name": "code-row"
|
|
749
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
750
|
+
"class": `${prefix}-toolbar-item-name`
|
|
751
|
+
}, [(_B = ult.value.toolbarTips) == null ? void 0 : _B.codeRow])]);
|
|
752
|
+
}
|
|
753
|
+
case "code": {
|
|
754
|
+
return createVNode("div", {
|
|
755
|
+
"class": `${prefix}-toolbar-item`,
|
|
756
|
+
"title": (_C = ult.value.toolbarTips) == null ? void 0 : _C.code,
|
|
757
|
+
"onClick": () => {
|
|
758
|
+
emitHandler("code");
|
|
653
759
|
}
|
|
654
|
-
}, [
|
|
655
|
-
name: "code"
|
|
656
|
-
}, null),
|
|
657
|
-
class: `${
|
|
658
|
-
}, [(
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
760
|
+
}, [createVNode(Icon, {
|
|
761
|
+
"name": "code"
|
|
762
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
763
|
+
"class": `${prefix}-toolbar-item-name`
|
|
764
|
+
}, [(_D = ult.value.toolbarTips) == null ? void 0 : _D.code])]);
|
|
765
|
+
}
|
|
766
|
+
case "link": {
|
|
767
|
+
return createVNode("div", {
|
|
768
|
+
"class": `${prefix}-toolbar-item`,
|
|
769
|
+
"title": (_E = ult.value.toolbarTips) == null ? void 0 : _E.link,
|
|
770
|
+
"onClick": () => {
|
|
771
|
+
modalData.type = "link";
|
|
772
|
+
modalData.linkVisible = true;
|
|
665
773
|
}
|
|
666
|
-
}, [
|
|
667
|
-
name: "link"
|
|
668
|
-
}, null),
|
|
669
|
-
class: `${
|
|
670
|
-
}, [(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
774
|
+
}, [createVNode(Icon, {
|
|
775
|
+
"name": "link"
|
|
776
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
777
|
+
"class": `${prefix}-toolbar-item-name`
|
|
778
|
+
}, [(_F = ult.value.toolbarTips) == null ? void 0 : _F.link])]);
|
|
779
|
+
}
|
|
780
|
+
case "image": {
|
|
781
|
+
return props2.noUploadImg ? createVNode("div", {
|
|
782
|
+
"class": `${prefix}-toolbar-item`,
|
|
783
|
+
"title": (_G = ult.value.toolbarTips) == null ? void 0 : _G.image,
|
|
784
|
+
"onClick": () => {
|
|
785
|
+
modalData.type = "image";
|
|
786
|
+
modalData.linkVisible = true;
|
|
677
787
|
}
|
|
678
|
-
}, [
|
|
679
|
-
name: "image"
|
|
680
|
-
}, null),
|
|
681
|
-
class: `${
|
|
682
|
-
}, [(
|
|
683
|
-
relative: `#${
|
|
684
|
-
visible:
|
|
685
|
-
onChange: (
|
|
686
|
-
|
|
788
|
+
}, [createVNode(Icon, {
|
|
789
|
+
"name": "image"
|
|
790
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
791
|
+
"class": `${prefix}-toolbar-item-name`
|
|
792
|
+
}, [(_H = ult.value.toolbarTips) == null ? void 0 : _H.image])]) : createVNode(Dropdown, {
|
|
793
|
+
"relative": `#${wrapperId}`,
|
|
794
|
+
"visible": visible.image,
|
|
795
|
+
"onChange": (v) => {
|
|
796
|
+
visible.image = v;
|
|
687
797
|
},
|
|
688
|
-
overlay:
|
|
689
|
-
class: `${
|
|
690
|
-
onClick: () => {
|
|
691
|
-
|
|
798
|
+
"overlay": createVNode("ul", {
|
|
799
|
+
"class": `${prefix}-menu`,
|
|
800
|
+
"onClick": () => {
|
|
801
|
+
visible.title = false;
|
|
692
802
|
}
|
|
693
|
-
}, [
|
|
694
|
-
class: `${
|
|
695
|
-
onClick: () => {
|
|
696
|
-
|
|
803
|
+
}, [createVNode("li", {
|
|
804
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-image`,
|
|
805
|
+
"onClick": () => {
|
|
806
|
+
modalData.type = "image";
|
|
807
|
+
modalData.linkVisible = true;
|
|
697
808
|
}
|
|
698
|
-
}, [(
|
|
699
|
-
class: `${
|
|
700
|
-
onClick: () => {
|
|
701
|
-
|
|
809
|
+
}, [(_I = ult.value.imgTitleItem) == null ? void 0 : _I.link]), createVNode("li", {
|
|
810
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-image`,
|
|
811
|
+
"onClick": () => {
|
|
812
|
+
uploadRef.value.click();
|
|
702
813
|
}
|
|
703
|
-
}, [(
|
|
704
|
-
class: `${
|
|
705
|
-
onClick: () => {
|
|
706
|
-
|
|
814
|
+
}, [(_J = ult.value.imgTitleItem) == null ? void 0 : _J.upload]), createVNode("li", {
|
|
815
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-image`,
|
|
816
|
+
"onClick": () => {
|
|
817
|
+
modalData.clipVisible = true;
|
|
707
818
|
}
|
|
708
|
-
}, [(
|
|
819
|
+
}, [(_K = ult.value.imgTitleItem) == null ? void 0 : _K.clip2upload])])
|
|
709
820
|
}, {
|
|
710
821
|
default: () => {
|
|
711
|
-
var
|
|
712
|
-
return [
|
|
713
|
-
class: `${
|
|
714
|
-
title: (
|
|
715
|
-
}, [
|
|
716
|
-
name: "image"
|
|
717
|
-
}, null),
|
|
718
|
-
class: `${
|
|
719
|
-
}, [(
|
|
822
|
+
var _a2, _b2;
|
|
823
|
+
return [createVNode("div", {
|
|
824
|
+
"class": `${prefix}-toolbar-item`,
|
|
825
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.image
|
|
826
|
+
}, [createVNode(Icon, {
|
|
827
|
+
"name": "image"
|
|
828
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
829
|
+
"class": `${prefix}-toolbar-item-name`
|
|
830
|
+
}, [(_b2 = ult.value.toolbarTips) == null ? void 0 : _b2.image])])];
|
|
720
831
|
}
|
|
721
832
|
});
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
833
|
+
}
|
|
834
|
+
case "table": {
|
|
835
|
+
return createVNode(Dropdown, {
|
|
836
|
+
"relative": `#${wrapperId}`,
|
|
837
|
+
"visible": visible.table,
|
|
838
|
+
"onChange": (v) => {
|
|
839
|
+
visible.table = v;
|
|
728
840
|
},
|
|
729
|
-
key: "bar-table",
|
|
730
|
-
overlay:
|
|
731
|
-
tableShape:
|
|
732
|
-
onSelected: (
|
|
733
|
-
|
|
734
|
-
selectedShape
|
|
841
|
+
"key": "bar-table",
|
|
842
|
+
"overlay": createVNode(TableShape$1, {
|
|
843
|
+
"tableShape": props2.tableShape,
|
|
844
|
+
"onSelected": (selectedShape) => {
|
|
845
|
+
emitHandler("table", {
|
|
846
|
+
selectedShape
|
|
735
847
|
});
|
|
736
848
|
}
|
|
737
849
|
}, null)
|
|
738
850
|
}, {
|
|
739
851
|
default: () => {
|
|
740
|
-
var
|
|
741
|
-
return [
|
|
742
|
-
class: `${
|
|
743
|
-
title: (
|
|
744
|
-
}, [
|
|
745
|
-
name: "table"
|
|
746
|
-
}, null),
|
|
747
|
-
class: `${
|
|
748
|
-
}, [(
|
|
852
|
+
var _a2, _b2;
|
|
853
|
+
return [createVNode("div", {
|
|
854
|
+
"class": `${prefix}-toolbar-item`,
|
|
855
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.table
|
|
856
|
+
}, [createVNode(Icon, {
|
|
857
|
+
"name": "table"
|
|
858
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
859
|
+
"class": `${prefix}-toolbar-item-name`
|
|
860
|
+
}, [(_b2 = ult.value.toolbarTips) == null ? void 0 : _b2.table])])];
|
|
749
861
|
}
|
|
750
862
|
});
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
863
|
+
}
|
|
864
|
+
case "revoke": {
|
|
865
|
+
return createVNode("div", {
|
|
866
|
+
"class": `${prefix}-toolbar-item`,
|
|
867
|
+
"title": (_L = ult.value.toolbarTips) == null ? void 0 : _L.revoke,
|
|
868
|
+
"onClick": () => {
|
|
869
|
+
bus.emit(editorId, CTRL_Z);
|
|
757
870
|
}
|
|
758
|
-
}, [
|
|
759
|
-
name: "revoke"
|
|
760
|
-
}, null),
|
|
761
|
-
class: `${
|
|
762
|
-
}, [(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
871
|
+
}, [createVNode(Icon, {
|
|
872
|
+
"name": "revoke"
|
|
873
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
874
|
+
"class": `${prefix}-toolbar-item-name`
|
|
875
|
+
}, [(_M = ult.value.toolbarTips) == null ? void 0 : _M.revoke])]);
|
|
876
|
+
}
|
|
877
|
+
case "next": {
|
|
878
|
+
return createVNode("div", {
|
|
879
|
+
"class": `${prefix}-toolbar-item`,
|
|
880
|
+
"title": (_N = ult.value.toolbarTips) == null ? void 0 : _N.next,
|
|
881
|
+
"onClick": () => {
|
|
882
|
+
bus.emit(editorId, CTRL_SHIFT_Z);
|
|
769
883
|
}
|
|
770
|
-
}, [
|
|
771
|
-
name: "next"
|
|
772
|
-
}, null),
|
|
773
|
-
class: `${
|
|
774
|
-
}, [(
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
884
|
+
}, [createVNode(Icon, {
|
|
885
|
+
"name": "next"
|
|
886
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
887
|
+
"class": `${prefix}-toolbar-item-name`
|
|
888
|
+
}, [(_O = ult.value.toolbarTips) == null ? void 0 : _O.next])]);
|
|
889
|
+
}
|
|
890
|
+
case "save": {
|
|
891
|
+
return createVNode("div", {
|
|
892
|
+
"class": `${prefix}-toolbar-item`,
|
|
893
|
+
"title": (_P = ult.value.toolbarTips) == null ? void 0 : _P.save,
|
|
894
|
+
"onClick": () => {
|
|
895
|
+
bus.emit(editorId, ON_SAVE);
|
|
781
896
|
}
|
|
782
|
-
}, [
|
|
783
|
-
name: "baocun"
|
|
784
|
-
}, null),
|
|
785
|
-
class: `${
|
|
786
|
-
}, [(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
897
|
+
}, [createVNode(Icon, {
|
|
898
|
+
"name": "baocun"
|
|
899
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
900
|
+
"class": `${prefix}-toolbar-item-name`
|
|
901
|
+
}, [(_Q = ult.value.toolbarTips) == null ? void 0 : _Q.save])]);
|
|
902
|
+
}
|
|
903
|
+
case "prettier": {
|
|
904
|
+
return !props2.noPrettier ? createVNode("div", {
|
|
905
|
+
"class": `${prefix}-toolbar-item`,
|
|
906
|
+
"title": (_R = ult.value.toolbarTips) == null ? void 0 : _R.prettier,
|
|
907
|
+
"onClick": () => {
|
|
908
|
+
emitHandler("prettier");
|
|
793
909
|
}
|
|
794
|
-
}, [
|
|
795
|
-
name: "prettier"
|
|
796
|
-
}, null),
|
|
797
|
-
class: `${
|
|
798
|
-
}, [(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
910
|
+
}, [createVNode(Icon, {
|
|
911
|
+
"name": "prettier"
|
|
912
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
913
|
+
"class": `${prefix}-toolbar-item-name`
|
|
914
|
+
}, [(_S = ult.value.toolbarTips) == null ? void 0 : _S.prettier])]) : "";
|
|
915
|
+
}
|
|
916
|
+
case "pageFullscreen": {
|
|
917
|
+
return !props2.setting.fullscreen && createVNode("div", {
|
|
918
|
+
"class": `${prefix}-toolbar-item`,
|
|
919
|
+
"title": (_T = ult.value.toolbarTips) == null ? void 0 : _T.pageFullscreen,
|
|
920
|
+
"onClick": () => {
|
|
921
|
+
props2.updateSetting("pageFullscreen");
|
|
805
922
|
}
|
|
806
|
-
}, [
|
|
807
|
-
name:
|
|
808
|
-
}, null),
|
|
809
|
-
class: `${
|
|
810
|
-
}, [(
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
923
|
+
}, [createVNode(Icon, {
|
|
924
|
+
"name": props2.setting.pageFullscreen ? "suoxiao" : "fangda"
|
|
925
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
926
|
+
"class": `${prefix}-toolbar-item-name`
|
|
927
|
+
}, [(_U = ult.value.toolbarTips) == null ? void 0 : _U.pageFullscreen])]);
|
|
928
|
+
}
|
|
929
|
+
case "fullscreen": {
|
|
930
|
+
return createVNode("div", {
|
|
931
|
+
"class": `${prefix}-toolbar-item`,
|
|
932
|
+
"title": (_V = ult.value.toolbarTips) == null ? void 0 : _V.fullscreen,
|
|
933
|
+
"onClick": () => {
|
|
934
|
+
fullscreenHandler();
|
|
817
935
|
}
|
|
818
|
-
}, [
|
|
819
|
-
name:
|
|
820
|
-
}, null),
|
|
821
|
-
class: `${
|
|
822
|
-
}, [(
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
936
|
+
}, [createVNode(Icon, {
|
|
937
|
+
"name": props2.setting.fullscreen ? "fullscreen-exit" : "fullscreen"
|
|
938
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
939
|
+
"class": `${prefix}-toolbar-item-name`
|
|
940
|
+
}, [(_W = ult.value.toolbarTips) == null ? void 0 : _W.fullscreen])]);
|
|
941
|
+
}
|
|
942
|
+
case "preview": {
|
|
943
|
+
return createVNode("div", {
|
|
944
|
+
"class": `${prefix}-toolbar-item`,
|
|
945
|
+
"title": (_X = ult.value.toolbarTips) == null ? void 0 : _X.preview,
|
|
946
|
+
"onClick": () => {
|
|
947
|
+
props2.updateSetting("preview");
|
|
829
948
|
}
|
|
830
|
-
}, [
|
|
831
|
-
name: "preview"
|
|
832
|
-
}, null),
|
|
833
|
-
class: `${
|
|
834
|
-
}, [(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
949
|
+
}, [createVNode(Icon, {
|
|
950
|
+
"name": "preview"
|
|
951
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
952
|
+
"class": `${prefix}-toolbar-item-name`
|
|
953
|
+
}, [(_Y = ult.value.toolbarTips) == null ? void 0 : _Y.preview])]);
|
|
954
|
+
}
|
|
955
|
+
case "htmlPreview": {
|
|
956
|
+
return createVNode("div", {
|
|
957
|
+
"class": `${prefix}-toolbar-item`,
|
|
958
|
+
"title": (_Z = ult.value.toolbarTips) == null ? void 0 : _Z.htmlPreview,
|
|
959
|
+
"onClick": () => {
|
|
960
|
+
props2.updateSetting("htmlPreview");
|
|
841
961
|
}
|
|
842
|
-
}, [
|
|
843
|
-
name: "coding"
|
|
844
|
-
}, null),
|
|
845
|
-
class: `${
|
|
846
|
-
}, [(
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
962
|
+
}, [createVNode(Icon, {
|
|
963
|
+
"name": "coding"
|
|
964
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
965
|
+
"class": `${prefix}-toolbar-item-name`
|
|
966
|
+
}, [(__ = ult.value.toolbarTips) == null ? void 0 : __.htmlPreview])]);
|
|
967
|
+
}
|
|
968
|
+
case "catalog": {
|
|
969
|
+
return createVNode("div", {
|
|
970
|
+
"class": `${prefix}-toolbar-item`,
|
|
971
|
+
"title": (_$ = ult.value.toolbarTips) == null ? void 0 : _$.catalog,
|
|
972
|
+
"onClick": () => {
|
|
973
|
+
bus.emit(editorId, CHANGE_CATALOG_VISIBLE);
|
|
853
974
|
},
|
|
854
|
-
key: "bar-catalog"
|
|
855
|
-
}, [
|
|
856
|
-
name: "catalog"
|
|
857
|
-
}, null),
|
|
858
|
-
class: `${
|
|
859
|
-
}, [(
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
975
|
+
"key": "bar-catalog"
|
|
976
|
+
}, [createVNode(Icon, {
|
|
977
|
+
"name": "catalog"
|
|
978
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
979
|
+
"class": `${prefix}-toolbar-item-name`
|
|
980
|
+
}, [(_aa = ult.value.toolbarTips) == null ? void 0 : _aa.catalog])]);
|
|
981
|
+
}
|
|
982
|
+
case "github": {
|
|
983
|
+
return createVNode("div", {
|
|
984
|
+
"class": `${prefix}-toolbar-item`,
|
|
985
|
+
"title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.github,
|
|
986
|
+
"onClick": () => linkTo("https://github.com/imzbf/md-editor-v3")
|
|
987
|
+
}, [createVNode(Icon, {
|
|
988
|
+
"name": "github"
|
|
989
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
990
|
+
"class": `${prefix}-toolbar-item-name`
|
|
991
|
+
}, [(_ca = ult.value.toolbarTips) == null ? void 0 : _ca.github])]);
|
|
992
|
+
}
|
|
993
|
+
case "mermaid": {
|
|
994
|
+
return createVNode(Dropdown, {
|
|
995
|
+
"relative": `#${wrapperId}`,
|
|
996
|
+
"visible": visible.mermaid,
|
|
997
|
+
"onChange": (v) => {
|
|
998
|
+
visible.mermaid = v;
|
|
876
999
|
},
|
|
877
|
-
overlay:
|
|
878
|
-
class: `${
|
|
879
|
-
onClick: () => {
|
|
880
|
-
|
|
1000
|
+
"overlay": createVNode("ul", {
|
|
1001
|
+
"class": `${prefix}-menu`,
|
|
1002
|
+
"onClick": () => {
|
|
1003
|
+
visible.mermaid = false;
|
|
881
1004
|
}
|
|
882
|
-
}, [
|
|
883
|
-
class: `${
|
|
884
|
-
onClick: () => {
|
|
885
|
-
|
|
1005
|
+
}, [createVNode("li", {
|
|
1006
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1007
|
+
"onClick": () => {
|
|
1008
|
+
emitHandler("flow");
|
|
886
1009
|
}
|
|
887
|
-
}, [(
|
|
888
|
-
class: `${
|
|
889
|
-
onClick: () => {
|
|
890
|
-
|
|
1010
|
+
}, [(_da = ult.value.mermaid) == null ? void 0 : _da.flow]), createVNode("li", {
|
|
1011
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1012
|
+
"onClick": () => {
|
|
1013
|
+
emitHandler("sequence");
|
|
891
1014
|
}
|
|
892
|
-
}, [(
|
|
893
|
-
class: `${
|
|
894
|
-
onClick: () => {
|
|
895
|
-
|
|
1015
|
+
}, [(_ea = ult.value.mermaid) == null ? void 0 : _ea.sequence]), createVNode("li", {
|
|
1016
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1017
|
+
"onClick": () => {
|
|
1018
|
+
emitHandler("gantt");
|
|
896
1019
|
}
|
|
897
|
-
}, [(
|
|
898
|
-
class: `${
|
|
899
|
-
onClick: () => {
|
|
900
|
-
|
|
1020
|
+
}, [(_fa = ult.value.mermaid) == null ? void 0 : _fa.gantt]), createVNode("li", {
|
|
1021
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1022
|
+
"onClick": () => {
|
|
1023
|
+
emitHandler("class");
|
|
901
1024
|
}
|
|
902
|
-
}, [(
|
|
903
|
-
class: `${
|
|
904
|
-
onClick: () => {
|
|
905
|
-
|
|
1025
|
+
}, [(_ga = ult.value.mermaid) == null ? void 0 : _ga.class]), createVNode("li", {
|
|
1026
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1027
|
+
"onClick": () => {
|
|
1028
|
+
emitHandler("state");
|
|
906
1029
|
}
|
|
907
|
-
}, [(
|
|
908
|
-
class: `${
|
|
909
|
-
onClick: () => {
|
|
910
|
-
|
|
1030
|
+
}, [(_ha = ult.value.mermaid) == null ? void 0 : _ha.state]), createVNode("li", {
|
|
1031
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1032
|
+
"onClick": () => {
|
|
1033
|
+
emitHandler("pie");
|
|
911
1034
|
}
|
|
912
|
-
}, [(
|
|
913
|
-
class: `${
|
|
914
|
-
onClick: () => {
|
|
915
|
-
|
|
1035
|
+
}, [(_ia = ult.value.mermaid) == null ? void 0 : _ia.pie]), createVNode("li", {
|
|
1036
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1037
|
+
"onClick": () => {
|
|
1038
|
+
emitHandler("relationship");
|
|
916
1039
|
}
|
|
917
|
-
}, [(
|
|
918
|
-
class: `${
|
|
919
|
-
onClick: () => {
|
|
920
|
-
|
|
1040
|
+
}, [(_ja = ult.value.mermaid) == null ? void 0 : _ja.relationship]), createVNode("li", {
|
|
1041
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1042
|
+
"onClick": () => {
|
|
1043
|
+
emitHandler("journey");
|
|
921
1044
|
}
|
|
922
|
-
}, [(
|
|
923
|
-
key: "bar-mermaid"
|
|
1045
|
+
}, [(_ka = ult.value.mermaid) == null ? void 0 : _ka.journey])]),
|
|
1046
|
+
"key": "bar-mermaid"
|
|
924
1047
|
}, {
|
|
925
1048
|
default: () => {
|
|
926
|
-
var
|
|
927
|
-
return [
|
|
928
|
-
class: `${
|
|
929
|
-
title: (
|
|
930
|
-
}, [
|
|
931
|
-
name: "mermaid"
|
|
932
|
-
}, null),
|
|
933
|
-
class: `${
|
|
934
|
-
}, [(
|
|
1049
|
+
var _a2, _b2;
|
|
1050
|
+
return [createVNode("div", {
|
|
1051
|
+
"class": `${prefix}-toolbar-item`,
|
|
1052
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.mermaid
|
|
1053
|
+
}, [createVNode(Icon, {
|
|
1054
|
+
"name": "mermaid"
|
|
1055
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
1056
|
+
"class": `${prefix}-toolbar-item-name`
|
|
1057
|
+
}, [(_b2 = ult.value.toolbarTips) == null ? void 0 : _b2.mermaid])])];
|
|
935
1058
|
}
|
|
936
1059
|
});
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1060
|
+
}
|
|
1061
|
+
case "katex": {
|
|
1062
|
+
return createVNode(Dropdown, {
|
|
1063
|
+
"relative": `#${wrapperId}`,
|
|
1064
|
+
"visible": visible.katex,
|
|
1065
|
+
"onChange": (v) => {
|
|
1066
|
+
visible.katex = v;
|
|
943
1067
|
},
|
|
944
|
-
overlay:
|
|
945
|
-
class: `${
|
|
946
|
-
onClick: () => {
|
|
947
|
-
|
|
1068
|
+
"overlay": createVNode("ul", {
|
|
1069
|
+
"class": `${prefix}-menu`,
|
|
1070
|
+
"onClick": () => {
|
|
1071
|
+
visible.katex = false;
|
|
948
1072
|
}
|
|
949
|
-
}, [
|
|
950
|
-
class: `${
|
|
951
|
-
onClick: () => {
|
|
952
|
-
|
|
1073
|
+
}, [createVNode("li", {
|
|
1074
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-katex`,
|
|
1075
|
+
"onClick": () => {
|
|
1076
|
+
emitHandler("katexInline");
|
|
953
1077
|
}
|
|
954
|
-
}, [(
|
|
955
|
-
class: `${
|
|
956
|
-
onClick: () => {
|
|
957
|
-
|
|
1078
|
+
}, [(_la = ult.value.katex) == null ? void 0 : _la.inline]), createVNode("li", {
|
|
1079
|
+
"class": `${prefix}-menu-item ${prefix}-menu-item-katex`,
|
|
1080
|
+
"onClick": () => {
|
|
1081
|
+
emitHandler("katexBlock");
|
|
958
1082
|
}
|
|
959
|
-
}, [(
|
|
960
|
-
key: "bar-katex"
|
|
1083
|
+
}, [(_ma = ult.value.katex) == null ? void 0 : _ma.block])]),
|
|
1084
|
+
"key": "bar-katex"
|
|
961
1085
|
}, {
|
|
962
1086
|
default: () => {
|
|
963
|
-
var
|
|
964
|
-
return [
|
|
965
|
-
class: `${
|
|
966
|
-
title: (
|
|
967
|
-
}, [
|
|
968
|
-
name: "formula"
|
|
969
|
-
}, null),
|
|
970
|
-
class: `${
|
|
971
|
-
}, [(
|
|
1087
|
+
var _a2, _b2;
|
|
1088
|
+
return [createVNode("div", {
|
|
1089
|
+
"class": `${prefix}-toolbar-item`,
|
|
1090
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.katex
|
|
1091
|
+
}, [createVNode(Icon, {
|
|
1092
|
+
"name": "formula"
|
|
1093
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
1094
|
+
"class": `${prefix}-toolbar-item-name`
|
|
1095
|
+
}, [(_b2 = ult.value.toolbarTips) == null ? void 0 : _b2.katex])])];
|
|
972
1096
|
}
|
|
973
1097
|
});
|
|
974
|
-
}
|
|
975
|
-
else if (e.defToolbars instanceof Array) {
|
|
976
|
-
const y = e.defToolbars[u];
|
|
977
|
-
return y ? gt(y, {
|
|
978
|
-
theme: n.value,
|
|
979
|
-
language: r.value,
|
|
980
|
-
insert(ge) {
|
|
981
|
-
v.emit(o, A, "universal", {
|
|
982
|
-
generate: ge
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
}) : "";
|
|
986
|
-
} else if (e.defToolbars && e.defToolbars.children instanceof Array) {
|
|
987
|
-
const y = e.defToolbars.children[u];
|
|
988
|
-
return y ? gt(y, {
|
|
989
|
-
theme: n.value,
|
|
990
|
-
language: r.value,
|
|
991
|
-
insert(ge) {
|
|
992
|
-
v.emit(o, A, "universal", {
|
|
993
|
-
generate: ge
|
|
994
|
-
});
|
|
995
1098
|
}
|
|
996
|
-
}
|
|
997
|
-
} else
|
|
1099
|
+
}
|
|
1100
|
+
} else if (props2.defToolbars instanceof Array) {
|
|
1101
|
+
const defItem = props2.defToolbars[barItem];
|
|
1102
|
+
if (defItem) {
|
|
1103
|
+
const defItemCloned = cloneVNode(defItem, {
|
|
1104
|
+
theme: theme.value,
|
|
1105
|
+
language: language.value,
|
|
1106
|
+
insert(generate) {
|
|
1107
|
+
bus.emit(editorId, REPLACE, "universal", {
|
|
1108
|
+
generate
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
return defItemCloned;
|
|
1113
|
+
}
|
|
1114
|
+
return "";
|
|
1115
|
+
} else if (props2.defToolbars && props2.defToolbars.children instanceof Array) {
|
|
1116
|
+
const defItem = props2.defToolbars.children[barItem];
|
|
1117
|
+
if (defItem) {
|
|
1118
|
+
const defItemCloned = cloneVNode(defItem, {
|
|
1119
|
+
theme: theme.value,
|
|
1120
|
+
language: language.value,
|
|
1121
|
+
insert(generate) {
|
|
1122
|
+
bus.emit(editorId, REPLACE, "universal", {
|
|
1123
|
+
generate
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
return defItemCloned;
|
|
1128
|
+
}
|
|
998
1129
|
return "";
|
|
1130
|
+
} else {
|
|
1131
|
+
return "";
|
|
1132
|
+
}
|
|
999
1133
|
};
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1134
|
+
watch(() => props2.toolbars, () => {
|
|
1135
|
+
nextTick(() => {
|
|
1136
|
+
if (wrapperRef.value) {
|
|
1137
|
+
draggingScroll(wrapperRef.value);
|
|
1138
|
+
}
|
|
1003
1139
|
});
|
|
1004
1140
|
}, {
|
|
1005
|
-
immediate:
|
|
1006
|
-
})
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}, [
|
|
1015
|
-
class: `${
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
}, [
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1141
|
+
immediate: true
|
|
1142
|
+
});
|
|
1143
|
+
return () => {
|
|
1144
|
+
const LeftBar = splitedbar.value[0].map((barItem) => barRender(barItem));
|
|
1145
|
+
const RightBar = splitedbar.value[1].map((barItem) => barRender(barItem));
|
|
1146
|
+
return createVNode(Fragment, null, [props2.toolbars.length > 0 && createVNode("div", {
|
|
1147
|
+
"class": `${prefix}-toolbar-wrapper`,
|
|
1148
|
+
"ref": wrapperRef,
|
|
1149
|
+
"id": wrapperId
|
|
1150
|
+
}, [createVNode("div", {
|
|
1151
|
+
"class": [`${prefix}-toolbar`, props2.showToolbarName && `${prefix}-stn`]
|
|
1152
|
+
}, [createVNode("div", {
|
|
1153
|
+
"class": `${prefix}-toolbar-left`,
|
|
1154
|
+
"ref": toolbarLeftRef
|
|
1155
|
+
}, [LeftBar]), createVNode("div", {
|
|
1156
|
+
"class": `${prefix}-toolbar-right`
|
|
1157
|
+
}, [RightBar])])]), createVNode("input", {
|
|
1158
|
+
"ref": uploadRef,
|
|
1159
|
+
"accept": "image/*",
|
|
1160
|
+
"type": "file",
|
|
1161
|
+
"multiple": true,
|
|
1162
|
+
"style": {
|
|
1025
1163
|
display: "none"
|
|
1026
1164
|
}
|
|
1027
|
-
}, null),
|
|
1028
|
-
linkVisible:
|
|
1029
|
-
clipVisible:
|
|
1030
|
-
type:
|
|
1031
|
-
onCancel: () => {
|
|
1032
|
-
|
|
1165
|
+
}, null), createVNode(Modals, {
|
|
1166
|
+
"linkVisible": modalData.linkVisible,
|
|
1167
|
+
"clipVisible": modalData.clipVisible,
|
|
1168
|
+
"type": modalData.type,
|
|
1169
|
+
"onCancel": () => {
|
|
1170
|
+
modalData.linkVisible = false;
|
|
1171
|
+
modalData.clipVisible = false;
|
|
1033
1172
|
},
|
|
1034
|
-
onOk: (
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1173
|
+
"onOk": (data) => {
|
|
1174
|
+
if (data) {
|
|
1175
|
+
emitHandler(modalData.type, {
|
|
1176
|
+
desc: data.desc,
|
|
1177
|
+
url: data.url
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
modalData.linkVisible = false;
|
|
1181
|
+
modalData.clipVisible = false;
|
|
1039
1182
|
}
|
|
1040
1183
|
}, null)]);
|
|
1041
1184
|
};
|
|
1042
1185
|
}
|
|
1043
|
-
})
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1186
|
+
});
|
|
1187
|
+
const DATA_LINE_SELECTOR = `.${prefix}-preview > [data-line]`;
|
|
1188
|
+
const scrollAutoWithScale = (pEle, cEle) => {
|
|
1189
|
+
const addEvent = debounce(() => {
|
|
1190
|
+
pEle.removeEventListener("scroll", scrollHandler);
|
|
1191
|
+
pEle.addEventListener("scroll", scrollHandler);
|
|
1192
|
+
cEle.removeEventListener("scroll", scrollHandler);
|
|
1193
|
+
cEle.addEventListener("scroll", scrollHandler);
|
|
1194
|
+
}, 50);
|
|
1195
|
+
const scrollHandler = (e) => {
|
|
1196
|
+
const pHeight = pEle.clientHeight;
|
|
1197
|
+
const cHeight = cEle.clientHeight;
|
|
1198
|
+
const pScrollHeight = pEle.scrollHeight;
|
|
1199
|
+
const cScrollHeight = cEle.scrollHeight;
|
|
1200
|
+
const scale = (pScrollHeight - pHeight) / (cScrollHeight - cHeight);
|
|
1201
|
+
if (e.target === pEle) {
|
|
1202
|
+
cEle.removeEventListener("scroll", scrollHandler);
|
|
1203
|
+
cEle.scrollTo({
|
|
1204
|
+
top: pEle.scrollTop / scale
|
|
1205
|
+
// behavior: 'smooth'
|
|
1206
|
+
});
|
|
1207
|
+
addEvent();
|
|
1208
|
+
} else {
|
|
1209
|
+
pEle.removeEventListener("scroll", scrollHandler);
|
|
1210
|
+
pEle.scrollTo({
|
|
1211
|
+
top: cEle.scrollTop * scale
|
|
1212
|
+
// behavior: 'smooth'
|
|
1213
|
+
});
|
|
1214
|
+
addEvent();
|
|
1215
|
+
}
|
|
1055
1216
|
};
|
|
1056
1217
|
return [
|
|
1057
1218
|
() => {
|
|
1058
|
-
|
|
1059
|
-
|
|
1219
|
+
addEvent().finally(() => {
|
|
1220
|
+
pEle.dispatchEvent(new Event("scroll"));
|
|
1060
1221
|
});
|
|
1061
1222
|
},
|
|
1062
1223
|
() => {
|
|
1063
|
-
|
|
1224
|
+
pEle.removeEventListener("scroll", scrollHandler);
|
|
1225
|
+
cEle.removeEventListener("scroll", scrollHandler);
|
|
1064
1226
|
}
|
|
1065
1227
|
];
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
|
|
1228
|
+
};
|
|
1229
|
+
const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
1230
|
+
const { view } = codeMirrorUt;
|
|
1231
|
+
const smoothScroll = createSmoothScroll();
|
|
1232
|
+
const getTopByLine = (line) => {
|
|
1233
|
+
return view.lineBlockAt(view.state.doc.line(line).from).top;
|
|
1234
|
+
};
|
|
1235
|
+
const getHeightByLine = (line) => {
|
|
1236
|
+
return view.lineBlockAt(view.state.doc.line(line).from).height;
|
|
1237
|
+
};
|
|
1238
|
+
let blockMap = [];
|
|
1239
|
+
let elesHasLineNumber = [];
|
|
1240
|
+
let startLines = [];
|
|
1241
|
+
const buildMap = () => {
|
|
1242
|
+
blockMap = [];
|
|
1243
|
+
elesHasLineNumber = [];
|
|
1244
|
+
startLines = [];
|
|
1245
|
+
elesHasLineNumber = elesHasLineNumber.concat(
|
|
1246
|
+
Array.from(cEle.querySelectorAll(DATA_LINE_SELECTOR))
|
|
1072
1247
|
);
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
const { lines
|
|
1076
|
-
let
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1248
|
+
const startLinesCalc = elesHasLineNumber.map((item) => Number(item.dataset.line) + 1);
|
|
1249
|
+
startLines = startLines.concat(startLinesCalc);
|
|
1250
|
+
const { lines } = view.state.doc;
|
|
1251
|
+
let start = 1;
|
|
1252
|
+
let end = startLinesCalc.shift() ?? lines;
|
|
1253
|
+
for (let i = 1; i <= lines; i++) {
|
|
1254
|
+
if (i === end) {
|
|
1255
|
+
start = i;
|
|
1256
|
+
end = startLinesCalc.shift() || lines + 1;
|
|
1257
|
+
}
|
|
1258
|
+
blockMap.push({
|
|
1259
|
+
start,
|
|
1260
|
+
end: end - 1
|
|
1081
1261
|
});
|
|
1262
|
+
}
|
|
1082
1263
|
};
|
|
1083
|
-
let
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1264
|
+
let pLock = 0;
|
|
1265
|
+
let cLock = 0;
|
|
1266
|
+
const pEleHandler = () => {
|
|
1267
|
+
var _a, _b;
|
|
1268
|
+
if (cLock !== 0) {
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
pLock++;
|
|
1272
|
+
const { scrollDOM, contentHeight } = view;
|
|
1273
|
+
let cElePaddingTop = +getComputedStyle(cEle).paddingTop.replace("px", "");
|
|
1274
|
+
const blockInfo = view.lineBlockAtHeight(scrollDOM.scrollTop);
|
|
1275
|
+
const { number: currLine } = view.state.doc.lineAt(blockInfo.from);
|
|
1276
|
+
const blockData = blockMap[currLine - 1];
|
|
1277
|
+
if (!blockData) {
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1280
|
+
let endLinePosition = getTopByLine(blockData.end) + getHeightByLine(blockData.end);
|
|
1281
|
+
let scale = 0;
|
|
1282
|
+
const startTop = getTopByLine(blockData.start);
|
|
1283
|
+
const startEle = cEle.querySelector(`[data-line="${blockData.start - 1}"]`) || ((_a = cEle.firstElementChild) == null ? void 0 : _a.firstElementChild);
|
|
1284
|
+
const endEle = cEle.querySelector(`[data-line="${blockData.end}"]`) || ((_b = cEle.lastElementChild) == null ? void 0 : _b.lastElementChild);
|
|
1285
|
+
let blockHeight = 0;
|
|
1286
|
+
let startEleOffetTop = 0;
|
|
1287
|
+
if (startTop === 0) {
|
|
1288
|
+
scale = scrollDOM.scrollTop / endLinePosition;
|
|
1289
|
+
if (startEle === endEle) {
|
|
1290
|
+
cElePaddingTop = 0;
|
|
1291
|
+
endLinePosition = contentHeight - scrollDOM.offsetHeight;
|
|
1292
|
+
blockHeight = endEle.offsetTop + endEle.offsetHeight - cEle.clientHeight;
|
|
1293
|
+
} else {
|
|
1294
|
+
blockHeight = endEle.offsetTop;
|
|
1295
|
+
}
|
|
1296
|
+
} else {
|
|
1297
|
+
scale = (scrollDOM.scrollTop - startTop) / (endLinePosition - startTop);
|
|
1298
|
+
startEleOffetTop = startEle.offsetTop;
|
|
1299
|
+
blockHeight = endEle.offsetTop - startEleOffetTop;
|
|
1300
|
+
}
|
|
1301
|
+
if (endLinePosition > scrollDOM.scrollHeight - scrollDOM.clientHeight) {
|
|
1302
|
+
scale = (scrollDOM.scrollTop - startTop) / (scrollDOM.scrollHeight - scrollDOM.clientHeight - startTop);
|
|
1303
|
+
startEleOffetTop = startEle.offsetTop;
|
|
1304
|
+
blockHeight = cEle.scrollHeight - cEle.clientHeight - startEleOffetTop + 10;
|
|
1305
|
+
}
|
|
1306
|
+
const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
|
|
1307
|
+
smoothScroll(cEle, scrollToTop, () => {
|
|
1308
|
+
pLock--;
|
|
1101
1309
|
});
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1310
|
+
};
|
|
1311
|
+
const cEleHandler = () => {
|
|
1312
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1313
|
+
if (pLock !== 0) {
|
|
1105
1314
|
return;
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1315
|
+
}
|
|
1316
|
+
cLock++;
|
|
1317
|
+
const { scrollDOM } = view;
|
|
1318
|
+
const cScrollTop = cEle.scrollTop;
|
|
1319
|
+
const cScrollHeight = cEle.scrollHeight;
|
|
1320
|
+
let realEleStart = (_a = cEle.firstElementChild) == null ? void 0 : _a.firstElementChild;
|
|
1321
|
+
let realEleEnd = (_b = cEle.firstElementChild) == null ? void 0 : _b.lastElementChild;
|
|
1322
|
+
if (startLines.length > 0) {
|
|
1323
|
+
let virtualLine = Math.ceil(
|
|
1324
|
+
Number(startLines[startLines.length - 1]) * (cScrollTop / cScrollHeight)
|
|
1325
|
+
);
|
|
1326
|
+
let startLineIndex = startLines.findLastIndex((value) => value <= virtualLine);
|
|
1327
|
+
startLineIndex = startLineIndex === -1 ? 0 : startLineIndex;
|
|
1328
|
+
virtualLine = startLines[startLineIndex];
|
|
1329
|
+
for (let i = startLineIndex; i >= 0 && i < startLines.length; ) {
|
|
1330
|
+
const currentElementTop = elesHasLineNumber[i].offsetTop;
|
|
1331
|
+
if (currentElementTop > cScrollTop) {
|
|
1332
|
+
if (i - 1 >= 0) {
|
|
1333
|
+
i--;
|
|
1118
1334
|
continue;
|
|
1119
1335
|
}
|
|
1120
|
-
|
|
1336
|
+
virtualLine = -1;
|
|
1337
|
+
startLineIndex = i;
|
|
1121
1338
|
break;
|
|
1122
1339
|
} else {
|
|
1123
|
-
if (
|
|
1124
|
-
|
|
1340
|
+
if (i + 1 <= startLines.length && elesHasLineNumber[i + 1].offsetTop < cScrollTop) {
|
|
1341
|
+
i++;
|
|
1125
1342
|
continue;
|
|
1126
1343
|
}
|
|
1127
|
-
|
|
1344
|
+
virtualLine = startLines[i];
|
|
1345
|
+
startLineIndex = i;
|
|
1128
1346
|
break;
|
|
1129
1347
|
}
|
|
1130
|
-
|
|
1348
|
+
}
|
|
1349
|
+
switch (virtualLine) {
|
|
1131
1350
|
case -1: {
|
|
1132
|
-
|
|
1351
|
+
realEleStart = (_c = cEle.firstElementChild) == null ? void 0 : _c.firstElementChild;
|
|
1352
|
+
realEleEnd = elesHasLineNumber[startLineIndex];
|
|
1133
1353
|
break;
|
|
1134
1354
|
}
|
|
1135
|
-
case
|
|
1136
|
-
|
|
1355
|
+
case startLines.length - 1: {
|
|
1356
|
+
realEleStart = elesHasLineNumber[startLineIndex];
|
|
1357
|
+
realEleEnd = (_d = cEle.firstElementChild) == null ? void 0 : _d.lastElementChild;
|
|
1137
1358
|
break;
|
|
1138
1359
|
}
|
|
1139
|
-
default:
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
let
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1360
|
+
default: {
|
|
1361
|
+
realEleStart = elesHasLineNumber[startLineIndex];
|
|
1362
|
+
realEleEnd = elesHasLineNumber[startLineIndex + 1];
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
const eleStartOffsetTop = realEleStart === ((_e = cEle.firstElementChild) == null ? void 0 : _e.firstElementChild) ? 0 : realEleStart.offsetTop;
|
|
1367
|
+
let eleEndOffsetTop = realEleEnd.offsetTop;
|
|
1368
|
+
let scale = 0;
|
|
1369
|
+
const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
|
|
1370
|
+
const firstLineScrollTop = getTopByLine(start);
|
|
1371
|
+
let endLineScrollTop = getTopByLine(end + 1);
|
|
1372
|
+
let blockHeight = 0;
|
|
1373
|
+
if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.scrollTop > cEle.scrollHeight - cEle.clientHeight) {
|
|
1374
|
+
scale = Math.max(
|
|
1375
|
+
(cScrollTop - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop - cEle.clientHeight),
|
|
1376
|
+
0
|
|
1377
|
+
);
|
|
1378
|
+
endLineScrollTop = getTopByLine(view.state.doc.lines) + getHeightByLine(view.state.doc.lines);
|
|
1379
|
+
blockHeight = 8 + endLineScrollTop - firstLineScrollTop - pEle.clientHeight;
|
|
1380
|
+
} else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
|
|
1381
|
+
if (realEleStart === realEleEnd) {
|
|
1382
|
+
eleEndOffsetTop = realEleEnd.offsetTop + realEleEnd.offsetHeight + +getComputedStyle(realEleEnd).marginBottom.replace("px", "");
|
|
1383
|
+
blockHeight = endLineScrollTop;
|
|
1384
|
+
} else {
|
|
1385
|
+
blockHeight = endLineScrollTop;
|
|
1386
|
+
}
|
|
1387
|
+
scale = Math.max(cScrollTop / eleEndOffsetTop, 0);
|
|
1388
|
+
} else {
|
|
1389
|
+
scale = Math.max(
|
|
1390
|
+
(cScrollTop - eleStartOffsetTop) / (eleEndOffsetTop - eleStartOffsetTop),
|
|
1391
|
+
0
|
|
1392
|
+
);
|
|
1393
|
+
blockHeight = endLineScrollTop - firstLineScrollTop;
|
|
1394
|
+
}
|
|
1395
|
+
smoothScroll(pEle, firstLineScrollTop + blockHeight * scale, () => {
|
|
1396
|
+
cLock--;
|
|
1155
1397
|
});
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1398
|
+
};
|
|
1399
|
+
const scrollHandler = throttle((e) => {
|
|
1400
|
+
var _a;
|
|
1401
|
+
const { scrollDOM, contentHeight } = view;
|
|
1402
|
+
const scrollDomHeight = scrollDOM.clientHeight;
|
|
1403
|
+
if (contentHeight <= scrollDomHeight || cEle.firstElementChild.clientHeight <= cEle.clientHeight) {
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
if (view.state.doc.lines < ((_a = blockMap[blockMap.length - 1]) == null ? void 0 : _a.end)) {
|
|
1407
|
+
return false;
|
|
1408
|
+
}
|
|
1409
|
+
if (e.target === pEle) {
|
|
1410
|
+
pEleHandler();
|
|
1411
|
+
} else {
|
|
1412
|
+
cEleHandler();
|
|
1413
|
+
}
|
|
1162
1414
|
}, 8);
|
|
1163
1415
|
return [
|
|
1164
1416
|
() => {
|
|
1165
|
-
|
|
1417
|
+
buildMap();
|
|
1418
|
+
pEle.addEventListener("scroll", scrollHandler);
|
|
1419
|
+
cEle.addEventListener("scroll", scrollHandler);
|
|
1420
|
+
pEle.dispatchEvent(new Event("scroll"));
|
|
1166
1421
|
},
|
|
1167
1422
|
() => {
|
|
1168
|
-
|
|
1423
|
+
pEle.removeEventListener("scroll", scrollHandler);
|
|
1424
|
+
cEle.removeEventListener("scroll", scrollHandler);
|
|
1169
1425
|
}
|
|
1170
1426
|
];
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1427
|
+
};
|
|
1428
|
+
const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
1429
|
+
const editorId = inject("editorId");
|
|
1430
|
+
let clearScrollAuto = () => {
|
|
1431
|
+
};
|
|
1432
|
+
let initScrollAuto = () => {
|
|
1175
1433
|
};
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
const
|
|
1179
|
-
`#${
|
|
1180
|
-
)
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
`[id="${n}-html-wrapper"]`
|
|
1434
|
+
const rebindEvent = () => {
|
|
1435
|
+
clearScrollAuto();
|
|
1436
|
+
const cmScroller = document.querySelector(
|
|
1437
|
+
`#${editorId} .cm-scroller`
|
|
1438
|
+
);
|
|
1439
|
+
const previewEle = document.querySelector(
|
|
1440
|
+
`[id="${editorId}-preview-wrapper"]`
|
|
1184
1441
|
);
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1442
|
+
const htmlEle = document.querySelector(
|
|
1443
|
+
`[id="${editorId}-html-wrapper"]`
|
|
1444
|
+
);
|
|
1445
|
+
if (previewEle || htmlEle) {
|
|
1446
|
+
const scrollHandler = previewEle ? scrollAuto : scrollAutoWithScale;
|
|
1447
|
+
const cEle = previewEle || htmlEle;
|
|
1448
|
+
[initScrollAuto, clearScrollAuto] = scrollHandler(
|
|
1449
|
+
cmScroller,
|
|
1450
|
+
cEle,
|
|
1451
|
+
codeMirrorUt.value
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
if (props2.scrollAuto) {
|
|
1455
|
+
initScrollAuto();
|
|
1456
|
+
}
|
|
1190
1457
|
};
|
|
1191
|
-
|
|
1458
|
+
watch(
|
|
1192
1459
|
[
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1460
|
+
html,
|
|
1461
|
+
toRef(props2.setting, "preview"),
|
|
1462
|
+
toRef(props2.setting, "htmlPreview"),
|
|
1463
|
+
toRef(props2.setting, "fullscreen"),
|
|
1464
|
+
toRef(props2.setting, "pageFullscreen")
|
|
1198
1465
|
],
|
|
1199
1466
|
() => {
|
|
1200
|
-
|
|
1201
|
-
}
|
|
1202
|
-
)
|
|
1203
|
-
|
|
1204
|
-
(
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1467
|
+
nextTick(rebindEvent);
|
|
1468
|
+
}
|
|
1469
|
+
);
|
|
1470
|
+
watch(
|
|
1471
|
+
() => props2.scrollAuto,
|
|
1472
|
+
(sa) => {
|
|
1473
|
+
if (sa) {
|
|
1474
|
+
initScrollAuto();
|
|
1475
|
+
} else {
|
|
1476
|
+
clearScrollAuto();
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
);
|
|
1480
|
+
onMounted(rebindEvent);
|
|
1481
|
+
};
|
|
1482
|
+
const directive2flag = (direct, codeMirrorUt, params) => {
|
|
1483
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1484
|
+
let targetValue = "";
|
|
1485
|
+
let deviationStart = 0;
|
|
1486
|
+
let deviationEnd = 0;
|
|
1487
|
+
let select = true;
|
|
1488
|
+
let replaceAll = false;
|
|
1489
|
+
const selectedText = codeMirrorUt.getSelectedText();
|
|
1490
|
+
const mermaidTemplate = (_a = configOption.editorConfig) == null ? void 0 : _a.mermaidTemplate;
|
|
1491
|
+
if (/^h[1-6]{1}$/.test(direct)) {
|
|
1492
|
+
const pix = direct.replace(/^h(\d)/, (_, num) => {
|
|
1493
|
+
return new Array(Number(num)).fill("#", 0, num).join("");
|
|
1494
|
+
});
|
|
1495
|
+
targetValue = `${pix} ${selectedText}`;
|
|
1496
|
+
deviationStart = pix.length + 1;
|
|
1497
|
+
} else if (direct === "prettier") {
|
|
1498
|
+
const prettier = window.prettier || ((_c = (_b = configOption.editorExtensions) == null ? void 0 : _b.prettier) == null ? void 0 : _c.prettierInstance);
|
|
1499
|
+
const prettierPlugins = [
|
|
1500
|
+
((_d = window.prettierPlugins) == null ? void 0 : _d.markdown) || ((_f = (_e = configOption.editorExtensions) == null ? void 0 : _e.prettier) == null ? void 0 : _f.parserMarkdownInstance)
|
|
1218
1501
|
];
|
|
1219
|
-
!
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1502
|
+
if (!prettier || prettierPlugins[0] === void 0) {
|
|
1503
|
+
bus.emit(params.editorId, ERROR_CATCHER, {
|
|
1504
|
+
name: "prettier",
|
|
1505
|
+
message: "prettier is undefined"
|
|
1506
|
+
});
|
|
1507
|
+
targetValue = codeMirrorUt.getValue();
|
|
1508
|
+
} else {
|
|
1509
|
+
targetValue = prettier.format(codeMirrorUt.getValue(), {
|
|
1510
|
+
parser: "markdown",
|
|
1511
|
+
plugins: prettierPlugins
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
select = false;
|
|
1515
|
+
replaceAll = true;
|
|
1516
|
+
} else {
|
|
1517
|
+
switch (direct) {
|
|
1228
1518
|
case "bold": {
|
|
1229
|
-
|
|
1519
|
+
targetValue = `**${selectedText}**`;
|
|
1520
|
+
deviationStart = 2;
|
|
1521
|
+
deviationEnd = -2;
|
|
1230
1522
|
break;
|
|
1231
1523
|
}
|
|
1232
1524
|
case "underline": {
|
|
1233
|
-
|
|
1525
|
+
targetValue = `<u>${selectedText}</u>`;
|
|
1526
|
+
deviationStart = 3;
|
|
1527
|
+
deviationEnd = -4;
|
|
1234
1528
|
break;
|
|
1235
1529
|
}
|
|
1236
1530
|
case "italic": {
|
|
1237
|
-
|
|
1531
|
+
targetValue = `*${selectedText}*`;
|
|
1532
|
+
deviationStart = 1;
|
|
1533
|
+
deviationEnd = -1;
|
|
1238
1534
|
break;
|
|
1239
1535
|
}
|
|
1240
1536
|
case "strikeThrough": {
|
|
1241
|
-
|
|
1537
|
+
targetValue = `~~${selectedText}~~`;
|
|
1538
|
+
deviationStart = 2;
|
|
1539
|
+
deviationEnd = -2;
|
|
1242
1540
|
break;
|
|
1243
1541
|
}
|
|
1244
1542
|
case "sub": {
|
|
1245
|
-
|
|
1543
|
+
targetValue = `<sub>${selectedText}</sub>`;
|
|
1544
|
+
deviationStart = 5;
|
|
1545
|
+
deviationEnd = -6;
|
|
1246
1546
|
break;
|
|
1247
1547
|
}
|
|
1248
1548
|
case "sup": {
|
|
1249
|
-
|
|
1549
|
+
targetValue = `<sup>${selectedText}</sup>`;
|
|
1550
|
+
deviationStart = 5;
|
|
1551
|
+
deviationEnd = -6;
|
|
1250
1552
|
break;
|
|
1251
1553
|
}
|
|
1252
1554
|
case "codeRow": {
|
|
1253
|
-
|
|
1555
|
+
targetValue = "`" + selectedText + "`";
|
|
1556
|
+
deviationStart = 1;
|
|
1557
|
+
deviationEnd = -1;
|
|
1254
1558
|
break;
|
|
1255
1559
|
}
|
|
1256
1560
|
case "quote": {
|
|
1257
|
-
|
|
1561
|
+
targetValue = `> ${selectedText}`;
|
|
1562
|
+
deviationStart = 2;
|
|
1258
1563
|
break;
|
|
1259
1564
|
}
|
|
1260
1565
|
case "orderedList": {
|
|
1261
|
-
|
|
1566
|
+
targetValue = `1. ${selectedText}`;
|
|
1567
|
+
deviationStart = 3;
|
|
1262
1568
|
break;
|
|
1263
1569
|
}
|
|
1264
1570
|
case "unorderedList": {
|
|
1265
|
-
|
|
1571
|
+
targetValue = `- ${selectedText}`;
|
|
1572
|
+
deviationStart = 2;
|
|
1266
1573
|
break;
|
|
1267
1574
|
}
|
|
1268
1575
|
case "task": {
|
|
1269
|
-
|
|
1576
|
+
targetValue = `- [ ] ${selectedText}`;
|
|
1577
|
+
deviationStart = 6;
|
|
1270
1578
|
break;
|
|
1271
1579
|
}
|
|
1272
1580
|
case "code": {
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1581
|
+
const text = params.text || selectedText || "";
|
|
1582
|
+
const mode = params.mode || "language";
|
|
1583
|
+
targetValue = `\`\`\`${mode}
|
|
1584
|
+
${text}
|
|
1276
1585
|
\`\`\`
|
|
1277
|
-
|
|
1586
|
+
`;
|
|
1587
|
+
deviationStart = 3;
|
|
1588
|
+
deviationEnd = 3 + mode.length - targetValue.length;
|
|
1278
1589
|
break;
|
|
1279
1590
|
}
|
|
1280
1591
|
case "table": {
|
|
1281
|
-
|
|
1282
|
-
const { selectedShape
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
n += `
|
|
1291
|
-
|`;
|
|
1292
|
-
for (let k = 0; k <= b; k++)
|
|
1293
|
-
n += " content |";
|
|
1592
|
+
targetValue = "|";
|
|
1593
|
+
const { selectedShape = { x: 1, y: 1 } } = params;
|
|
1594
|
+
const { x, y } = selectedShape;
|
|
1595
|
+
for (let i = 0; i <= y; i++) {
|
|
1596
|
+
targetValue += " col |";
|
|
1597
|
+
}
|
|
1598
|
+
targetValue += "\n|";
|
|
1599
|
+
for (let i = 0; i <= y; i++) {
|
|
1600
|
+
targetValue += " - |";
|
|
1294
1601
|
}
|
|
1295
|
-
|
|
1602
|
+
for (let row = 0; row <= x; row++) {
|
|
1603
|
+
targetValue += "\n|";
|
|
1604
|
+
for (let col = 0; col <= y; col++) {
|
|
1605
|
+
targetValue += " content |";
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
deviationStart = 2;
|
|
1609
|
+
deviationEnd = 5 - targetValue.length;
|
|
1296
1610
|
break;
|
|
1297
1611
|
}
|
|
1298
1612
|
case "link": {
|
|
1299
|
-
const { desc
|
|
1300
|
-
|
|
1613
|
+
const { desc, url } = params;
|
|
1614
|
+
targetValue = `[${desc}](${url})`;
|
|
1615
|
+
select = false;
|
|
1301
1616
|
break;
|
|
1302
1617
|
}
|
|
1303
1618
|
case "image": {
|
|
1304
|
-
const { desc
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1619
|
+
const { desc, url, urls } = params;
|
|
1620
|
+
if (urls instanceof Array) {
|
|
1621
|
+
targetValue = urls.reduce((pVal, _url) => {
|
|
1622
|
+
const {
|
|
1623
|
+
url: url2 = "",
|
|
1624
|
+
alt = "",
|
|
1625
|
+
title = ""
|
|
1626
|
+
} = typeof _url === "object" ? _url : { url: _url };
|
|
1627
|
+
return pVal + `
|
|
1628
|
+
`;
|
|
1629
|
+
}, "");
|
|
1630
|
+
} else {
|
|
1631
|
+
targetValue = `
|
|
1312
1632
|
`;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1633
|
+
}
|
|
1634
|
+
select = false;
|
|
1315
1635
|
break;
|
|
1316
1636
|
}
|
|
1317
1637
|
case "flow": {
|
|
1318
|
-
|
|
1319
|
-
${(
|
|
1320
|
-
Start --> Stop`}
|
|
1638
|
+
targetValue = `\`\`\`mermaid
|
|
1639
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.flow) || "flowchart TD \n Start --> Stop"}
|
|
1321
1640
|
\`\`\`
|
|
1322
|
-
|
|
1641
|
+
`;
|
|
1642
|
+
deviationStart = 3;
|
|
1643
|
+
deviationEnd = 10 - targetValue.length;
|
|
1323
1644
|
break;
|
|
1324
1645
|
}
|
|
1325
1646
|
case "sequence": {
|
|
1326
|
-
|
|
1327
|
-
${(
|
|
1328
|
-
A->>B: hello!
|
|
1329
|
-
B-->>A: hi!
|
|
1330
|
-
A-)B: bye!`}
|
|
1647
|
+
targetValue = `\`\`\`mermaid
|
|
1648
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.sequence) || "sequenceDiagram\n A->>B: hello!\n B-->>A: hi!\n A-)B: bye!"}
|
|
1331
1649
|
\`\`\`
|
|
1332
|
-
|
|
1650
|
+
`;
|
|
1651
|
+
deviationStart = 3;
|
|
1652
|
+
deviationEnd = 10 - targetValue.length;
|
|
1333
1653
|
break;
|
|
1334
1654
|
}
|
|
1335
1655
|
case "gantt": {
|
|
1336
|
-
|
|
1337
|
-
${(
|
|
1338
|
-
title A Gantt Diagram
|
|
1339
|
-
dateFormat YYYY-MM-DD
|
|
1340
|
-
section Section
|
|
1341
|
-
A task :a1, 2014-01-01, 30d
|
|
1342
|
-
Another task :after a1, 20d`}
|
|
1656
|
+
targetValue = `\`\`\`mermaid
|
|
1657
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.gantt) || "gantt\ntitle A Gantt Diagram\ndateFormat YYYY-MM-DD\nsection Section\nA task :a1, 2014-01-01, 30d\nAnother task :after a1, 20d"}
|
|
1343
1658
|
\`\`\`
|
|
1344
|
-
|
|
1659
|
+
`;
|
|
1660
|
+
deviationStart = 3;
|
|
1661
|
+
deviationEnd = 10 - targetValue.length;
|
|
1345
1662
|
break;
|
|
1346
1663
|
}
|
|
1347
1664
|
case "class": {
|
|
1348
|
-
|
|
1349
|
-
${(
|
|
1350
|
-
class Animal
|
|
1351
|
-
Vehicle <|-- Car`}
|
|
1665
|
+
targetValue = `\`\`\`mermaid
|
|
1666
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.class) || "classDiagram\n class Animal\n Vehicle <|-- Car"}
|
|
1352
1667
|
\`\`\`
|
|
1353
|
-
|
|
1668
|
+
`;
|
|
1669
|
+
deviationStart = 3;
|
|
1670
|
+
deviationEnd = 10 - targetValue.length;
|
|
1354
1671
|
break;
|
|
1355
1672
|
}
|
|
1356
1673
|
case "state": {
|
|
1357
|
-
|
|
1358
|
-
${(
|
|
1359
|
-
s1 --> s2`}
|
|
1674
|
+
targetValue = `\`\`\`mermaid
|
|
1675
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.state) || "stateDiagram-v2\n s1 --> s2"}
|
|
1360
1676
|
\`\`\`
|
|
1361
|
-
|
|
1677
|
+
`;
|
|
1678
|
+
deviationStart = 3;
|
|
1679
|
+
deviationEnd = 10 - targetValue.length;
|
|
1362
1680
|
break;
|
|
1363
1681
|
}
|
|
1364
1682
|
case "pie": {
|
|
1365
|
-
|
|
1366
|
-
${(
|
|
1367
|
-
"Dogs" : 386
|
|
1368
|
-
"Cats" : 85
|
|
1369
|
-
"Rats" : 15`}
|
|
1683
|
+
targetValue = `\`\`\`mermaid
|
|
1684
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.pie) || 'pie title Pets adopted by volunteers\n "Dogs" : 386\n "Cats" : 85\n "Rats" : 15'}
|
|
1370
1685
|
\`\`\`
|
|
1371
|
-
|
|
1686
|
+
`;
|
|
1687
|
+
deviationStart = 3;
|
|
1688
|
+
deviationEnd = 10 - targetValue.length;
|
|
1372
1689
|
break;
|
|
1373
1690
|
}
|
|
1374
1691
|
case "relationship": {
|
|
1375
|
-
|
|
1376
|
-
${(
|
|
1377
|
-
CAR ||--o{ NAMED-DRIVER : allows
|
|
1378
|
-
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
1692
|
+
targetValue = `\`\`\`mermaid
|
|
1693
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.relationship) || "erDiagram\n CAR ||--o{ NAMED-DRIVER : allows\n PERSON ||--o{ NAMED-DRIVER : is"}
|
|
1379
1694
|
\`\`\`
|
|
1380
|
-
|
|
1695
|
+
`;
|
|
1696
|
+
deviationStart = 3;
|
|
1697
|
+
deviationEnd = 10 - targetValue.length;
|
|
1381
1698
|
break;
|
|
1382
1699
|
}
|
|
1383
1700
|
case "journey": {
|
|
1384
|
-
|
|
1385
|
-
${(
|
|
1386
|
-
title My working day
|
|
1387
|
-
section Go to work
|
|
1388
|
-
Make tea: 5: Me
|
|
1389
|
-
Go upstairs: 3: Me
|
|
1390
|
-
Do work: 1: Me, Cat
|
|
1391
|
-
section Go home
|
|
1392
|
-
Go downstairs: 5: Me
|
|
1393
|
-
Sit down: 5: Me`}
|
|
1701
|
+
targetValue = `\`\`\`mermaid
|
|
1702
|
+
${(mermaidTemplate == null ? void 0 : mermaidTemplate.journey) || "journey\n title My working day\n section Go to work\n Make tea: 5: Me\n Go upstairs: 3: Me\n Do work: 1: Me, Cat\n section Go home\n Go downstairs: 5: Me\n Sit down: 5: Me"}
|
|
1394
1703
|
\`\`\`
|
|
1395
|
-
|
|
1704
|
+
`;
|
|
1705
|
+
deviationStart = 3;
|
|
1706
|
+
deviationEnd = 10 - targetValue.length;
|
|
1396
1707
|
break;
|
|
1397
1708
|
}
|
|
1398
1709
|
case "katexInline": {
|
|
1399
|
-
|
|
1710
|
+
targetValue = "$$";
|
|
1711
|
+
deviationStart = 1;
|
|
1712
|
+
deviationEnd = -1;
|
|
1400
1713
|
break;
|
|
1401
1714
|
}
|
|
1402
1715
|
case "katexBlock": {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
`, r = 3, i = -4;
|
|
1716
|
+
targetValue = "$$\n\n$$\n";
|
|
1717
|
+
deviationStart = 3;
|
|
1718
|
+
deviationEnd = -4;
|
|
1407
1719
|
break;
|
|
1408
1720
|
}
|
|
1409
1721
|
case "universal": {
|
|
1410
|
-
const { generate
|
|
1411
|
-
|
|
1722
|
+
const { generate } = params;
|
|
1723
|
+
const insertOptions = generate(selectedText);
|
|
1724
|
+
targetValue = insertOptions.targetValue;
|
|
1725
|
+
select = insertOptions.select ?? true;
|
|
1726
|
+
deviationStart = insertOptions.deviationStart || 0;
|
|
1727
|
+
deviationEnd = insertOptions.deviationEnd || 0;
|
|
1412
1728
|
}
|
|
1413
1729
|
}
|
|
1730
|
+
}
|
|
1414
1731
|
return {
|
|
1415
|
-
text:
|
|
1732
|
+
text: targetValue,
|
|
1416
1733
|
options: {
|
|
1417
1734
|
// 是否选中
|
|
1418
|
-
select
|
|
1735
|
+
select,
|
|
1419
1736
|
// 选中时,开始位置的偏移量
|
|
1420
|
-
deviationStart
|
|
1737
|
+
deviationStart,
|
|
1421
1738
|
// 结束的偏移量
|
|
1422
|
-
deviationEnd
|
|
1739
|
+
deviationEnd,
|
|
1423
1740
|
// 是否整个替换
|
|
1424
|
-
replaceAll
|
|
1741
|
+
replaceAll
|
|
1425
1742
|
}
|
|
1426
1743
|
};
|
|
1427
|
-
}
|
|
1744
|
+
};
|
|
1745
|
+
const chalky$1 = "#e5c07b", coral$1 = "var(--md-color)", cyan$1 = "#56b6c2", invalid$1 = "#ffffff", ivory$1 = "var(--md-color)", stone$1 = "#e5c07b", malibu$1 = "#e5c07b", sage$1 = "var(--md-color)", whiskey$1 = "#d19a66", violet$1 = "#c678dd", darkBackground$1 = "#21252b", highlightBackground$1 = "#2c313a", background$1 = "var(--md-bk-color)", tooltipBackground$1 = "var(--md-bk-color)", selection$1 = "#ceedfa33", cursor$1 = "#528bff";
|
|
1746
|
+
const oneDarkTheme = EditorView.theme(
|
|
1428
1747
|
{
|
|
1429
1748
|
"&": {
|
|
1430
|
-
color:
|
|
1431
|
-
backgroundColor:
|
|
1749
|
+
color: ivory$1,
|
|
1750
|
+
backgroundColor: background$1
|
|
1432
1751
|
},
|
|
1433
1752
|
".cm-content": {
|
|
1434
|
-
caretColor:
|
|
1753
|
+
caretColor: cursor$1
|
|
1435
1754
|
},
|
|
1436
|
-
".cm-cursor, .cm-dropCursor": { borderLeftColor:
|
|
1437
|
-
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor:
|
|
1438
|
-
".cm-panels": { backgroundColor:
|
|
1755
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor$1 },
|
|
1756
|
+
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection$1 },
|
|
1757
|
+
".cm-panels": { backgroundColor: darkBackground$1, color: ivory$1 },
|
|
1439
1758
|
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
1440
1759
|
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
1441
1760
|
".cm-searchMatch": {
|
|
@@ -1451,13 +1770,13 @@ $$
|
|
|
1451
1770
|
backgroundColor: "#bad0f847"
|
|
1452
1771
|
},
|
|
1453
1772
|
".cm-gutters": {
|
|
1454
|
-
backgroundColor:
|
|
1455
|
-
color:
|
|
1773
|
+
backgroundColor: background$1,
|
|
1774
|
+
color: ivory$1,
|
|
1456
1775
|
borderRight: "1px solid",
|
|
1457
1776
|
borderColor: "var(--md-border-color)"
|
|
1458
1777
|
},
|
|
1459
1778
|
".cm-activeLineGutter": {
|
|
1460
|
-
backgroundColor:
|
|
1779
|
+
backgroundColor: highlightBackground$1
|
|
1461
1780
|
},
|
|
1462
1781
|
".cm-foldPlaceholder": {
|
|
1463
1782
|
backgroundColor: "transparent",
|
|
@@ -1466,78 +1785,82 @@ $$
|
|
|
1466
1785
|
},
|
|
1467
1786
|
".cm-tooltip": {
|
|
1468
1787
|
border: "1px solid var(--md-border-color)",
|
|
1469
|
-
backgroundColor:
|
|
1788
|
+
backgroundColor: tooltipBackground$1
|
|
1470
1789
|
},
|
|
1471
1790
|
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
1472
1791
|
borderTopColor: "transparent",
|
|
1473
1792
|
borderBottomColor: "transparent"
|
|
1474
1793
|
},
|
|
1475
1794
|
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
1476
|
-
borderTopColor:
|
|
1477
|
-
borderBottomColor:
|
|
1795
|
+
borderTopColor: tooltipBackground$1,
|
|
1796
|
+
borderBottomColor: tooltipBackground$1
|
|
1478
1797
|
},
|
|
1479
1798
|
".cm-tooltip-autocomplete": {
|
|
1480
1799
|
"& > ul > li[aria-selected]": {
|
|
1481
|
-
color:
|
|
1800
|
+
color: ivory$1
|
|
1482
1801
|
}
|
|
1483
1802
|
}
|
|
1484
1803
|
},
|
|
1485
|
-
{ dark:
|
|
1486
|
-
)
|
|
1487
|
-
|
|
1488
|
-
{ tag:
|
|
1489
|
-
{ tag: [
|
|
1490
|
-
{ tag: [
|
|
1491
|
-
{ tag: [
|
|
1804
|
+
{ dark: true }
|
|
1805
|
+
);
|
|
1806
|
+
const oneDarkHighlightStyle = HighlightStyle.define([
|
|
1807
|
+
{ tag: tags.keyword, color: violet$1 },
|
|
1808
|
+
{ tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName], color: coral$1 },
|
|
1809
|
+
{ tag: [tags.function(tags.variableName), tags.labelName], color: malibu$1 },
|
|
1810
|
+
{ tag: [tags.color, tags.constant(tags.name), tags.standard(tags.name)], color: whiskey$1 },
|
|
1811
|
+
{ tag: [tags.definition(tags.name), tags.separator], color: ivory$1 },
|
|
1492
1812
|
{
|
|
1493
1813
|
tag: [
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1814
|
+
tags.typeName,
|
|
1815
|
+
tags.className,
|
|
1816
|
+
tags.number,
|
|
1817
|
+
tags.changed,
|
|
1818
|
+
tags.annotation,
|
|
1819
|
+
tags.modifier,
|
|
1820
|
+
tags.self,
|
|
1821
|
+
tags.namespace
|
|
1502
1822
|
],
|
|
1503
|
-
color:
|
|
1823
|
+
color: chalky$1
|
|
1504
1824
|
},
|
|
1505
1825
|
{
|
|
1506
1826
|
tag: [
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1827
|
+
tags.operator,
|
|
1828
|
+
tags.operatorKeyword,
|
|
1829
|
+
tags.url,
|
|
1830
|
+
tags.escape,
|
|
1831
|
+
tags.regexp,
|
|
1832
|
+
tags.link,
|
|
1833
|
+
tags.special(tags.string)
|
|
1514
1834
|
],
|
|
1515
|
-
color:
|
|
1835
|
+
color: cyan$1
|
|
1516
1836
|
},
|
|
1517
|
-
{ tag: [
|
|
1518
|
-
{ tag:
|
|
1519
|
-
{ tag:
|
|
1520
|
-
{ tag:
|
|
1521
|
-
{ tag:
|
|
1522
|
-
{ tag:
|
|
1523
|
-
{ tag: [
|
|
1524
|
-
{ tag: [
|
|
1525
|
-
{ tag:
|
|
1526
|
-
])
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1837
|
+
{ tag: [tags.meta, tags.comment], color: stone$1 },
|
|
1838
|
+
{ tag: tags.strong, fontWeight: "bold" },
|
|
1839
|
+
{ tag: tags.emphasis, fontStyle: "italic" },
|
|
1840
|
+
{ tag: tags.strikethrough, textDecoration: "line-through" },
|
|
1841
|
+
{ tag: tags.link, color: stone$1, textDecoration: "underline" },
|
|
1842
|
+
{ tag: tags.heading, fontWeight: "bold", color: coral$1 },
|
|
1843
|
+
{ tag: [tags.atom, tags.bool, tags.special(tags.variableName)], color: whiskey$1 },
|
|
1844
|
+
{ tag: [tags.processingInstruction, tags.string, tags.inserted], color: sage$1 },
|
|
1845
|
+
{ tag: tags.invalid, color: invalid$1 }
|
|
1846
|
+
]);
|
|
1847
|
+
const oneDark = [
|
|
1848
|
+
oneDarkTheme,
|
|
1849
|
+
syntaxHighlighting(oneDarkHighlightStyle)
|
|
1850
|
+
];
|
|
1851
|
+
const chalky = "#e5c07b", coral = "#3f4a54", cyan = "#56b6c2", invalid = "#fff", ivory = "#3f4a54", stone = "#2d8cf0", malibu = "#2d8cf0", sage = "#3f4a54", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#ceedfa33", background = "var(--md-bk-color)", tooltipBackground = "var(--md-bk-color)", selection = "#bad5fa", cursor = "#3f4a54";
|
|
1852
|
+
const oneLightTheme = EditorView.theme(
|
|
1530
1853
|
{
|
|
1531
1854
|
"&": {
|
|
1532
|
-
color:
|
|
1533
|
-
backgroundColor:
|
|
1855
|
+
color: ivory,
|
|
1856
|
+
backgroundColor: background
|
|
1534
1857
|
},
|
|
1535
1858
|
".cm-content": {
|
|
1536
|
-
caretColor:
|
|
1859
|
+
caretColor: cursor
|
|
1537
1860
|
},
|
|
1538
|
-
".cm-cursor, .cm-dropCursor": { borderLeftColor:
|
|
1539
|
-
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor:
|
|
1540
|
-
".cm-panels": { backgroundColor:
|
|
1861
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
|
|
1862
|
+
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
|
|
1863
|
+
".cm-panels": { backgroundColor: darkBackground, color: ivory },
|
|
1541
1864
|
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
1542
1865
|
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
1543
1866
|
".cm-searchMatch": {
|
|
@@ -1553,13 +1876,13 @@ $$
|
|
|
1553
1876
|
backgroundColor: "#bad0f847"
|
|
1554
1877
|
},
|
|
1555
1878
|
".cm-gutters": {
|
|
1556
|
-
backgroundColor:
|
|
1557
|
-
color:
|
|
1879
|
+
backgroundColor: background,
|
|
1880
|
+
color: ivory,
|
|
1558
1881
|
borderRight: "1px solid",
|
|
1559
1882
|
borderColor: "var(--md-border-color)"
|
|
1560
1883
|
},
|
|
1561
1884
|
".cm-activeLineGutter": {
|
|
1562
|
-
backgroundColor:
|
|
1885
|
+
backgroundColor: highlightBackground
|
|
1563
1886
|
},
|
|
1564
1887
|
".cm-foldPlaceholder": {
|
|
1565
1888
|
backgroundColor: "transparent",
|
|
@@ -1568,109 +1891,122 @@ $$
|
|
|
1568
1891
|
},
|
|
1569
1892
|
".cm-tooltip": {
|
|
1570
1893
|
border: "1px solid var(--md-border-color)",
|
|
1571
|
-
backgroundColor:
|
|
1894
|
+
backgroundColor: tooltipBackground
|
|
1572
1895
|
},
|
|
1573
1896
|
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
1574
1897
|
borderTopColor: "transparent",
|
|
1575
1898
|
borderBottomColor: "transparent"
|
|
1576
1899
|
},
|
|
1577
1900
|
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
1578
|
-
borderTopColor:
|
|
1579
|
-
borderBottomColor:
|
|
1901
|
+
borderTopColor: tooltipBackground,
|
|
1902
|
+
borderBottomColor: tooltipBackground
|
|
1580
1903
|
},
|
|
1581
1904
|
".cm-tooltip-autocomplete": {
|
|
1582
1905
|
"& > ul > li[aria-selected]": {
|
|
1583
|
-
color:
|
|
1906
|
+
color: ivory
|
|
1584
1907
|
}
|
|
1585
1908
|
}
|
|
1586
1909
|
}
|
|
1587
1910
|
// { dark: true }
|
|
1588
|
-
)
|
|
1589
|
-
|
|
1590
|
-
{ tag:
|
|
1591
|
-
{ tag: [
|
|
1592
|
-
{ tag: [
|
|
1593
|
-
{ tag: [
|
|
1911
|
+
);
|
|
1912
|
+
const oneLightHighlightStyle = HighlightStyle.define([
|
|
1913
|
+
{ tag: tags.keyword, color: violet },
|
|
1914
|
+
{ tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName], color: coral },
|
|
1915
|
+
{ tag: [tags.function(tags.variableName), tags.labelName], color: malibu },
|
|
1916
|
+
{ tag: [tags.color, tags.constant(tags.name), tags.standard(tags.name)], color: whiskey },
|
|
1917
|
+
{ tag: [tags.definition(tags.name), tags.separator], color: ivory },
|
|
1594
1918
|
{
|
|
1595
1919
|
tag: [
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1920
|
+
tags.typeName,
|
|
1921
|
+
tags.className,
|
|
1922
|
+
tags.number,
|
|
1923
|
+
tags.changed,
|
|
1924
|
+
tags.annotation,
|
|
1925
|
+
tags.modifier,
|
|
1926
|
+
tags.self,
|
|
1927
|
+
tags.namespace
|
|
1604
1928
|
],
|
|
1605
|
-
color:
|
|
1929
|
+
color: chalky
|
|
1606
1930
|
},
|
|
1607
1931
|
{
|
|
1608
1932
|
tag: [
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1933
|
+
tags.operator,
|
|
1934
|
+
tags.operatorKeyword,
|
|
1935
|
+
tags.url,
|
|
1936
|
+
tags.escape,
|
|
1937
|
+
tags.regexp,
|
|
1938
|
+
tags.link,
|
|
1939
|
+
tags.special(tags.string)
|
|
1616
1940
|
],
|
|
1617
|
-
color:
|
|
1941
|
+
color: cyan
|
|
1618
1942
|
},
|
|
1619
|
-
{ tag: [
|
|
1620
|
-
{ tag:
|
|
1621
|
-
{ tag:
|
|
1622
|
-
{ tag:
|
|
1623
|
-
{ tag:
|
|
1624
|
-
{ tag:
|
|
1625
|
-
{ tag: [
|
|
1626
|
-
{ tag: [
|
|
1627
|
-
{ tag:
|
|
1628
|
-
])
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1943
|
+
{ tag: [tags.meta, tags.comment], color: stone },
|
|
1944
|
+
{ tag: tags.strong, fontWeight: "bold" },
|
|
1945
|
+
{ tag: tags.emphasis, fontStyle: "italic" },
|
|
1946
|
+
{ tag: tags.strikethrough, textDecoration: "line-through" },
|
|
1947
|
+
{ tag: tags.link, color: stone, textDecoration: "underline" },
|
|
1948
|
+
{ tag: tags.heading, fontWeight: "bold", color: coral },
|
|
1949
|
+
{ tag: [tags.atom, tags.bool, tags.special(tags.variableName)], color: whiskey },
|
|
1950
|
+
{ tag: [tags.processingInstruction, tags.string, tags.inserted], color: sage },
|
|
1951
|
+
{ tag: tags.invalid, color: invalid }
|
|
1952
|
+
]);
|
|
1953
|
+
const oneLight = [
|
|
1954
|
+
oneLightTheme,
|
|
1955
|
+
syntaxHighlighting(oneLightHighlightStyle)
|
|
1956
|
+
];
|
|
1957
|
+
const getPairApply = (flag, type, title, suffix, selectType) => {
|
|
1958
|
+
return (view, _completion, from, to) => {
|
|
1959
|
+
const label = `${flag}${type}`.slice(to - from);
|
|
1960
|
+
view.dispatch(view.state.replaceSelection(`${label}${title}${suffix}`));
|
|
1961
|
+
const newTo = from + _completion.label.length + (selectType === "title" ? title.length : 0);
|
|
1962
|
+
view.dispatch({
|
|
1963
|
+
selection: EditorSelection.create(
|
|
1964
|
+
[
|
|
1965
|
+
EditorSelection.range(
|
|
1966
|
+
from + _completion.label.length + (selectType === "title" ? 1 : -type.length),
|
|
1967
|
+
newTo
|
|
1968
|
+
),
|
|
1969
|
+
EditorSelection.cursor(newTo)
|
|
1970
|
+
],
|
|
1971
|
+
1
|
|
1972
|
+
)
|
|
1973
|
+
});
|
|
1974
|
+
view.focus();
|
|
1975
|
+
};
|
|
1976
|
+
};
|
|
1977
|
+
const getApply = (_label) => {
|
|
1978
|
+
return (view, _completion, from, to) => {
|
|
1979
|
+
const label = _label.slice(to - from);
|
|
1980
|
+
view.dispatch(view.state.replaceSelection(`${label} `));
|
|
1981
|
+
};
|
|
1982
|
+
};
|
|
1983
|
+
const createAutocompletion = (completions) => {
|
|
1984
|
+
const defaultCompletion = (context) => {
|
|
1985
|
+
const word = context.matchBefore(
|
|
1653
1986
|
/^#+|^-\s*\[*\s*\]*|`+|\[|!\[*|^\|\s?\|?|^\$\$?|!+\s*\w*/
|
|
1654
1987
|
);
|
|
1655
|
-
|
|
1656
|
-
|
|
1988
|
+
if (word === null || word.from == word.to && context.explicit) {
|
|
1989
|
+
return null;
|
|
1990
|
+
}
|
|
1991
|
+
return {
|
|
1992
|
+
from: word.from,
|
|
1657
1993
|
options: [
|
|
1658
1994
|
// 标题
|
|
1659
|
-
...["h1", "h2", "h3", "h4", "h5", "h6"].map((
|
|
1660
|
-
const
|
|
1995
|
+
...["h1", "h2", "h3", "h4", "h5", "h6"].map((key, index) => {
|
|
1996
|
+
const label = new Array(index + 1).fill("#").join("");
|
|
1661
1997
|
return {
|
|
1662
|
-
label
|
|
1998
|
+
label,
|
|
1663
1999
|
type: "text",
|
|
1664
|
-
apply:
|
|
2000
|
+
apply: getApply(label)
|
|
1665
2001
|
};
|
|
1666
2002
|
}),
|
|
1667
2003
|
// 任务列表
|
|
1668
|
-
...["unchecked", "checked"].map((
|
|
1669
|
-
const
|
|
2004
|
+
...["unchecked", "checked"].map((key) => {
|
|
2005
|
+
const label = key === "checked" ? "- [x]" : "- [ ]";
|
|
1670
2006
|
return {
|
|
1671
|
-
label
|
|
2007
|
+
label,
|
|
1672
2008
|
type: "text",
|
|
1673
|
-
apply:
|
|
2009
|
+
apply: getApply(label)
|
|
1674
2010
|
};
|
|
1675
2011
|
}),
|
|
1676
2012
|
// 代码
|
|
@@ -1678,11 +2014,13 @@ $$
|
|
|
1678
2014
|
["`", ""],
|
|
1679
2015
|
["```", "language"],
|
|
1680
2016
|
["```mermaid\n", ""]
|
|
1681
|
-
].map((
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
2017
|
+
].map((c) => {
|
|
2018
|
+
return {
|
|
2019
|
+
label: `${c[0]}${c[1]}`,
|
|
2020
|
+
type: "text",
|
|
2021
|
+
apply: getPairApply(c[0], c[1], "", c[0] === "`" ? "`" : "\n```", "type")
|
|
2022
|
+
};
|
|
2023
|
+
}),
|
|
1686
2024
|
// 链接
|
|
1687
2025
|
{
|
|
1688
2026
|
label: "[]()",
|
|
@@ -1697,23 +2035,18 @@ $$
|
|
|
1697
2035
|
label: "| |",
|
|
1698
2036
|
type: "text",
|
|
1699
2037
|
detail: "table",
|
|
1700
|
-
apply:
|
|
1701
|
-
| - | - | - |
|
|
1702
|
-
| content | content | content |
|
|
1703
|
-
| content | content | content |`
|
|
2038
|
+
apply: "| col | col | col |\n| - | - | - |\n| content | content | content |\n| content | content | content |"
|
|
1704
2039
|
},
|
|
1705
2040
|
// 公式
|
|
1706
2041
|
{
|
|
1707
2042
|
label: "$",
|
|
1708
2043
|
type: "text",
|
|
1709
|
-
apply:
|
|
2044
|
+
apply: getPairApply("$", "", "", "$", "type")
|
|
1710
2045
|
},
|
|
1711
2046
|
{
|
|
1712
2047
|
label: "$$",
|
|
1713
2048
|
type: "text",
|
|
1714
|
-
apply:
|
|
1715
|
-
`, `
|
|
1716
|
-
$$`, "title")
|
|
2049
|
+
apply: getPairApply("$$", "", "\n", "\n$$", "title")
|
|
1717
2050
|
},
|
|
1718
2051
|
// 那啥?
|
|
1719
2052
|
...[
|
|
@@ -1733,40 +2066,52 @@ $$`, "title")
|
|
|
1733
2066
|
"caution",
|
|
1734
2067
|
"error",
|
|
1735
2068
|
"attention"
|
|
1736
|
-
].map((
|
|
1737
|
-
label
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
2069
|
+
].map((key) => {
|
|
2070
|
+
const label = `!!! ${key}`;
|
|
2071
|
+
return {
|
|
2072
|
+
label,
|
|
2073
|
+
type: "text",
|
|
2074
|
+
apply: getPairApply("!!!", ` ${key}`, " Title", "\n\n!!!", "title")
|
|
2075
|
+
};
|
|
2076
|
+
})
|
|
1743
2077
|
]
|
|
1744
2078
|
};
|
|
1745
2079
|
};
|
|
1746
|
-
return
|
|
1747
|
-
override:
|
|
2080
|
+
return autocompletion({
|
|
2081
|
+
override: completions ? [defaultCompletion, ...completions] : [defaultCompletion]
|
|
1748
2082
|
});
|
|
1749
|
-
}, J = (e) => {
|
|
1750
|
-
const o = new Q();
|
|
1751
|
-
return (n) => (o.get(e.state) ? e.dispatch({ effects: o.reconfigure(n) }) : e.dispatch({
|
|
1752
|
-
effects: il.appendConfig.of(o.of(n))
|
|
1753
|
-
}), !0);
|
|
1754
2083
|
};
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
2084
|
+
const toggleWith = (view) => {
|
|
2085
|
+
const mc = new Compartment();
|
|
2086
|
+
const toggle = (extension) => {
|
|
2087
|
+
mc.get(view.state) ? view.dispatch({ effects: mc.reconfigure(extension) }) : view.dispatch({
|
|
2088
|
+
effects: StateEffect.appendConfig.of(mc.of(extension))
|
|
2089
|
+
});
|
|
2090
|
+
return true;
|
|
2091
|
+
};
|
|
2092
|
+
return toggle;
|
|
2093
|
+
};
|
|
2094
|
+
class CodeMirrorUt {
|
|
2095
|
+
constructor(view) {
|
|
2096
|
+
__publicField(this, "view");
|
|
2097
|
+
__publicField(this, "maxLength", Number.MAX_SAFE_INTEGER);
|
|
1759
2098
|
// 切换tabSize的执行方法。切换时,Compartment实例需要相同
|
|
1760
|
-
|
|
1761
|
-
|
|
2099
|
+
__publicField(this, "toggleTabSize");
|
|
2100
|
+
__publicField(this, "togglePlaceholder");
|
|
1762
2101
|
/**
|
|
1763
2102
|
* 设置全部的扩展
|
|
1764
2103
|
*/
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
this.view =
|
|
2104
|
+
__publicField(this, "setExtensions");
|
|
2105
|
+
__publicField(this, "toggleDisabled");
|
|
2106
|
+
__publicField(this, "toggleReadOnly");
|
|
2107
|
+
__publicField(this, "toggleMaxlength");
|
|
2108
|
+
this.view = view;
|
|
2109
|
+
this.toggleTabSize = toggleWith(this.view);
|
|
2110
|
+
this.togglePlaceholder = toggleWith(this.view);
|
|
2111
|
+
this.setExtensions = toggleWith(this.view);
|
|
2112
|
+
this.toggleDisabled = toggleWith(this.view);
|
|
2113
|
+
this.toggleReadOnly = toggleWith(this.view);
|
|
2114
|
+
this.toggleMaxlength = toggleWith(this.view);
|
|
1770
2115
|
}
|
|
1771
2116
|
getValue() {
|
|
1772
2117
|
return this.view.state.doc.toString();
|
|
@@ -1778,12 +2123,12 @@ class bo {
|
|
|
1778
2123
|
* @param from 插入开始位置
|
|
1779
2124
|
* @param to 插入结束位置
|
|
1780
2125
|
*/
|
|
1781
|
-
setValue(
|
|
2126
|
+
setValue(insert, from = 0, to = this.view.state.doc.length) {
|
|
1782
2127
|
this.view.dispatch({
|
|
1783
2128
|
changes: {
|
|
1784
|
-
from
|
|
1785
|
-
to
|
|
1786
|
-
insert
|
|
2129
|
+
from,
|
|
2130
|
+
to,
|
|
2131
|
+
insert
|
|
1787
2132
|
}
|
|
1788
2133
|
});
|
|
1789
2134
|
}
|
|
@@ -1791,8 +2136,8 @@ class bo {
|
|
|
1791
2136
|
* 获取选中的文本
|
|
1792
2137
|
*/
|
|
1793
2138
|
getSelectedText() {
|
|
1794
|
-
const { from
|
|
1795
|
-
return this.view.state.sliceDoc(
|
|
2139
|
+
const { from, to } = this.view.state.selection.main;
|
|
2140
|
+
return this.view.state.sliceDoc(from, to);
|
|
1796
2141
|
}
|
|
1797
2142
|
/**
|
|
1798
2143
|
* 使用新的内容替换选中的内容
|
|
@@ -1800,47 +2145,52 @@ class bo {
|
|
|
1800
2145
|
* @param text 待替换内容
|
|
1801
2146
|
* @param options 替换后是否选中
|
|
1802
2147
|
*/
|
|
1803
|
-
replaceSelectedText(
|
|
2148
|
+
replaceSelectedText(text, options = {
|
|
1804
2149
|
// 是否选中
|
|
1805
|
-
select:
|
|
2150
|
+
select: true,
|
|
1806
2151
|
// 选中时,开始位置的偏移量
|
|
1807
2152
|
deviationStart: 0,
|
|
1808
2153
|
// 结束的偏移量
|
|
1809
2154
|
deviationEnd: 0,
|
|
1810
2155
|
// 直接替换所有文本
|
|
1811
|
-
replaceAll:
|
|
1812
|
-
},
|
|
2156
|
+
replaceAll: false
|
|
2157
|
+
}, editorId) {
|
|
1813
2158
|
try {
|
|
1814
|
-
if (
|
|
1815
|
-
|
|
2159
|
+
if (options.replaceAll) {
|
|
2160
|
+
this.setValue(text);
|
|
2161
|
+
if (text.length > this.maxLength) {
|
|
1816
2162
|
throw new Error("The input text is too long");
|
|
2163
|
+
}
|
|
1817
2164
|
return;
|
|
1818
2165
|
}
|
|
1819
|
-
if (this.view.state.doc.length - this.getSelectedText().length +
|
|
2166
|
+
if (this.view.state.doc.length - this.getSelectedText().length + text.length > this.maxLength) {
|
|
1820
2167
|
throw new Error("The input text is too long");
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
2168
|
+
}
|
|
2169
|
+
const { from } = this.view.state.selection.main;
|
|
2170
|
+
this.view.dispatch(this.view.state.replaceSelection(text));
|
|
2171
|
+
if (options.select) {
|
|
2172
|
+
const to = from + text.length + options.deviationEnd;
|
|
1824
2173
|
this.view.dispatch({
|
|
1825
|
-
selection:
|
|
2174
|
+
selection: EditorSelection.create(
|
|
1826
2175
|
[
|
|
1827
|
-
|
|
1828
|
-
|
|
2176
|
+
EditorSelection.range(from + options.deviationStart, to),
|
|
2177
|
+
EditorSelection.cursor(to)
|
|
1829
2178
|
],
|
|
1830
2179
|
1
|
|
1831
2180
|
)
|
|
1832
2181
|
});
|
|
1833
2182
|
}
|
|
1834
2183
|
this.view.focus();
|
|
1835
|
-
} catch (
|
|
1836
|
-
if (
|
|
1837
|
-
|
|
2184
|
+
} catch (e) {
|
|
2185
|
+
if (e.message === "The input text is too long") {
|
|
2186
|
+
bus.emit(editorId, ERROR_CATCHER, {
|
|
1838
2187
|
name: "overlength",
|
|
1839
|
-
message:
|
|
1840
|
-
data:
|
|
2188
|
+
message: e.message,
|
|
2189
|
+
data: text
|
|
1841
2190
|
});
|
|
1842
|
-
else
|
|
1843
|
-
throw
|
|
2191
|
+
} else {
|
|
2192
|
+
throw e;
|
|
2193
|
+
}
|
|
1844
2194
|
}
|
|
1845
2195
|
}
|
|
1846
2196
|
/**
|
|
@@ -1848,10 +2198,10 @@ class bo {
|
|
|
1848
2198
|
*
|
|
1849
2199
|
* @param tabSize 需要切换的大小
|
|
1850
2200
|
*/
|
|
1851
|
-
setTabSize(
|
|
2201
|
+
setTabSize(tabSize) {
|
|
1852
2202
|
this.toggleTabSize([
|
|
1853
|
-
|
|
1854
|
-
|
|
2203
|
+
EditorState.tabSize.of(tabSize),
|
|
2204
|
+
indentUnit.of(" ".repeat(tabSize))
|
|
1855
2205
|
]);
|
|
1856
2206
|
}
|
|
1857
2207
|
/**
|
|
@@ -1859,453 +2209,666 @@ class bo {
|
|
|
1859
2209
|
*
|
|
1860
2210
|
* @param t 目标内容
|
|
1861
2211
|
*/
|
|
1862
|
-
setPlaceholder(
|
|
1863
|
-
this.togglePlaceholder(
|
|
2212
|
+
setPlaceholder(t) {
|
|
2213
|
+
this.togglePlaceholder(placeholder(t));
|
|
1864
2214
|
}
|
|
1865
|
-
focus(
|
|
1866
|
-
|
|
2215
|
+
focus(options) {
|
|
2216
|
+
this.view.focus();
|
|
2217
|
+
if (!options) {
|
|
1867
2218
|
return;
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2219
|
+
}
|
|
2220
|
+
let anchor = 0;
|
|
2221
|
+
let head = 0;
|
|
2222
|
+
let pos = 0;
|
|
2223
|
+
switch (options) {
|
|
2224
|
+
case "start": {
|
|
1871
2225
|
break;
|
|
2226
|
+
}
|
|
1872
2227
|
case "end": {
|
|
1873
|
-
|
|
2228
|
+
const length = this.getValue().length;
|
|
2229
|
+
anchor = head = pos = length;
|
|
1874
2230
|
break;
|
|
1875
2231
|
}
|
|
1876
|
-
default:
|
|
1877
|
-
|
|
2232
|
+
default: {
|
|
2233
|
+
anchor = options.rangeAnchor || options.cursorPos;
|
|
2234
|
+
head = options.rangeHead || options.cursorPos;
|
|
2235
|
+
pos = options.cursorPos;
|
|
2236
|
+
}
|
|
1878
2237
|
}
|
|
1879
2238
|
this.view.dispatch({
|
|
1880
|
-
scrollIntoView:
|
|
1881
|
-
selection:
|
|
1882
|
-
[
|
|
2239
|
+
scrollIntoView: true,
|
|
2240
|
+
selection: EditorSelection.create(
|
|
2241
|
+
[EditorSelection.range(anchor, head), EditorSelection.cursor(pos)],
|
|
1883
2242
|
1
|
|
1884
2243
|
)
|
|
1885
2244
|
});
|
|
1886
2245
|
}
|
|
1887
|
-
setDisabled(
|
|
1888
|
-
this.toggleDisabled([
|
|
2246
|
+
setDisabled(d) {
|
|
2247
|
+
this.toggleDisabled([EditorView.editable.of(!d)]);
|
|
1889
2248
|
}
|
|
1890
|
-
setReadOnly(
|
|
1891
|
-
this.toggleReadOnly([
|
|
2249
|
+
setReadOnly(r) {
|
|
2250
|
+
this.toggleReadOnly([EditorState.readOnly.of(r)]);
|
|
1892
2251
|
}
|
|
1893
|
-
setMaxLength(
|
|
1894
|
-
this.maxLength =
|
|
1895
|
-
|
|
2252
|
+
setMaxLength(ml) {
|
|
2253
|
+
this.maxLength = ml;
|
|
2254
|
+
this.toggleMaxlength([
|
|
2255
|
+
EditorState.changeFilter.of((tr) => {
|
|
2256
|
+
return tr.newDoc.length <= ml;
|
|
2257
|
+
})
|
|
1896
2258
|
]);
|
|
1897
2259
|
}
|
|
1898
2260
|
}
|
|
1899
|
-
const
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1902
|
-
if (!
|
|
2261
|
+
const usePasteUpload = (props2) => {
|
|
2262
|
+
const editorId = inject("editorId");
|
|
2263
|
+
const pasteHandler = (e) => {
|
|
2264
|
+
if (!e.clipboardData) {
|
|
1903
2265
|
return;
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
2266
|
+
}
|
|
2267
|
+
if (e.clipboardData.files.length > 0) {
|
|
2268
|
+
const { files } = e.clipboardData;
|
|
2269
|
+
bus.emit(
|
|
2270
|
+
editorId,
|
|
2271
|
+
UPLOAD_IMAGE,
|
|
2272
|
+
Array.from(files).filter((file) => {
|
|
2273
|
+
return /image\/.*/.test(file.type);
|
|
2274
|
+
})
|
|
2275
|
+
);
|
|
2276
|
+
e.preventDefault();
|
|
1911
2277
|
return;
|
|
1912
2278
|
}
|
|
1913
|
-
if (
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1916
|
-
mode:
|
|
1917
|
-
text:
|
|
1918
|
-
})
|
|
2279
|
+
if (props2.autoDetectCode && e.clipboardData.types.includes("vscode-editor-data")) {
|
|
2280
|
+
const vscCoodInfo = JSON.parse(e.clipboardData.getData("vscode-editor-data"));
|
|
2281
|
+
bus.emit(editorId, REPLACE, "code", {
|
|
2282
|
+
mode: vscCoodInfo.mode,
|
|
2283
|
+
text: e.clipboardData.getData("text/plain")
|
|
2284
|
+
});
|
|
2285
|
+
e.preventDefault();
|
|
1919
2286
|
return;
|
|
1920
2287
|
}
|
|
1921
|
-
const
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
2288
|
+
const targetValue = e.clipboardData.getData("text/plain");
|
|
2289
|
+
if (props2.maxlength && targetValue.length + props2.modelValue.length > props2.maxlength) {
|
|
2290
|
+
bus.emit(editorId, ERROR_CATCHER, {
|
|
2291
|
+
name: "overlength",
|
|
2292
|
+
message: "The input text is too long",
|
|
2293
|
+
data: targetValue
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
1927
2296
|
};
|
|
1928
|
-
|
|
1929
|
-
|
|
2297
|
+
return pasteHandler;
|
|
2298
|
+
};
|
|
2299
|
+
const createCommands = (id, contentProps2) => {
|
|
2300
|
+
const CtrlB = {
|
|
1930
2301
|
key: "Ctrl-b",
|
|
1931
2302
|
mac: "Cmd-b",
|
|
1932
|
-
run: () =>
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
preventDefault: !0
|
|
1939
|
-
},
|
|
1940
|
-
{
|
|
2303
|
+
run: () => {
|
|
2304
|
+
bus.emit(id, REPLACE, "bold");
|
|
2305
|
+
return true;
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2308
|
+
const CtrlS = {
|
|
1941
2309
|
key: "Ctrl-s",
|
|
1942
2310
|
mac: "Cmd-s",
|
|
1943
|
-
run: (
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
2311
|
+
run: (view) => {
|
|
2312
|
+
bus.emit(id, ON_SAVE, view.state.doc.toString());
|
|
2313
|
+
return true;
|
|
2314
|
+
},
|
|
2315
|
+
shift: () => {
|
|
2316
|
+
bus.emit(id, REPLACE, "strikeThrough");
|
|
2317
|
+
return true;
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
const CtrlU = {
|
|
1947
2321
|
key: "Ctrl-u",
|
|
1948
2322
|
mac: "Cmd-u",
|
|
1949
|
-
run: () =>
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2323
|
+
run: () => {
|
|
2324
|
+
bus.emit(id, REPLACE, "underline");
|
|
2325
|
+
return true;
|
|
2326
|
+
},
|
|
2327
|
+
shift: () => {
|
|
2328
|
+
bus.emit(id, REPLACE, "unorderedList");
|
|
2329
|
+
return true;
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
const CtrlI = {
|
|
1953
2333
|
key: "Ctrl-i",
|
|
1954
2334
|
mac: "Cmd-i",
|
|
1955
|
-
run: () =>
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
2335
|
+
run: () => {
|
|
2336
|
+
bus.emit(id, REPLACE, "italic");
|
|
2337
|
+
return true;
|
|
2338
|
+
},
|
|
2339
|
+
shift: () => {
|
|
2340
|
+
bus.emit(id, OPEN_MODALS, "image");
|
|
2341
|
+
return true;
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
const Ctrl1 = {
|
|
1959
2345
|
key: "Ctrl-1",
|
|
1960
2346
|
mac: "Cmd-1",
|
|
1961
|
-
run: () =>
|
|
1962
|
-
|
|
1963
|
-
|
|
2347
|
+
run: () => {
|
|
2348
|
+
bus.emit(id, REPLACE, "h1");
|
|
2349
|
+
return true;
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
const Ctrl2 = {
|
|
1964
2353
|
key: "Ctrl-2",
|
|
1965
2354
|
mac: "Cmd-2",
|
|
1966
|
-
run: () =>
|
|
1967
|
-
|
|
1968
|
-
|
|
2355
|
+
run: () => {
|
|
2356
|
+
bus.emit(id, REPLACE, "h2");
|
|
2357
|
+
return true;
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
const Ctrl3 = {
|
|
1969
2361
|
key: "Ctrl-3",
|
|
1970
2362
|
mac: "Cmd-3",
|
|
1971
|
-
run: () =>
|
|
1972
|
-
|
|
1973
|
-
|
|
2363
|
+
run: () => {
|
|
2364
|
+
bus.emit(id, REPLACE, "h3");
|
|
2365
|
+
return true;
|
|
2366
|
+
}
|
|
2367
|
+
};
|
|
2368
|
+
const Ctrl4 = {
|
|
1974
2369
|
key: "Ctrl-4",
|
|
1975
2370
|
mac: "Cmd-4",
|
|
1976
|
-
run: () =>
|
|
1977
|
-
|
|
1978
|
-
|
|
2371
|
+
run: () => {
|
|
2372
|
+
bus.emit(id, REPLACE, "h4");
|
|
2373
|
+
return true;
|
|
2374
|
+
}
|
|
2375
|
+
};
|
|
2376
|
+
const Ctrl5 = {
|
|
1979
2377
|
key: "Ctrl-5",
|
|
1980
2378
|
mac: "Cmd-5",
|
|
1981
|
-
run: () =>
|
|
1982
|
-
|
|
1983
|
-
|
|
2379
|
+
run: () => {
|
|
2380
|
+
bus.emit(id, REPLACE, "h5");
|
|
2381
|
+
return true;
|
|
2382
|
+
}
|
|
2383
|
+
};
|
|
2384
|
+
const Ctrl6 = {
|
|
1984
2385
|
key: "Ctrl-6",
|
|
1985
2386
|
mac: "Cmd-6",
|
|
1986
|
-
run: () =>
|
|
1987
|
-
|
|
1988
|
-
|
|
2387
|
+
run: () => {
|
|
2388
|
+
bus.emit(id, REPLACE, "h6");
|
|
2389
|
+
return true;
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
const CtrlArrowUp = {
|
|
1989
2393
|
key: "Ctrl-ArrowUp",
|
|
1990
2394
|
mac: "Cmd-ArrowUp",
|
|
1991
|
-
run: () =>
|
|
1992
|
-
|
|
1993
|
-
|
|
2395
|
+
run: () => {
|
|
2396
|
+
bus.emit(id, REPLACE, "sup");
|
|
2397
|
+
return true;
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
const CtrlArrowDown = {
|
|
1994
2401
|
key: "Ctrl-ArrowDown",
|
|
1995
2402
|
mac: "Cmd-ArrowDown",
|
|
1996
|
-
run: () =>
|
|
1997
|
-
|
|
1998
|
-
|
|
2403
|
+
run: () => {
|
|
2404
|
+
bus.emit(id, REPLACE, "sub");
|
|
2405
|
+
return true;
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
const CtrlO = {
|
|
1999
2409
|
key: "Ctrl-o",
|
|
2000
2410
|
mac: "Cmd-o",
|
|
2001
|
-
run: () =>
|
|
2002
|
-
|
|
2003
|
-
|
|
2411
|
+
run: () => {
|
|
2412
|
+
bus.emit(id, REPLACE, "orderedList");
|
|
2413
|
+
return true;
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
const CtrlC = {
|
|
2004
2417
|
key: "Ctrl-c",
|
|
2005
2418
|
mac: "Cmd-c",
|
|
2006
|
-
shift: () =>
|
|
2007
|
-
|
|
2008
|
-
return
|
|
2419
|
+
shift: () => {
|
|
2420
|
+
bus.emit(id, REPLACE, "code");
|
|
2421
|
+
return true;
|
|
2422
|
+
},
|
|
2423
|
+
any(_view, e) {
|
|
2424
|
+
if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === "KeyC") {
|
|
2425
|
+
bus.emit(id, REPLACE, "codeRow");
|
|
2426
|
+
return true;
|
|
2427
|
+
}
|
|
2428
|
+
return false;
|
|
2009
2429
|
}
|
|
2010
|
-
}
|
|
2011
|
-
{
|
|
2430
|
+
};
|
|
2431
|
+
const CtrlL = {
|
|
2012
2432
|
key: "Ctrl-l",
|
|
2013
2433
|
mac: "Cmd-l",
|
|
2014
|
-
run: () =>
|
|
2015
|
-
|
|
2016
|
-
|
|
2434
|
+
run: () => {
|
|
2435
|
+
bus.emit(id, OPEN_MODALS, "link");
|
|
2436
|
+
return true;
|
|
2437
|
+
}
|
|
2438
|
+
};
|
|
2439
|
+
const CtrlF = {
|
|
2017
2440
|
key: "Ctrl-f",
|
|
2018
2441
|
mac: "Cmd-f",
|
|
2019
|
-
shift: () =>
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2442
|
+
shift: () => {
|
|
2443
|
+
if (!contentProps2.noPrettier) {
|
|
2444
|
+
bus.emit(id, REPLACE, "prettier");
|
|
2445
|
+
return true;
|
|
2446
|
+
}
|
|
2447
|
+
return false;
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
const CtrlT = {
|
|
2451
|
+
any: (_view, e) => {
|
|
2452
|
+
if ((e.ctrlKey || e.metaKey) && e.altKey && e.shiftKey && e.code === "KeyT") {
|
|
2453
|
+
bus.emit(id, REPLACE, "table");
|
|
2454
|
+
return true;
|
|
2455
|
+
}
|
|
2456
|
+
return false;
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
const CtrlD = {
|
|
2460
|
+
key: "Ctrl-d",
|
|
2461
|
+
mac: "Cmd-d",
|
|
2462
|
+
run: deleteLine,
|
|
2463
|
+
preventDefault: true
|
|
2464
|
+
};
|
|
2465
|
+
return [
|
|
2466
|
+
CtrlB,
|
|
2467
|
+
CtrlD,
|
|
2468
|
+
CtrlS,
|
|
2469
|
+
CtrlU,
|
|
2470
|
+
CtrlI,
|
|
2471
|
+
Ctrl1,
|
|
2472
|
+
Ctrl2,
|
|
2473
|
+
Ctrl3,
|
|
2474
|
+
Ctrl4,
|
|
2475
|
+
Ctrl5,
|
|
2476
|
+
Ctrl6,
|
|
2477
|
+
CtrlArrowUp,
|
|
2478
|
+
CtrlArrowDown,
|
|
2479
|
+
CtrlO,
|
|
2480
|
+
CtrlC,
|
|
2481
|
+
CtrlL,
|
|
2482
|
+
CtrlF,
|
|
2483
|
+
CtrlT
|
|
2484
|
+
];
|
|
2485
|
+
};
|
|
2486
|
+
const useCodeMirror = (props2) => {
|
|
2487
|
+
const tabWidth = inject("tabWidth");
|
|
2488
|
+
const editorId = inject("editorId");
|
|
2489
|
+
const theme = inject("theme");
|
|
2490
|
+
const inputWrapperRef = ref();
|
|
2491
|
+
const codeMirrorUt = shallowRef();
|
|
2492
|
+
const languageComp = new Compartment(), themeComp = new Compartment(), autocompletionComp = new Compartment(), historyComp = new Compartment(), eventComp = new Compartment();
|
|
2493
|
+
const mdEditorCommands = createCommands(editorId, props2);
|
|
2494
|
+
const spelling = ref(false);
|
|
2495
|
+
const pasteHandler = usePasteUpload(props2);
|
|
2496
|
+
const domEventHandlers = {
|
|
2497
|
+
paste: pasteHandler,
|
|
2498
|
+
blur: props2.onBlur,
|
|
2499
|
+
focus: props2.onFocus,
|
|
2500
|
+
drop: props2.onDrop,
|
|
2030
2501
|
compositionstart: () => {
|
|
2031
|
-
console.log("compositionstart")
|
|
2502
|
+
console.log("compositionstart");
|
|
2503
|
+
spelling.value = true;
|
|
2032
2504
|
},
|
|
2033
|
-
compositionend: (
|
|
2034
|
-
console.log("compositionend")
|
|
2505
|
+
compositionend: (_e, view) => {
|
|
2506
|
+
console.log("compositionend");
|
|
2507
|
+
spelling.value = false;
|
|
2508
|
+
props2.updateModelValue(view.state.doc.toString());
|
|
2035
2509
|
},
|
|
2036
|
-
input: (
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2510
|
+
input: (e) => {
|
|
2511
|
+
if (props2.onInput) {
|
|
2512
|
+
props2.onInput(e);
|
|
2513
|
+
}
|
|
2514
|
+
const { data } = e;
|
|
2515
|
+
if (props2.maxlength && props2.modelValue.length + data.length > props2.maxlength) {
|
|
2516
|
+
bus.emit(editorId, ERROR_CATCHER, {
|
|
2517
|
+
name: "overlength",
|
|
2518
|
+
message: "The input text is too long",
|
|
2519
|
+
data
|
|
2520
|
+
});
|
|
2521
|
+
}
|
|
2044
2522
|
}
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2523
|
+
};
|
|
2524
|
+
const defaultExtensions = [
|
|
2525
|
+
keymap.of([...defaultKeymap, ...historyKeymap, ...mdEditorCommands, indentWithTab]),
|
|
2526
|
+
historyComp.of(history()),
|
|
2527
|
+
languageComp.of(markdown({ codeLanguages: languages })),
|
|
2049
2528
|
// 横向换行
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2529
|
+
EditorView$1.lineWrapping,
|
|
2530
|
+
EditorView$1.updateListener.of((update) => {
|
|
2531
|
+
if (update.docChanged) {
|
|
2532
|
+
props2.onChange(update.state.doc.toString());
|
|
2533
|
+
if (!spelling.value) {
|
|
2534
|
+
props2.updateModelValue(update.state.doc.toString());
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2053
2537
|
}),
|
|
2054
|
-
|
|
2055
|
-
]
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2538
|
+
eventComp.of(EditorView$1.domEventHandlers(domEventHandlers))
|
|
2539
|
+
];
|
|
2540
|
+
const getExtensions = () => {
|
|
2541
|
+
const extensions = [
|
|
2542
|
+
...defaultExtensions,
|
|
2543
|
+
themeComp.of(theme.value === "light" ? oneLight : oneDark),
|
|
2544
|
+
autocompletionComp.of(createAutocompletion(props2.completions))
|
|
2060
2545
|
];
|
|
2061
|
-
return
|
|
2062
|
-
|
|
2546
|
+
return configOption.codeMirrorExtensions(theme.value, extensions, [
|
|
2547
|
+
...mdEditorCommands
|
|
2063
2548
|
]);
|
|
2064
2549
|
};
|
|
2065
|
-
|
|
2066
|
-
const
|
|
2067
|
-
doc:
|
|
2068
|
-
parent:
|
|
2069
|
-
extensions: [
|
|
2070
|
-
})
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2550
|
+
onMounted(() => {
|
|
2551
|
+
const view = new EditorView$1({
|
|
2552
|
+
doc: props2.modelValue,
|
|
2553
|
+
parent: inputWrapperRef.value,
|
|
2554
|
+
extensions: [getExtensions()]
|
|
2555
|
+
});
|
|
2556
|
+
const nc = new CodeMirrorUt(view);
|
|
2557
|
+
codeMirrorUt.value = nc;
|
|
2558
|
+
setTimeout(() => {
|
|
2559
|
+
nc.setTabSize(tabWidth);
|
|
2560
|
+
nc.setDisabled(props2.disabled);
|
|
2561
|
+
nc.setReadOnly(props2.readonly);
|
|
2562
|
+
props2.placeholder && nc.setPlaceholder(props2.placeholder);
|
|
2563
|
+
typeof props2.maxlength === "number" && nc.setMaxLength(props2.maxlength);
|
|
2564
|
+
props2.autofocus && view.focus();
|
|
2565
|
+
}, 0);
|
|
2566
|
+
bus.on(editorId, {
|
|
2567
|
+
name: CTRL_Z,
|
|
2075
2568
|
callback() {
|
|
2076
|
-
|
|
2569
|
+
undo(view);
|
|
2077
2570
|
}
|
|
2078
|
-
})
|
|
2079
|
-
|
|
2571
|
+
});
|
|
2572
|
+
bus.on(editorId, {
|
|
2573
|
+
name: CTRL_SHIFT_Z,
|
|
2080
2574
|
callback() {
|
|
2081
|
-
|
|
2082
|
-
}
|
|
2083
|
-
})
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2575
|
+
redo(view);
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2578
|
+
bus.on(editorId, {
|
|
2579
|
+
name: REPLACE,
|
|
2580
|
+
callback(direct, params = {}) {
|
|
2581
|
+
var _a;
|
|
2582
|
+
const { text, options } = directive2flag(direct, codeMirrorUt.value, params);
|
|
2583
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.replaceSelectedText(text, options, editorId);
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
bus.on(editorId, {
|
|
2587
|
+
name: EVENT_LISTENER,
|
|
2588
|
+
callback(handlers) {
|
|
2589
|
+
var _a;
|
|
2590
|
+
const nextDomEventHandlers = {
|
|
2591
|
+
...domEventHandlers
|
|
2592
|
+
};
|
|
2593
|
+
const defaultEventNames = Object.keys(domEventHandlers);
|
|
2594
|
+
for (const eventName in handlers) {
|
|
2595
|
+
const en = eventName;
|
|
2596
|
+
if (defaultEventNames.includes(en)) {
|
|
2597
|
+
nextDomEventHandlers[en] = (e, v) => {
|
|
2598
|
+
handlers[en](e, v);
|
|
2599
|
+
if (!e.defaultPrevented) {
|
|
2600
|
+
domEventHandlers[en](e, v);
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2603
|
+
} else {
|
|
2604
|
+
nextDomEventHandlers[en] = handlers[en];
|
|
2605
|
+
}
|
|
2102
2606
|
}
|
|
2103
|
-
(
|
|
2104
|
-
effects:
|
|
2105
|
-
|
|
2607
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
2608
|
+
effects: eventComp.reconfigure(
|
|
2609
|
+
EditorView$1.domEventHandlers(nextDomEventHandlers)
|
|
2106
2610
|
)
|
|
2107
2611
|
});
|
|
2108
2612
|
}
|
|
2109
2613
|
});
|
|
2110
|
-
})
|
|
2111
|
-
|
|
2614
|
+
});
|
|
2615
|
+
watch(
|
|
2616
|
+
theme,
|
|
2112
2617
|
() => {
|
|
2113
|
-
var
|
|
2114
|
-
(
|
|
2115
|
-
effects:
|
|
2618
|
+
var _a;
|
|
2619
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
2620
|
+
effects: themeComp.reconfigure(theme.value === "light" ? oneLight : oneDark)
|
|
2116
2621
|
});
|
|
2117
2622
|
},
|
|
2118
2623
|
{
|
|
2119
|
-
deep:
|
|
2624
|
+
deep: true
|
|
2120
2625
|
}
|
|
2121
|
-
)
|
|
2122
|
-
|
|
2626
|
+
);
|
|
2627
|
+
watch(
|
|
2628
|
+
() => props2.completions,
|
|
2123
2629
|
() => {
|
|
2124
|
-
var
|
|
2125
|
-
(
|
|
2126
|
-
effects:
|
|
2630
|
+
var _a;
|
|
2631
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
2632
|
+
effects: autocompletionComp.reconfigure(createAutocompletion(props2.completions))
|
|
2127
2633
|
});
|
|
2128
2634
|
},
|
|
2129
2635
|
{
|
|
2130
|
-
deep:
|
|
2636
|
+
deep: true
|
|
2131
2637
|
}
|
|
2132
|
-
)
|
|
2133
|
-
|
|
2638
|
+
);
|
|
2639
|
+
watch(
|
|
2640
|
+
() => props2.modelValue,
|
|
2134
2641
|
() => {
|
|
2135
|
-
var
|
|
2136
|
-
((
|
|
2642
|
+
var _a, _b;
|
|
2643
|
+
if (((_a = codeMirrorUt.value) == null ? void 0 : _a.getValue()) !== props2.modelValue) {
|
|
2644
|
+
(_b = codeMirrorUt.value) == null ? void 0 : _b.setValue(props2.modelValue);
|
|
2645
|
+
}
|
|
2137
2646
|
}
|
|
2138
|
-
)
|
|
2139
|
-
|
|
2647
|
+
);
|
|
2648
|
+
watch(
|
|
2649
|
+
() => props2.placeholder,
|
|
2140
2650
|
() => {
|
|
2141
|
-
var
|
|
2142
|
-
(
|
|
2651
|
+
var _a;
|
|
2652
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.setPlaceholder(props2.placeholder);
|
|
2143
2653
|
}
|
|
2144
|
-
)
|
|
2145
|
-
|
|
2654
|
+
);
|
|
2655
|
+
watch(
|
|
2656
|
+
() => props2.disabled,
|
|
2146
2657
|
() => {
|
|
2147
|
-
var
|
|
2148
|
-
(
|
|
2658
|
+
var _a;
|
|
2659
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.setDisabled(props2.disabled);
|
|
2149
2660
|
}
|
|
2150
|
-
)
|
|
2151
|
-
|
|
2661
|
+
);
|
|
2662
|
+
watch(
|
|
2663
|
+
() => props2.readonly,
|
|
2152
2664
|
() => {
|
|
2153
|
-
var
|
|
2154
|
-
(
|
|
2665
|
+
var _a;
|
|
2666
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.setDisabled(props2.readonly);
|
|
2155
2667
|
}
|
|
2156
|
-
)
|
|
2157
|
-
|
|
2668
|
+
);
|
|
2669
|
+
watch(
|
|
2670
|
+
() => props2.maxlength,
|
|
2158
2671
|
() => {
|
|
2159
|
-
var
|
|
2160
|
-
|
|
2672
|
+
var _a;
|
|
2673
|
+
if (props2.maxlength) {
|
|
2674
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.setMaxLength(props2.maxlength);
|
|
2675
|
+
}
|
|
2161
2676
|
}
|
|
2162
|
-
)
|
|
2163
|
-
|
|
2164
|
-
|
|
2677
|
+
);
|
|
2678
|
+
return {
|
|
2679
|
+
inputWrapperRef,
|
|
2680
|
+
codeMirrorUt,
|
|
2165
2681
|
resetHistory() {
|
|
2166
|
-
var
|
|
2167
|
-
(
|
|
2168
|
-
effects:
|
|
2169
|
-
})
|
|
2170
|
-
|
|
2682
|
+
var _a, _b;
|
|
2683
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
2684
|
+
effects: historyComp.reconfigure([])
|
|
2685
|
+
});
|
|
2686
|
+
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({
|
|
2687
|
+
effects: historyComp.reconfigure(history())
|
|
2171
2688
|
});
|
|
2172
2689
|
}
|
|
2173
2690
|
};
|
|
2174
|
-
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2691
|
+
};
|
|
2692
|
+
const useResize = (props2, contentRef, resizeRef) => {
|
|
2693
|
+
const state = reactive({
|
|
2694
|
+
resizedWidth: props2.inputBoxWitdh
|
|
2695
|
+
});
|
|
2696
|
+
const inputWrapperStyle = reactive({
|
|
2697
|
+
width: props2.inputBoxWitdh
|
|
2698
|
+
});
|
|
2699
|
+
const resizeOperateStyle = reactive({
|
|
2700
|
+
left: props2.inputBoxWitdh,
|
|
2181
2701
|
display: "initial"
|
|
2182
|
-
})
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2702
|
+
});
|
|
2703
|
+
const resizeMousemove = (e) => {
|
|
2704
|
+
var _a, _b, _c;
|
|
2705
|
+
const maxWidth = ((_a = contentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
|
|
2706
|
+
const contentX = ((_b = contentRef.value) == null ? void 0 : _b.getBoundingClientRect().x) || 0;
|
|
2707
|
+
let nextWidth = e.x - contentX;
|
|
2708
|
+
if (nextWidth < MinInputBoxWidth) {
|
|
2709
|
+
nextWidth = MinInputBoxWidth;
|
|
2710
|
+
} else if (nextWidth > maxWidth - MinInputBoxWidth) {
|
|
2711
|
+
nextWidth = maxWidth - MinInputBoxWidth;
|
|
2712
|
+
}
|
|
2713
|
+
const ibw = `${nextWidth}px`;
|
|
2714
|
+
inputWrapperStyle.width = ibw;
|
|
2715
|
+
resizeOperateStyle.left = ibw;
|
|
2716
|
+
state.resizedWidth = ibw;
|
|
2717
|
+
(_c = props2.onInputBoxWitdhChange) == null ? void 0 : _c.call(props2, ibw);
|
|
2718
|
+
};
|
|
2719
|
+
const resizeMousedown = () => {
|
|
2720
|
+
document.addEventListener("mousemove", resizeMousemove);
|
|
2721
|
+
};
|
|
2722
|
+
const resizeMouseup = () => {
|
|
2723
|
+
document.removeEventListener("mousemove", resizeMousemove);
|
|
2193
2724
|
};
|
|
2194
|
-
|
|
2195
|
-
var
|
|
2196
|
-
(
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
()
|
|
2202
|
-
(
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2725
|
+
onMounted(() => {
|
|
2726
|
+
var _a;
|
|
2727
|
+
(_a = resizeRef.value) == null ? void 0 : _a.addEventListener("mousedown", resizeMousedown);
|
|
2728
|
+
document.addEventListener("mouseup", resizeMouseup);
|
|
2729
|
+
});
|
|
2730
|
+
onBeforeUnmount(() => {
|
|
2731
|
+
var _a, _b;
|
|
2732
|
+
(_a = resizeRef.value) == null ? void 0 : _a.removeEventListener("mousedown", resizeMousedown);
|
|
2733
|
+
(_b = resizeRef.value) == null ? void 0 : _b.removeEventListener("mouseup", resizeMouseup);
|
|
2734
|
+
});
|
|
2735
|
+
watch(
|
|
2736
|
+
() => props2.inputBoxWitdh,
|
|
2737
|
+
(nVal) => {
|
|
2738
|
+
if (nVal) {
|
|
2739
|
+
inputWrapperStyle.width = nVal;
|
|
2740
|
+
resizeOperateStyle.left = nVal;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
);
|
|
2744
|
+
watch(
|
|
2745
|
+
[toRef(props2.setting, "htmlPreview"), toRef(props2.setting, "preview")],
|
|
2207
2746
|
() => {
|
|
2208
|
-
!
|
|
2747
|
+
if (!props2.setting.htmlPreview && !props2.setting.preview) {
|
|
2748
|
+
inputWrapperStyle.width = "100%";
|
|
2749
|
+
resizeOperateStyle.display = "none";
|
|
2750
|
+
} else {
|
|
2751
|
+
inputWrapperStyle.width = state.resizedWidth;
|
|
2752
|
+
resizeOperateStyle.display = "initial";
|
|
2753
|
+
}
|
|
2209
2754
|
},
|
|
2210
2755
|
{
|
|
2211
|
-
immediate:
|
|
2756
|
+
immediate: true
|
|
2212
2757
|
}
|
|
2213
|
-
)
|
|
2214
|
-
|
|
2758
|
+
);
|
|
2759
|
+
return { inputWrapperStyle, resizeOperateStyle };
|
|
2760
|
+
};
|
|
2761
|
+
const Content = /* @__PURE__ */ defineComponent({
|
|
2215
2762
|
name: "MDEditorContent",
|
|
2216
|
-
props:
|
|
2217
|
-
setup(
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2763
|
+
props: contentProps,
|
|
2764
|
+
setup(props2, ctx) {
|
|
2765
|
+
const editorId = inject("editorId");
|
|
2766
|
+
const html = ref("");
|
|
2767
|
+
const contentRef = ref();
|
|
2768
|
+
const resizeRef = ref();
|
|
2769
|
+
const {
|
|
2770
|
+
inputWrapperRef,
|
|
2771
|
+
codeMirrorUt,
|
|
2772
|
+
resetHistory
|
|
2773
|
+
} = useCodeMirror(props2);
|
|
2774
|
+
const {
|
|
2775
|
+
inputWrapperStyle,
|
|
2776
|
+
resizeOperateStyle
|
|
2777
|
+
} = useResize(props2, contentRef, resizeRef);
|
|
2778
|
+
useAutoScroll(props2, html, codeMirrorUt);
|
|
2779
|
+
ctx.expose({
|
|
2227
2780
|
getSelectedText() {
|
|
2228
|
-
var
|
|
2229
|
-
return (
|
|
2781
|
+
var _a;
|
|
2782
|
+
return (_a = codeMirrorUt.value) == null ? void 0 : _a.getSelectedText();
|
|
2230
2783
|
},
|
|
2231
|
-
focus(
|
|
2232
|
-
var
|
|
2233
|
-
(
|
|
2784
|
+
focus(options) {
|
|
2785
|
+
var _a;
|
|
2786
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.focus(options);
|
|
2234
2787
|
},
|
|
2235
|
-
resetHistory
|
|
2236
|
-
})
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2788
|
+
resetHistory
|
|
2789
|
+
});
|
|
2790
|
+
return () => {
|
|
2791
|
+
return createVNode("div", {
|
|
2792
|
+
"class": `${prefix}-content${props2.setting.htmlPreview || props2.setting.preview ? " has-preview" : ""}`,
|
|
2793
|
+
"ref": contentRef
|
|
2794
|
+
}, [createVNode("div", {
|
|
2795
|
+
"class": `${prefix}-input-wrapper`,
|
|
2796
|
+
"style": inputWrapperStyle,
|
|
2797
|
+
"ref": inputWrapperRef
|
|
2798
|
+
}, null), (props2.setting.htmlPreview || props2.setting.preview) && createVNode("div", {
|
|
2799
|
+
"class": `${prefix}-resize-operate`,
|
|
2800
|
+
"style": resizeOperateStyle,
|
|
2801
|
+
"ref": resizeRef
|
|
2802
|
+
}, null), createVNode(ContentPreview, {
|
|
2803
|
+
"modelValue": props2.modelValue,
|
|
2804
|
+
"setting": props2.setting,
|
|
2805
|
+
"onHtmlChanged": (html_) => {
|
|
2806
|
+
html.value = html_;
|
|
2807
|
+
props2.onHtmlChanged(html_);
|
|
2808
|
+
},
|
|
2809
|
+
"onGetCatalog": props2.onGetCatalog,
|
|
2810
|
+
"mdHeadingId": props2.mdHeadingId,
|
|
2811
|
+
"noMermaid": props2.noMermaid,
|
|
2812
|
+
"sanitize": props2.sanitize,
|
|
2813
|
+
"noKatex": props2.noKatex,
|
|
2814
|
+
"formatCopiedText": props2.formatCopiedText,
|
|
2815
|
+
"noHighlight": props2.noHighlight,
|
|
2816
|
+
"noImgZoomIn": props2.noImgZoomIn,
|
|
2817
|
+
"sanitizeMermaid": props2.sanitizeMermaid
|
|
2818
|
+
}, null), props2.catalogVisible && createVNode(MdCatalog, {
|
|
2819
|
+
"theme": props2.theme,
|
|
2820
|
+
"class": `${prefix}-catalog-editor`,
|
|
2821
|
+
"editorId": editorId,
|
|
2822
|
+
"mdHeadingId": props2.mdHeadingId,
|
|
2823
|
+
"key": "internal-catalog"
|
|
2824
|
+
}, null)]);
|
|
2825
|
+
};
|
|
2269
2826
|
}
|
|
2270
|
-
})
|
|
2827
|
+
});
|
|
2828
|
+
const MarkdownTotal = /* @__PURE__ */ defineComponent({
|
|
2271
2829
|
props: {
|
|
2272
2830
|
modelValue: {
|
|
2273
2831
|
type: String,
|
|
2274
2832
|
default: ""
|
|
2275
2833
|
}
|
|
2276
2834
|
},
|
|
2277
|
-
setup(
|
|
2278
|
-
const
|
|
2835
|
+
setup(props2) {
|
|
2836
|
+
const ult = inject("usedLanguageText");
|
|
2279
2837
|
return () => {
|
|
2280
|
-
var
|
|
2281
|
-
return
|
|
2282
|
-
class: `${
|
|
2283
|
-
}, [
|
|
2284
|
-
class: `${
|
|
2285
|
-
}, [`${(
|
|
2838
|
+
var _a, _b;
|
|
2839
|
+
return createVNode("div", {
|
|
2840
|
+
"class": `${prefix}-footer-item`
|
|
2841
|
+
}, [createVNode("label", {
|
|
2842
|
+
"class": `${prefix}-footer-label`
|
|
2843
|
+
}, [`${(_a = ult.value.footer) == null ? void 0 : _a.markdownTotal}:`]), createVNode("span", null, [((_b = props2.modelValue) == null ? void 0 : _b.length) || 0])]);
|
|
2286
2844
|
};
|
|
2287
2845
|
}
|
|
2288
|
-
})
|
|
2846
|
+
});
|
|
2847
|
+
const props$2 = {
|
|
2289
2848
|
checked: {
|
|
2290
2849
|
type: Boolean,
|
|
2291
|
-
default:
|
|
2850
|
+
default: false
|
|
2292
2851
|
},
|
|
2293
2852
|
onChange: {
|
|
2294
2853
|
type: Function,
|
|
2295
2854
|
default: () => {
|
|
2296
2855
|
}
|
|
2297
2856
|
}
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2857
|
+
};
|
|
2858
|
+
const Checkbox = /* @__PURE__ */ defineComponent({
|
|
2859
|
+
props: props$2,
|
|
2860
|
+
setup(props2) {
|
|
2861
|
+
return () => {
|
|
2862
|
+
return createVNode("div", {
|
|
2863
|
+
"class": [`${prefix}-checkbox`, props2.checked && `${prefix}-checkbox-checked`],
|
|
2864
|
+
"onClick": () => {
|
|
2865
|
+
props2.onChange(!props2.checked);
|
|
2866
|
+
}
|
|
2867
|
+
}, null);
|
|
2868
|
+
};
|
|
2307
2869
|
}
|
|
2308
|
-
})
|
|
2870
|
+
});
|
|
2871
|
+
const props$1 = {
|
|
2309
2872
|
scrollAuto: {
|
|
2310
2873
|
type: Boolean
|
|
2311
2874
|
},
|
|
@@ -2314,26 +2877,28 @@ const vo = (e) => {
|
|
|
2314
2877
|
default: () => {
|
|
2315
2878
|
}
|
|
2316
2879
|
}
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2880
|
+
};
|
|
2881
|
+
const ScrollAuto = /* @__PURE__ */ defineComponent({
|
|
2882
|
+
props: props$1,
|
|
2883
|
+
setup(props2) {
|
|
2884
|
+
const ult = inject("usedLanguageText");
|
|
2321
2885
|
return () => {
|
|
2322
|
-
var
|
|
2323
|
-
return
|
|
2324
|
-
class: `${
|
|
2325
|
-
}, [
|
|
2326
|
-
class: `${
|
|
2327
|
-
onClick: () => {
|
|
2328
|
-
|
|
2886
|
+
var _a;
|
|
2887
|
+
return createVNode("div", {
|
|
2888
|
+
"class": `${prefix}-footer-item`
|
|
2889
|
+
}, [createVNode("label", {
|
|
2890
|
+
"class": `${prefix}-footer-label`,
|
|
2891
|
+
"onClick": () => {
|
|
2892
|
+
props2.onScrollAutoChange(!props2.scrollAuto);
|
|
2329
2893
|
}
|
|
2330
|
-
}, [(
|
|
2331
|
-
checked:
|
|
2332
|
-
onChange:
|
|
2894
|
+
}, [(_a = ult.value.footer) == null ? void 0 : _a.scrollAuto]), createVNode(Checkbox, {
|
|
2895
|
+
"checked": props2.scrollAuto,
|
|
2896
|
+
"onChange": props2.onScrollAutoChange
|
|
2333
2897
|
}, null)]);
|
|
2334
2898
|
};
|
|
2335
2899
|
}
|
|
2336
|
-
})
|
|
2900
|
+
});
|
|
2901
|
+
const props = {
|
|
2337
2902
|
modelValue: {
|
|
2338
2903
|
type: String,
|
|
2339
2904
|
default: ""
|
|
@@ -2353,144 +2918,194 @@ const vo = (e) => {
|
|
|
2353
2918
|
defFooters: {
|
|
2354
2919
|
type: Object
|
|
2355
2920
|
}
|
|
2356
|
-
}
|
|
2921
|
+
};
|
|
2922
|
+
const Footer = /* @__PURE__ */ defineComponent({
|
|
2357
2923
|
name: "MDEditorFooter",
|
|
2358
|
-
props
|
|
2359
|
-
setup(
|
|
2360
|
-
const
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2924
|
+
props,
|
|
2925
|
+
setup(props2) {
|
|
2926
|
+
const splitedItems = computed(() => {
|
|
2927
|
+
const moduleSplitIndex = props2.footers.indexOf("=");
|
|
2928
|
+
const barLeft = moduleSplitIndex === -1 ? props2.footers : props2.footers.slice(0, moduleSplitIndex);
|
|
2929
|
+
const barRight = moduleSplitIndex === -1 ? [] : props2.footers.slice(moduleSplitIndex, Number.MAX_SAFE_INTEGER);
|
|
2930
|
+
return [barLeft, barRight];
|
|
2931
|
+
});
|
|
2932
|
+
const footerRender = (name) => {
|
|
2933
|
+
if (allFooter.includes(name)) {
|
|
2934
|
+
switch (name) {
|
|
2935
|
+
case "markdownTotal": {
|
|
2936
|
+
return createVNode(MarkdownTotal, {
|
|
2937
|
+
"modelValue": props2.modelValue
|
|
2369
2938
|
}, null);
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2939
|
+
}
|
|
2940
|
+
case "scrollSwitch": {
|
|
2941
|
+
return createVNode(ScrollAuto, {
|
|
2942
|
+
"scrollAuto": props2.scrollAuto,
|
|
2943
|
+
"onScrollAutoChange": props2.onScrollAutoChange
|
|
2374
2944
|
}, null);
|
|
2945
|
+
}
|
|
2375
2946
|
}
|
|
2376
|
-
else
|
|
2377
|
-
return
|
|
2947
|
+
} else if (props2.defFooters instanceof Array) {
|
|
2948
|
+
return props2.defFooters[name] || "";
|
|
2949
|
+
} else if (props2.defFooters && props2.defFooters.children instanceof Array) {
|
|
2950
|
+
return props2.defFooters.children[name] || "";
|
|
2951
|
+
} else {
|
|
2952
|
+
return "";
|
|
2953
|
+
}
|
|
2378
2954
|
};
|
|
2379
2955
|
return () => {
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2956
|
+
const LeftFooter = splitedItems.value[0].map((name) => footerRender(name));
|
|
2957
|
+
const RightFooter = splitedItems.value[1].map((name) => footerRender(name));
|
|
2958
|
+
return createVNode("div", {
|
|
2959
|
+
"class": `${prefix}-footer`
|
|
2960
|
+
}, [createVNode("div", {
|
|
2961
|
+
"class": `${prefix}-footer-left`
|
|
2962
|
+
}, [LeftFooter]), createVNode("div", {
|
|
2963
|
+
"class": `${prefix}-footer-right`
|
|
2964
|
+
}, [RightFooter])]);
|
|
2388
2965
|
};
|
|
2389
2966
|
}
|
|
2390
|
-
})
|
|
2967
|
+
});
|
|
2968
|
+
const Editor = /* @__PURE__ */ defineComponent({
|
|
2391
2969
|
name: "MdEditorV3",
|
|
2392
|
-
props:
|
|
2393
|
-
emits:
|
|
2394
|
-
setup(
|
|
2970
|
+
props: editorProps,
|
|
2971
|
+
emits: editorEmits,
|
|
2972
|
+
setup(props2, ctx) {
|
|
2395
2973
|
const {
|
|
2396
|
-
editorId
|
|
2397
|
-
noKatex
|
|
2398
|
-
noMermaid
|
|
2399
|
-
noPrettier
|
|
2400
|
-
noUploadImg
|
|
2401
|
-
noHighlight
|
|
2402
|
-
} =
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2974
|
+
editorId,
|
|
2975
|
+
noKatex,
|
|
2976
|
+
noMermaid,
|
|
2977
|
+
noPrettier,
|
|
2978
|
+
noUploadImg,
|
|
2979
|
+
noHighlight
|
|
2980
|
+
} = props2;
|
|
2981
|
+
const state = reactive({
|
|
2982
|
+
scrollAuto: props2.scrollAuto
|
|
2983
|
+
});
|
|
2984
|
+
const codeRef = ref();
|
|
2985
|
+
useOnSave(props2, ctx);
|
|
2986
|
+
useProvide(props2);
|
|
2987
|
+
useExpansion(props2);
|
|
2988
|
+
useErrorCatcher(props2, ctx);
|
|
2989
|
+
const [setting, updateSetting] = useConfig(props2, ctx);
|
|
2990
|
+
const catalogVisible = useCatalog(props2);
|
|
2991
|
+
onBeforeUnmount(() => {
|
|
2992
|
+
bus.clear(editorId);
|
|
2993
|
+
});
|
|
2994
|
+
useExpose(props2, ctx, catalogVisible, setting, updateSetting, codeRef);
|
|
2995
|
+
return () => {
|
|
2996
|
+
var _a;
|
|
2997
|
+
const defToolbars = getSlot({
|
|
2998
|
+
props: props2,
|
|
2999
|
+
ctx
|
|
3000
|
+
}, "defToolbars");
|
|
3001
|
+
const defFooters = getSlot({
|
|
3002
|
+
props: props2,
|
|
3003
|
+
ctx
|
|
2417
3004
|
}, "defFooters");
|
|
2418
|
-
return
|
|
2419
|
-
id:
|
|
2420
|
-
class: [
|
|
2421
|
-
style:
|
|
2422
|
-
}, [
|
|
2423
|
-
noPrettier:
|
|
2424
|
-
toolbars:
|
|
2425
|
-
toolbarsExclude:
|
|
2426
|
-
setting:
|
|
2427
|
-
updateSetting:
|
|
2428
|
-
tableShape:
|
|
2429
|
-
defToolbars:
|
|
2430
|
-
noUploadImg:
|
|
2431
|
-
showToolbarName:
|
|
2432
|
-
}, null),
|
|
2433
|
-
ref:
|
|
2434
|
-
modelValue:
|
|
2435
|
-
setting:
|
|
2436
|
-
mdHeadingId:
|
|
2437
|
-
noMermaid:
|
|
2438
|
-
noPrettier:
|
|
2439
|
-
sanitize:
|
|
2440
|
-
placeholder:
|
|
2441
|
-
noKatex:
|
|
2442
|
-
scrollAuto:
|
|
2443
|
-
formatCopiedText:
|
|
2444
|
-
autofocus:
|
|
2445
|
-
disabled:
|
|
2446
|
-
readonly:
|
|
2447
|
-
maxlength:
|
|
2448
|
-
autoDetectCode:
|
|
2449
|
-
noHighlight:
|
|
2450
|
-
updateModelValue: (
|
|
2451
|
-
|
|
3005
|
+
return createVNode("div", {
|
|
3006
|
+
"id": editorId,
|
|
3007
|
+
"class": [prefix, props2.class, props2.theme === "dark" && `${prefix}-dark`, setting.fullscreen || setting.pageFullscreen ? `${prefix}-fullscreen` : ""],
|
|
3008
|
+
"style": props2.style
|
|
3009
|
+
}, [createVNode(ToolBar, {
|
|
3010
|
+
"noPrettier": noPrettier,
|
|
3011
|
+
"toolbars": props2.toolbars,
|
|
3012
|
+
"toolbarsExclude": props2.toolbarsExclude,
|
|
3013
|
+
"setting": setting,
|
|
3014
|
+
"updateSetting": updateSetting,
|
|
3015
|
+
"tableShape": props2.tableShape,
|
|
3016
|
+
"defToolbars": defToolbars,
|
|
3017
|
+
"noUploadImg": noUploadImg,
|
|
3018
|
+
"showToolbarName": props2.showToolbarName
|
|
3019
|
+
}, null), createVNode(Content, {
|
|
3020
|
+
"ref": codeRef,
|
|
3021
|
+
"modelValue": props2.modelValue,
|
|
3022
|
+
"setting": setting,
|
|
3023
|
+
"mdHeadingId": props2.mdHeadingId,
|
|
3024
|
+
"noMermaid": noMermaid,
|
|
3025
|
+
"noPrettier": noPrettier,
|
|
3026
|
+
"sanitize": props2.sanitize,
|
|
3027
|
+
"placeholder": props2.placeholder,
|
|
3028
|
+
"noKatex": noKatex,
|
|
3029
|
+
"scrollAuto": state.scrollAuto,
|
|
3030
|
+
"formatCopiedText": props2.formatCopiedText,
|
|
3031
|
+
"autofocus": props2.autoFocus,
|
|
3032
|
+
"disabled": props2.disabled,
|
|
3033
|
+
"readonly": props2.readOnly,
|
|
3034
|
+
"maxlength": props2.maxLength,
|
|
3035
|
+
"autoDetectCode": props2.autoDetectCode,
|
|
3036
|
+
"noHighlight": noHighlight,
|
|
3037
|
+
"updateModelValue": (value) => {
|
|
3038
|
+
ctx.emit("update:modelValue", value);
|
|
2452
3039
|
},
|
|
2453
|
-
onChange: (
|
|
2454
|
-
|
|
3040
|
+
"onChange": (value) => {
|
|
3041
|
+
if (props2.onChange) {
|
|
3042
|
+
props2.onChange(value);
|
|
3043
|
+
}
|
|
3044
|
+
ctx.emit("onChange", value);
|
|
2455
3045
|
},
|
|
2456
|
-
onHtmlChanged: (
|
|
2457
|
-
|
|
3046
|
+
"onHtmlChanged": (html) => {
|
|
3047
|
+
if (props2.onHtmlChanged) {
|
|
3048
|
+
props2.onHtmlChanged(html);
|
|
3049
|
+
}
|
|
3050
|
+
ctx.emit("onHtmlChanged", html);
|
|
2458
3051
|
},
|
|
2459
|
-
onGetCatalog: (
|
|
2460
|
-
|
|
3052
|
+
"onGetCatalog": (list) => {
|
|
3053
|
+
if (props2.onGetCatalog) {
|
|
3054
|
+
props2.onGetCatalog(list);
|
|
3055
|
+
}
|
|
3056
|
+
ctx.emit("onGetCatalog", list);
|
|
2461
3057
|
},
|
|
2462
|
-
onBlur: (
|
|
2463
|
-
|
|
3058
|
+
"onBlur": (e) => {
|
|
3059
|
+
if (props2.onBlur) {
|
|
3060
|
+
props2.onBlur(e);
|
|
3061
|
+
}
|
|
3062
|
+
ctx.emit("onBlur", e);
|
|
2464
3063
|
},
|
|
2465
|
-
onFocus: (
|
|
2466
|
-
|
|
3064
|
+
"onFocus": (e) => {
|
|
3065
|
+
if (props2.onFocus) {
|
|
3066
|
+
props2.onFocus(e);
|
|
3067
|
+
}
|
|
3068
|
+
ctx.emit("onFocus", e);
|
|
2467
3069
|
},
|
|
2468
|
-
onInput: (
|
|
2469
|
-
|
|
3070
|
+
"onInput": (e) => {
|
|
3071
|
+
if (props2.onInput) {
|
|
3072
|
+
props2.onInput(e);
|
|
3073
|
+
}
|
|
3074
|
+
ctx.emit("onInput", e);
|
|
2470
3075
|
},
|
|
2471
|
-
completions:
|
|
2472
|
-
catalogVisible:
|
|
2473
|
-
theme:
|
|
2474
|
-
noImgZoomIn:
|
|
2475
|
-
onDrop: (
|
|
2476
|
-
|
|
3076
|
+
"completions": props2.completions,
|
|
3077
|
+
"catalogVisible": catalogVisible.value,
|
|
3078
|
+
"theme": props2.theme,
|
|
3079
|
+
"noImgZoomIn": props2.noImgZoomIn,
|
|
3080
|
+
"onDrop": (e) => {
|
|
3081
|
+
if (props2.onDrop) {
|
|
3082
|
+
props2.onDrop(e);
|
|
3083
|
+
}
|
|
3084
|
+
ctx.emit("onDrop", e);
|
|
2477
3085
|
},
|
|
2478
|
-
inputBoxWitdh:
|
|
2479
|
-
onInputBoxWitdhChange: (
|
|
2480
|
-
|
|
3086
|
+
"inputBoxWitdh": props2.inputBoxWitdh,
|
|
3087
|
+
"onInputBoxWitdhChange": (width) => {
|
|
3088
|
+
if (props2.onInputBoxWitdhChange) {
|
|
3089
|
+
props2.onInputBoxWitdhChange(width);
|
|
3090
|
+
}
|
|
3091
|
+
ctx.emit("onInputBoxWitdhChange", width);
|
|
2481
3092
|
},
|
|
2482
|
-
sanitizeMermaid:
|
|
2483
|
-
}, null), ((
|
|
2484
|
-
modelValue:
|
|
2485
|
-
footers:
|
|
2486
|
-
defFooters:
|
|
2487
|
-
scrollAuto:
|
|
2488
|
-
onScrollAutoChange: (
|
|
3093
|
+
"sanitizeMermaid": props2.sanitizeMermaid
|
|
3094
|
+
}, null), ((_a = props2.footers) == null ? void 0 : _a.length) > 0 && createVNode(Footer, {
|
|
3095
|
+
"modelValue": props2.modelValue,
|
|
3096
|
+
"footers": props2.footers,
|
|
3097
|
+
"defFooters": defFooters,
|
|
3098
|
+
"scrollAuto": state.scrollAuto,
|
|
3099
|
+
"onScrollAutoChange": (v) => state.scrollAuto = v
|
|
2489
3100
|
}, null)]);
|
|
2490
3101
|
};
|
|
2491
3102
|
}
|
|
2492
3103
|
});
|
|
2493
|
-
|
|
3104
|
+
Editor.install = (app) => {
|
|
3105
|
+
app.component(Editor.name, Editor);
|
|
3106
|
+
app.use(NormalToolbar).use(DropdownToolbar).use(ModalToolbar).use(MdCatalog).use(MdPreview);
|
|
3107
|
+
return app;
|
|
3108
|
+
};
|
|
2494
3109
|
export {
|
|
2495
|
-
|
|
3110
|
+
Editor as default
|
|
2496
3111
|
};
|