md-editor-v3 4.12.0 → 4.12.1
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/lib/cjs/DropdownToolbar.cjs +3 -1
- package/lib/cjs/MdCatalog.cjs +270 -1
- package/lib/cjs/MdEditor.cjs +3101 -58
- package/lib/cjs/MdModal.cjs +3 -1
- package/lib/cjs/MdPreview.cjs +3 -1
- package/lib/cjs/ModalToolbar.cjs +124 -1
- package/lib/cjs/NormalToolbar.cjs +61 -1
- package/lib/cjs/chunks/config.cjs +290 -1
- package/lib/cjs/chunks/dom.cjs +64 -1
- package/lib/cjs/chunks/index.cjs +1863 -8
- package/lib/cjs/chunks/index2.cjs +198 -1
- package/lib/cjs/chunks/index3.cjs +270 -1
- package/lib/cjs/chunks/index4.cjs +141 -2
- package/lib/cjs/chunks/vue-tsx.cjs +10 -1
- package/lib/cjs/config.cjs +12 -1
- package/lib/cjs/index.cjs +25 -1
- package/lib/es/DropdownToolbar.mjs +2 -2
- package/lib/es/MdCatalog.mjs +164 -114
- package/lib/es/MdEditor.mjs +2292 -1677
- package/lib/es/MdModal.mjs +2 -2
- package/lib/es/MdPreview.mjs +2 -2
- package/lib/es/ModalToolbar.mjs +55 -38
- package/lib/es/NormalToolbar.mjs +26 -18
- package/lib/es/chunks/config.mjs +73 -54
- package/lib/es/chunks/dom.mjs +57 -24
- package/lib/es/chunks/index.mjs +1093 -611
- package/lib/es/chunks/index2.mjs +126 -78
- package/lib/es/chunks/index3.mjs +185 -111
- package/lib/es/chunks/index4.mjs +124 -73
- package/lib/es/chunks/vue-tsx.mjs +8 -8
- package/lib/es/config.mjs +11 -10
- package/lib/es/index.mjs +23 -23
- package/lib/preview.css +200 -1
- package/lib/style.css +592 -1
- package/lib/types/MdEditor/components/Modal/Modal.d.ts +1 -1
- package/lib/types/MdEditor/components/Modal/index.d.ts +3 -3
- package/lib/umd/index.js +75625 -114
- package/package.json +1 -1
package/lib/es/MdModal.mjs
CHANGED
package/lib/es/MdPreview.mjs
CHANGED
package/lib/es/ModalToolbar.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent
|
|
2
|
-
import { p as
|
|
3
|
-
import { g as
|
|
4
|
-
import { M as
|
|
5
|
-
function
|
|
6
|
-
return typeof
|
|
1
|
+
import { defineComponent, createVNode, Fragment, isVNode } from "vue";
|
|
2
|
+
import { p as prefix } from "./chunks/config.mjs";
|
|
3
|
+
import { g as getSlot } from "./chunks/vue-tsx.mjs";
|
|
4
|
+
import { M as MdModal } from "./chunks/index3.mjs";
|
|
5
|
+
function _isSlot(s) {
|
|
6
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
8
|
+
const props = {
|
|
9
9
|
title: {
|
|
10
10
|
type: String,
|
|
11
11
|
default: ""
|
|
@@ -40,11 +40,11 @@ const m = {
|
|
|
40
40
|
*/
|
|
41
41
|
showAdjust: {
|
|
42
42
|
type: Boolean,
|
|
43
|
-
default:
|
|
43
|
+
default: false
|
|
44
44
|
},
|
|
45
45
|
isFullscreen: {
|
|
46
46
|
type: Boolean,
|
|
47
|
-
default:
|
|
47
|
+
default: false
|
|
48
48
|
},
|
|
49
49
|
onAdjust: {
|
|
50
50
|
type: Function
|
|
@@ -64,45 +64,62 @@ const m = {
|
|
|
64
64
|
/**
|
|
65
65
|
* ==结束
|
|
66
66
|
*/
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
|
+
const ModalToolbar = /* @__PURE__ */ defineComponent({
|
|
68
69
|
name: "ModalToolbar",
|
|
69
|
-
props
|
|
70
|
+
props,
|
|
70
71
|
emits: ["onClick", "onClose", "onAdjust"],
|
|
71
|
-
setup(
|
|
72
|
+
setup(props2, ctx) {
|
|
72
73
|
return () => {
|
|
73
|
-
const
|
|
74
|
-
props:
|
|
75
|
-
ctx
|
|
76
|
-
}, "trigger")
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const Trigger = getSlot({
|
|
75
|
+
props: props2,
|
|
76
|
+
ctx
|
|
77
|
+
}, "trigger");
|
|
78
|
+
const Default = getSlot({
|
|
79
|
+
props: props2,
|
|
80
|
+
ctx
|
|
79
81
|
}, "default");
|
|
80
|
-
return
|
|
81
|
-
class: `${
|
|
82
|
-
title:
|
|
83
|
-
onClick: () => {
|
|
84
|
-
|
|
82
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
83
|
+
"class": `${prefix}-toolbar-item`,
|
|
84
|
+
"title": props2.title,
|
|
85
|
+
"onClick": () => {
|
|
86
|
+
if (props2.onClick instanceof Function) {
|
|
87
|
+
props2.onClick();
|
|
88
|
+
} else {
|
|
89
|
+
ctx.emit("onClick");
|
|
90
|
+
}
|
|
85
91
|
}
|
|
86
|
-
}, [
|
|
87
|
-
width:
|
|
88
|
-
height:
|
|
89
|
-
title:
|
|
90
|
-
visible:
|
|
91
|
-
onClose: () => {
|
|
92
|
-
|
|
92
|
+
}, [Trigger]), createVNode(MdModal, {
|
|
93
|
+
"width": props2.width,
|
|
94
|
+
"height": props2.height,
|
|
95
|
+
"title": props2.modalTitle,
|
|
96
|
+
"visible": props2.visible,
|
|
97
|
+
"onClose": () => {
|
|
98
|
+
if (props2.onClose instanceof Function) {
|
|
99
|
+
props2.onClose();
|
|
100
|
+
} else {
|
|
101
|
+
ctx.emit("onClose");
|
|
102
|
+
}
|
|
93
103
|
},
|
|
94
|
-
showAdjust:
|
|
95
|
-
isFullscreen:
|
|
96
|
-
onAdjust: (
|
|
97
|
-
|
|
104
|
+
"showAdjust": props2.showAdjust,
|
|
105
|
+
"isFullscreen": props2.isFullscreen,
|
|
106
|
+
"onAdjust": (v) => {
|
|
107
|
+
if (props2.onAdjust instanceof Function) {
|
|
108
|
+
props2.onAdjust(v);
|
|
109
|
+
} else {
|
|
110
|
+
ctx.emit("onAdjust", v);
|
|
111
|
+
}
|
|
98
112
|
}
|
|
99
|
-
},
|
|
100
|
-
default: () => [
|
|
113
|
+
}, _isSlot(Default) ? Default : {
|
|
114
|
+
default: () => [Default]
|
|
101
115
|
})]);
|
|
102
116
|
};
|
|
103
117
|
}
|
|
104
118
|
});
|
|
105
|
-
|
|
119
|
+
ModalToolbar.install = (app) => {
|
|
120
|
+
app.component(ModalToolbar.name, ModalToolbar);
|
|
121
|
+
return app;
|
|
122
|
+
};
|
|
106
123
|
export {
|
|
107
|
-
|
|
124
|
+
ModalToolbar as default
|
|
108
125
|
};
|
package/lib/es/NormalToolbar.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent
|
|
2
|
-
import { p as
|
|
3
|
-
import { g as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent, createVNode } from "vue";
|
|
2
|
+
import { p as prefix } from "./chunks/config.mjs";
|
|
3
|
+
import { g as getSlot } from "./chunks/vue-tsx.mjs";
|
|
4
|
+
const props = {
|
|
5
5
|
title: {
|
|
6
6
|
type: String,
|
|
7
7
|
default: ""
|
|
@@ -28,27 +28,35 @@ const m = {
|
|
|
28
28
|
/**
|
|
29
29
|
* ==结束
|
|
30
30
|
*/
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const NormalToolbar = /* @__PURE__ */ defineComponent({
|
|
32
33
|
name: "NormalToolbar",
|
|
33
|
-
props
|
|
34
|
+
props,
|
|
34
35
|
emits: ["onClick"],
|
|
35
|
-
setup(
|
|
36
|
+
setup(props2, ctx) {
|
|
36
37
|
return () => {
|
|
37
|
-
const
|
|
38
|
-
props:
|
|
39
|
-
ctx
|
|
38
|
+
const Trigger = getSlot({
|
|
39
|
+
props: props2,
|
|
40
|
+
ctx
|
|
40
41
|
}, "trigger");
|
|
41
|
-
return
|
|
42
|
-
class: `${
|
|
43
|
-
title:
|
|
44
|
-
onClick: (
|
|
45
|
-
|
|
42
|
+
return createVNode("div", {
|
|
43
|
+
"class": `${prefix}-toolbar-item`,
|
|
44
|
+
"title": props2.title,
|
|
45
|
+
"onClick": (e) => {
|
|
46
|
+
if (props2.onClick instanceof Function) {
|
|
47
|
+
props2.onClick(e);
|
|
48
|
+
} else {
|
|
49
|
+
ctx.emit("onClick", e);
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
|
-
}, [
|
|
52
|
+
}, [Trigger]);
|
|
48
53
|
};
|
|
49
54
|
}
|
|
50
55
|
});
|
|
51
|
-
|
|
56
|
+
NormalToolbar.install = (app) => {
|
|
57
|
+
app.component(NormalToolbar.name, NormalToolbar);
|
|
58
|
+
return app;
|
|
59
|
+
};
|
|
52
60
|
export {
|
|
53
|
-
|
|
61
|
+
NormalToolbar as default
|
|
54
62
|
};
|
package/lib/es/chunks/config.mjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const prefix = "md-editor";
|
|
2
|
+
const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.js";
|
|
3
|
+
const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.css";
|
|
4
|
+
const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
5
|
+
const highlightUrl = `${cdnBase}/highlight.js/11.8.0/highlight.min.js`;
|
|
6
|
+
const prettierUrl = {
|
|
7
|
+
main: `${cdnBase}/prettier/2.8.0/standalone.js`,
|
|
8
|
+
markdown: `${cdnBase}/prettier/2.8.0/parser-markdown.js`
|
|
9
|
+
};
|
|
10
|
+
const cropperUrl = {
|
|
11
|
+
css: `${cdnBase}/cropperjs/1.5.13/cropper.min.css`,
|
|
12
|
+
js: `${cdnBase}/cropperjs/1.5.13/cropper.min.js`
|
|
13
|
+
};
|
|
14
|
+
const screenfullUrl = `${cdnBase}/screenfull.js/5.2.0/screenfull.min.js`;
|
|
15
|
+
const allToolbar = [
|
|
8
16
|
"bold",
|
|
9
17
|
"underline",
|
|
10
18
|
"italic",
|
|
@@ -37,7 +45,9 @@ const a = "md-editor", o = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.js
|
|
|
37
45
|
"htmlPreview",
|
|
38
46
|
"catalog",
|
|
39
47
|
"github"
|
|
40
|
-
]
|
|
48
|
+
];
|
|
49
|
+
const allFooter = ["markdownTotal", "=", "scrollSwitch"];
|
|
50
|
+
const staticTextDefault = {
|
|
41
51
|
"zh-CN": {
|
|
42
52
|
toolbarTips: {
|
|
43
53
|
bold: "加粗",
|
|
@@ -200,73 +210,82 @@ const a = "md-editor", o = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.js
|
|
|
200
210
|
scrollAuto: "Scroll Auto"
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
};
|
|
214
|
+
const mermaidUrl = `${cdnBase}/mermaid/10.6.1/mermaid.esm.min.mjs`;
|
|
215
|
+
const katexUrl = {
|
|
216
|
+
js: `${cdnBase}/KaTeX/0.16.9/katex.min.js`,
|
|
217
|
+
css: `${cdnBase}/KaTeX/0.16.9/katex.min.css`
|
|
218
|
+
};
|
|
219
|
+
const codeCss = {
|
|
207
220
|
a11y: {
|
|
208
|
-
light: `${
|
|
209
|
-
dark: `${
|
|
221
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/a11y-light.min.css`,
|
|
222
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/a11y-dark.min.css`
|
|
210
223
|
},
|
|
211
224
|
atom: {
|
|
212
|
-
light: `${
|
|
213
|
-
dark: `${
|
|
225
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/atom-one-light.min.css`,
|
|
226
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/atom-one-dark.min.css`
|
|
214
227
|
},
|
|
215
228
|
github: {
|
|
216
|
-
light: `${
|
|
217
|
-
dark: `${
|
|
229
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/github.min.css`,
|
|
230
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/github-dark.min.css`
|
|
218
231
|
},
|
|
219
232
|
gradient: {
|
|
220
|
-
light: `${
|
|
221
|
-
dark: `${
|
|
233
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/gradient-light.min.css`,
|
|
234
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/gradient-dark.min.css`
|
|
222
235
|
},
|
|
223
236
|
kimbie: {
|
|
224
|
-
light: `${
|
|
225
|
-
dark: `${
|
|
237
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/kimbie-light.min.css`,
|
|
238
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/kimbie-dark.min.css`
|
|
226
239
|
},
|
|
227
240
|
paraiso: {
|
|
228
|
-
light: `${
|
|
229
|
-
dark: `${
|
|
241
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/paraiso-light.min.css`,
|
|
242
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/paraiso-dark.min.css`
|
|
230
243
|
},
|
|
231
244
|
qtcreator: {
|
|
232
|
-
light: `${
|
|
233
|
-
dark: `${
|
|
245
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/qtcreator-light.min.css`,
|
|
246
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/qtcreator-dark.min.css`
|
|
234
247
|
},
|
|
235
248
|
stackoverflow: {
|
|
236
|
-
light: `${
|
|
237
|
-
dark: `${
|
|
249
|
+
light: `${cdnBase}/highlight.js/11.8.0/styles/stackoverflow-light.min.css`,
|
|
250
|
+
dark: `${cdnBase}/highlight.js/11.8.0/styles/stackoverflow-dark.min.css`
|
|
238
251
|
}
|
|
239
|
-
}
|
|
252
|
+
};
|
|
253
|
+
const configOption = {
|
|
240
254
|
editorExtensions: {},
|
|
241
255
|
editorConfig: {},
|
|
242
|
-
codeMirrorExtensions: (
|
|
256
|
+
codeMirrorExtensions: (_theme, innerExtensions) => innerExtensions,
|
|
243
257
|
markdownItConfig: () => {
|
|
244
258
|
},
|
|
245
|
-
markdownItPlugins: (
|
|
259
|
+
markdownItPlugins: (s) => s,
|
|
246
260
|
iconfontType: "svg",
|
|
247
|
-
mermaidConfig: (
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
261
|
+
mermaidConfig: (c) => c
|
|
262
|
+
};
|
|
263
|
+
const config = (option) => {
|
|
264
|
+
if (option) {
|
|
265
|
+
for (const key in option) {
|
|
266
|
+
const optionItem = option[key];
|
|
267
|
+
if (optionItem) {
|
|
268
|
+
configOption[key] = optionItem;
|
|
269
|
+
}
|
|
253
270
|
}
|
|
254
|
-
}
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const MinInputBoxWidth = 170;
|
|
255
274
|
export {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
k,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
MinInputBoxWidth as M,
|
|
276
|
+
iconfontSvgUrl as a,
|
|
277
|
+
allToolbar as b,
|
|
278
|
+
config as c,
|
|
279
|
+
allFooter as d,
|
|
280
|
+
configOption as e,
|
|
281
|
+
codeCss as f,
|
|
282
|
+
prettierUrl as g,
|
|
283
|
+
highlightUrl as h,
|
|
284
|
+
iconfontClassUrl as i,
|
|
285
|
+
cropperUrl as j,
|
|
286
|
+
katexUrl as k,
|
|
287
|
+
screenfullUrl as l,
|
|
288
|
+
mermaidUrl as m,
|
|
289
|
+
prefix as p,
|
|
290
|
+
staticTextDefault as s
|
|
272
291
|
};
|
package/lib/es/chunks/dom.mjs
CHANGED
|
@@ -1,32 +1,65 @@
|
|
|
1
|
-
import { debounce
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { debounce } from "@vavt/util";
|
|
2
|
+
const keyMove = (trigger, moveHandler) => {
|
|
3
|
+
const triggerMouseDown = (mdown) => {
|
|
4
|
+
const parent = trigger.parentElement || document.body;
|
|
5
|
+
const width = parent.offsetWidth;
|
|
6
|
+
const height = parent.offsetHeight;
|
|
7
|
+
const { clientWidth } = document.documentElement;
|
|
8
|
+
const { clientHeight } = document.documentElement;
|
|
9
|
+
const x = mdown.offsetX;
|
|
10
|
+
const y = mdown.offsetY;
|
|
11
|
+
const mouseMoveHandler = (e) => {
|
|
12
|
+
let tx = e.x + document.body.scrollLeft - document.body.clientLeft - x;
|
|
13
|
+
let ty = e.y + document.body.scrollTop - document.body.clientTop - y;
|
|
14
|
+
tx = tx < 1 ? 1 : tx < clientWidth - width - 1 ? tx : clientWidth - width - 1;
|
|
15
|
+
ty = ty < 1 ? 1 : ty < clientHeight - height - 1 ? ty : clientHeight - height - 1;
|
|
16
|
+
if (moveHandler) {
|
|
17
|
+
moveHandler(tx, ty);
|
|
18
|
+
} else {
|
|
19
|
+
parent.style.left = `${tx}px`;
|
|
20
|
+
parent.style.top = `${ty}px`;
|
|
21
|
+
}
|
|
7
22
|
};
|
|
8
|
-
document.addEventListener("mousemove",
|
|
9
|
-
const
|
|
10
|
-
document.removeEventListener("mousemove",
|
|
23
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
24
|
+
const mouseUpHandler = () => {
|
|
25
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
26
|
+
document.removeEventListener("mouseup", mouseUpHandler);
|
|
11
27
|
};
|
|
12
|
-
document.addEventListener("mouseup",
|
|
28
|
+
document.addEventListener("mouseup", mouseUpHandler);
|
|
13
29
|
};
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
trigger.addEventListener("mousedown", triggerMouseDown);
|
|
31
|
+
return () => {
|
|
32
|
+
trigger.removeEventListener("mousedown", triggerMouseDown);
|
|
16
33
|
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
34
|
+
};
|
|
35
|
+
const appendHandler = (ele, checkKey = "") => {
|
|
36
|
+
const insertedEle = document.getElementById(ele.id);
|
|
37
|
+
const onload_ = ele.onload;
|
|
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);
|
|
22
44
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
if (!insertedEle) {
|
|
46
|
+
ele.addEventListener("load", onload);
|
|
47
|
+
document.head.appendChild(ele);
|
|
48
|
+
} else if (checkKey !== "") {
|
|
49
|
+
insertedEle.addEventListener("load", onload);
|
|
50
|
+
if (Reflect.get(window, checkKey)) {
|
|
51
|
+
insertedEle.dispatchEvent(new Event("load"));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const updateHandler = debounce((id, attr, value) => {
|
|
56
|
+
const ele = document.getElementById(id);
|
|
57
|
+
if (ele) {
|
|
58
|
+
ele.setAttribute(attr, value);
|
|
59
|
+
}
|
|
27
60
|
}, 10);
|
|
28
61
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
62
|
+
appendHandler as a,
|
|
63
|
+
keyMove as k,
|
|
64
|
+
updateHandler as u
|
|
32
65
|
};
|