md-editor-v3 4.13.5 → 4.14.0-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.
Files changed (41) hide show
  1. package/README.md +18 -2
  2. package/lib/cjs/MdCatalog.cjs +14 -8
  3. package/lib/cjs/MdEditor.cjs +105 -79
  4. package/lib/cjs/ModalToolbar.cjs +3 -0
  5. package/lib/cjs/chunks/config.cjs +174 -16
  6. package/lib/cjs/chunks/dom.cjs +14 -5
  7. package/lib/cjs/chunks/event-name.cjs +95 -0
  8. package/lib/cjs/chunks/index.cjs +207 -165
  9. package/lib/cjs/chunks/index2.cjs +3 -0
  10. package/lib/cjs/chunks/index3.cjs +3 -8
  11. package/lib/cjs/chunks/index4.cjs +7 -94
  12. package/lib/cjs/config.cjs +1 -0
  13. package/lib/cjs/index.cjs +1 -0
  14. package/lib/es/MdCatalog.mjs +12 -6
  15. package/lib/es/MdEditor.mjs +52 -26
  16. package/lib/es/ModalToolbar.mjs +3 -0
  17. package/lib/es/chunks/config.mjs +176 -18
  18. package/lib/es/chunks/dom.mjs +14 -5
  19. package/lib/es/chunks/event-name.mjs +96 -0
  20. package/lib/es/chunks/index.mjs +159 -117
  21. package/lib/es/chunks/index2.mjs +3 -0
  22. package/lib/es/chunks/index3.mjs +4 -9
  23. package/lib/es/chunks/index4.mjs +11 -98
  24. package/lib/es/config.mjs +2 -1
  25. package/lib/es/index.mjs +2 -1
  26. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +6 -0
  27. package/lib/types/DropdownToolbar/index.d.ts +12 -0
  28. package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
  29. package/lib/types/MdCatalog/index.d.ts +3 -3
  30. package/lib/types/MdEditor/Editor.d.ts +0 -3
  31. package/lib/types/MdEditor/config.d.ts +1 -0
  32. package/lib/types/MdEditor/index.d.ts +0 -7
  33. package/lib/types/MdEditor/props.d.ts +2 -1
  34. package/lib/types/MdEditor/type.d.ts +46 -0
  35. package/lib/types/MdEditor/utils/dom.d.ts +9 -1
  36. package/lib/types/MdEditor/utils/index.d.ts +4 -0
  37. package/lib/types/ModalToolbar/ModalToolbar.d.ts +6 -0
  38. package/lib/types/ModalToolbar/index.d.ts +12 -0
  39. package/lib/types/config.d.ts +1 -1
  40. package/lib/umd/index.js +43 -43
  41. package/package.json +2 -2
package/README.md CHANGED
@@ -138,7 +138,7 @@ Except for the same as `MdPreview`:
138
138
  | toolbarsExclude | `Array<ToolbarNames \| number>` | [] | Don't show contents of toolbar, all keys`toolbars` |
139
139
  | noPrettier | `boolean` | false | Use prettier to beautify content or not |
140
140
  | tabWidth | `number` | 2 | One tab eq some spaces |
141
- | tableShape | `[number, number]` | [6, 4] | Preset the size of the table, [columns, rows] |
141
+ | tableShape | `[number, number] \| [number, number, number, number]` | [6, 4] | Preset the size of the table, [columns, rows, Maximum number of columns, Maximum number of rows] |
142
142
  | placeholder | `string` | '' | |
143
143
  | footers | `Array<'markdownTotal' \| '=' \| 'scrollSwitch' \| number>` | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by `'='`. Set it to `[]` to hidden footer |
144
144
  | scrollAuto | `boolean` | true | Scroll default setting |
@@ -658,7 +658,9 @@ config({
658
658
  ...more
659
659
  },
660
660
  // Default 500ms. It is set to 0ms when preview only and not set.
661
- renderDelay: 500
661
+ renderDelay: 500,
662
+ // for modal component
663
+ zIndex: 2000
662
664
  }
663
665
  });
