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/es/chunks/dom.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { debounce } from "@vavt/util";
|
|
2
1
|
const keyMove = (trigger, moveHandler) => {
|
|
3
2
|
const triggerMouseDown = (mdown) => {
|
|
4
3
|
const parent = trigger.parentElement || document.body;
|
|
@@ -32,32 +31,37 @@ const keyMove = (trigger, moveHandler) => {
|
|
|
32
31
|
trigger.removeEventListener("mousedown", triggerMouseDown);
|
|
33
32
|
};
|
|
34
33
|
};
|
|
35
|
-
const appendHandler = (
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
ele.onload = null;
|
|
39
|
-
const onload = function(e) {
|
|
40
|
-
if (typeof onload_ === "function") {
|
|
41
|
-
onload_.bind(this)(e);
|
|
42
|
-
}
|
|
43
|
-
ele.removeEventListener("load", onload);
|
|
44
|
-
};
|
|
34
|
+
const appendHandler = (tagName, attributes, checkKey = "") => {
|
|
35
|
+
var _a;
|
|
36
|
+
const insertedEle = document.getElementById(attributes.id);
|
|
45
37
|
if (!insertedEle) {
|
|
46
|
-
|
|
38
|
+
const attrsCopy = { ...attributes };
|
|
39
|
+
attrsCopy.onload = null;
|
|
40
|
+
const ele = createHTMLElement(tagName, attrsCopy);
|
|
41
|
+
onload && ele.addEventListener("load", onload);
|
|
47
42
|
document.head.appendChild(ele);
|
|
48
43
|
} else if (checkKey !== "") {
|
|
49
|
-
insertedEle.addEventListener("load", onload);
|
|
50
44
|
if (Reflect.get(window, checkKey)) {
|
|
51
|
-
|
|
45
|
+
(_a = attributes.onload) == null ? void 0 : _a.call(insertedEle, new Event("load"));
|
|
46
|
+
} else {
|
|
47
|
+
attributes.onload && insertedEle.addEventListener("load", attributes.onload);
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
};
|
|
55
|
-
const updateHandler =
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
const updateHandler = (tagName, attributes) => {
|
|
52
|
+
const insertedEle = document.getElementById(attributes.id);
|
|
53
|
+
insertedEle == null ? void 0 : insertedEle.remove();
|
|
54
|
+
appendHandler(tagName, attributes);
|
|
55
|
+
};
|
|
56
|
+
const createHTMLElement = (tagName, attributes) => {
|
|
57
|
+
const element = document.createElement(tagName);
|
|
58
|
+
Object.keys(attributes).forEach((key) => {
|
|
59
|
+
if (attributes[key] !== void 0) {
|
|
60
|
+
element[key] = attributes[key];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return element;
|
|
64
|
+
};
|
|
61
65
|
export {
|
|
62
66
|
appendHandler as a,
|
|
63
67
|
keyMove as k,
|
|
@@ -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
|
+
};
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inject, watch, toRef, onMounted, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
4
|
import { 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";
|
|
@@ -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
|
|
62
|
+
var _a;
|
|
62
63
|
let clearTimer = -1;
|
|
63
64
|
(_a = pre.querySelector(".copy-button")) == null ? void 0 : _a.remove();
|
|
64
|
-
const copyBtnText =
|
|
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 =
|
|
75
|
-
const failTip =
|
|
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
|
-
|
|
100
|
-
const
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
appendHandler("link", {
|
|
106
|
+
...highlight.value.css,
|
|
107
|
+
rel: "stylesheet",
|
|
108
|
+
id: `${prefix}-hlCss`
|
|
109
|
+
});
|
|
110
|
+
appendHandler(
|
|
111
|
+
"script",
|
|
112
|
+
{
|
|
113
|
+
...highlight.value.js,
|
|
114
|
+
id: `${prefix}-hljs`,
|
|
115
|
+
onload() {
|
|
116
|
+
hljsRef.value = window.hljs;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"hljs"
|
|
120
|
+
);
|
|
122
121
|
});
|
|
123
122
|
watch(
|
|
124
|
-
() =>
|
|
125
|
-
(
|
|
126
|
-
updateHandler(
|
|
123
|
+
() => highlight.value.css,
|
|
124
|
+
() => {
|
|
125
|
+
updateHandler("link", {
|
|
126
|
+
...highlight.value.css,
|
|
127
|
+
rel: "stylesheet",
|
|
128
|
+
id: `${prefix}-hlCss`
|
|
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
|
|
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,40 @@ const useMermaid = (props) => {
|
|
|
159
161
|
}
|
|
160
162
|
);
|
|
161
163
|
onMounted(() => {
|
|
162
|
-
|
|
164
|
+
var _a, _b, _c;
|
|
165
|
+
if (props.noMermaid || ((_a = mermaidRef.value) == null ? void 0 : _a.instance)) {
|
|
163
166
|
return;
|
|
164
167
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
168
|
+
const jsSrc = editorExtensions.mermaid.js;
|
|
169
|
+
if (/\.mjs/.test(jsSrc)) {
|
|
170
|
+
appendHandler("link", {
|
|
171
|
+
...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
|
|
172
|
+
rel: "modulepreload",
|
|
173
|
+
href: jsSrc,
|
|
174
|
+
id: `${prefix}-mermaid-m`
|
|
175
|
+
});
|
|
176
|
+
import(
|
|
177
|
+
/* @vite-ignore */
|
|
178
|
+
/* webpackIgnore: true */
|
|
179
|
+
jsSrc
|
|
180
|
+
).then((module) => {
|
|
181
|
+
mermaidRef.value = module.default;
|
|
182
|
+
configMermaid();
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
appendHandler(
|
|
186
|
+
"script",
|
|
187
|
+
{
|
|
188
|
+
...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
|
|
189
|
+
src: jsSrc,
|
|
190
|
+
id: `${prefix}-mermaid`,
|
|
191
|
+
onload() {
|
|
192
|
+
mermaidRef.value = window.mermaid;
|
|
193
|
+
configMermaid();
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"mermaid"
|
|
197
|
+
);
|
|
186
198
|
}
|
|
187
199
|
});
|
|
188
200
|
const replaceMermaid = () => {
|
|
@@ -234,25 +246,28 @@ const useMermaid = (props) => {
|
|
|
234
246
|
return { mermaidRef, reRenderRef, replaceMermaid };
|
|
235
247
|
};
|
|
236
248
|
const useKatex = (props) => {
|
|
237
|
-
|
|
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);
|
|
249
|
+
const katex = shallowRef(configOption.editorExtensions.katex.instance);
|
|
241
250
|
onMounted(() => {
|
|
242
|
-
if (
|
|
243
|
-
|
|
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);
|
|
251
|
+
if (props.noKatex || katex.value) {
|
|
252
|
+
return;
|
|
255
253
|
}
|
|
254
|
+
const { editorExtensions } = configOption;
|
|
255
|
+
appendHandler(
|
|
256
|
+
"script",
|
|
257
|
+
{
|
|
258
|
+
src: editorExtensions.katex.js,
|
|
259
|
+
id: `${prefix}-katex`,
|
|
260
|
+
onload() {
|
|
261
|
+
katex.value = window.katex;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"katex"
|
|
265
|
+
);
|
|
266
|
+
appendHandler("link", {
|
|
267
|
+
rel: "stylesheet",
|
|
268
|
+
href: editorExtensions.katex.css,
|
|
269
|
+
id: `${prefix}-katexCss`
|
|
270
|
+
});
|
|
256
271
|
});
|
|
257
272
|
return katex;
|
|
258
273
|
};
|
|
@@ -659,11 +674,6 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
659
674
|
editorId
|
|
660
675
|
});
|
|
661
676
|
const plugins = [
|
|
662
|
-
{
|
|
663
|
-
type: "katex",
|
|
664
|
-
plugin: KatexPlugin$1,
|
|
665
|
-
options: { katexRef }
|
|
666
|
-
},
|
|
667
677
|
{
|
|
668
678
|
type: "image",
|
|
669
679
|
plugin: ImageFiguresPlugin,
|
|
@@ -718,6 +728,13 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
718
728
|
}
|
|
719
729
|
}
|
|
720
730
|
];
|
|
731
|
+
if (!props.noKatex) {
|
|
732
|
+
plugins.push({
|
|
733
|
+
type: "katex",
|
|
734
|
+
plugin: KatexPlugin$1,
|
|
735
|
+
options: { katexRef }
|
|
736
|
+
});
|
|
737
|
+
}
|
|
721
738
|
if (!props.noMermaid) {
|
|
722
739
|
plugins.push({
|
|
723
740
|
type: "mermaid",
|
|
@@ -778,10 +795,17 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
778
795
|
});
|
|
779
796
|
watch(
|
|
780
797
|
[toRef(props, "modelValue"), needReRender, reRenderRef],
|
|
781
|
-
debounce(
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
)
|
|
798
|
+
debounce(markHtml, previewOnly ? 0 : editorConfig.renderDelay)
|
|
799
|
+
);
|
|
800
|
+
watch(
|
|
801
|
+
() => props.setting.preview,
|
|
802
|
+
() => {
|
|
803
|
+
if (props.setting.preview) {
|
|
804
|
+
nextTick(() => {
|
|
805
|
+
bus.emit(editorId, CATALOG_CHANGED, headsRef.value);
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}
|
|
785
809
|
);
|
|
786
810
|
onMounted(() => {
|
|
787
811
|
bus.on(editorId, {
|
|
@@ -1020,9 +1044,9 @@ const useOnSave = (props, context) => {
|
|
|
1020
1044
|
});
|
|
1021
1045
|
};
|
|
1022
1046
|
const useProvidePreview = (props) => {
|
|
1023
|
-
var _a, _b;
|
|
1024
1047
|
const { editorId } = props;
|
|
1025
|
-
const
|
|
1048
|
+
const hljsUrls = configOption.editorExtensions.highlight;
|
|
1049
|
+
const hljsAttrs = configOption.editorExtensionsAttrs.highlight;
|
|
1026
1050
|
provide("editorId", editorId);
|
|
1027
1051
|
provide(
|
|
1028
1052
|
"theme",
|
|
@@ -1035,23 +1059,32 @@ const useProvidePreview = (props) => {
|
|
|
1035
1059
|
provide(
|
|
1036
1060
|
"highlight",
|
|
1037
1061
|
computed(() => {
|
|
1062
|
+
const { js: jsUrl } = hljsUrls;
|
|
1038
1063
|
const cssList = {
|
|
1039
1064
|
...codeCss,
|
|
1040
|
-
...
|
|
1065
|
+
...hljsUrls.css
|
|
1041
1066
|
};
|
|
1042
|
-
const
|
|
1067
|
+
const { js: jsAttrs, css: cssAttrs = {} } = hljsAttrs || {};
|
|
1068
|
+
const _theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
|
|
1069
|
+
const codeCssHref = cssList[props.codeTheme] ? cssList[props.codeTheme][_theme] : codeCss.atom[_theme];
|
|
1070
|
+
const codeCssAttrs = cssList[props.codeTheme] && cssAttrs[props.codeTheme] ? cssAttrs[props.codeTheme][_theme] : cssAttrs["atom"] ? cssAttrs["atom"][_theme] : {};
|
|
1043
1071
|
return {
|
|
1044
|
-
js:
|
|
1045
|
-
|
|
1072
|
+
js: {
|
|
1073
|
+
src: jsUrl,
|
|
1074
|
+
...jsAttrs
|
|
1075
|
+
},
|
|
1076
|
+
css: {
|
|
1077
|
+
href: codeCssHref,
|
|
1078
|
+
...codeCssAttrs
|
|
1079
|
+
}
|
|
1046
1080
|
};
|
|
1047
1081
|
})
|
|
1048
1082
|
);
|
|
1049
1083
|
provide("showCodeRowNumber", props.showCodeRowNumber);
|
|
1050
1084
|
const usedLanguageText = computed(() => {
|
|
1051
|
-
var _a2, _b2;
|
|
1052
1085
|
const allText = {
|
|
1053
1086
|
...staticTextDefault,
|
|
1054
|
-
...
|
|
1087
|
+
...configOption.editorConfig.languageUserDefined
|
|
1055
1088
|
};
|
|
1056
1089
|
return deepMerge(
|
|
1057
1090
|
deepClone(staticTextDefault["en-US"]),
|
|
@@ -1074,54 +1107,62 @@ const useProvide = (props) => {
|
|
|
1074
1107
|
};
|
|
1075
1108
|
const useExpansionPreview = (props) => {
|
|
1076
1109
|
onMounted(() => {
|
|
1077
|
-
|
|
1078
|
-
if (
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1110
|
+
const { editorExtensions, editorExtensionsAttrs, iconfontType } = configOption;
|
|
1111
|
+
if (props.noIconfont) {
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
if (iconfontType === "svg") {
|
|
1115
|
+
appendHandler("script", {
|
|
1116
|
+
...editorExtensionsAttrs.iconfont,
|
|
1117
|
+
src: editorExtensions.iconfont,
|
|
1118
|
+
id: `${prefix}-icon`
|
|
1119
|
+
});
|
|
1120
|
+
} else {
|
|
1121
|
+
appendHandler("link", {
|
|
1122
|
+
...editorExtensionsAttrs.iconfontClass,
|
|
1123
|
+
rel: "stylesheet",
|
|
1124
|
+
href: editorExtensions.iconfontClass,
|
|
1125
|
+
id: `${prefix}-icon-class`
|
|
1126
|
+
});
|
|
1091
1127
|
}
|
|
1092
1128
|
});
|
|
1093
1129
|
};
|
|
1094
1130
|
const useExpansion = (props) => {
|
|
1095
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1096
1131
|
const { noPrettier, noUploadImg } = props;
|
|
1097
|
-
const { editorExtensions } = configOption;
|
|
1098
|
-
const noPrettierScript = noPrettier ||
|
|
1099
|
-
const noParserMarkdownScript = noPrettier ||
|
|
1100
|
-
const noCropperScript = noUploadImg ||
|
|
1132
|
+
const { editorExtensions, editorExtensionsAttrs } = configOption;
|
|
1133
|
+
const noPrettierScript = noPrettier || editorExtensions.prettier.prettierInstance;
|
|
1134
|
+
const noParserMarkdownScript = noPrettier || editorExtensions.prettier.parserMarkdownInstance;
|
|
1135
|
+
const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
|
|
1101
1136
|
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
1137
|
if (!noCropperScript) {
|
|
1117
|
-
|
|
1118
|
-
appendHandler(
|
|
1138
|
+
const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
|
|
1139
|
+
appendHandler("link", {
|
|
1140
|
+
...css,
|
|
1141
|
+
rel: "stylesheet",
|
|
1142
|
+
href: editorExtensions.cropper.css,
|
|
1143
|
+
id: `${prefix}-cropperCss`
|
|
1144
|
+
});
|
|
1145
|
+
appendHandler("script", {
|
|
1146
|
+
...js,
|
|
1147
|
+
src: editorExtensions.cropper.js,
|
|
1148
|
+
id: `${prefix}-cropper`
|
|
1149
|
+
});
|
|
1119
1150
|
}
|
|
1120
1151
|
if (!noPrettierScript) {
|
|
1121
|
-
|
|
1152
|
+
const { standaloneJs = {} } = editorExtensionsAttrs.prettier || {};
|
|
1153
|
+
appendHandler("script", {
|
|
1154
|
+
...standaloneJs,
|
|
1155
|
+
src: editorExtensions.prettier.standaloneJs,
|
|
1156
|
+
id: `${prefix}-prettier`
|
|
1157
|
+
});
|
|
1122
1158
|
}
|
|
1123
1159
|
if (!noParserMarkdownScript) {
|
|
1124
|
-
|
|
1160
|
+
const { parserMarkdownJs = {} } = editorExtensionsAttrs.prettier || {};
|
|
1161
|
+
appendHandler("script", {
|
|
1162
|
+
...parserMarkdownJs,
|
|
1163
|
+
src: editorExtensions.prettier.parserMarkdownJs,
|
|
1164
|
+
id: `${prefix}-prettierMD`
|
|
1165
|
+
});
|
|
1125
1166
|
}
|
|
1126
1167
|
});
|
|
1127
1168
|
useExpansionPreview(props);
|
|
@@ -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
|
* 空提示
|
package/lib/es/chunks/index2.mjs
CHANGED
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -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,
|
|
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 =
|
|
152
|
-
state.modalStyle.zIndex =
|
|
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(() => {
|