md-editor-v3 4.13.5 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -2
- package/lib/cjs/MdCatalog.cjs +14 -8
- package/lib/cjs/MdEditor.cjs +120 -85
- package/lib/cjs/ModalToolbar.cjs +3 -0
- package/lib/cjs/chunks/config.cjs +174 -16
- package/lib/cjs/chunks/dom.cjs +24 -20
- package/lib/cjs/chunks/event-name.cjs +95 -0
- package/lib/cjs/chunks/index.cjs +219 -177
- package/lib/cjs/chunks/index2.cjs +3 -0
- package/lib/cjs/chunks/index3.cjs +3 -8
- package/lib/cjs/chunks/index4.cjs +7 -94
- package/lib/cjs/config.cjs +1 -0
- package/lib/cjs/index.cjs +1 -0
- package/lib/es/MdCatalog.mjs +12 -6
- package/lib/es/MdEditor.mjs +66 -31
- package/lib/es/ModalToolbar.mjs +3 -0
- package/lib/es/chunks/config.mjs +176 -18
- package/lib/es/chunks/dom.mjs +24 -20
- package/lib/es/chunks/event-name.mjs +96 -0
- package/lib/es/chunks/index.mjs +170 -128
- package/lib/es/chunks/index2.mjs +3 -0
- package/lib/es/chunks/index3.mjs +4 -9
- package/lib/es/chunks/index4.mjs +11 -98
- package/lib/es/config.mjs +2 -1
- package/lib/es/index.mjs +2 -1
- package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +6 -0
- package/lib/types/DropdownToolbar/index.d.ts +12 -0
- package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
- package/lib/types/MdCatalog/index.d.ts +3 -3
- package/lib/types/MdEditor/Editor.d.ts +0 -3
- package/lib/types/MdEditor/config.d.ts +1 -0
- package/lib/types/MdEditor/index.d.ts +0 -7
- package/lib/types/MdEditor/props.d.ts +2 -1
- package/lib/types/MdEditor/type.d.ts +46 -0
- package/lib/types/MdEditor/utils/dom.d.ts +10 -2
- package/lib/types/MdEditor/utils/index.d.ts +4 -0
- package/lib/types/ModalToolbar/ModalToolbar.d.ts +6 -0
- package/lib/types/ModalToolbar/index.d.ts +12 -0
- package/lib/types/config.d.ts +1 -1
- package/lib/umd/index.js +41 -41
- package/package.json +2 -2
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -9,9 +9,10 @@ const vue = require("vue");
|
|
|
9
9
|
const config = require("./chunks/config.cjs");
|
|
10
10
|
const util = require("@vavt/util");
|
|
11
11
|
const DropdownToolbar = require("./chunks/index2.cjs");
|
|
12
|
-
const
|
|
12
|
+
const eventName = require("./chunks/event-name.cjs");
|
|
13
13
|
const dom = require("./chunks/dom.cjs");
|
|
14
14
|
const MdModal = require("./chunks/index3.cjs");
|
|
15
|
+
const index = require("./chunks/index4.cjs");
|
|
15
16
|
const codemirror = require("codemirror");
|
|
16
17
|
const view = require("@codemirror/view");
|
|
17
18
|
const languageData = require("@codemirror/language-data");
|
|
@@ -85,14 +86,13 @@ const toolbarProps = {
|
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
const useSreenfull = (props2) => {
|
|
88
|
-
var _a, _b, _c, _d;
|
|
89
89
|
const editorId = vue.inject("editorId");
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const { editorExtensions, editorExtensionsAttrs } = config.configOption;
|
|
91
|
+
let screenfull = editorExtensions.screenfull.instance;
|
|
92
92
|
const screenfullMe = vue.ref(false);
|
|
93
93
|
const fullscreenHandler = (status) => {
|
|
94
94
|
if (!screenfull) {
|
|
95
|
-
|
|
95
|
+
eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
|
|
96
96
|
name: "fullscreen",
|
|
97
97
|
message: "fullscreen is undefined"
|
|
98
98
|
});
|
|
@@ -125,18 +125,24 @@ const useSreenfull = (props2) => {
|
|
|
125
125
|
onScreenfullEvent();
|
|
126
126
|
};
|
|
127
127
|
vue.onMounted(() => {
|
|
128
|
+
var _a;
|
|
128
129
|
onScreenfullEvent();
|
|
129
130
|
if (!screenfull) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
dom.appendHandler(
|
|
132
|
+
"script",
|
|
133
|
+
{
|
|
134
|
+
...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
|
|
135
|
+
src: editorExtensions.screenfull.js,
|
|
136
|
+
id: `${config.prefix}-screenfull`,
|
|
137
|
+
onload: screenfullLoad
|
|
138
|
+
},
|
|
139
|
+
"screenfull"
|
|
140
|
+
);
|
|
135
141
|
}
|
|
136
142
|
});
|
|
137
143
|
vue.onMounted(() => {
|
|
138
|
-
|
|
139
|
-
name:
|
|
144
|
+
eventName.bus.on(editorId, {
|
|
145
|
+
name: eventName.CHANGE_FULL_SCREEN,
|
|
140
146
|
callback: fullscreenHandler
|
|
141
147
|
});
|
|
142
148
|
});
|
|
@@ -161,21 +167,46 @@ const TableShape = /* @__PURE__ */ vue.defineComponent({
|
|
|
161
167
|
x: -1,
|
|
162
168
|
y: -1
|
|
163
169
|
});
|
|
170
|
+
const initShape = () => {
|
|
171
|
+
const shape = [...props2.tableShape];
|
|
172
|
+
if (!shape[2] || shape[2] < shape[0]) {
|
|
173
|
+
shape[2] = shape[0];
|
|
174
|
+
}
|
|
175
|
+
if (!shape[3] || shape[3] < shape[3]) {
|
|
176
|
+
shape[3] = shape[1];
|
|
177
|
+
}
|
|
178
|
+
return shape;
|
|
179
|
+
};
|
|
180
|
+
const tableShape = vue.ref(initShape());
|
|
181
|
+
vue.watch(() => props2.tableShape, () => {
|
|
182
|
+
tableShape.value = initShape();
|
|
183
|
+
});
|
|
164
184
|
return () => vue.createVNode("div", {
|
|
165
185
|
"class": `${config.prefix}-table-shape`,
|
|
166
186
|
"onMouseleave": () => {
|
|
187
|
+
tableShape.value = initShape();
|
|
167
188
|
hoverPosition.x = -1;
|
|
168
189
|
hoverPosition.y = -1;
|
|
169
190
|
}
|
|
170
|
-
}, [new Array(
|
|
191
|
+
}, [new Array(tableShape.value[1]).fill("").map((_, rowIndex) => vue.createVNode("div", {
|
|
171
192
|
"class": `${config.prefix}-table-shape-row`,
|
|
172
193
|
"key": `table-shape-row-${rowIndex}`
|
|
173
|
-
}, [new Array(
|
|
194
|
+
}, [new Array(tableShape.value[0]).fill("").map((_2, colIndex) => vue.createVNode("div", {
|
|
174
195
|
"class": `${config.prefix}-table-shape-col`,
|
|
175
196
|
"key": `table-shape-col-${colIndex}`,
|
|
176
197
|
"onMouseenter": () => {
|
|
177
198
|
hoverPosition.x = rowIndex;
|
|
178
199
|
hoverPosition.y = colIndex;
|
|
200
|
+
if (colIndex + 1 === tableShape.value[0] && colIndex + 1 < tableShape.value[2]) {
|
|
201
|
+
tableShape.value[0]++;
|
|
202
|
+
} else if (colIndex + 2 < tableShape.value[0] && tableShape.value[0] > props2.tableShape[0]) {
|
|
203
|
+
tableShape.value[0]--;
|
|
204
|
+
}
|
|
205
|
+
if (rowIndex + 1 === tableShape.value[1] && rowIndex + 1 < tableShape.value[3]) {
|
|
206
|
+
tableShape.value[1]++;
|
|
207
|
+
} else if (rowIndex + 2 < tableShape.value[1] && tableShape.value[1] > props2.tableShape[1]) {
|
|
208
|
+
tableShape.value[1]--;
|
|
209
|
+
}
|
|
179
210
|
},
|
|
180
211
|
"onClick": () => {
|
|
181
212
|
props2.onSelected(hoverPosition);
|
|
@@ -308,10 +339,9 @@ const props$4 = {
|
|
|
308
339
|
const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
309
340
|
props: props$4,
|
|
310
341
|
setup(props2) {
|
|
311
|
-
var _a, _b, _c;
|
|
312
342
|
const ult = vue.inject("usedLanguageText");
|
|
313
343
|
const editorId = vue.inject("editorId");
|
|
314
|
-
let Cropper =
|
|
344
|
+
let Cropper = config.configOption.editorExtensions.cropper.instance;
|
|
315
345
|
const uploadRef = vue.ref();
|
|
316
346
|
const uploadImgRef = vue.ref();
|
|
317
347
|
const previewTargetRef = vue.ref();
|
|
@@ -328,7 +358,7 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
|
328
358
|
Cropper = Cropper || window.Cropper;
|
|
329
359
|
uploadRef.value.onchange = () => {
|
|
330
360
|
if (!Cropper) {
|
|
331
|
-
|
|
361
|
+
eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
|
|
332
362
|
name: "Cropper",
|
|
333
363
|
message: "Cropper is undefined"
|
|
334
364
|
});
|
|
@@ -377,10 +407,10 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
|
377
407
|
data.imgSelected = false;
|
|
378
408
|
};
|
|
379
409
|
return () => {
|
|
380
|
-
var
|
|
410
|
+
var _a;
|
|
381
411
|
return vue.createVNode(MdModal.MdModal, {
|
|
382
412
|
"class": `${config.prefix}-modal-clip`,
|
|
383
|
-
"title": (
|
|
413
|
+
"title": (_a = ult.value.clipModalTips) == null ? void 0 : _a.title,
|
|
384
414
|
"visible": props2.visible,
|
|
385
415
|
"onClose": props2.onCancel,
|
|
386
416
|
"showAdjust": true,
|
|
@@ -392,7 +422,7 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
|
392
422
|
"height": "421px"
|
|
393
423
|
}, {
|
|
394
424
|
default: () => {
|
|
395
|
-
var
|
|
425
|
+
var _a2, _b;
|
|
396
426
|
return [vue.createVNode("div", {
|
|
397
427
|
"class": `${config.prefix}-form-item ${config.prefix}-clip`
|
|
398
428
|
}, [vue.createVNode("div", {
|
|
@@ -431,11 +461,11 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
|
431
461
|
"onClick": () => {
|
|
432
462
|
if (cropper) {
|
|
433
463
|
const cvs = cropper.getCroppedCanvas();
|
|
434
|
-
|
|
464
|
+
eventName.bus.emit(editorId, eventName.UPLOAD_IMAGE, [index.base642File(cvs.toDataURL("image/png"))], props2.onOk);
|
|
435
465
|
reset();
|
|
436
466
|
}
|
|
437
467
|
}
|
|
438
|
-
}, [((
|
|
468
|
+
}, [((_a2 = ult.value.clipModalTips) == null ? void 0 : _a2.buttonUpload) || ((_b = ult.value.linkModalTips) == null ? void 0 : _b.buttonOK)])]), vue.createVNode("input", {
|
|
439
469
|
"ref": uploadRef,
|
|
440
470
|
"accept": "image/*",
|
|
441
471
|
"type": "file",
|
|
@@ -514,7 +544,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
514
544
|
katex: false
|
|
515
545
|
});
|
|
516
546
|
const emitHandler = (direct, params) => {
|
|
517
|
-
|
|
547
|
+
eventName.bus.emit(editorId, eventName.REPLACE, direct, params);
|
|
518
548
|
};
|
|
519
549
|
const modalData = vue.reactive({
|
|
520
550
|
type: "link",
|
|
@@ -523,8 +553,8 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
523
553
|
});
|
|
524
554
|
const toolbarLeftRef = vue.ref();
|
|
525
555
|
vue.onMounted(() => {
|
|
526
|
-
|
|
527
|
-
name:
|
|
556
|
+
eventName.bus.on(editorId, {
|
|
557
|
+
name: eventName.OPEN_MODALS,
|
|
528
558
|
callback(type) {
|
|
529
559
|
modalData.type = type;
|
|
530
560
|
modalData.linkVisible = true;
|
|
@@ -540,7 +570,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
540
570
|
});
|
|
541
571
|
const uploadRef = vue.ref();
|
|
542
572
|
const uploadHandler = () => {
|
|
543
|
-
|
|
573
|
+
eventName.bus.emit(editorId, eventName.UPLOAD_IMAGE, Array.from(uploadRef.value.files || []));
|
|
544
574
|
uploadRef.value.value = "";
|
|
545
575
|
};
|
|
546
576
|
vue.onMounted(() => {
|
|
@@ -869,7 +899,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
869
899
|
"class": `${config.prefix}-toolbar-item`,
|
|
870
900
|
"title": (_L = ult.value.toolbarTips) == null ? void 0 : _L.revoke,
|
|
871
901
|
"onClick": () => {
|
|
872
|
-
|
|
902
|
+
eventName.bus.emit(editorId, eventName.CTRL_Z);
|
|
873
903
|
}
|
|
874
904
|
}, [vue.createVNode(MdModal.Icon, {
|
|
875
905
|
"name": "revoke"
|
|
@@ -882,7 +912,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
882
912
|
"class": `${config.prefix}-toolbar-item`,
|
|
883
913
|
"title": (_N = ult.value.toolbarTips) == null ? void 0 : _N.next,
|
|
884
914
|
"onClick": () => {
|
|
885
|
-
|
|
915
|
+
eventName.bus.emit(editorId, eventName.CTRL_SHIFT_Z);
|
|
886
916
|
}
|
|
887
917
|
}, [vue.createVNode(MdModal.Icon, {
|
|
888
918
|
"name": "next"
|
|
@@ -895,7 +925,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
895
925
|
"class": `${config.prefix}-toolbar-item`,
|
|
896
926
|
"title": (_P = ult.value.toolbarTips) == null ? void 0 : _P.save,
|
|
897
927
|
"onClick": () => {
|
|
898
|
-
|
|
928
|
+
eventName.bus.emit(editorId, eventName.ON_SAVE);
|
|
899
929
|
}
|
|
900
930
|
}, [vue.createVNode(MdModal.Icon, {
|
|
901
931
|
"name": "baocun"
|
|
@@ -986,7 +1016,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
986
1016
|
"class": `${config.prefix}-toolbar-item`,
|
|
987
1017
|
"title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.catalog,
|
|
988
1018
|
"onClick": () => {
|
|
989
|
-
|
|
1019
|
+
eventName.bus.emit(editorId, eventName.CHANGE_CATALOG_VISIBLE);
|
|
990
1020
|
},
|
|
991
1021
|
"key": "bar-catalog"
|
|
992
1022
|
}, [vue.createVNode(MdModal.Icon, {
|
|
@@ -1121,7 +1151,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
1121
1151
|
previewTheme: previewTheme.value,
|
|
1122
1152
|
language: language2.value,
|
|
1123
1153
|
insert(generate) {
|
|
1124
|
-
|
|
1154
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
|
|
1125
1155
|
generate
|
|
1126
1156
|
});
|
|
1127
1157
|
}
|
|
@@ -1137,7 +1167,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
1137
1167
|
previewTheme: previewTheme.value,
|
|
1138
1168
|
language: language2.value,
|
|
1139
1169
|
insert(generate) {
|
|
1140
|
-
|
|
1170
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
|
|
1141
1171
|
generate
|
|
1142
1172
|
});
|
|
1143
1173
|
}
|
|
@@ -1509,14 +1539,14 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
1509
1539
|
vue.onMounted(rebindEvent);
|
|
1510
1540
|
};
|
|
1511
1541
|
const directive2flag = (direct, codeMirrorUt, params) => {
|
|
1512
|
-
var _a
|
|
1542
|
+
var _a;
|
|
1513
1543
|
let targetValue = "";
|
|
1514
1544
|
let deviationStart = 0;
|
|
1515
1545
|
let deviationEnd = 0;
|
|
1516
1546
|
let select = true;
|
|
1517
1547
|
let replaceAll = false;
|
|
1518
1548
|
const selectedText = codeMirrorUt.getSelectedText();
|
|
1519
|
-
const mermaidTemplate =
|
|
1549
|
+
const mermaidTemplate = config.configOption.editorConfig.mermaidTemplate;
|
|
1520
1550
|
if (/^h[1-6]{1}$/.test(direct)) {
|
|
1521
1551
|
const pix = direct.replace(/^h(\d)/, (_, num) => {
|
|
1522
1552
|
return new Array(Number(num)).fill("#", 0, num).join("");
|
|
@@ -1524,12 +1554,12 @@ const directive2flag = (direct, codeMirrorUt, params) => {
|
|
|
1524
1554
|
targetValue = `${pix} ${selectedText}`;
|
|
1525
1555
|
deviationStart = pix.length + 1;
|
|
1526
1556
|
} else if (direct === "prettier") {
|
|
1527
|
-
const prettier = window.prettier ||
|
|
1557
|
+
const prettier = window.prettier || config.configOption.editorExtensions.prettier.prettierInstance;
|
|
1528
1558
|
const prettierPlugins = [
|
|
1529
|
-
((
|
|
1559
|
+
((_a = window.prettierPlugins) == null ? void 0 : _a.markdown) || config.configOption.editorExtensions.prettier.parserMarkdownInstance
|
|
1530
1560
|
];
|
|
1531
1561
|
if (!prettier || prettierPlugins[0] === void 0) {
|
|
1532
|
-
|
|
1562
|
+
eventName.bus.emit(params.editorId, eventName.ERROR_CATCHER, {
|
|
1533
1563
|
name: "prettier",
|
|
1534
1564
|
message: "prettier is undefined"
|
|
1535
1565
|
});
|
|
@@ -2212,7 +2242,7 @@ class CodeMirrorUt {
|
|
|
2212
2242
|
this.view.focus();
|
|
2213
2243
|
} catch (e) {
|
|
2214
2244
|
if (e.message === "The input text is too long") {
|
|
2215
|
-
|
|
2245
|
+
eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
|
|
2216
2246
|
name: "overlength",
|
|
2217
2247
|
message: e.message,
|
|
2218
2248
|
data: text
|
|
@@ -2292,7 +2322,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
|
|
|
2292
2322
|
const imgInsert = (tv) => {
|
|
2293
2323
|
if (tv instanceof Promise) {
|
|
2294
2324
|
tv.then((targetValue) => {
|
|
2295
|
-
|
|
2325
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
|
|
2296
2326
|
generate() {
|
|
2297
2327
|
return {
|
|
2298
2328
|
targetValue
|
|
@@ -2303,7 +2333,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
|
|
|
2303
2333
|
console.error(err);
|
|
2304
2334
|
});
|
|
2305
2335
|
} else {
|
|
2306
|
-
|
|
2336
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
|
|
2307
2337
|
generate() {
|
|
2308
2338
|
return {
|
|
2309
2339
|
targetValue: tv
|
|
@@ -2319,9 +2349,9 @@ const usePasteUpload = (props2, codeMirrorUt) => {
|
|
|
2319
2349
|
}
|
|
2320
2350
|
if (e.clipboardData.files.length > 0) {
|
|
2321
2351
|
const { files } = e.clipboardData;
|
|
2322
|
-
|
|
2352
|
+
eventName.bus.emit(
|
|
2323
2353
|
editorId,
|
|
2324
|
-
|
|
2354
|
+
eventName.UPLOAD_IMAGE,
|
|
2325
2355
|
Array.from(files).filter((file) => {
|
|
2326
2356
|
return /image\/.*/.test(file.type);
|
|
2327
2357
|
})
|
|
@@ -2362,7 +2392,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
|
|
|
2362
2392
|
}
|
|
2363
2393
|
if (props2.autoDetectCode && e.clipboardData.types.includes("vscode-editor-data")) {
|
|
2364
2394
|
const vscCoodInfo = JSON.parse(e.clipboardData.getData("vscode-editor-data"));
|
|
2365
|
-
|
|
2395
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "code", {
|
|
2366
2396
|
mode: vscCoodInfo.mode,
|
|
2367
2397
|
text: e.clipboardData.getData("text/plain")
|
|
2368
2398
|
});
|
|
@@ -2370,7 +2400,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
|
|
|
2370
2400
|
return;
|
|
2371
2401
|
}
|
|
2372
2402
|
if (props2.maxlength && targetValue.length + props2.modelValue.length > props2.maxlength) {
|
|
2373
|
-
|
|
2403
|
+
eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
|
|
2374
2404
|
name: "overlength",
|
|
2375
2405
|
message: "The input text is too long",
|
|
2376
2406
|
data: targetValue
|
|
@@ -2384,7 +2414,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2384
2414
|
key: "Ctrl-b",
|
|
2385
2415
|
mac: "Cmd-b",
|
|
2386
2416
|
run: () => {
|
|
2387
|
-
|
|
2417
|
+
eventName.bus.emit(id, eventName.REPLACE, "bold");
|
|
2388
2418
|
return true;
|
|
2389
2419
|
}
|
|
2390
2420
|
};
|
|
@@ -2392,11 +2422,11 @@ const createCommands = (id, contentProps) => {
|
|
|
2392
2422
|
key: "Ctrl-s",
|
|
2393
2423
|
mac: "Cmd-s",
|
|
2394
2424
|
run: (view2) => {
|
|
2395
|
-
|
|
2425
|
+
eventName.bus.emit(id, eventName.ON_SAVE, view2.state.doc.toString());
|
|
2396
2426
|
return true;
|
|
2397
2427
|
},
|
|
2398
2428
|
shift: () => {
|
|
2399
|
-
|
|
2429
|
+
eventName.bus.emit(id, eventName.REPLACE, "strikeThrough");
|
|
2400
2430
|
return true;
|
|
2401
2431
|
}
|
|
2402
2432
|
};
|
|
@@ -2404,11 +2434,11 @@ const createCommands = (id, contentProps) => {
|
|
|
2404
2434
|
key: "Ctrl-u",
|
|
2405
2435
|
mac: "Cmd-u",
|
|
2406
2436
|
run: () => {
|
|
2407
|
-
|
|
2437
|
+
eventName.bus.emit(id, eventName.REPLACE, "underline");
|
|
2408
2438
|
return true;
|
|
2409
2439
|
},
|
|
2410
2440
|
shift: () => {
|
|
2411
|
-
|
|
2441
|
+
eventName.bus.emit(id, eventName.REPLACE, "unorderedList");
|
|
2412
2442
|
return true;
|
|
2413
2443
|
}
|
|
2414
2444
|
};
|
|
@@ -2416,11 +2446,11 @@ const createCommands = (id, contentProps) => {
|
|
|
2416
2446
|
key: "Ctrl-i",
|
|
2417
2447
|
mac: "Cmd-i",
|
|
2418
2448
|
run: () => {
|
|
2419
|
-
|
|
2449
|
+
eventName.bus.emit(id, eventName.REPLACE, "italic");
|
|
2420
2450
|
return true;
|
|
2421
2451
|
},
|
|
2422
2452
|
shift: () => {
|
|
2423
|
-
|
|
2453
|
+
eventName.bus.emit(id, eventName.OPEN_MODALS, "image");
|
|
2424
2454
|
return true;
|
|
2425
2455
|
}
|
|
2426
2456
|
};
|
|
@@ -2428,7 +2458,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2428
2458
|
key: "Ctrl-1",
|
|
2429
2459
|
mac: "Cmd-1",
|
|
2430
2460
|
run: () => {
|
|
2431
|
-
|
|
2461
|
+
eventName.bus.emit(id, eventName.REPLACE, "h1");
|
|
2432
2462
|
return true;
|
|
2433
2463
|
}
|
|
2434
2464
|
};
|
|
@@ -2436,7 +2466,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2436
2466
|
key: "Ctrl-2",
|
|
2437
2467
|
mac: "Cmd-2",
|
|
2438
2468
|
run: () => {
|
|
2439
|
-
|
|
2469
|
+
eventName.bus.emit(id, eventName.REPLACE, "h2");
|
|
2440
2470
|
return true;
|
|
2441
2471
|
}
|
|
2442
2472
|
};
|
|
@@ -2444,7 +2474,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2444
2474
|
key: "Ctrl-3",
|
|
2445
2475
|
mac: "Cmd-3",
|
|
2446
2476
|
run: () => {
|
|
2447
|
-
|
|
2477
|
+
eventName.bus.emit(id, eventName.REPLACE, "h3");
|
|
2448
2478
|
return true;
|
|
2449
2479
|
}
|
|
2450
2480
|
};
|
|
@@ -2452,7 +2482,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2452
2482
|
key: "Ctrl-4",
|
|
2453
2483
|
mac: "Cmd-4",
|
|
2454
2484
|
run: () => {
|
|
2455
|
-
|
|
2485
|
+
eventName.bus.emit(id, eventName.REPLACE, "h4");
|
|
2456
2486
|
return true;
|
|
2457
2487
|
}
|
|
2458
2488
|
};
|
|
@@ -2460,7 +2490,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2460
2490
|
key: "Ctrl-5",
|
|
2461
2491
|
mac: "Cmd-5",
|
|
2462
2492
|
run: () => {
|
|
2463
|
-
|
|
2493
|
+
eventName.bus.emit(id, eventName.REPLACE, "h5");
|
|
2464
2494
|
return true;
|
|
2465
2495
|
}
|
|
2466
2496
|
};
|
|
@@ -2468,7 +2498,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2468
2498
|
key: "Ctrl-6",
|
|
2469
2499
|
mac: "Cmd-6",
|
|
2470
2500
|
run: () => {
|
|
2471
|
-
|
|
2501
|
+
eventName.bus.emit(id, eventName.REPLACE, "h6");
|
|
2472
2502
|
return true;
|
|
2473
2503
|
}
|
|
2474
2504
|
};
|
|
@@ -2476,7 +2506,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2476
2506
|
key: "Ctrl-ArrowUp",
|
|
2477
2507
|
mac: "Cmd-ArrowUp",
|
|
2478
2508
|
run: () => {
|
|
2479
|
-
|
|
2509
|
+
eventName.bus.emit(id, eventName.REPLACE, "sup");
|
|
2480
2510
|
return true;
|
|
2481
2511
|
}
|
|
2482
2512
|
};
|
|
@@ -2484,7 +2514,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2484
2514
|
key: "Ctrl-ArrowDown",
|
|
2485
2515
|
mac: "Cmd-ArrowDown",
|
|
2486
2516
|
run: () => {
|
|
2487
|
-
|
|
2517
|
+
eventName.bus.emit(id, eventName.REPLACE, "sub");
|
|
2488
2518
|
return true;
|
|
2489
2519
|
}
|
|
2490
2520
|
};
|
|
@@ -2492,7 +2522,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2492
2522
|
key: "Ctrl-o",
|
|
2493
2523
|
mac: "Cmd-o",
|
|
2494
2524
|
run: () => {
|
|
2495
|
-
|
|
2525
|
+
eventName.bus.emit(id, eventName.REPLACE, "orderedList");
|
|
2496
2526
|
return true;
|
|
2497
2527
|
}
|
|
2498
2528
|
};
|
|
@@ -2500,12 +2530,12 @@ const createCommands = (id, contentProps) => {
|
|
|
2500
2530
|
key: "Ctrl-c",
|
|
2501
2531
|
mac: "Cmd-c",
|
|
2502
2532
|
shift: () => {
|
|
2503
|
-
|
|
2533
|
+
eventName.bus.emit(id, eventName.REPLACE, "code");
|
|
2504
2534
|
return true;
|
|
2505
2535
|
},
|
|
2506
2536
|
any(_view, e) {
|
|
2507
2537
|
if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === "KeyC") {
|
|
2508
|
-
|
|
2538
|
+
eventName.bus.emit(id, eventName.REPLACE, "codeRow");
|
|
2509
2539
|
return true;
|
|
2510
2540
|
}
|
|
2511
2541
|
return false;
|
|
@@ -2515,7 +2545,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2515
2545
|
key: "Ctrl-l",
|
|
2516
2546
|
mac: "Cmd-l",
|
|
2517
2547
|
run: () => {
|
|
2518
|
-
|
|
2548
|
+
eventName.bus.emit(id, eventName.OPEN_MODALS, "link");
|
|
2519
2549
|
return true;
|
|
2520
2550
|
}
|
|
2521
2551
|
};
|
|
@@ -2524,7 +2554,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2524
2554
|
mac: "Cmd-f",
|
|
2525
2555
|
shift: () => {
|
|
2526
2556
|
if (!contentProps.noPrettier) {
|
|
2527
|
-
|
|
2557
|
+
eventName.bus.emit(id, eventName.REPLACE, "prettier");
|
|
2528
2558
|
return true;
|
|
2529
2559
|
}
|
|
2530
2560
|
return false;
|
|
@@ -2533,7 +2563,7 @@ const createCommands = (id, contentProps) => {
|
|
|
2533
2563
|
const CtrlT = {
|
|
2534
2564
|
any: (_view, e) => {
|
|
2535
2565
|
if ((e.ctrlKey || e.metaKey) && e.altKey && e.shiftKey && e.code === "KeyT") {
|
|
2536
|
-
|
|
2566
|
+
eventName.bus.emit(id, eventName.REPLACE, "table");
|
|
2537
2567
|
return true;
|
|
2538
2568
|
}
|
|
2539
2569
|
return false;
|
|
@@ -2595,7 +2625,7 @@ const useCodeMirror = (props2) => {
|
|
|
2595
2625
|
}
|
|
2596
2626
|
const { data } = e;
|
|
2597
2627
|
if (props2.maxlength && props2.modelValue.length + data.length > props2.maxlength) {
|
|
2598
|
-
|
|
2628
|
+
eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
|
|
2599
2629
|
name: "overlength",
|
|
2600
2630
|
message: "The input text is too long",
|
|
2601
2631
|
data
|
|
@@ -2645,20 +2675,20 @@ const useCodeMirror = (props2) => {
|
|
|
2645
2675
|
typeof props2.maxlength === "number" && nc.setMaxLength(props2.maxlength);
|
|
2646
2676
|
props2.autofocus && view2.focus();
|
|
2647
2677
|
}, 0);
|
|
2648
|
-
|
|
2649
|
-
name:
|
|
2678
|
+
eventName.bus.on(editorId, {
|
|
2679
|
+
name: eventName.CTRL_Z,
|
|
2650
2680
|
callback() {
|
|
2651
2681
|
commands.undo(view2);
|
|
2652
2682
|
}
|
|
2653
2683
|
});
|
|
2654
|
-
|
|
2655
|
-
name:
|
|
2684
|
+
eventName.bus.on(editorId, {
|
|
2685
|
+
name: eventName.CTRL_SHIFT_Z,
|
|
2656
2686
|
callback() {
|
|
2657
2687
|
commands.redo(view2);
|
|
2658
2688
|
}
|
|
2659
2689
|
});
|
|
2660
|
-
|
|
2661
|
-
name:
|
|
2690
|
+
eventName.bus.on(editorId, {
|
|
2691
|
+
name: eventName.REPLACE,
|
|
2662
2692
|
callback(direct, params = {}) {
|
|
2663
2693
|
var _a, _b;
|
|
2664
2694
|
if (direct === "image" && params.transform) {
|
|
@@ -2687,16 +2717,16 @@ const useCodeMirror = (props2) => {
|
|
|
2687
2717
|
}
|
|
2688
2718
|
}
|
|
2689
2719
|
});
|
|
2690
|
-
|
|
2691
|
-
name:
|
|
2720
|
+
eventName.bus.on(editorId, {
|
|
2721
|
+
name: eventName.EVENT_LISTENER,
|
|
2692
2722
|
callback: util.throttle((handlers) => {
|
|
2693
2723
|
var _a;
|
|
2694
2724
|
const nextDomEventHandlers = {
|
|
2695
2725
|
...domEventHandlers
|
|
2696
2726
|
};
|
|
2697
2727
|
const defaultEventNames = Object.keys(domEventHandlers);
|
|
2698
|
-
for (const
|
|
2699
|
-
const en =
|
|
2728
|
+
for (const eventName2 in handlers) {
|
|
2729
|
+
const en = eventName2;
|
|
2700
2730
|
if (defaultEventNames.includes(en)) {
|
|
2701
2731
|
nextDomEventHandlers[en] = (e, v) => {
|
|
2702
2732
|
handlers[en](e, v);
|
|
@@ -2826,11 +2856,17 @@ const useResize = (props2, contentRef, resizeRef) => {
|
|
|
2826
2856
|
const resizeMouseup = () => {
|
|
2827
2857
|
document.removeEventListener("mousemove", resizeMousemove);
|
|
2828
2858
|
};
|
|
2829
|
-
vue.
|
|
2830
|
-
|
|
2831
|
-
(
|
|
2832
|
-
|
|
2833
|
-
|
|
2859
|
+
vue.watch(
|
|
2860
|
+
[resizeRef],
|
|
2861
|
+
() => {
|
|
2862
|
+
var _a, _b;
|
|
2863
|
+
(_a = resizeRef.value) == null ? void 0 : _a.addEventListener("mousedown", resizeMousedown);
|
|
2864
|
+
(_b = resizeRef.value) == null ? void 0 : _b.addEventListener("mouseup", resizeMouseup);
|
|
2865
|
+
},
|
|
2866
|
+
{
|
|
2867
|
+
immediate: true
|
|
2868
|
+
}
|
|
2869
|
+
);
|
|
2834
2870
|
vue.onBeforeUnmount(() => {
|
|
2835
2871
|
var _a, _b;
|
|
2836
2872
|
(_a = resizeRef.value) == null ? void 0 : _a.removeEventListener("mousedown", resizeMousedown);
|
|
@@ -3105,11 +3141,10 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
|
3105
3141
|
const [setting, updateSetting] = MdPreview.useConfig(props2, ctx);
|
|
3106
3142
|
const catalogVisible = MdPreview.useCatalog(props2);
|
|
3107
3143
|
vue.onBeforeUnmount(() => {
|
|
3108
|
-
|
|
3144
|
+
eventName.bus.clear(editorId);
|
|
3109
3145
|
});
|
|
3110
3146
|
MdPreview.useExpose(props2, ctx, catalogVisible, setting, updateSetting, codeRef);
|
|
3111
3147
|
return () => {
|
|
3112
|
-
var _a;
|
|
3113
3148
|
const defToolbars = vueTsx.getSlot({
|
|
3114
3149
|
props: props2,
|
|
3115
3150
|
ctx
|
|
@@ -3122,7 +3157,7 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
|
3122
3157
|
"id": editorId,
|
|
3123
3158
|
"class": [config.prefix, props2.class, props2.theme === "dark" && `${config.prefix}-dark`, setting.fullscreen || setting.pageFullscreen ? `${config.prefix}-fullscreen` : ""],
|
|
3124
3159
|
"style": props2.style
|
|
3125
|
-
}, [vue.createVNode(ToolBar, {
|
|
3160
|
+
}, [props2.toolbars.length > 0 && vue.createVNode(ToolBar, {
|
|
3126
3161
|
"noPrettier": noPrettier,
|
|
3127
3162
|
"toolbars": props2.toolbars,
|
|
3128
3163
|
"toolbarsExclude": props2.toolbarsExclude,
|
|
@@ -3208,7 +3243,7 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
|
3208
3243
|
},
|
|
3209
3244
|
"sanitizeMermaid": props2.sanitizeMermaid,
|
|
3210
3245
|
"transformImgUrl": props2.transformImgUrl
|
|
3211
|
-
}, null),
|
|
3246
|
+
}, null), props2.footers.length > 0 && vue.createVNode(Footer, {
|
|
3212
3247
|
"modelValue": props2.modelValue,
|
|
3213
3248
|
"footers": props2.footers,
|
|
3214
3249
|
"defFooters": defFooters,
|