664
666
  ```
@@ -718,6 +720,20 @@ export interface EditorExtensions {
718
720
 
719
721
  </details>
720
722
 
723
+ ### editorExtensionsAttrs
724
+
725
+ Synchronously add attributes to the CDN link tags, consistent with the type of `editorExtensions`, with a value type of `HTMLElementTagNameMap['tagName']`.
726
+
727
+ ```js
728
+ import { config, editorExtensionsAttrs } from 'md-editor-rt';
729
+
730
+ config({
731
+ editorExtensionsAttrs
732
+ });
733
+ ```
734
+
735
+ Do not attempt to define the src \ onload \ id of the script and rel \ href \ id of the link in editorExtensionsAttrs, as they will be overwritten by default values
736
+
721
737
  ### 🫨 iconfontType
722
738
 
723
739
  Set the way to display icons:
@@ -2,6 +2,7 @@
2
2
  const vue = require("vue");
3
3
  const config = require("./chunks/config.cjs");
4
4
  const index = require("./chunks/index4.cjs");
5
+ const eventName = require("./chunks/event-name.cjs");
5
6
  const props$1 = {
6
7
  tocItem: {
7
8
  type: Object,
@@ -225,18 +226,23 @@ const MdCatalog = /* @__PURE__ */ vue.defineComponent({
225
226
  }
226
227
  });
227
228
  vue.onMounted(() => {
228
- const scrollElement = getScrollElement();
229
- const eventEle = scrollElement === document.documentElement ? window : scrollElement;
230
- eventEle == null ? void 0 : eventEle.addEventListener("scroll", scrollHandler);
231
- index.bus.on(editorId, {
232
- name: index.CATALOG_CHANGED,
229
+ let scrollContainer = window;
230
+ const findScrollContainer = () => {
231
+ const scrollElement_ = getScrollElement();
232
+ scrollContainer = scrollElement_ === document.documentElement ? window : scrollElement_;
233
+ };
234
+ eventName.bus.on(editorId, {
235
+ name: eventName.CATALOG_CHANGED,
233
236
  callback: (_list) => {
234
- eventEle == null ? void 0 : eventEle.removeEventListener("scroll", scrollHandler);
237
+ scrollContainer == null ? void 0 : scrollContainer.removeEventListener("scroll", scrollHandler);
235
238
  findActiveHeading(_list);
236
- eventEle == null ? void 0 : eventEle.addEventListener("scroll", scrollHandler);
239
+ findScrollContainer();
240
+ scrollContainer == null ? void 0 : scrollContainer.addEventListener("scroll", scrollHandler);
237
241
  }
238
242
  });
239
- index.bus.emit(editorId, index.PUSH_CATALOG);
243
+ eventName.bus.emit(editorId, eventName.PUSH_CATALOG);
244
+ findScrollContainer();
245
+ scrollContainer == null ? void 0 : scrollContainer.addEventListener("scroll", scrollHandler);
240
246
  });
241
247
  vue.onBeforeUnmount(() => {
242
248
  var _a;
@@ -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 index = require("./chunks/index4.cjs");
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
- let screenfull = (_b = (_a = config.configOption.editorExtensions) == null ? void 0 : _a.screenfull) == null ? void 0 : _b.instance;
91
- const screenfullJs = (_d = (_c = config.configOption.editorExtensions) == null ? void 0 : _c.screenfull) == null ? void 0 : _d.js;
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
- index.bus.emit(editorId, index.ERROR_CATCHER, {
95
+ eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
96
96
  name: "fullscreen",
97
97
  message: "fullscreen is undefined"
98
98
  });
@@ -125,18 +125,21 @@ const useSreenfull = (props2) => {
125
125
  onScreenfullEvent();
126
126
  };
127
127
  vue.onMounted(() => {
128
+ var _a;
128
129
  onScreenfullEvent();
129
130
  if (!screenfull) {
130
- const screenScript = document.createElement("script");
131
- screenScript.src = screenfullJs || config.screenfullUrl;
132
- screenScript.onload = screenfullLoad;
133
- screenScript.id = `${config.prefix}-screenfull`;
131
+ const screenScript = dom.createHTMLElement("script", {
132
+ ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
133
+ src: editorExtensions.screenfull.js,
134
+ id: `${config.prefix}-screenfull`,
135
+ onload: screenfullLoad
136
+ });
134
137
  dom.appendHandler(screenScript, "screenfull");
135
138
  }
136
139
  });
137
140
  vue.onMounted(() => {
138
- index.bus.on(editorId, {
139
- name: index.CHANGE_FULL_SCREEN,
141
+ eventName.bus.on(editorId, {
142
+ name: eventName.CHANGE_FULL_SCREEN,
140
143
  callback: fullscreenHandler
141
144
  });
142
145
  });
@@ -161,21 +164,46 @@ const TableShape = /* @__PURE__ */ vue.defineComponent({
161
164
  x: -1,
162
165
  y: -1
163
166
  });
167
+ const initShape = () => {
168
+ const shape = [...props2.tableShape];
169
+ if (!shape[2] || shape[2] < shape[0]) {
170
+ shape[2] = shape[0];
171
+ }
172
+ if (!shape[3] || shape[3] < shape[3]) {
173
+ shape[3] = shape[1];
174
+ }
175
+ return shape;
176
+ };
177
+ const tableShape = vue.ref(initShape());
178
+ vue.watch(() => props2.tableShape, () => {
179
+ tableShape.value = initShape();
180
+ });
164
181
  return () => vue.createVNode("div", {
165
182
  "class": `${config.prefix}-table-shape`,
166
183
  "onMouseleave": () => {
184
+ tableShape.value = initShape();
167
185
  hoverPosition.x = -1;
168
186
  hoverPosition.y = -1;
169
187
  }
170
- }, [new Array(props2.tableShape[1]).fill("").map((_, rowIndex) => vue.createVNode("div", {
188
+ }, [new Array(tableShape.value[1]).fill("").map((_, rowIndex) => vue.createVNode("div", {
171
189
  "class": `${config.prefix}-table-shape-row`,
172
190
  "key": `table-shape-row-${rowIndex}`
173
- }, [new Array(props2.tableShape[0]).fill("").map((_2, colIndex) => vue.createVNode("div", {
191
+ }, [new Array(tableShape.value[0]).fill("").map((_2, colIndex) => vue.createVNode("div", {
174
192
  "class": `${config.prefix}-table-shape-col`,
175
193
  "key": `table-shape-col-${colIndex}`,
176
194
  "onMouseenter": () => {
177
195
  hoverPosition.x = rowIndex;
178
196
  hoverPosition.y = colIndex;
197
+ if (colIndex + 1 === tableShape.value[0] && colIndex + 1 < tableShape.value[2]) {
198
+ tableShape.value[0]++;
199
+ } else if (colIndex + 2 < tableShape.value[0] && tableShape.value[0] > props2.tableShape[0]) {
200
+ tableShape.value[0]--;
201
+ }
202
+ if (rowIndex + 1 === tableShape.value[1] && rowIndex + 1 < tableShape.value[3]) {
203
+ tableShape.value[1]++;
204
+ } else if (rowIndex + 2 < tableShape.value[1] && tableShape.value[1] > props2.tableShape[1]) {
205
+ tableShape.value[1]--;
206
+ }
179
207
  },
180
208
  "onClick": () => {
181
209
  props2.onSelected(hoverPosition);
@@ -308,10 +336,9 @@ const props$4 = {
308
336
  const ClipModal = /* @__PURE__ */ vue.defineComponent({
309
337
  props: props$4,
310
338
  setup(props2) {
311
- var _a, _b, _c;
312
339
  const ult = vue.inject("usedLanguageText");
313
340
  const editorId = vue.inject("editorId");
314
- let Cropper = (_c = (_b = (_a = config.configOption) == null ? void 0 : _a.editorExtensions) == null ? void 0 : _b.cropper) == null ? void 0 : _c.instance;
341
+ let Cropper = config.configOption.editorExtensions.cropper.instance;
315
342
  const uploadRef = vue.ref();
316
343
  const uploadImgRef = vue.ref();
317
344
  const previewTargetRef = vue.ref();
@@ -328,7 +355,7 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
328
355
  Cropper = Cropper || window.Cropper;
329
356
  uploadRef.value.onchange = () => {
330
357
  if (!Cropper) {
331
- index.bus.emit(editorId, index.ERROR_CATCHER, {
358
+ eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
332
359
  name: "Cropper",
333
360
  message: "Cropper is undefined"
334
361
  });
@@ -377,10 +404,10 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
377
404
  data.imgSelected = false;
378
405
  };
379
406
  return () => {
380
- var _a2;
407
+ var _a;
381
408
  return vue.createVNode(MdModal.MdModal, {
382
409
  "class": `${config.prefix}-modal-clip`,
383
- "title": (_a2 = ult.value.clipModalTips) == null ? void 0 : _a2.title,
410
+ "title": (_a = ult.value.clipModalTips) == null ? void 0 : _a.title,
384
411
  "visible": props2.visible,
385
412
  "onClose": props2.onCancel,
386
413
  "showAdjust": true,
@@ -392,7 +419,7 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
392
419
  "height": "421px"
393
420
  }, {
394
421
  default: () => {
395
- var _a3, _b2;
422
+ var _a2, _b;
396
423
  return [vue.createVNode("div", {
397
424
  "class": `${config.prefix}-form-item ${config.prefix}-clip`
398
425
  }, [vue.createVNode("div", {
@@ -431,11 +458,11 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
431
458
  "onClick": () => {
432
459
  if (cropper) {
433
460
  const cvs = cropper.getCroppedCanvas();
434
- index.bus.emit(editorId, index.UPLOAD_IMAGE, [index.base642File(cvs.toDataURL("image/png"))], props2.onOk);
461
+ eventName.bus.emit(editorId, eventName.UPLOAD_IMAGE, [index.base642File(cvs.toDataURL("image/png"))], props2.onOk);
435
462
  reset();
436
463
  }
437
464
  }
438
- }, [((_a3 = ult.value.clipModalTips) == null ? void 0 : _a3.buttonUpload) || ((_b2 = ult.value.linkModalTips) == null ? void 0 : _b2.buttonOK)])]), vue.createVNode("input", {
465
+ }, [((_a2 = ult.value.clipModalTips) == null ? void 0 : _a2.buttonUpload) || ((_b = ult.value.linkModalTips) == null ? void 0 : _b.buttonOK)])]), vue.createVNode("input", {
439
466
  "ref": uploadRef,
440
467
  "accept": "image/*",
441
468
  "type": "file",
@@ -514,7 +541,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
514
541
  katex: false
515
542
  });
516
543
  const emitHandler = (direct, params) => {
517
- index.bus.emit(editorId, index.REPLACE, direct, params);
544
+ eventName.bus.emit(editorId, eventName.REPLACE, direct, params);
518
545
  };
519
546
  const modalData = vue.reactive({
520
547
  type: "link",
@@ -523,8 +550,8 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
523
550
  });
524
551
  const toolbarLeftRef = vue.ref();
525
552
  vue.onMounted(() => {
526
- index.bus.on(editorId, {
527
- name: index.OPEN_MODALS,
553
+ eventName.bus.on(editorId, {
554
+ name: eventName.OPEN_MODALS,
528
555
  callback(type) {
529
556
  modalData.type = type;
530
557
  modalData.linkVisible = true;
@@ -540,7 +567,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
540
567
  });
541
568
  const uploadRef = vue.ref();
542
569
  const uploadHandler = () => {
543
- index.bus.emit(editorId, index.UPLOAD_IMAGE, Array.from(uploadRef.value.files || []));
570
+ eventName.bus.emit(editorId, eventName.UPLOAD_IMAGE, Array.from(uploadRef.value.files || []));
544
571
  uploadRef.value.value = "";
545
572
  };
546
573
  vue.onMounted(() => {
@@ -869,7 +896,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
869
896
  "class": `${config.prefix}-toolbar-item`,
870
897
  "title": (_L = ult.value.toolbarTips) == null ? void 0 : _L.revoke,
871
898
  "onClick": () => {
872
- index.bus.emit(editorId, index.CTRL_Z);
899
+ eventName.bus.emit(editorId, eventName.CTRL_Z);
873
900
  }
874
901
  }, [vue.createVNode(MdModal.Icon, {
875
902
  "name": "revoke"
@@ -882,7 +909,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
882
909
  "class": `${config.prefix}-toolbar-item`,
883
910
  "title": (_N = ult.value.toolbarTips) == null ? void 0 : _N.next,
884
911
  "onClick": () => {
885
- index.bus.emit(editorId, index.CTRL_SHIFT_Z);
912
+ eventName.bus.emit(editorId, eventName.CTRL_SHIFT_Z);
886
913
  }
887
914
  }, [vue.createVNode(MdModal.Icon, {
888
915
  "name": "next"
@@ -895,7 +922,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
895
922
  "class": `${config.prefix}-toolbar-item`,
896
923
  "title": (_P = ult.value.toolbarTips) == null ? void 0 : _P.save,
897
924
  "onClick": () => {
898
- index.bus.emit(editorId, index.ON_SAVE);
925
+ eventName.bus.emit(editorId, eventName.ON_SAVE);
899
926
  }
900
927
  }, [vue.createVNode(MdModal.Icon, {
901
928
  "name": "baocun"
@@ -986,7 +1013,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
986
1013
  "class": `${config.prefix}-toolbar-item`,
987
1014
  "title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.catalog,
988
1015
  "onClick": () => {
989
- index.bus.emit(editorId, index.CHANGE_CATALOG_VISIBLE);
1016
+ eventName.bus.emit(editorId, eventName.CHANGE_CATALOG_VISIBLE);
990
1017
  },
991
1018
  "key": "bar-catalog"
992
1019
  }, [vue.createVNode(MdModal.Icon, {
@@ -1121,7 +1148,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
1121
1148
  previewTheme: previewTheme.value,
1122
1149
  language: language2.value,
1123
1150
  insert(generate) {
1124
- index.bus.emit(editorId, index.REPLACE, "universal", {
1151
+ eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
1125
1152
  generate
1126
1153
  });
1127
1154
  }
@@ -1137,7 +1164,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
1137
1164
  previewTheme: previewTheme.value,
1138
1165
  language: language2.value,
1139
1166
  insert(generate) {
1140
- index.bus.emit(editorId, index.REPLACE, "universal", {
1167
+ eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
1141
1168
  generate
1142
1169
  });
1143
1170
  }
@@ -1509,14 +1536,14 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
1509
1536
  vue.onMounted(rebindEvent);
1510
1537
  };
1511
1538
  const directive2flag = (direct, codeMirrorUt, params) => {
1512
- var _a, _b, _c, _d, _e, _f;
1539
+ var _a;
1513
1540
  let targetValue = "";
1514
1541
  let deviationStart = 0;
1515
1542
  let deviationEnd = 0;
1516
1543
  let select = true;
1517
1544
  let replaceAll = false;
1518
1545
  const selectedText = codeMirrorUt.getSelectedText();
1519
- const mermaidTemplate = (_a = config.configOption.editorConfig) == null ? void 0 : _a.mermaidTemplate;
1546
+ const mermaidTemplate = config.configOption.editorConfig.mermaidTemplate;
1520
1547
  if (/^h[1-6]{1}$/.test(direct)) {
1521
1548
  const pix = direct.replace(/^h(\d)/, (_, num) => {
1522
1549
  return new Array(Number(num)).fill("#", 0, num).join("");
@@ -1524,12 +1551,12 @@ const directive2flag = (direct, codeMirrorUt, params) => {
1524
1551
  targetValue = `${pix} ${selectedText}`;
1525
1552
  deviationStart = pix.length + 1;
1526
1553
  } else if (direct === "prettier") {
1527
- const prettier = window.prettier || ((_c = (_b = config.configOption.editorExtensions) == null ? void 0 : _b.prettier) == null ? void 0 : _c.prettierInstance);
1554
+ const prettier = window.prettier || config.configOption.editorExtensions.prettier.prettierInstance;
1528
1555
  const prettierPlugins = [
1529
- ((_d = window.prettierPlugins) == null ? void 0 : _d.markdown) || ((_f = (_e = config.configOption.editorExtensions) == null ? void 0 : _e.prettier) == null ? void 0 : _f.parserMarkdownInstance)
1556
+ ((_a = window.prettierPlugins) == null ? void 0 : _a.markdown) || config.configOption.editorExtensions.prettier.parserMarkdownInstance
1530
1557
  ];
1531
1558
  if (!prettier || prettierPlugins[0] === void 0) {
1532
- index.bus.emit(params.editorId, index.ERROR_CATCHER, {
1559
+ eventName.bus.emit(params.editorId, eventName.ERROR_CATCHER, {
1533
1560
  name: "prettier",
1534
1561
  message: "prettier is undefined"
1535
1562
  });
@@ -2212,7 +2239,7 @@ class CodeMirrorUt {
2212
2239
  this.view.focus();
2213
2240
  } catch (e) {
2214
2241
  if (e.message === "The input text is too long") {
2215
- index.bus.emit(editorId, index.ERROR_CATCHER, {
2242
+ eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
2216
2243
  name: "overlength",
2217
2244
  message: e.message,
2218
2245
  data: text
@@ -2292,7 +2319,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
2292
2319
  const imgInsert = (tv) => {
2293
2320
  if (tv instanceof Promise) {
2294
2321
  tv.then((targetValue) => {
2295
- index.bus.emit(editorId, index.REPLACE, "universal", {
2322
+ eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
2296
2323
  generate() {
2297
2324
  return {
2298
2325
  targetValue
@@ -2303,7 +2330,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
2303
2330
  console.error(err);
2304
2331
  });
2305
2332
  } else {
2306
- index.bus.emit(editorId, index.REPLACE, "universal", {
2333
+ eventName.bus.emit(editorId, eventName.REPLACE, "universal", {
2307
2334
  generate() {
2308
2335
  return {
2309
2336
  targetValue: tv
@@ -2319,9 +2346,9 @@ const usePasteUpload = (props2, codeMirrorUt) => {
2319
2346
  }
2320
2347
  if (e.clipboardData.files.length > 0) {
2321
2348
  const { files } = e.clipboardData;
2322
- index.bus.emit(
2349
+ eventName.bus.emit(
2323
2350
  editorId,
2324
- index.UPLOAD_IMAGE,
2351
+ eventName.UPLOAD_IMAGE,
2325
2352
  Array.from(files).filter((file) => {
2326
2353
  return /image\/.*/.test(file.type);
2327
2354
  })
@@ -2362,7 +2389,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
2362
2389
  }
2363
2390
  if (props2.autoDetectCode && e.clipboardData.types.includes("vscode-editor-data")) {
2364
2391
  const vscCoodInfo = JSON.parse(e.clipboardData.getData("vscode-editor-data"));
2365
- index.bus.emit(editorId, index.REPLACE, "code", {
2392
+ eventName.bus.emit(editorId, eventName.REPLACE, "code", {
2366
2393
  mode: vscCoodInfo.mode,
2367
2394
  text: e.clipboardData.getData("text/plain")
2368
2395
  });
@@ -2370,7 +2397,7 @@ const usePasteUpload = (props2, codeMirrorUt) => {
2370
2397
  return;
2371
2398
  }
2372
2399
  if (props2.maxlength && targetValue.length + props2.modelValue.length > props2.maxlength) {
2373
- index.bus.emit(editorId, index.ERROR_CATCHER, {
2400
+ eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
2374
2401
  name: "overlength",
2375
2402
  message: "The input text is too long",
2376
2403
  data: targetValue
@@ -2384,7 +2411,7 @@ const createCommands = (id, contentProps) => {
2384
2411
  key: "Ctrl-b",
2385
2412
  mac: "Cmd-b",
2386
2413
  run: () => {
2387
- index.bus.emit(id, index.REPLACE, "bold");
2414
+ eventName.bus.emit(id, eventName.REPLACE, "bold");
2388
2415
  return true;
2389
2416
  }
2390
2417
  };
@@ -2392,11 +2419,11 @@ const createCommands = (id, contentProps) => {
2392
2419
  key: "Ctrl-s",
2393
2420
  mac: "Cmd-s",
2394
2421
  run: (view2) => {
2395
- index.bus.emit(id, index.ON_SAVE, view2.state.doc.toString());
2422
+ eventName.bus.emit(id, eventName.ON_SAVE, view2.state.doc.toString());
2396
2423
  return true;
2397
2424
  },
2398
2425
  shift: () => {
2399
- index.bus.emit(id, index.REPLACE, "strikeThrough");
2426
+ eventName.bus.emit(id, eventName.REPLACE, "strikeThrough");
2400
2427
  return true;
2401
2428
  }
2402
2429
  };
@@ -2404,11 +2431,11 @@ const createCommands = (id, contentProps) => {
2404
2431
  key: "Ctrl-u",
2405
2432
  mac: "Cmd-u",
2406
2433
  run: () => {
2407
- index.bus.emit(id, index.REPLACE, "underline");
2434
+ eventName.bus.emit(id, eventName.REPLACE, "underline");
2408
2435
  return true;
2409
2436
  },
2410
2437
  shift: () => {
2411
- index.bus.emit(id, index.REPLACE, "unorderedList");
2438
+ eventName.bus.emit(id, eventName.REPLACE, "unorderedList");
2412
2439
  return true;
2413
2440
  }
2414
2441
  };
@@ -2416,11 +2443,11 @@ const createCommands = (id, contentProps) => {
2416
2443
  key: "Ctrl-i",
2417
2444
  mac: "Cmd-i",
2418
2445
  run: () => {
2419
- index.bus.emit(id, index.REPLACE, "italic");
2446
+ eventName.bus.emit(id, eventName.REPLACE, "italic");
2420
2447
  return true;
2421
2448
  },
2422
2449
  shift: () => {
2423
- index.bus.emit(id, index.OPEN_MODALS, "image");
2450
+ eventName.bus.emit(id, eventName.OPEN_MODALS, "image");
2424
2451
  return true;
2425
2452
  }
2426
2453
  };
@@ -2428,7 +2455,7 @@ const createCommands = (id, contentProps) => {
2428
2455
  key: "Ctrl-1",
2429
2456
  mac: "Cmd-1",
2430
2457
  run: () => {
2431
- index.bus.emit(id, index.REPLACE, "h1");
2458
+ eventName.bus.emit(id, eventName.REPLACE, "h1");
2432
2459
  return true;
2433
2460
  }
2434
2461
  };
@@ -2436,7 +2463,7 @@ const createCommands = (id, contentProps) => {
2436
2463
  key: "Ctrl-2",
2437
2464
  mac: "Cmd-2",
2438
2465
  run: () => {
2439
- index.bus.emit(id, index.REPLACE, "h2");
2466
+ eventName.bus.emit(id, eventName.REPLACE, "h2");
2440
2467
  return true;
2441
2468
  }
2442
2469
  };
@@ -2444,7 +2471,7 @@ const createCommands = (id, contentProps) => {
2444
2471
  key: "Ctrl-3",
2445
2472
  mac: "Cmd-3",
2446
2473
  run: () => {
2447
- index.bus.emit(id, index.REPLACE, "h3");
2474
+ eventName.bus.emit(id, eventName.REPLACE, "h3");
2448
2475
  return true;
2449
2476
  }
2450
2477
  };
@@ -2452,7 +2479,7 @@ const createCommands = (id, contentProps) => {
2452
2479
  key: "Ctrl-4",
2453
2480
  mac: "Cmd-4",
2454
2481
  run: () => {
2455
- index.bus.emit(id, index.REPLACE, "h4");
2482
+ eventName.bus.emit(id, eventName.REPLACE, "h4");
2456
2483
  return true;
2457
2484
  }
2458
2485
  };
@@ -2460,7 +2487,7 @@ const createCommands = (id, contentProps) => {
2460
2487
  key: "Ctrl-5",
2461
2488
  mac: "Cmd-5",
2462
2489
  run: () => {
2463
- index.bus.emit(id, index.REPLACE, "h5");
2490
+ eventName.bus.emit(id, eventName.REPLACE, "h5");
2464
2491
  return true;
2465
2492
  }
2466
2493
  };
@@ -2468,7 +2495,7 @@ const createCommands = (id, contentProps) => {
2468
2495
  key: "Ctrl-6",
2469
2496
  mac: "Cmd-6",
2470
2497
  run: () => {
2471
- index.bus.emit(id, index.REPLACE, "h6");
2498
+ eventName.bus.emit(id, eventName.REPLACE, "h6");
2472
2499
  return true;
2473
2500
  }
2474
2501
  };
@@ -2476,7 +2503,7 @@ const createCommands = (id, contentProps) => {
2476
2503
  key: "Ctrl-ArrowUp",
2477
2504
  mac: "Cmd-ArrowUp",
2478
2505
  run: () => {
2479
- index.bus.emit(id, index.REPLACE, "sup");
2506
+ eventName.bus.emit(id, eventName.REPLACE, "sup");
2480
2507
  return true;
2481
2508
  }
2482
2509
  };
@@ -2484,7 +2511,7 @@ const createCommands = (id, contentProps) => {
2484
2511
  key: "Ctrl-ArrowDown",
2485
2512
  mac: "Cmd-ArrowDown",
2486
2513
  run: () => {
2487
- index.bus.emit(id, index.REPLACE, "sub");
2514
+ eventName.bus.emit(id, eventName.REPLACE, "sub");
2488
2515
  return true;
2489
2516
  }
2490
2517
  };
@@ -2492,7 +2519,7 @@ const createCommands = (id, contentProps) => {
2492
2519
  key: "Ctrl-o",
2493
2520
  mac: "Cmd-o",
2494
2521
  run: () => {
2495
- index.bus.emit(id, index.REPLACE, "orderedList");
2522
+ eventName.bus.emit(id, eventName.REPLACE, "orderedList");
2496
2523
  return true;
2497
2524
  }
2498
2525
  };
@@ -2500,12 +2527,12 @@ const createCommands = (id, contentProps) => {
2500
2527
  key: "Ctrl-c",
2501
2528
  mac: "Cmd-c",
2502
2529
  shift: () => {
2503
- index.bus.emit(id, index.REPLACE, "code");
2530
+ eventName.bus.emit(id, eventName.REPLACE, "code");
2504
2531
  return true;
2505
2532
  },
2506
2533
  any(_view, e) {
2507
2534
  if ((e.ctrlKey || e.metaKey) && e.altKey && e.code === "KeyC") {
2508
- index.bus.emit(id, index.REPLACE, "codeRow");
2535
+ eventName.bus.emit(id, eventName.REPLACE, "codeRow");
2509
2536
  return true;
2510
2537
  }
2511
2538
  return false;
@@ -2515,7 +2542,7 @@ const createCommands = (id, contentProps) => {
2515
2542
  key: "Ctrl-l",
2516
2543
  mac: "Cmd-l",
2517
2544
  run: () => {
2518
- index.bus.emit(id, index.OPEN_MODALS, "link");
2545
+ eventName.bus.emit(id, eventName.OPEN_MODALS, "link");
2519
2546
  return true;
2520
2547
  }
2521
2548
  };
@@ -2524,7 +2551,7 @@ const createCommands = (id, contentProps) => {
2524
2551
  mac: "Cmd-f",
2525
2552
  shift: () => {
2526
2553
  if (!contentProps.noPrettier) {
2527
- index.bus.emit(id, index.REPLACE, "prettier");
2554
+ eventName.bus.emit(id, eventName.REPLACE, "prettier");
2528
2555
  return true;
2529
2556
  }
2530
2557
  return false;
@@ -2533,7 +2560,7 @@ const createCommands = (id, contentProps) => {
2533
2560
  const CtrlT = {
2534
2561
  any: (_view, e) => {
2535
2562
  if ((e.ctrlKey || e.metaKey) && e.altKey && e.shiftKey && e.code === "KeyT") {
2536
- index.bus.emit(id, index.REPLACE, "table");
2563
+ eventName.bus.emit(id, eventName.REPLACE, "table");
2537
2564
  return true;
2538
2565
  }
2539
2566
  return false;
@@ -2595,7 +2622,7 @@ const useCodeMirror = (props2) => {
2595
2622
  }
2596
2623
  const { data } = e;
2597
2624
  if (props2.maxlength && props2.modelValue.length + data.length > props2.maxlength) {
2598
- index.bus.emit(editorId, index.ERROR_CATCHER, {
2625
+ eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
2599
2626
  name: "overlength",
2600
2627
  message: "The input text is too long",
2601
2628
  data
@@ -2645,20 +2672,20 @@ const useCodeMirror = (props2) => {
2645
2672
  typeof props2.maxlength === "number" && nc.setMaxLength(props2.maxlength);
2646
2673
  props2.autofocus && view2.focus();
2647
2674
  }, 0);
2648
- index.bus.on(editorId, {
2649
- name: index.CTRL_Z,
2675
+ eventName.bus.on(editorId, {
2676
+ name: eventName.CTRL_Z,
2650
2677
  callback() {
2651
2678
  commands.undo(view2);
2652
2679
  }
2653
2680
  });
2654
- index.bus.on(editorId, {
2655
- name: index.CTRL_SHIFT_Z,
2681
+ eventName.bus.on(editorId, {
2682
+ name: eventName.CTRL_SHIFT_Z,
2656
2683
  callback() {
2657
2684
  commands.redo(view2);
2658
2685
  }
2659
2686
  });
2660
- index.bus.on(editorId, {
2661
- name: index.REPLACE,
2687
+ eventName.bus.on(editorId, {
2688
+ name: eventName.REPLACE,
2662
2689
  callback(direct, params = {}) {
2663
2690
  var _a, _b;
2664
2691
  if (direct === "image" && params.transform) {
@@ -2687,16 +2714,16 @@ const useCodeMirror = (props2) => {
2687
2714
  }
2688
2715
  }
2689
2716
  });
2690
- index.bus.on(editorId, {
2691
- name: index.EVENT_LISTENER,
2717
+ eventName.bus.on(editorId, {
2718
+ name: eventName.EVENT_LISTENER,
2692
2719
  callback: util.throttle((handlers) => {
2693
2720
  var _a;
2694
2721
  const nextDomEventHandlers = {
2695
2722
  ...domEventHandlers
2696
2723
  };
2697
2724
  const defaultEventNames = Object.keys(domEventHandlers);
2698
- for (const eventName in handlers) {
2699
- const en = eventName;
2725
+ for (const eventName2 in handlers) {
2726
+ const en = eventName2;
2700
2727
  if (defaultEventNames.includes(en)) {
2701
2728
  nextDomEventHandlers[en] = (e, v) => {
2702
2729
  handlers[en](e, v);
@@ -3105,11 +3132,10 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
3105
3132
  const [setting, updateSetting] = MdPreview.useConfig(props2, ctx);
3106
3133
  const catalogVisible = MdPreview.useCatalog(props2);
3107
3134
  vue.onBeforeUnmount(() => {
3108
- index.bus.clear(editorId);
3135
+ eventName.bus.clear(editorId);
3109
3136
  });
3110
3137
  MdPreview.useExpose(props2, ctx, catalogVisible, setting, updateSetting, codeRef);
3111
3138
  return () => {
3112
- var _a;
3113
3139
  const defToolbars = vueTsx.getSlot({
3114
3140
  props: props2,
3115
3141
  ctx
@@ -3122,7 +3148,7 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
3122
3148
  "id": editorId,
3123
3149
  "class": [config.prefix, props2.class, props2.theme === "dark" && `${config.prefix}-dark`, setting.fullscreen || setting.pageFullscreen ? `${config.prefix}-fullscreen` : ""],
3124
3150
  "style": props2.style
3125
- }, [vue.createVNode(ToolBar, {
3151
+ }, [props2.toolbars.length > 0 && vue.createVNode(ToolBar, {
3126
3152
  "noPrettier": noPrettier,
3127
3153
  "toolbars": props2.toolbars,
3128
3154
  "toolbarsExclude": props2.toolbarsExclude,
@@ -3208,7 +3234,7 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
3208
3234
  },
3209
3235
  "sanitizeMermaid": props2.sanitizeMermaid,
3210
3236
  "transformImgUrl": props2.transformImgUrl
3211
- }, null), ((_a = props2.footers) == null ? void 0 : _a.length) > 0 && vue.createVNode(Footer, {
3237
+ }, null), props2.footers.length > 0 && vue.createVNode(Footer, {
3212
3238
  "modelValue": props2.modelValue,
3213
3239
  "footers": props2.footers,
3214
3240
  "defFooters": defFooters,
@@ -61,6 +61,9 @@ const props = {
61
61
  },
62
62
  theme: {
63
63
  type: String
64
+ },
65
+ previewTheme: {
66
+ type: String
64
67
  }
65
68
  /**
66
69
  * ==结束