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.
- package/README.md +18 -2
- package/lib/cjs/MdCatalog.cjs +14 -8
- package/lib/cjs/MdEditor.cjs +105 -79
- package/lib/cjs/ModalToolbar.cjs +3 -0
- package/lib/cjs/chunks/config.cjs +174 -16
- package/lib/cjs/chunks/dom.cjs +14 -5
- package/lib/cjs/chunks/event-name.cjs +95 -0
- package/lib/cjs/chunks/index.cjs +207 -165
- package/lib/cjs/chunks/index2.cjs +5 -1
- 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 +52 -26
- package/lib/es/ModalToolbar.mjs +3 -0
- package/lib/es/chunks/config.mjs +176 -18
- package/lib/es/chunks/dom.mjs +14 -5
- package/lib/es/chunks/event-name.mjs +96 -0
- package/lib/es/chunks/index.mjs +159 -117
- package/lib/es/chunks/index2.mjs +5 -1
- 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/preview.css +1 -1
- package/lib/style.css +1 -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 +9 -1
- 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 +43 -43
- package/package.json +3 -3
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const vue = require("vue");
|
|
3
3
|
const config = require("./config.cjs");
|
|
4
|
-
const
|
|
4
|
+
const eventName = require("./event-name.cjs");
|
|
5
5
|
const dom = require("./dom.cjs");
|
|
6
6
|
const util = require("@vavt/util");
|
|
7
7
|
const mediumZoom = require("medium-zoom");
|
|
@@ -10,6 +10,7 @@ const mdit = require("markdown-it");
|
|
|
10
10
|
const ImageFiguresPlugin = require("markdown-it-image-figures");
|
|
11
11
|
const TaskListPlugin = require("markdown-it-task-lists");
|
|
12
12
|
const XSSPlugin = require("markdown-it-xss");
|
|
13
|
+
const index = require("./index4.cjs");
|
|
13
14
|
const lruCache = require("lru-cache");
|
|
14
15
|
const userZoom = (props, html) => {
|
|
15
16
|
const editorId = vue.inject("editorId");
|
|
@@ -59,21 +60,20 @@ const useCopyCode = (props, html, key) => {
|
|
|
59
60
|
const customIcon = vue.inject("customIcon");
|
|
60
61
|
const initCopyEntry = () => {
|
|
61
62
|
document.querySelectorAll(`#${editorId}-preview pre`).forEach((pre) => {
|
|
62
|
-
var _a
|
|
63
|
+
var _a;
|
|
63
64
|
let clearTimer = -1;
|
|
64
65
|
(_a = pre.querySelector(".copy-button")) == null ? void 0 : _a.remove();
|
|
65
|
-
const copyBtnText =
|
|
66
|
+
const copyBtnText = ult.value.copyCode.text;
|
|
66
67
|
const copyButton = document.createElement("span");
|
|
67
68
|
copyButton.setAttribute("class", "copy-button");
|
|
68
69
|
copyButton.dataset.tips = copyBtnText;
|
|
69
70
|
copyButton.innerHTML = StrIcon("copy", customIcon.value);
|
|
70
71
|
copyButton.addEventListener("click", () => {
|
|
71
|
-
var _a2, _b2;
|
|
72
72
|
clearTimeout(clearTimer);
|
|
73
73
|
const codeText = pre.querySelector("code").innerText;
|
|
74
74
|
const success = copy(props.formatCopiedText(codeText));
|
|
75
|
-
const succssTip =
|
|
76
|
-
const failTip =
|
|
75
|
+
const succssTip = ult.value.copyCode.successTips;
|
|
76
|
+
const failTip = ult.value.copyCode.failTips;
|
|
77
77
|
copyButton.dataset.tips = success ? succssTip : failTip;
|
|
78
78
|
clearTimer = window.setTimeout(() => {
|
|
79
79
|
copyButton.dataset.tips = copyBtnText;
|
|
@@ -97,43 +97,45 @@ const useCopyCode = (props, html, key) => {
|
|
|
97
97
|
vue.onMounted(initCopyEntry);
|
|
98
98
|
};
|
|
99
99
|
const useHighlight = (props) => {
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const hljs = hljsConf == null ? void 0 : hljsConf.instance;
|
|
103
|
-
const highlightUrl = vue.inject("highlight");
|
|
104
|
-
const hljsRef = vue.shallowRef(hljs);
|
|
100
|
+
const highlight = vue.inject("highlight");
|
|
101
|
+
const hljsRef = vue.shallowRef(config.configOption.editorExtensions.highlight.instance);
|
|
105
102
|
vue.onMounted(() => {
|
|
106
|
-
if (props.noHighlight) {
|
|
103
|
+
if (props.noHighlight || hljsRef.value) {
|
|
107
104
|
return;
|
|
108
105
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
const highlightScript = dom.createHTMLElement("script", {
|
|
107
|
+
...highlight.value.js,
|
|
108
|
+
id: `${config.prefix}-hljs`,
|
|
109
|
+
onload() {
|
|
113
110
|
hljsRef.value = window.hljs;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const highlightLink = dom.createHTMLElement("link", {
|
|
114
|
+
...highlight.value.css,
|
|
115
|
+
rel: "stylesheet",
|
|
116
|
+
id: `${config.prefix}-hlCss`
|
|
117
|
+
});
|
|
118
|
+
dom.appendHandler(highlightLink);
|
|
119
|
+
dom.appendHandler(highlightScript, "hljs");
|
|
123
120
|
});
|
|
124
121
|
vue.watch(
|
|
125
|
-
() =>
|
|
126
|
-
(
|
|
127
|
-
dom.updateHandler(
|
|
122
|
+
() => highlight.value.css,
|
|
123
|
+
() => {
|
|
124
|
+
dom.updateHandler(
|
|
125
|
+
dom.createHTMLElement("link", {
|
|
126
|
+
...highlight.value.css,
|
|
127
|
+
rel: "stylesheet",
|
|
128
|
+
id: `${config.prefix}-hlCss`
|
|
129
|
+
})
|
|
130
|
+
);
|
|
128
131
|
}
|
|
129
132
|
);
|
|
130
133
|
return hljsRef;
|
|
131
134
|
};
|
|
132
135
|
const useMermaid = (props) => {
|
|
133
136
|
const theme = vue.inject("theme");
|
|
134
|
-
const { editorExtensions, mermaidConfig } = config.configOption;
|
|
135
|
-
const
|
|
136
|
-
const mermaidRef = vue.shallowRef(mermaidConf == null ? void 0 : mermaidConf.instance);
|
|
137
|
+
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.configOption;
|
|
138
|
+
const mermaidRef = vue.shallowRef(editorExtensions.mermaid.instance);
|
|
137
139
|
const reRenderRef = vue.shallowRef(-1);
|
|
138
140
|
const mermaidCache = new lruCache.LRUCache({
|
|
139
141
|
max: 1e3,
|
|
@@ -160,30 +162,38 @@ const useMermaid = (props) => {
|
|
|
160
162
|
}
|
|
161
163
|
);
|
|
162
164
|
vue.onMounted(() => {
|
|
163
|
-
|
|
165
|
+
var _a, _b, _c;
|
|
166
|
+
if (props.noMermaid || ((_a = mermaidRef.value) == null ? void 0 : _a.instance)) {
|
|
164
167
|
return;
|
|
165
168
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
169
|
+
const jsSrc = editorExtensions.mermaid.js;
|
|
170
|
+
if (/\.mjs/.test(jsSrc)) {
|
|
171
|
+
const modulePreload = dom.createHTMLElement("link", {
|
|
172
|
+
...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
|
|
173
|
+
rel: "modulepreload",
|
|
174
|
+
href: jsSrc,
|
|
175
|
+
id: `${config.prefix}-mermaid-m`
|
|
176
|
+
});
|
|
177
|
+
dom.appendHandler(modulePreload);
|
|
178
|
+
import(
|
|
179
|
+
/* @vite-ignore */
|
|
180
|
+
/* webpackIgnore: true */
|
|
181
|
+
jsSrc
|
|
182
|
+
).then((module2) => {
|
|
183
|
+
mermaidRef.value = module2.default;
|
|
184
|
+
configMermaid();
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
const mermaidScript = dom.createHTMLElement("script", {
|
|
188
|
+
...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
|
|
189
|
+
src: jsSrc,
|
|
190
|
+
id: `${config.prefix}-mermaid`,
|
|
191
|
+
onload() {
|
|
182
192
|
mermaidRef.value = window.mermaid;
|
|
183
193
|
configMermaid();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
dom.appendHandler(mermaidScript, "mermaid");
|
|
187
197
|
}
|
|
188
198
|
});
|
|
189
199
|
const replaceMermaid = () => {
|
|
@@ -235,25 +245,26 @@ const useMermaid = (props) => {
|
|
|
235
245
|
return { mermaidRef, reRenderRef, replaceMermaid };
|
|
236
246
|
};
|
|
237
247
|
const useKatex = (props) => {
|
|
238
|
-
|
|
239
|
-
const katexConf = (_a = config.configOption.editorExtensions) == null ? void 0 : _a.katex;
|
|
240
|
-
const katexIns = katexConf == null ? void 0 : katexConf.instance;
|
|
241
|
-
const katex = vue.shallowRef(katexIns);
|
|
248
|
+
const katex = vue.shallowRef(config.configOption.editorExtensions.katex.instance);
|
|
242
249
|
vue.onMounted(() => {
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
katexScript.src = (katexConf == null ? void 0 : katexConf.js) || config.katexUrl.js;
|
|
246
|
-
katexScript.onload = () => {
|
|
247
|
-
katex.value = window.katex;
|
|
248
|
-
};
|
|
249
|
-
katexScript.id = `${config.prefix}-katex`;
|
|
250
|
-
const katexLink = document.createElement("link");
|
|
251
|
-
katexLink.rel = "stylesheet";
|
|
252
|
-
katexLink.href = (katexConf == null ? void 0 : katexConf.css) || config.katexUrl.css;
|
|
253
|
-
katexLink.id = `${config.prefix}-katexCss`;
|
|
254
|
-
dom.appendHandler(katexScript, "katex");
|
|
255
|
-
dom.appendHandler(katexLink);
|
|
250
|
+
if (props.noKatex || katex.value) {
|
|
251
|
+
return;
|
|
256
252
|
}
|
|
253
|
+
const { editorExtensions } = config.configOption;
|
|
254
|
+
const katexScript = dom.createHTMLElement("script", {
|
|
255
|
+
src: editorExtensions.katex.js,
|
|
256
|
+
id: `${config.prefix}-katex`,
|
|
257
|
+
onload() {
|
|
258
|
+
katex.value = window.katex;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const katexLink = dom.createHTMLElement("link", {
|
|
262
|
+
rel: "stylesheet",
|
|
263
|
+
href: editorExtensions.katex.css,
|
|
264
|
+
id: `${config.prefix}-katexCss`
|
|
265
|
+
});
|
|
266
|
+
dom.appendHandler(katexScript, "katex");
|
|
267
|
+
dom.appendHandler(katexLink);
|
|
257
268
|
});
|
|
258
269
|
return katex;
|
|
259
270
|
};
|
|
@@ -762,10 +773,10 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
762
773
|
const key = vue.ref(`_article-key_${util.uuid()}`);
|
|
763
774
|
const html = vue.ref(props.sanitize(md.render(props.modelValue)));
|
|
764
775
|
const updatedTodo = () => {
|
|
765
|
-
|
|
776
|
+
eventName.bus.emit(editorId, eventName.BUILD_FINISHED, html.value);
|
|
766
777
|
props.onHtmlChanged(html.value);
|
|
767
778
|
props.onGetCatalog(headsRef.value);
|
|
768
|
-
|
|
779
|
+
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
769
780
|
replaceMermaid();
|
|
770
781
|
};
|
|
771
782
|
vue.onMounted(updatedTodo);
|
|
@@ -779,20 +790,27 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
779
790
|
});
|
|
780
791
|
vue.watch(
|
|
781
792
|
[vue.toRef(props, "modelValue"), needReRender, reRenderRef],
|
|
782
|
-
util.debounce(
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
)
|
|
793
|
+
util.debounce(markHtml, previewOnly ? 0 : editorConfig.renderDelay)
|
|
794
|
+
);
|
|
795
|
+
vue.watch(
|
|
796
|
+
() => props.setting.preview,
|
|
797
|
+
() => {
|
|
798
|
+
if (props.setting.preview) {
|
|
799
|
+
vue.nextTick(() => {
|
|
800
|
+
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
786
804
|
);
|
|
787
805
|
vue.onMounted(() => {
|
|
788
|
-
|
|
789
|
-
name:
|
|
806
|
+
eventName.bus.on(editorId, {
|
|
807
|
+
name: eventName.PUSH_CATALOG,
|
|
790
808
|
callback() {
|
|
791
|
-
|
|
809
|
+
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
792
810
|
}
|
|
793
811
|
});
|
|
794
|
-
|
|
795
|
-
name:
|
|
812
|
+
eventName.bus.on(editorId, {
|
|
813
|
+
name: eventName.RERENDER,
|
|
796
814
|
callback: () => {
|
|
797
815
|
markHtml();
|
|
798
816
|
key.value = `_article-key_${util.uuid()}`;
|
|
@@ -987,15 +1005,15 @@ const useOnSave = (props, context) => {
|
|
|
987
1005
|
}
|
|
988
1006
|
);
|
|
989
1007
|
vue.onMounted(() => {
|
|
990
|
-
|
|
991
|
-
name:
|
|
1008
|
+
eventName.bus.on(editorId, {
|
|
1009
|
+
name: eventName.BUILD_FINISHED,
|
|
992
1010
|
callback(html) {
|
|
993
1011
|
state.buildFinished = true;
|
|
994
1012
|
state.html = html;
|
|
995
1013
|
}
|
|
996
1014
|
});
|
|
997
|
-
|
|
998
|
-
name:
|
|
1015
|
+
eventName.bus.on(editorId, {
|
|
1016
|
+
name: eventName.ON_SAVE,
|
|
999
1017
|
callback() {
|
|
1000
1018
|
const htmlPromise = new Promise((rev) => {
|
|
1001
1019
|
if (state.buildFinished) {
|
|
@@ -1003,10 +1021,10 @@ const useOnSave = (props, context) => {
|
|
|
1003
1021
|
} else {
|
|
1004
1022
|
const buildFinishedCallback = (html) => {
|
|
1005
1023
|
rev(html);
|
|
1006
|
-
|
|
1024
|
+
eventName.bus.remove(editorId, eventName.BUILD_FINISHED, buildFinishedCallback);
|
|
1007
1025
|
};
|
|
1008
|
-
|
|
1009
|
-
name:
|
|
1026
|
+
eventName.bus.on(editorId, {
|
|
1027
|
+
name: eventName.BUILD_FINISHED,
|
|
1010
1028
|
callback: buildFinishedCallback
|
|
1011
1029
|
});
|
|
1012
1030
|
}
|
|
@@ -1021,9 +1039,9 @@ const useOnSave = (props, context) => {
|
|
|
1021
1039
|
});
|
|
1022
1040
|
};
|
|
1023
1041
|
const useProvidePreview = (props) => {
|
|
1024
|
-
var _a, _b;
|
|
1025
1042
|
const { editorId } = props;
|
|
1026
|
-
const
|
|
1043
|
+
const hljsUrls = config.configOption.editorExtensions.highlight;
|
|
1044
|
+
const hljsAttrs = config.configOption.editorExtensionsAttrs.highlight;
|
|
1027
1045
|
vue.provide("editorId", editorId);
|
|
1028
1046
|
vue.provide(
|
|
1029
1047
|
"theme",
|
|
@@ -1036,23 +1054,32 @@ const useProvidePreview = (props) => {
|
|
|
1036
1054
|
vue.provide(
|
|
1037
1055
|
"highlight",
|
|
1038
1056
|
vue.computed(() => {
|
|
1057
|
+
const { js: jsUrl } = hljsUrls;
|
|
1039
1058
|
const cssList = {
|
|
1040
1059
|
...config.codeCss,
|
|
1041
|
-
...
|
|
1060
|
+
...hljsUrls.css
|
|
1042
1061
|
};
|
|
1043
|
-
const
|
|
1062
|
+
const { js: jsAttrs, css: cssAttrs = {} } = hljsAttrs || {};
|
|
1063
|
+
const _theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
|
|
1064
|
+
const codeCssHref = cssList[props.codeTheme] ? cssList[props.codeTheme][_theme] : config.codeCss.atom[_theme];
|
|
1065
|
+
const codeCssAttrs = cssList[props.codeTheme] && cssAttrs[props.codeTheme] ? cssAttrs[props.codeTheme][_theme] : cssAttrs["atom"] ? cssAttrs["atom"][_theme] : {};
|
|
1044
1066
|
return {
|
|
1045
|
-
js:
|
|
1046
|
-
|
|
1067
|
+
js: {
|
|
1068
|
+
src: jsUrl,
|
|
1069
|
+
...jsAttrs
|
|
1070
|
+
},
|
|
1071
|
+
css: {
|
|
1072
|
+
href: codeCssHref,
|
|
1073
|
+
...codeCssAttrs
|
|
1074
|
+
}
|
|
1047
1075
|
};
|
|
1048
1076
|
})
|
|
1049
1077
|
);
|
|
1050
1078
|
vue.provide("showCodeRowNumber", props.showCodeRowNumber);
|
|
1051
1079
|
const usedLanguageText = vue.computed(() => {
|
|
1052
|
-
var _a2, _b2;
|
|
1053
1080
|
const allText = {
|
|
1054
1081
|
...config.staticTextDefault,
|
|
1055
|
-
...
|
|
1082
|
+
...config.configOption.editorConfig.languageUserDefined
|
|
1056
1083
|
};
|
|
1057
1084
|
return util.deepMerge(
|
|
1058
1085
|
util.deepClone(config.staticTextDefault["en-US"]),
|
|
@@ -1075,53 +1102,67 @@ const useProvide = (props) => {
|
|
|
1075
1102
|
};
|
|
1076
1103
|
const useExpansionPreview = (props) => {
|
|
1077
1104
|
vue.onMounted(() => {
|
|
1078
|
-
|
|
1079
|
-
if (
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1105
|
+
const { editorExtensions, editorExtensionsAttrs, iconfontType } = config.configOption;
|
|
1106
|
+
if (props.noIconfont) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if (iconfontType === "svg") {
|
|
1110
|
+
const iconfontScript = dom.createHTMLElement("script", {
|
|
1111
|
+
...editorExtensionsAttrs.iconfont,
|
|
1112
|
+
src: editorExtensions.iconfont,
|
|
1113
|
+
id: `${config.prefix}-icon`
|
|
1114
|
+
});
|
|
1115
|
+
dom.appendHandler(iconfontScript);
|
|
1116
|
+
} else {
|
|
1117
|
+
const iconfontLink = dom.createHTMLElement("link", {
|
|
1118
|
+
...editorExtensionsAttrs.iconfontClass,
|
|
1119
|
+
rel: "stylesheet",
|
|
1120
|
+
href: editorExtensions.iconfontClass,
|
|
1121
|
+
id: `${config.prefix}-icon-class`
|
|
1122
|
+
});
|
|
1123
|
+
dom.appendHandler(iconfontLink);
|
|
1092
1124
|
}
|
|
1093
1125
|
});
|
|
1094
1126
|
};
|
|
1095
1127
|
const useExpansion = (props) => {
|
|
1096
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1097
1128
|
const { noPrettier, noUploadImg } = props;
|
|
1098
|
-
const { editorExtensions } = config.configOption;
|
|
1099
|
-
const noPrettierScript = noPrettier ||
|
|
1100
|
-
const noParserMarkdownScript = noPrettier ||
|
|
1101
|
-
const noCropperScript = noUploadImg ||
|
|
1129
|
+
const { editorExtensions, editorExtensionsAttrs } = config.configOption;
|
|
1130
|
+
const noPrettierScript = noPrettier || editorExtensions.prettier.prettierInstance;
|
|
1131
|
+
const noParserMarkdownScript = noPrettier || editorExtensions.prettier.parserMarkdownInstance;
|
|
1132
|
+
const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
|
|
1102
1133
|
vue.onMounted(() => {
|
|
1103
|
-
var _a2, _b2, _c2, _d2;
|
|
1104
|
-
const prettierScript = document.createElement("script");
|
|
1105
|
-
const prettierMDScript = document.createElement("script");
|
|
1106
|
-
prettierScript.src = ((_a2 = editorExtensions == null ? void 0 : editorExtensions.prettier) == null ? void 0 : _a2.standaloneJs) || config.prettierUrl.main;
|
|
1107
|
-
prettierScript.id = `${config.prefix}-prettier`;
|
|
1108
|
-
prettierMDScript.src = ((_b2 = editorExtensions == null ? void 0 : editorExtensions.prettier) == null ? void 0 : _b2.parserMarkdownJs) || config.prettierUrl.markdown;
|
|
1109
|
-
prettierMDScript.id = `${config.prefix}-prettierMD`;
|
|
1110
|
-
const cropperLink = document.createElement("link");
|
|
1111
|
-
cropperLink.rel = "stylesheet";
|
|
1112
|
-
cropperLink.href = ((_c2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _c2.css) || config.cropperUrl.css;
|
|
1113
|
-
cropperLink.id = `${config.prefix}-cropperCss`;
|
|
1114
|
-
const cropperScript = document.createElement("script");
|
|
1115
|
-
cropperScript.src = ((_d2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _d2.js) || config.cropperUrl.js;
|
|
1116
|
-
cropperScript.id = `${config.prefix}-cropper`;
|
|
1117
1134
|
if (!noCropperScript) {
|
|
1135
|
+
const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
|
|
1136
|
+
const cropperLink = dom.createHTMLElement("link", {
|
|
1137
|
+
...css,
|
|
1138
|
+
rel: "stylesheet",
|
|
1139
|
+
href: editorExtensions.cropper.css,
|
|
1140
|
+
id: `${config.prefix}-cropperCss`
|
|
1141
|
+
});
|
|
1142
|
+
const cropperScript = dom.createHTMLElement("script", {
|
|
1143
|
+
...js,
|
|
1144
|
+
src: editorExtensions.cropper.js,
|
|
1145
|
+
id: `${config.prefix}-cropper`
|
|
1146
|
+
});
|
|
1118
1147
|
dom.appendHandler(cropperLink);
|
|
1119
1148
|
dom.appendHandler(cropperScript);
|
|
1120
1149
|
}
|
|
1121
1150
|
if (!noPrettierScript) {
|
|
1151
|
+
const { standaloneJs = {} } = editorExtensionsAttrs.prettier || {};
|
|
1152
|
+
const prettierScript = dom.createHTMLElement("script", {
|
|
1153
|
+
...standaloneJs,
|
|
1154
|
+
src: editorExtensions.prettier.standaloneJs,
|
|
1155
|
+
id: `${config.prefix}-prettier`
|
|
1156
|
+
});
|
|
1122
1157
|
dom.appendHandler(prettierScript);
|
|
1123
1158
|
}
|
|
1124
1159
|
if (!noParserMarkdownScript) {
|
|
1160
|
+
const { parserMarkdownJs = {} } = editorExtensionsAttrs.prettier || {};
|
|
1161
|
+
const prettierMDScript = dom.createHTMLElement("script", {
|
|
1162
|
+
...parserMarkdownJs,
|
|
1163
|
+
src: editorExtensions.prettier.parserMarkdownJs,
|
|
1164
|
+
id: `${config.prefix}-prettierMD`
|
|
1165
|
+
});
|
|
1125
1166
|
dom.appendHandler(prettierMDScript);
|
|
1126
1167
|
}
|
|
1127
1168
|
});
|
|
@@ -1130,8 +1171,8 @@ const useExpansion = (props) => {
|
|
|
1130
1171
|
const useErrorCatcher = (props, context) => {
|
|
1131
1172
|
const { editorId } = props;
|
|
1132
1173
|
vue.onMounted(() => {
|
|
1133
|
-
|
|
1134
|
-
name:
|
|
1174
|
+
eventName.bus.on(editorId, {
|
|
1175
|
+
name: eventName.ERROR_CATCHER,
|
|
1135
1176
|
callback: (err) => {
|
|
1136
1177
|
if (props.onError instanceof Function) {
|
|
1137
1178
|
props.onError(err);
|
|
@@ -1173,11 +1214,11 @@ const useConfig = (props, context) => {
|
|
|
1173
1214
|
};
|
|
1174
1215
|
vue.watch(() => [setting.pageFullscreen, setting.fullscreen], adjustBody);
|
|
1175
1216
|
vue.onMounted(() => {
|
|
1176
|
-
|
|
1177
|
-
name:
|
|
1217
|
+
eventName.bus.on(editorId, {
|
|
1218
|
+
name: eventName.UPLOAD_IMAGE,
|
|
1178
1219
|
callback(files, cb) {
|
|
1179
1220
|
const insertHanlder = (urls) => {
|
|
1180
|
-
|
|
1221
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "image", {
|
|
1181
1222
|
desc: "",
|
|
1182
1223
|
urls
|
|
1183
1224
|
});
|
|
@@ -1199,8 +1240,8 @@ const useCatalog = (props) => {
|
|
|
1199
1240
|
const { editorId } = props;
|
|
1200
1241
|
const catalogShow = vue.ref(false);
|
|
1201
1242
|
vue.onMounted(() => {
|
|
1202
|
-
|
|
1203
|
-
name:
|
|
1243
|
+
eventName.bus.on(editorId, {
|
|
1244
|
+
name: eventName.CHANGE_CATALOG_VISIBLE,
|
|
1204
1245
|
callback: (v) => {
|
|
1205
1246
|
if (v === void 0) {
|
|
1206
1247
|
catalogShow.value = !catalogShow.value;
|
|
@@ -1220,42 +1261,42 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1220
1261
|
vue.watch(
|
|
1221
1262
|
() => setting.pageFullscreen,
|
|
1222
1263
|
(newVal) => {
|
|
1223
|
-
|
|
1264
|
+
eventName.bus.emit(editorId, eventName.PAGE_FULL_SCREEN_CHANGED, newVal);
|
|
1224
1265
|
}
|
|
1225
1266
|
);
|
|
1226
1267
|
vue.watch(
|
|
1227
1268
|
() => setting.fullscreen,
|
|
1228
1269
|
(newVal) => {
|
|
1229
|
-
|
|
1270
|
+
eventName.bus.emit(editorId, eventName.FULL_SCREEN_CHANGED, newVal);
|
|
1230
1271
|
}
|
|
1231
1272
|
);
|
|
1232
1273
|
vue.watch(
|
|
1233
1274
|
() => setting.preview,
|
|
1234
1275
|
(newVal) => {
|
|
1235
|
-
|
|
1276
|
+
eventName.bus.emit(editorId, eventName.PREVIEW_CHANGED, newVal);
|
|
1236
1277
|
}
|
|
1237
1278
|
);
|
|
1238
1279
|
vue.watch(
|
|
1239
1280
|
() => setting.previewOnly,
|
|
1240
1281
|
(newVal) => {
|
|
1241
|
-
|
|
1282
|
+
eventName.bus.emit(editorId, eventName.PREVIEW_ONLY_CHANGED, newVal);
|
|
1242
1283
|
}
|
|
1243
1284
|
);
|
|
1244
1285
|
vue.watch(
|
|
1245
1286
|
() => setting.htmlPreview,
|
|
1246
1287
|
(newVal) => {
|
|
1247
|
-
|
|
1288
|
+
eventName.bus.emit(editorId, eventName.HTML_PREVIEW_CHANGED, newVal);
|
|
1248
1289
|
}
|
|
1249
1290
|
);
|
|
1250
1291
|
vue.watch(catalogVisible, (newVal) => {
|
|
1251
|
-
|
|
1292
|
+
eventName.bus.emit(editorId, eventName.CATALOG_VISIBLE_CHANGED, newVal);
|
|
1252
1293
|
});
|
|
1253
1294
|
const exposeParam = {
|
|
1254
|
-
on(eventName, callBack) {
|
|
1255
|
-
switch (eventName) {
|
|
1295
|
+
on(eventName$1, callBack) {
|
|
1296
|
+
switch (eventName$1) {
|
|
1256
1297
|
case "pageFullscreen": {
|
|
1257
|
-
|
|
1258
|
-
name:
|
|
1298
|
+
eventName.bus.on(editorId, {
|
|
1299
|
+
name: eventName.PAGE_FULL_SCREEN_CHANGED,
|
|
1259
1300
|
callback(status) {
|
|
1260
1301
|
callBack(status);
|
|
1261
1302
|
}
|
|
@@ -1263,8 +1304,8 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1263
1304
|
break;
|
|
1264
1305
|
}
|
|
1265
1306
|
case "fullscreen": {
|
|
1266
|
-
|
|
1267
|
-
name:
|
|
1307
|
+
eventName.bus.on(editorId, {
|
|
1308
|
+
name: eventName.FULL_SCREEN_CHANGED,
|
|
1268
1309
|
callback(status) {
|
|
1269
1310
|
callBack(status);
|
|
1270
1311
|
}
|
|
@@ -1272,8 +1313,8 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1272
1313
|
break;
|
|
1273
1314
|
}
|
|
1274
1315
|
case "preview": {
|
|
1275
|
-
|
|
1276
|
-
name:
|
|
1316
|
+
eventName.bus.on(editorId, {
|
|
1317
|
+
name: eventName.PREVIEW_CHANGED,
|
|
1277
1318
|
callback(status) {
|
|
1278
1319
|
callBack(status);
|
|
1279
1320
|
}
|
|
@@ -1281,8 +1322,8 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1281
1322
|
break;
|
|
1282
1323
|
}
|
|
1283
1324
|
case "previewOnly": {
|
|
1284
|
-
|
|
1285
|
-
name:
|
|
1325
|
+
eventName.bus.on(editorId, {
|
|
1326
|
+
name: eventName.PREVIEW_ONLY_CHANGED,
|
|
1286
1327
|
callback(status) {
|
|
1287
1328
|
callBack(status);
|
|
1288
1329
|
}
|
|
@@ -1290,8 +1331,8 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1290
1331
|
break;
|
|
1291
1332
|
}
|
|
1292
1333
|
case "htmlPreview": {
|
|
1293
|
-
|
|
1294
|
-
name:
|
|
1334
|
+
eventName.bus.on(editorId, {
|
|
1335
|
+
name: eventName.HTML_PREVIEW_CHANGED,
|
|
1295
1336
|
callback(status) {
|
|
1296
1337
|
callBack(status);
|
|
1297
1338
|
}
|
|
@@ -1299,8 +1340,8 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1299
1340
|
break;
|
|
1300
1341
|
}
|
|
1301
1342
|
case "catalog": {
|
|
1302
|
-
|
|
1303
|
-
name:
|
|
1343
|
+
eventName.bus.on(editorId, {
|
|
1344
|
+
name: eventName.CATALOG_VISIBLE_CHANGED,
|
|
1304
1345
|
callback(status) {
|
|
1305
1346
|
callBack(status);
|
|
1306
1347
|
}
|
|
@@ -1313,7 +1354,7 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1313
1354
|
updateSetting("pageFullscreen", status);
|
|
1314
1355
|
},
|
|
1315
1356
|
toggleFullscreen(status) {
|
|
1316
|
-
|
|
1357
|
+
eventName.bus.emit(editorId, eventName.CHANGE_FULL_SCREEN, status);
|
|
1317
1358
|
},
|
|
1318
1359
|
togglePreview(status) {
|
|
1319
1360
|
updateSetting("preview", status);
|
|
@@ -1325,20 +1366,20 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1325
1366
|
updateSetting("htmlPreview", status);
|
|
1326
1367
|
},
|
|
1327
1368
|
toggleCatalog(status) {
|
|
1328
|
-
|
|
1369
|
+
eventName.bus.emit(editorId, eventName.CHANGE_CATALOG_VISIBLE, status);
|
|
1329
1370
|
},
|
|
1330
1371
|
triggerSave() {
|
|
1331
|
-
|
|
1372
|
+
eventName.bus.emit(editorId, eventName.ON_SAVE);
|
|
1332
1373
|
},
|
|
1333
1374
|
insert(generate) {
|
|
1334
|
-
|
|
1375
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "universal", { generate });
|
|
1335
1376
|
},
|
|
1336
1377
|
focus(options) {
|
|
1337
1378
|
var _a;
|
|
1338
1379
|
(_a = codeRef.value) == null ? void 0 : _a.focus(options);
|
|
1339
1380
|
},
|
|
1340
1381
|
rerender() {
|
|
1341
|
-
|
|
1382
|
+
eventName.bus.emit(editorId, eventName.RERENDER);
|
|
1342
1383
|
},
|
|
1343
1384
|
getSelectedText() {
|
|
1344
1385
|
var _a;
|
|
@@ -1349,10 +1390,10 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1349
1390
|
(_a = codeRef.value) == null ? void 0 : _a.resetHistory();
|
|
1350
1391
|
},
|
|
1351
1392
|
domEventHandlers(handlers) {
|
|
1352
|
-
|
|
1393
|
+
eventName.bus.emit(editorId, eventName.EVENT_LISTENER, handlers);
|
|
1353
1394
|
},
|
|
1354
1395
|
execCommand(direct) {
|
|
1355
|
-
|
|
1396
|
+
eventName.bus.emit(editorId, eventName.REPLACE, direct);
|
|
1356
1397
|
}
|
|
1357
1398
|
};
|
|
1358
1399
|
ctx.expose(exposeParam);
|
|
@@ -1644,11 +1685,12 @@ const editorProps = {
|
|
|
1644
1685
|
/**
|
|
1645
1686
|
* 表格预设格子数
|
|
1646
1687
|
*
|
|
1688
|
+
* 也可以是[6, 4, 10, 8]
|
|
1689
|
+
*
|
|
1647
1690
|
* @default [6, 4]
|
|
1648
1691
|
*/
|
|
1649
1692
|
tableShape: {
|
|
1650
|
-
type: Array
|
|
1651
|
-
default: () => [6, 4]
|
|
1693
|
+
type: Array
|
|
1652
1694
|
},
|
|
1653
1695
|
/**
|
|
1654
1696
|
* 空提示
|
|
@@ -1828,7 +1870,7 @@ const useExpose = (props, ctx) => {
|
|
|
1828
1870
|
const { editorId } = props;
|
|
1829
1871
|
const exposeParam = {
|
|
1830
1872
|
rerender() {
|
|
1831
|
-
|
|
1873
|
+
eventName.bus.emit(editorId, eventName.RERENDER);
|
|
1832
1874
|
}
|
|
1833
1875
|
};
|
|
1834
1876
|
ctx.expose(exposeParam);
|
|
@@ -1848,7 +1890,7 @@ const MdPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
1848
1890
|
useExpansionPreview(props);
|
|
1849
1891
|
useExpose(props, ctx);
|
|
1850
1892
|
vue.onBeforeUnmount(() => {
|
|
1851
|
-
|
|
1893
|
+
eventName.bus.clear(editorId);
|
|
1852
1894
|
});
|
|
1853
1895
|
return () => {
|
|
1854
1896
|
return vue.createVNode("div", {
|