md-editor-v3 4.3.0 → 4.5.0-beta.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 +131 -111
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +27 -27
- package/lib/cjs/MdModal.cjs +1 -1
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/ModalToolbar.cjs +1 -1
- package/lib/cjs/chunks/config.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +6 -6
- package/lib/cjs/chunks/index3.cjs +1 -2
- package/lib/cjs/chunks/index4.cjs +2 -0
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdCatalog.mjs +1 -1
- package/lib/es/MdEditor.mjs +925 -1117
- package/lib/es/MdModal.mjs +6 -139
- package/lib/es/MdPreview.mjs +1 -1
- package/lib/es/ModalToolbar.mjs +1 -1
- package/lib/es/chunks/config.mjs +25 -26
- package/lib/es/chunks/index.mjs +430 -327
- package/lib/es/chunks/index3.mjs +163 -61
- package/lib/es/chunks/index4.mjs +69 -0
- package/lib/es/index.mjs +18 -17
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/Editor.d.ts +19 -1
- package/lib/types/MdEditor/components/Icon/Icon.d.ts +16 -0
- package/lib/types/MdEditor/components/Icon/Str.d.ts +3 -0
- package/lib/types/MdEditor/components/Icon/index.d.ts +16 -0
- package/lib/types/MdEditor/config.d.ts +2 -1
- package/lib/types/MdEditor/index.d.ts +42 -4
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +33 -73
- package/lib/types/MdEditor/layouts/Content/index.d.ts +73 -58
- package/lib/types/MdEditor/layouts/Content/props.d.ts +73 -17
- package/lib/types/MdEditor/props.d.ts +29 -1
- package/lib/types/MdEditor/type.d.ts +37 -8
- package/lib/types/MdPreview/MdPreview.d.ts +18 -0
- package/lib/types/MdPreview/index.d.ts +39 -1
- package/lib/umd/index.js +43 -43
- package/package.json +1 -1
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -1,69 +1,171 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { defineComponent as v, createVNode as t, inject as k, h as M, ref as f, reactive as b, computed as j, onMounted as F, onBeforeUnmount as w, watch as p, nextTick as S } from "vue";
|
|
2
|
+
import { p as l, a as H } from "./config.mjs";
|
|
3
|
+
import { g as y } from "./vue-tsx.mjs";
|
|
4
|
+
import { k as g } from "./dom.mjs";
|
|
5
|
+
const T = /* @__PURE__ */ v({
|
|
6
|
+
props: {
|
|
7
|
+
name: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: ""
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
setup(e) {
|
|
13
|
+
return () => H.iconfontType === "svg" ? t("svg", {
|
|
14
|
+
class: `${l}-icon`,
|
|
15
|
+
"aria-hidden": "true"
|
|
16
|
+
}, [t("use", {
|
|
17
|
+
"xlink:href": `#${l}-icon-${e.name}`
|
|
18
|
+
}, null)]) : t("i", {
|
|
19
|
+
class: `${l}-iconfont ${l}-icon-${e.name}`
|
|
20
|
+
}, null);
|
|
8
21
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
}), C = /* @__PURE__ */ v({
|
|
23
|
+
props: {
|
|
24
|
+
name: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: ""
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
setup(e) {
|
|
30
|
+
const c = k("customIcon");
|
|
31
|
+
return () => {
|
|
32
|
+
const i = c.value[e.name];
|
|
33
|
+
return typeof i == "object" ? typeof i.component == "object" ? M(i.component, i.props) : t("span", {
|
|
34
|
+
innerHTML: i.component
|
|
35
|
+
}, null) : t(T, {
|
|
36
|
+
name: e.name
|
|
37
|
+
}, null);
|
|
38
|
+
};
|
|
13
39
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
}), z = {
|
|
41
|
+
title: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: ""
|
|
44
|
+
},
|
|
45
|
+
visible: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: !1
|
|
48
|
+
},
|
|
49
|
+
width: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "auto"
|
|
52
|
+
},
|
|
53
|
+
height: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "auto"
|
|
56
|
+
},
|
|
57
|
+
onClose: {
|
|
58
|
+
type: Function
|
|
59
|
+
},
|
|
60
|
+
showAdjust: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: !1
|
|
63
|
+
},
|
|
64
|
+
isFullscreen: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: !1
|
|
67
|
+
},
|
|
68
|
+
onAdjust: {
|
|
69
|
+
type: Function,
|
|
70
|
+
default: () => {
|
|
71
|
+
}
|
|
17
72
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
73
|
+
}, h = /* @__PURE__ */ v({
|
|
74
|
+
name: "MdModal",
|
|
75
|
+
props: z,
|
|
76
|
+
emits: ["onClose"],
|
|
77
|
+
setup(e, c) {
|
|
78
|
+
const i = f(e.visible), a = f([`${l}-modal`]), m = f(), r = f();
|
|
79
|
+
let d = () => {
|
|
80
|
+
};
|
|
81
|
+
const o = b({
|
|
82
|
+
initPos: {
|
|
83
|
+
left: "0px",
|
|
84
|
+
top: "0px"
|
|
85
|
+
},
|
|
86
|
+
historyPos: {
|
|
87
|
+
left: "0px",
|
|
88
|
+
top: "0px"
|
|
31
89
|
}
|
|
90
|
+
}), P = j(() => e.isFullscreen ? {
|
|
91
|
+
width: "100%",
|
|
92
|
+
height: "100%"
|
|
93
|
+
} : {
|
|
94
|
+
width: e.width,
|
|
95
|
+
height: e.height
|
|
32
96
|
});
|
|
97
|
+
return F(() => {
|
|
98
|
+
d = g(r.value, (s, n) => {
|
|
99
|
+
o.initPos.left = s + "px", o.initPos.top = n + "px";
|
|
100
|
+
});
|
|
101
|
+
}), w(() => {
|
|
102
|
+
d();
|
|
103
|
+
}), p(() => e.isFullscreen, (s) => {
|
|
104
|
+
s ? d() : d = g(r.value, (n, u) => {
|
|
105
|
+
o.initPos.left = n + "px", o.initPos.top = u + "px";
|
|
106
|
+
});
|
|
107
|
+
}), p(() => e.visible, (s) => {
|
|
108
|
+
s ? (a.value.push("zoom-in"), i.value = s, S(() => {
|
|
109
|
+
const n = m.value.offsetWidth / 2, u = m.value.offsetHeight / 2, $ = document.documentElement.clientWidth / 2, x = document.documentElement.clientHeight / 2;
|
|
110
|
+
o.initPos.left = $ - n + "px", o.initPos.top = x - u + "px";
|
|
111
|
+
}), setTimeout(() => {
|
|
112
|
+
a.value = a.value.filter((n) => n !== "zoom-in");
|
|
113
|
+
}, 140)) : (a.value.push("zoom-out"), setTimeout(() => {
|
|
114
|
+
a.value = a.value.filter((n) => n !== "zoom-out"), i.value = s;
|
|
115
|
+
}, 130));
|
|
116
|
+
}), () => {
|
|
117
|
+
const s = y({
|
|
118
|
+
ctx: c
|
|
119
|
+
}), n = y({
|
|
120
|
+
props: e,
|
|
121
|
+
ctx: c
|
|
122
|
+
}, "title");
|
|
123
|
+
return t("div", {
|
|
124
|
+
style: {
|
|
125
|
+
display: i.value ? "block" : "none"
|
|
126
|
+
}
|
|
127
|
+
}, [t("div", {
|
|
128
|
+
class: `${l}-modal-mask`,
|
|
129
|
+
onClick: () => {
|
|
130
|
+
e.onClose ? e.onClose() : c.emit("onClose");
|
|
131
|
+
}
|
|
132
|
+
}, null), t("div", {
|
|
133
|
+
class: a.value,
|
|
134
|
+
style: {
|
|
135
|
+
...o.initPos,
|
|
136
|
+
...P.value
|
|
137
|
+
},
|
|
138
|
+
ref: m
|
|
139
|
+
}, [t("div", {
|
|
140
|
+
class: `${l}-modal-header`,
|
|
141
|
+
ref: r
|
|
142
|
+
}, [n || ""]), t("div", {
|
|
143
|
+
class: `${l}-modal-body`
|
|
144
|
+
}, [s]), t("div", {
|
|
145
|
+
class: `${l}-modal-func`
|
|
146
|
+
}, [e.showAdjust && t("div", {
|
|
147
|
+
class: `${l}-modal-adjust`,
|
|
148
|
+
onClick: (u) => {
|
|
149
|
+
u.stopPropagation(), e.isFullscreen ? o.initPos = o.historyPos : (o.historyPos = o.initPos, o.initPos = {
|
|
150
|
+
left: "0",
|
|
151
|
+
top: "0"
|
|
152
|
+
}), e.onAdjust(!e.isFullscreen);
|
|
153
|
+
}
|
|
154
|
+
}, [t(C, {
|
|
155
|
+
name: e.isFullscreen ? "suoxiao" : "fangda"
|
|
156
|
+
}, null)]), t("div", {
|
|
157
|
+
class: `${l}-modal-close`,
|
|
158
|
+
onClick: (u) => {
|
|
159
|
+
u.stopPropagation(), e.onClose ? e.onClose() : c.emit("onClose");
|
|
160
|
+
}
|
|
161
|
+
}, [t(C, {
|
|
162
|
+
name: "close"
|
|
163
|
+
}, null)])])])]);
|
|
164
|
+
};
|
|
33
165
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const s = o.split(","), n = s[0].match(/:(.*?);/);
|
|
37
|
-
if (n) {
|
|
38
|
-
const e = n[1], i = atob(s[1]);
|
|
39
|
-
let r = i.length;
|
|
40
|
-
const l = new Uint8Array(r);
|
|
41
|
-
for (; r--; )
|
|
42
|
-
l[r] = i.charCodeAt(r);
|
|
43
|
-
return new File([l], t, { type: e });
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}, b = (o) => {
|
|
47
|
-
if (!o)
|
|
48
|
-
return o;
|
|
49
|
-
const t = o.split(`
|
|
50
|
-
`), s = ['<span rn-wrapper aria-hidden="true">'];
|
|
51
|
-
return t.forEach(() => {
|
|
52
|
-
s.push("<span></span>");
|
|
53
|
-
}), s.push("</span>"), `<span class="code-block">${o}</span>${s.join("")}`;
|
|
54
|
-
}, R = (o, t) => {
|
|
55
|
-
if (!o || !t)
|
|
56
|
-
return 0;
|
|
57
|
-
const s = o == null ? void 0 : o.getBoundingClientRect();
|
|
58
|
-
if (t === document.documentElement)
|
|
59
|
-
return s.top - t.clientTop;
|
|
60
|
-
const n = t == null ? void 0 : t.getBoundingClientRect();
|
|
61
|
-
return s.top - n.top;
|
|
62
|
-
}, m = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
|
|
166
|
+
});
|
|
167
|
+
h.install = (e) => (e.component(h.name, h), e);
|
|
63
168
|
export {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
R as c,
|
|
67
|
-
b as g,
|
|
68
|
-
m as u
|
|
169
|
+
C as I,
|
|
170
|
+
h as M
|
|
69
171
|
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var c = (o, t, s) => t in o ? a(o, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[t] = s;
|
|
3
|
+
var p = (o, t, s) => (c(o, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
class u {
|
|
5
|
+
constructor() {
|
|
6
|
+
// 事件池
|
|
7
|
+
p(this, "pools", {});
|
|
8
|
+
}
|
|
9
|
+
// 移除事件监听
|
|
10
|
+
remove(t, s, n) {
|
|
11
|
+
const i = this.pools[t] && this.pools[t][s];
|
|
12
|
+
i && (this.pools[t][s] = i.filter((r) => r !== n));
|
|
13
|
+
}
|
|
14
|
+
// 清空全部事件,由于单一实例,多次注册会被共享内容
|
|
15
|
+
clear(t) {
|
|
16
|
+
this.pools[t] = {};
|
|
17
|
+
}
|
|
18
|
+
// 注册事件监听
|
|
19
|
+
on(t, s) {
|
|
20
|
+
return this.pools[t] || (this.pools[t] = {}), this.pools[t][s.name] || (this.pools[t][s.name] = []), this.pools[t][s.name].push(s.callback), this.pools[t][s.name].includes(s.callback);
|
|
21
|
+
}
|
|
22
|
+
// 触发事件
|
|
23
|
+
emit(t, s, ...n) {
|
|
24
|
+
this.pools[t] || (this.pools[t] = {});
|
|
25
|
+
const i = this.pools[t][s];
|
|
26
|
+
i && i.forEach((r) => {
|
|
27
|
+
try {
|
|
28
|
+
r(...n);
|
|
29
|
+
} catch (l) {
|
|
30
|
+
console.error(`${s} monitor event exception!`, l);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const g = new u(), f = (o, t = "image.png") => {
|
|
36
|
+
const s = o.split(","), n = s[0].match(/:(.*?);/);
|
|
37
|
+
if (n) {
|
|
38
|
+
const e = n[1], i = atob(s[1]);
|
|
39
|
+
let r = i.length;
|
|
40
|
+
const l = new Uint8Array(r);
|
|
41
|
+
for (; r--; )
|
|
42
|
+
l[r] = i.charCodeAt(r);
|
|
43
|
+
return new File([l], t, { type: e });
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}, b = (o) => {
|
|
47
|
+
if (!o)
|
|
48
|
+
return o;
|
|
49
|
+
const t = o.split(`
|
|
50
|
+
`), s = ['<span rn-wrapper aria-hidden="true">'];
|
|
51
|
+
return t.forEach(() => {
|
|
52
|
+
s.push("<span></span>");
|
|
53
|
+
}), s.push("</span>"), `<span class="code-block">${o}</span>${s.join("")}`;
|
|
54
|
+
}, R = (o, t) => {
|
|
55
|
+
if (!o || !t)
|
|
56
|
+
return 0;
|
|
57
|
+
const s = o == null ? void 0 : o.getBoundingClientRect();
|
|
58
|
+
if (t === document.documentElement)
|
|
59
|
+
return s.top - t.clientTop;
|
|
60
|
+
const n = t == null ? void 0 : t.getBoundingClientRect();
|
|
61
|
+
return s.top - n.top;
|
|
62
|
+
}, m = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
|
|
63
|
+
export {
|
|
64
|
+
f as a,
|
|
65
|
+
g as b,
|
|
66
|
+
R as c,
|
|
67
|
+
b as g,
|
|
68
|
+
m as u
|
|
69
|
+
};
|
package/lib/es/index.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { M as
|
|
3
|
-
import { default as
|
|
4
|
-
import { D as
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { c as
|
|
8
|
-
import {
|
|
1
|
+
import { default as C } from "./MdEditor.mjs";
|
|
2
|
+
import { M as N } from "./chunks/index.mjs";
|
|
3
|
+
import { default as h } from "./NormalToolbar.mjs";
|
|
4
|
+
import { D as k } from "./chunks/index2.mjs";
|
|
5
|
+
import { default as y } from "./ModalToolbar.mjs";
|
|
6
|
+
import { default as A } from "./MdCatalog.mjs";
|
|
7
|
+
import { c as F } from "./chunks/config.mjs";
|
|
8
|
+
import { M as H } from "./chunks/index3.mjs";
|
|
9
9
|
import "vue";
|
|
10
10
|
import "@vavt/util";
|
|
11
|
-
import "./chunks/
|
|
11
|
+
import "./chunks/index4.mjs";
|
|
12
12
|
import "./chunks/dom.mjs";
|
|
13
13
|
import "codemirror";
|
|
14
14
|
import "@codemirror/view";
|
|
15
15
|
import "@codemirror/language-data";
|
|
16
16
|
import "@codemirror/lang-markdown";
|
|
17
|
+
import "@codemirror/lang-html";
|
|
17
18
|
import "@codemirror/commands";
|
|
18
19
|
import "@codemirror/language";
|
|
19
20
|
import "@lezer/highlight";
|
|
@@ -27,12 +28,12 @@ import "markdown-it-image-figures";
|
|
|
27
28
|
import "markdown-it-task-lists";
|
|
28
29
|
import "lru-cache";
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
k as DropdownToolbar,
|
|
32
|
+
A as MdCatalog,
|
|
33
|
+
C as MdEditor,
|
|
34
|
+
H as MdModal,
|
|
35
|
+
N as MdPreview,
|
|
36
|
+
y as ModalToolbar,
|
|
37
|
+
h as NormalToolbar,
|
|
38
|
+
F as config
|
|
38
39
|
};
|