md-editor-v3 4.13.4 → 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 (43) 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 +5 -1
  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 +5 -1
  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/preview.css +1 -1
  27. package/lib/style.css +1 -1
  28. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +6 -0
  29. package/lib/types/DropdownToolbar/index.d.ts +12 -0
  30. package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
  31. package/lib/types/MdCatalog/index.d.ts +3 -3
  32. package/lib/types/MdEditor/Editor.d.ts +0 -3
  33. package/lib/types/MdEditor/config.d.ts +1 -0
  34. package/lib/types/MdEditor/index.d.ts +0 -7
  35. package/lib/types/MdEditor/props.d.ts +2 -1
  36. package/lib/types/MdEditor/type.d.ts +46 -0
  37. package/lib/types/MdEditor/utils/dom.d.ts +9 -1
  38. package/lib/types/MdEditor/utils/index.d.ts +4 -0
  39. package/lib/types/ModalToolbar/ModalToolbar.d.ts +6 -0
  40. package/lib/types/ModalToolbar/index.d.ts +12 -0
  41. package/lib/types/config.d.ts +1 -1
  42. package/lib/umd/index.js +43 -43
  43. package/package.json +3 -3
@@ -0,0 +1,96 @@
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
+ class Bus {
8
+ constructor() {
9
+ // 事件池
10
+ __publicField(this, "pools", {});
11
+ }
12
+ // 移除事件监听
13
+ remove(race, name, func) {
14
+ const targetRace = this.pools[race];
15
+ const events = targetRace && this.pools[race][name];
16
+ if (events) {
17
+ this.pools[race][name] = events.filter((item) => item !== func);
18
+ }
19
+ }
20
+ // 清空全部事件,由于单一实例,多次注册会被共享内容
21
+ clear(race) {
22
+ this.pools[race] = {};
23
+ }
24
+ // 注册事件监听
25
+ on(race, event) {
26
+ if (!this.pools[race]) {
27
+ this.pools[race] = {};
28
+ }
29
+ if (!this.pools[race][event.name]) {
30
+ this.pools[race][event.name] = [];
31
+ }
32
+ this.pools[race][event.name].push(event.callback);
33
+ return this.pools[race][event.name].includes(event.callback);
34
+ }
35
+ // 触发事件
36
+ emit(race, name, ...params) {
37
+ if (!this.pools[race]) {
38
+ this.pools[race] = {};
39
+ }
40
+ const targetRace = this.pools[race];
41
+ const events = targetRace[name];
42
+ if (events) {
43
+ events.forEach((item) => {
44
+ try {
45
+ item(...params);
46
+ } catch (error) {
47
+ console.error(`${name} monitor event exception!`, error);
48
+ }
49
+ });
50
+ }
51
+ }
52
+ }
53
+ const bus = new Bus();
54
+ const ON_SAVE = "onSave";
55
+ const CHANGE_CATALOG_VISIBLE = "changeCatalogVisible";
56
+ const CHANGE_FULL_SCREEN = "changeFullscreen";
57
+ const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
58
+ const FULL_SCREEN_CHANGED = "fullscreenChanged";
59
+ const PREVIEW_CHANGED = "previewChanged";
60
+ const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
61
+ const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
62
+ const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
63
+ const BUILD_FINISHED = "buildFinished";
64
+ const ERROR_CATCHER = "errorCatcher";
65
+ const REPLACE = "replace";
66
+ const UPLOAD_IMAGE = "uploadImage";
67
+ const OPEN_MODALS = "openModals";
68
+ const CTRL_Z = "ctrlZ";
69
+ const CTRL_SHIFT_Z = "ctrlShiftZ";
70
+ const CATALOG_CHANGED = "catalogChanged";
71
+ const PUSH_CATALOG = "pushCatalog";
72
+ const RERENDER = "rerender";
73
+ const EVENT_LISTENER = "eventListener";
74
+ export {
75
+ BUILD_FINISHED as B,
76
+ CATALOG_CHANGED as C,
77
+ ERROR_CATCHER as E,
78
+ FULL_SCREEN_CHANGED as F,
79
+ HTML_PREVIEW_CHANGED as H,
80
+ ON_SAVE as O,
81
+ PUSH_CATALOG as P,
82
+ RERENDER as R,
83
+ UPLOAD_IMAGE as U,
84
+ CHANGE_CATALOG_VISIBLE as a,
85
+ bus as b,
86
+ PAGE_FULL_SCREEN_CHANGED as c,
87
+ PREVIEW_CHANGED as d,
88
+ PREVIEW_ONLY_CHANGED as e,
89
+ CATALOG_VISIBLE_CHANGED as f,
90
+ REPLACE as g,
91
+ CHANGE_FULL_SCREEN as h,
92
+ EVENT_LISTENER as i,
93
+ OPEN_MODALS as j,
94
+ CTRL_SHIFT_Z as k,
95
+ CTRL_Z as l
96
+ };
@@ -1,7 +1,7 @@
1
1
  import { inject, watch, toRef, onMounted, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
2
- import { e as configOption, p as prefix, m as mermaidUrl, k as katexUrl, f as codeCss, h as highlightUrl, s as staticTextDefault, a as iconfontSvgUrl, i as iconfontClassUrl, g as prettierUrl, j as cropperUrl, b as allToolbar, d as allFooter } from "./config.mjs";
3
- import { a as generateCodeRowNumber, b as bus, P as PUSH_CATALOG, C as CATALOG_CHANGED, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, d as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, e as PREVIEW_CHANGED, f as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, h as CATALOG_VISIBLE_CHANGED, i as REPLACE, j as CHANGE_FULL_SCREEN, k as EVENT_LISTENER, l as getNextId } from "./index4.mjs";
4
- import { a as appendHandler, u as updateHandler } from "./dom.mjs";
2
+ import { f as configOption, p as prefix, g as codeCss, s as staticTextDefault, b as allToolbar, d as allFooter } from "./config.mjs";
3
+ import { b as bus, C as CATALOG_CHANGED, P as PUSH_CATALOG, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, c as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, d as PREVIEW_CHANGED, e as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, f as CATALOG_VISIBLE_CHANGED, g as REPLACE, h as CHANGE_FULL_SCREEN, i as EVENT_LISTENER } from "./event-name.mjs";
4
+ import { c as createHTMLElement, a as appendHandler, u as updateHandler } from "./dom.mjs";
5
5
  import { debounce, uuid, deepMerge, deepClone } from "@vavt/util";
6
6
  import mediumZoom from "medium-zoom";
7
7
  import copy from "copy-to-clipboard";
@@ -9,6 +9,7 @@ import mdit from "markdown-it";
9
9
  import ImageFiguresPlugin from "markdown-it-image-figures";
10
10
  import TaskListPlugin from "markdown-it-task-lists";
11
11
  import XSSPlugin from "markdown-it-xss";
12
+ import { b as generateCodeRowNumber, c as getNextId } from "./index4.mjs";
12
13
  import { LRUCache } from "lru-cache";
13
14
  const userZoom = (props, html) => {
14
15
  const editorId = inject("editorId");
@@ -58,21 +59,20 @@ const useCopyCode = (props, html, key) => {
58
59
  const customIcon = inject("customIcon");
59
60
  const initCopyEntry = () => {
60
61
  document.querySelectorAll(`#${editorId}-preview pre`).forEach((pre) => {
61
- var _a, _b;
62
+ var _a;
62
63
  let clearTimer = -1;
63
64
  (_a = pre.querySelector(".copy-button")) == null ? void 0 : _a.remove();
64
- const copyBtnText = ((_b = ult.value.copyCode) == null ? void 0 : _b.text) || "复制代码";
65
+ const copyBtnText = ult.value.copyCode.text;
65
66
  const copyButton = document.createElement("span");
66
67
  copyButton.setAttribute("class", "copy-button");
67
68
  copyButton.dataset.tips = copyBtnText;
68
69
  copyButton.innerHTML = StrIcon("copy", customIcon.value);
69
70
  copyButton.addEventListener("click", () => {
70
- var _a2, _b2;
71
71
  clearTimeout(clearTimer);
72
72
  const codeText = pre.querySelector("code").innerText;
73
73
  const success = copy(props.formatCopiedText(codeText));
74
- const succssTip = ((_a2 = ult.value.copyCode) == null ? void 0 : _a2.successTips) || "已复制!";
75
- const failTip = ((_b2 = ult.value.copyCode) == null ? void 0 : _b2.failTips) || "已复制!";
74
+ const succssTip = ult.value.copyCode.successTips;
75
+ const failTip = ult.value.copyCode.failTips;
76
76
  copyButton.dataset.tips = success ? succssTip : failTip;
77
77
  clearTimer = window.setTimeout(() => {
78
78
  copyButton.dataset.tips = copyBtnText;
@@ -96,43 +96,45 @@ const useCopyCode = (props, html, key) => {
96
96
  onMounted(initCopyEntry);
97
97
  };
98
98
  const useHighlight = (props) => {
99
- var _a;
100
- const hljsConf = (_a = configOption.editorExtensions) == null ? void 0 : _a.highlight;
101
- const hljs = hljsConf == null ? void 0 : hljsConf.instance;
102
- const highlightUrl2 = inject("highlight");
103
- const hljsRef = shallowRef(hljs);
99
+ const highlight = inject("highlight");
100
+ const hljsRef = shallowRef(configOption.editorExtensions.highlight.instance);
104
101
  onMounted(() => {
105
- if (props.noHighlight) {
102
+ if (props.noHighlight || hljsRef.value) {
106
103
  return;
107
104
  }
108
- if (!hljsRef.value) {
109
- const highlightScript = document.createElement("script");
110
- highlightScript.src = highlightUrl2.value.js;
111
- highlightScript.onload = () => {
105
+ const highlightScript = createHTMLElement("script", {
106
+ ...highlight.value.js,
107
+ id: `${prefix}-hljs`,
108
+ onload() {
112
109
  hljsRef.value = window.hljs;
113
- };
114
- highlightScript.id = `${prefix}-hljs`;
115
- appendHandler(highlightScript, "hljs");
116
- const highlightLink = document.createElement("link");
117
- highlightLink.rel = "stylesheet";
118
- highlightLink.href = highlightUrl2.value.css;
119
- highlightLink.id = `${prefix}-hlCss`;
120
- appendHandler(highlightLink);
121
- }
110
+ }
111
+ });
112
+ const highlightLink = createHTMLElement("link", {
113
+ ...highlight.value.css,
114
+ rel: "stylesheet",
115
+ id: `${prefix}-hlCss`
116
+ });
117
+ appendHandler(highlightLink);
118
+ appendHandler(highlightScript, "hljs");
122
119
  });
123
120
  watch(
124
- () => highlightUrl2.value.css,
125
- (url) => {
126
- updateHandler(`${prefix}-hlCss`, "href", url);
121
+ () => highlight.value.css,
122
+ () => {
123
+ updateHandler(
124
+ createHTMLElement("link", {
125
+ ...highlight.value.css,
126
+ rel: "stylesheet",
127
+ id: `${prefix}-hlCss`
128
+ })
129
+ );
127
130
  }
128
131
  );
129
132
  return hljsRef;
130
133
  };
131
134
  const useMermaid = (props) => {
132
135
  const theme = inject("theme");
133
- const { editorExtensions, mermaidConfig } = configOption;
134
- const mermaidConf = editorExtensions == null ? void 0 : editorExtensions.mermaid;
135
- const mermaidRef = shallowRef(mermaidConf == null ? void 0 : mermaidConf.instance);
136
+ const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = configOption;
137
+ const mermaidRef = shallowRef(editorExtensions.mermaid.instance);
136
138
  const reRenderRef = shallowRef(-1);
137
139
  const mermaidCache = new LRUCache({
138
140
  max: 1e3,
@@ -159,30 +161,38 @@ const useMermaid = (props) => {
159
161
  }
160
162
  );
161
163
  onMounted(() => {
162
- if (props.noMermaid) {
164
+ var _a, _b, _c;
165
+ if (props.noMermaid || ((_a = mermaidRef.value) == null ? void 0 : _a.instance)) {
163
166
  return;
164
167
  }
165
- if (!(mermaidConf == null ? void 0 : mermaidConf.instance)) {
166
- const jsSrc = (mermaidConf == null ? void 0 : mermaidConf.js) || mermaidUrl;
167
- if (/\.mjs/.test(jsSrc)) {
168
- import(
169
- /* @vite-ignore */
170
- /* webpackIgnore: true */
171
- jsSrc
172
- ).then((module) => {
173
- mermaidRef.value = module.default;
174
- configMermaid();
175
- });
176
- } else {
177
- const mermaidScript = document.createElement("script");
178
- mermaidScript.id = `${prefix}-mermaid`;
179
- mermaidScript.src = jsSrc;
180
- mermaidScript.onload = () => {
168
+ const jsSrc = editorExtensions.mermaid.js;
169
+ if (/\.mjs/.test(jsSrc)) {
170
+ const modulePreload = createHTMLElement("link", {
171
+ ...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
172
+ rel: "modulepreload",
173
+ href: jsSrc,
174
+ id: `${prefix}-mermaid-m`
175
+ });
176
+ appendHandler(modulePreload);
177
+ import(
178
+ /* @vite-ignore */
179
+ /* webpackIgnore: true */
180
+ jsSrc
181
+ ).then((module) => {
182
+ mermaidRef.value = module.default;
183
+ configMermaid();
184
+ });
185
+ } else {
186
+ const mermaidScript = createHTMLElement("script", {
187
+ ...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
188
+ src: jsSrc,
189
+ id: `${prefix}-mermaid`,
190
+ onload() {
181
191
  mermaidRef.value = window.mermaid;
182
192
  configMermaid();
183
- };
184
- appendHandler(mermaidScript, "mermaid");
185
- }
193
+ }
194
+ });
195
+ appendHandler(mermaidScript, "mermaid");
186
196
  }
187
197
  });
188
198
  const replaceMermaid = () => {
@@ -234,25 +244,26 @@ const useMermaid = (props) => {
234
244
  return { mermaidRef, reRenderRef, replaceMermaid };
235
245
  };
236
246
  const useKatex = (props) => {
237
- var _a;
238
- const katexConf = (_a = configOption.editorExtensions) == null ? void 0 : _a.katex;
239
- const katexIns = katexConf == null ? void 0 : katexConf.instance;
240
- const katex = shallowRef(katexIns);
247
+ const katex = shallowRef(configOption.editorExtensions.katex.instance);
241
248
  onMounted(() => {
242
- if (!props.noKatex && !katex.value) {
243
- const katexScript = document.createElement("script");
244
- katexScript.src = (katexConf == null ? void 0 : katexConf.js) || katexUrl.js;
245
- katexScript.onload = () => {
246
- katex.value = window.katex;
247
- };
248
- katexScript.id = `${prefix}-katex`;
249
- const katexLink = document.createElement("link");
250
- katexLink.rel = "stylesheet";
251
- katexLink.href = (katexConf == null ? void 0 : katexConf.css) || katexUrl.css;
252
- katexLink.id = `${prefix}-katexCss`;
253
- appendHandler(katexScript, "katex");
254
- appendHandler(katexLink);
249
+ if (props.noKatex || katex.value) {
250
+ return;
255
251
  }
252
+ const { editorExtensions } = configOption;
253
+ const katexScript = createHTMLElement("script", {
254
+ src: editorExtensions.katex.js,
255
+ id: `${prefix}-katex`,
256
+ onload() {
257
+ katex.value = window.katex;
258
+ }
259
+ });
260
+ const katexLink = createHTMLElement("link", {
261
+ rel: "stylesheet",
262
+ href: editorExtensions.katex.css,
263
+ id: `${prefix}-katexCss`
264
+ });
265
+ appendHandler(katexScript, "katex");
266
+ appendHandler(katexLink);
256
267
  });
257
268
  return katex;
258
269
  };
@@ -778,10 +789,17 @@ const useMarkdownIt = (props, previewOnly) => {
778
789
  });
779
790
  watch(
780
791
  [toRef(props, "modelValue"), needReRender, reRenderRef],
781
- debounce(
782
- markHtml,
783
- (editorConfig == null ? void 0 : editorConfig.renderDelay) !== void 0 ? editorConfig == null ? void 0 : editorConfig.renderDelay : previewOnly ? 0 : 500
784
- )
792
+ debounce(markHtml, previewOnly ? 0 : editorConfig.renderDelay)
793
+ );
794
+ watch(
795
+ () => props.setting.preview,
796
+ () => {
797
+ if (props.setting.preview) {
798
+ nextTick(() => {
799
+ bus.emit(editorId, CATALOG_CHANGED, headsRef.value);
800
+ });
801
+ }
802
+ }
785
803
  );
786
804
  onMounted(() => {
787
805
  bus.on(editorId, {
@@ -1020,9 +1038,9 @@ const useOnSave = (props, context) => {
1020
1038
  });
1021
1039
  };
1022
1040
  const useProvidePreview = (props) => {
1023
- var _a, _b;
1024
1041
  const { editorId } = props;
1025
- const highlightConfig = (_b = (_a = configOption) == null ? void 0 : _a.editorExtensions) == null ? void 0 : _b.highlight;
1042
+ const hljsUrls = configOption.editorExtensions.highlight;
1043
+ const hljsAttrs = configOption.editorExtensionsAttrs.highlight;
1026
1044
  provide("editorId", editorId);
1027
1045
  provide(
1028
1046
  "theme",
@@ -1035,23 +1053,32 @@ const useProvidePreview = (props) => {
1035
1053
  provide(
1036
1054
  "highlight",
1037
1055
  computed(() => {
1056
+ const { js: jsUrl } = hljsUrls;
1038
1057
  const cssList = {
1039
1058
  ...codeCss,
1040
- ...highlightConfig == null ? void 0 : highlightConfig.css
1059
+ ...hljsUrls.css
1041
1060
  };
1042
- const theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
1061
+ const { js: jsAttrs, css: cssAttrs = {} } = hljsAttrs || {};
1062
+ const _theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
1063
+ const codeCssHref = cssList[props.codeTheme] ? cssList[props.codeTheme][_theme] : codeCss.atom[_theme];
1064
+ const codeCssAttrs = cssList[props.codeTheme] && cssAttrs[props.codeTheme] ? cssAttrs[props.codeTheme][_theme] : cssAttrs["atom"] ? cssAttrs["atom"][_theme] : {};
1043
1065
  return {
1044
- js: (highlightConfig == null ? void 0 : highlightConfig.js) || highlightUrl,
1045
- css: cssList[props.codeTheme] ? cssList[props.codeTheme][theme] : codeCss.atom[theme]
1066
+ js: {
1067
+ src: jsUrl,
1068
+ ...jsAttrs
1069
+ },
1070
+ css: {
1071
+ href: codeCssHref,
1072
+ ...codeCssAttrs
1073
+ }
1046
1074
  };
1047
1075
  })
1048
1076
  );
1049
1077
  provide("showCodeRowNumber", props.showCodeRowNumber);
1050
1078
  const usedLanguageText = computed(() => {
1051
- var _a2, _b2;
1052
1079
  const allText = {
1053
1080
  ...staticTextDefault,
1054
- ...(_b2 = (_a2 = configOption) == null ? void 0 : _a2.editorConfig) == null ? void 0 : _b2.languageUserDefined
1081
+ ...configOption.editorConfig.languageUserDefined
1055
1082
  };
1056
1083
  return deepMerge(
1057
1084
  deepClone(staticTextDefault["en-US"]),
@@ -1074,53 +1101,67 @@ const useProvide = (props) => {
1074
1101
  };
1075
1102
  const useExpansionPreview = (props) => {
1076
1103
  onMounted(() => {
1077
- var _a, _b;
1078
- if (!props.noIconfont) {
1079
- if (configOption.iconfontType === "svg") {
1080
- const iconfontScript = document.createElement("script");
1081
- iconfontScript.src = ((_a = configOption.editorExtensions) == null ? void 0 : _a.iconfont) || iconfontSvgUrl;
1082
- iconfontScript.id = `${prefix}-icon`;
1083
- appendHandler(iconfontScript);
1084
- } else {
1085
- const iconfontLink = document.createElement("link");
1086
- iconfontLink.rel = "stylesheet";
1087
- iconfontLink.href = ((_b = configOption.editorExtensions) == null ? void 0 : _b.iconfontClass) || iconfontClassUrl;
1088
- iconfontLink.id = `${prefix}-icon-class`;
1089
- appendHandler(iconfontLink);
1090
- }
1104
+ const { editorExtensions, editorExtensionsAttrs, iconfontType } = configOption;
1105
+ if (props.noIconfont) {
1106
+ return;
1107
+ }
1108
+ if (iconfontType === "svg") {
1109
+ const iconfontScript = createHTMLElement("script", {
1110
+ ...editorExtensionsAttrs.iconfont,
1111
+ src: editorExtensions.iconfont,
1112
+ id: `${prefix}-icon`
1113
+ });
1114
+ appendHandler(iconfontScript);
1115
+ } else {
1116
+ const iconfontLink = createHTMLElement("link", {
1117
+ ...editorExtensionsAttrs.iconfontClass,
1118
+ rel: "stylesheet",
1119
+ href: editorExtensions.iconfontClass,
1120
+ id: `${prefix}-icon-class`
1121
+ });
1122
+ appendHandler(iconfontLink);
1091
1123
  }
1092
1124
  });
1093
1125
  };
1094
1126
  const useExpansion = (props) => {
1095
- var _a, _b, _c, _d, _e, _f;
1096
1127
  const { noPrettier, noUploadImg } = props;
1097
- const { editorExtensions } = configOption;
1098
- const noPrettierScript = noPrettier || !!((_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.prettier) == null ? void 0 : _b.prettierInstance);
1099
- const noParserMarkdownScript = noPrettier || !!((_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.prettier) == null ? void 0 : _d.parserMarkdownInstance);
1100
- const noCropperScript = noUploadImg || !!((_f = (_e = configOption.editorExtensions) == null ? void 0 : _e.cropper) == null ? void 0 : _f.instance);
1128
+ const { editorExtensions, editorExtensionsAttrs } = configOption;
1129
+ const noPrettierScript = noPrettier || editorExtensions.prettier.prettierInstance;
1130
+ const noParserMarkdownScript = noPrettier || editorExtensions.prettier.parserMarkdownInstance;
1131
+ const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
1101
1132
  onMounted(() => {
1102
- var _a2, _b2, _c2, _d2;
1103
- const prettierScript = document.createElement("script");
1104
- const prettierMDScript = document.createElement("script");
1105
- prettierScript.src = ((_a2 = editorExtensions == null ? void 0 : editorExtensions.prettier) == null ? void 0 : _a2.standaloneJs) || prettierUrl.main;
1106
- prettierScript.id = `${prefix}-prettier`;
1107
- prettierMDScript.src = ((_b2 = editorExtensions == null ? void 0 : editorExtensions.prettier) == null ? void 0 : _b2.parserMarkdownJs) || prettierUrl.markdown;
1108
- prettierMDScript.id = `${prefix}-prettierMD`;
1109
- const cropperLink = document.createElement("link");
1110
- cropperLink.rel = "stylesheet";
1111
- cropperLink.href = ((_c2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _c2.css) || cropperUrl.css;
1112
- cropperLink.id = `${prefix}-cropperCss`;
1113
- const cropperScript = document.createElement("script");
1114
- cropperScript.src = ((_d2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _d2.js) || cropperUrl.js;
1115
- cropperScript.id = `${prefix}-cropper`;
1116
1133
  if (!noCropperScript) {
1134
+ const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
1135
+ const cropperLink = createHTMLElement("link", {
1136
+ ...css,
1137
+ rel: "stylesheet",
1138
+ href: editorExtensions.cropper.css,
1139
+ id: `${prefix}-cropperCss`
1140
+ });
1141
+ const cropperScript = createHTMLElement("script", {
1142
+ ...js,
1143
+ src: editorExtensions.cropper.js,
1144
+ id: `${prefix}-cropper`
1145
+ });
1117
1146
  appendHandler(cropperLink);
1118
1147
  appendHandler(cropperScript);
1119
1148
  }
1120
1149
  if (!noPrettierScript) {
1150
+ const { standaloneJs = {} } = editorExtensionsAttrs.prettier || {};
1151
+ const prettierScript = createHTMLElement("script", {
1152
+ ...standaloneJs,
1153
+ src: editorExtensions.prettier.standaloneJs,
1154
+ id: `${prefix}-prettier`
1155
+ });
1121
1156
  appendHandler(prettierScript);
1122
1157
  }
1123
1158
  if (!noParserMarkdownScript) {
1159
+ const { parserMarkdownJs = {} } = editorExtensionsAttrs.prettier || {};
1160
+ const prettierMDScript = createHTMLElement("script", {
1161
+ ...parserMarkdownJs,
1162
+ src: editorExtensions.prettier.parserMarkdownJs,
1163
+ id: `${prefix}-prettierMD`
1164
+ });
1124
1165
  appendHandler(prettierMDScript);
1125
1166
  }
1126
1167
  });
@@ -1643,11 +1684,12 @@ const editorProps = {
1643
1684
  /**
1644
1685
  * 表格预设格子数
1645
1686
  *
1687
+ * 也可以是[6, 4, 10, 8]
1688
+ *
1646
1689
  * @default [6, 4]
1647
1690
  */
1648
1691
  tableShape: {
1649
- type: Array,
1650
- default: () => [6, 4]
1692
+ type: Array
1651
1693
  },
1652
1694
  /**
1653
1695
  * 空提示
@@ -107,7 +107,8 @@ const Dropdown = /* @__PURE__ */ defineComponent({
107
107
  ctx
108
108
  }, "overlay");
109
109
  const trigger = cloneVNode(slotDefault instanceof Array ? slotDefault[0] : slotDefault, {
110
- ref: triggerRef
110
+ ref: triggerRef,
111
+ key: "cloned-dropdown-trigger"
111
112
  });
112
113
  const overlay = createVNode("div", {
113
114
  "class": [`${prefix}-dropdown`, ctl.overlayClass],
@@ -151,6 +152,9 @@ const props = {
151
152
  theme: {
152
153
  type: String
153
154
  },
155
+ previewTheme: {
156
+ type: String
157
+ },
154
158
  /**
155
159
  * ==结束
156
160
  */
@@ -1,7 +1,8 @@
1
1
  import { defineComponent, createVNode, inject, h, ref, shallowRef, reactive, computed, watch, nextTick, onMounted, Teleport } from "vue";
2
- import { p as prefix, e as configOption } from "./config.mjs";
2
+ import { p as prefix, f as configOption } from "./config.mjs";
3
3
  import { g as getSlot } from "./vue-tsx.mjs";
4
4
  import { k as keyMove } from "./dom.mjs";
5
+ import { a as getZIndexIncrement } from "./index4.mjs";
5
6
  const Icon$1 = /* @__PURE__ */ defineComponent({
6
7
  props: {
7
8
  name: {
@@ -85,12 +86,6 @@ const props = {
85
86
  default: () => ({})
86
87
  }
87
88
  };
88
- const getNextIndex = /* @__PURE__ */ (() => {
89
- let startIndex = 2e4;
90
- return () => {
91
- return ++startIndex;
92
- };
93
- })();
94
89
  const MdModal = /* @__PURE__ */ defineComponent({
95
90
  name: "MdModal",
96
91
  props,
@@ -148,8 +143,8 @@ const MdModal = /* @__PURE__ */ defineComponent({
148
143
  });
149
144
  watch(() => props2.visible, (nVal) => {
150
145
  if (nVal) {
151
- state.maskStyle.zIndex = getNextIndex();
152
- state.modalStyle.zIndex = getNextIndex();
146
+ state.maskStyle.zIndex = configOption.editorConfig.zIndex + getZIndexIncrement();
147
+ state.modalStyle.zIndex = configOption.editorConfig.zIndex + getZIndexIncrement();
153
148
  modalClass.value.push("zoom-in");
154
149
  modalVisible.value = nVal;
155
150
  nextTick(() => {
@@ -1,76 +1,3 @@
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
- class Bus {
8
- constructor() {
9
- // 事件池
10
- __publicField(this, "pools", {});
11
- }
12
- // 移除事件监听
13
- remove(race, name, func) {
14
- const targetRace = this.pools[race];
15
- const events = targetRace && this.pools[race][name];
16
- if (events) {
17
- this.pools[race][name] = events.filter((item) => item !== func);
18
- }
19
- }
20
- // 清空全部事件,由于单一实例,多次注册会被共享内容
21
- clear(race) {
22
- this.pools[race] = {};
23
- }
24
- // 注册事件监听
25
- on(race, event) {
26
- if (!this.pools[race]) {
27
- this.pools[race] = {};
28
- }
29
- if (!this.pools[race][event.name]) {
30
- this.pools[race][event.name] = [];
31
- }
32
- this.pools[race][event.name].push(event.callback);
33
- return this.pools[race][event.name].includes(event.callback);
34
- }
35
- // 触发事件
36
- emit(race, name, ...params) {
37
- if (!this.pools[race]) {
38
- this.pools[race] = {};
39
- }
40
- const targetRace = this.pools[race];
41
- const events = targetRace[name];
42
- if (events) {
43
- events.forEach((item) => {
44
- try {
45
- item(...params);
46
- } catch (error) {
47
- console.error(`${name} monitor event exception!`, error);
48
- }
49
- });
50
- }
51
- }
52
- }
53
- const bus = new Bus();
54
- const ON_SAVE = "onSave";
55
- const CHANGE_CATALOG_VISIBLE = "changeCatalogVisible";
56
- const CHANGE_FULL_SCREEN = "changeFullscreen";
57
- const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
58
- const FULL_SCREEN_CHANGED = "fullscreenChanged";
59
- const PREVIEW_CHANGED = "previewChanged";
60
- const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
61
- const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
62
- const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
63
- const BUILD_FINISHED = "buildFinished";
64
- const ERROR_CATCHER = "errorCatcher";
65
- const REPLACE = "replace";
66
- const UPLOAD_IMAGE = "uploadImage";
67
- const OPEN_MODALS = "openModals";
68
- const CTRL_Z = "ctrlZ";
69
- const CTRL_SHIFT_Z = "ctrlShiftZ";
70
- const CATALOG_CHANGED = "catalogChanged";
71
- const PUSH_CATALOG = "pushCatalog";
72
- const RERENDER = "rerender";
73
- const EVENT_LISTENER = "eventListener";
74
1
  const base642File = (base64, fileName = "image.png") => {
75
2
  const arr = base64.split(",");
76
3
  const regResult = arr[0].match(/:(.*?);/);
@@ -115,30 +42,16 @@ const getNextId = /* @__PURE__ */ (() => {
115
42
  return prefix + ++count;
116
43
  };
117
44
  })();
45
+ const getZIndexIncrement = /* @__PURE__ */ (() => {
46
+ let startIndex = 0;
47
+ return () => {
48
+ return ++startIndex;
49
+ };
50
+ })();
118
51
  export {
119
- BUILD_FINISHED as B,
120
- CATALOG_CHANGED as C,
121
- ERROR_CATCHER as E,
122
- FULL_SCREEN_CHANGED as F,
123
- HTML_PREVIEW_CHANGED as H,
124
- ON_SAVE as O,
125
- PUSH_CATALOG as P,
126
- RERENDER as R,
127
- UPLOAD_IMAGE as U,
128
- generateCodeRowNumber as a,
129
- bus as b,
130
- CHANGE_CATALOG_VISIBLE as c,
131
- PAGE_FULL_SCREEN_CHANGED as d,
132
- PREVIEW_CHANGED as e,
133
- PREVIEW_ONLY_CHANGED as f,
134
- getRelativeTop as g,
135
- CATALOG_VISIBLE_CHANGED as h,
136
- REPLACE as i,
137
- CHANGE_FULL_SCREEN as j,
138
- EVENT_LISTENER as k,
139
- getNextId as l,
140
- base642File as m,
141
- OPEN_MODALS as n,
142
- CTRL_SHIFT_Z as o,
143
- CTRL_Z as p
52
+ getZIndexIncrement as a,
53
+ generateCodeRowNumber as b,
54
+ getNextId as c,
55
+ base642File as d,
56
+ getRelativeTop as g
144
57
  };