md-editor-v3 4.2.1-beta.0 → 4.2.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/MdEditor.cjs +16 -16
- package/lib/cjs/chunks/index.cjs +1 -1
- package/lib/cjs/chunks/index2.cjs +1 -1
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdEditor.mjs +296 -289
- package/lib/es/chunks/index.mjs +2 -2
- package/lib/es/chunks/index2.mjs +37 -42
- package/lib/es/chunks/index4.mjs +21 -19
- package/lib/es/index.mjs +14 -15
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +0 -9
- package/lib/types/MdEditor/layouts/Content/index.d.ts +15 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +8 -1
- package/lib/types/MdEditor/type.d.ts +1 -3
- package/lib/umd/index.js +34 -34
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -98,9 +98,9 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
98
98
|
const s = document.querySelectorAll(
|
|
99
99
|
`div.${p}-mermaid`
|
|
100
100
|
), r = document.createElement("div");
|
|
101
|
-
r.style.width = document.body.offsetWidth + "px", r.style.height = document.body.offsetHeight + "px", r.style.position = "fixed", r.style.zIndex = "-10000", r.style.top = "-10000"
|
|
101
|
+
r.style.width = document.body.offsetWidth + "px", r.style.height = document.body.offsetHeight + "px", r.style.position = "fixed", r.style.zIndex = "-10000", r.style.top = "-10000";
|
|
102
102
|
let m = s.length;
|
|
103
|
-
s.forEach(async (f) => {
|
|
103
|
+
m > 0 && document.body.appendChild(r), s.forEach(async (f) => {
|
|
104
104
|
let b = i.get(f.innerText);
|
|
105
105
|
if (!b) {
|
|
106
106
|
const g = he(), h = t.value.renderAsync || t.value.render;
|
package/lib/es/chunks/index2.mjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { defineComponent as H, reactive as
|
|
1
|
+
import { defineComponent as H, reactive as E, ref as C, watch as T, onMounted as D, onBeforeUnmount as $, cloneVNode as O, createVNode as c, inject as j } from "vue";
|
|
2
2
|
import { p as g } from "./config.mjs";
|
|
3
|
-
import { g as
|
|
3
|
+
import { g as d } from "./vue-tsx.mjs";
|
|
4
4
|
const B = {
|
|
5
|
-
trigger: {
|
|
6
|
-
type: String,
|
|
7
|
-
default: "hover"
|
|
8
|
-
},
|
|
9
5
|
overlay: {
|
|
10
6
|
type: [String, Object],
|
|
11
7
|
default: ""
|
|
@@ -27,56 +23,55 @@ const B = {
|
|
|
27
23
|
}, I = /* @__PURE__ */ H({
|
|
28
24
|
props: B,
|
|
29
25
|
setup(e, a) {
|
|
30
|
-
const
|
|
31
|
-
overlayClass: [
|
|
26
|
+
const i = `${g}-dropdown-hidden`, t = E({
|
|
27
|
+
overlayClass: [i],
|
|
32
28
|
overlayStyle: {},
|
|
33
29
|
triggerHover: !1,
|
|
34
30
|
overlayHover: !1
|
|
35
|
-
}),
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
const
|
|
31
|
+
}), r = C(), n = C(), y = () => {
|
|
32
|
+
var p;
|
|
33
|
+
t.triggerHover = !0;
|
|
34
|
+
const o = r.value, l = n.value;
|
|
35
|
+
if (!o || !l)
|
|
36
|
+
return;
|
|
37
|
+
const v = o.getBoundingClientRect(), u = o.offsetTop, L = o.offsetLeft, S = v.height, b = v.width, w = ((p = document.querySelector(e.relative)) == null ? void 0 : p.scrollLeft) || 0;
|
|
39
38
|
t.overlayStyle = {
|
|
40
39
|
...t.overlayStyle,
|
|
41
|
-
top:
|
|
42
|
-
left:
|
|
40
|
+
top: u + S + "px",
|
|
41
|
+
left: L - l.offsetWidth / 2 + b / 2 - w + "px"
|
|
43
42
|
}, e.onChange(!0);
|
|
44
43
|
}, m = () => {
|
|
45
44
|
t.overlayHover = !0;
|
|
46
45
|
};
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
T(() => e.visible, (o) => {
|
|
47
|
+
o ? t.overlayClass = t.overlayClass.filter((l) => l !== i) : t.overlayClass.push(i);
|
|
49
48
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
let C = -1;
|
|
55
|
-
const c = (r) => {
|
|
56
|
-
o.value === r.target ? t.triggerHover = !1 : t.overlayHover = !1, clearTimeout(C), C = window.setTimeout(() => {
|
|
49
|
+
let h = -1;
|
|
50
|
+
const s = (o) => {
|
|
51
|
+
r.value === o.target ? t.triggerHover = !1 : t.overlayHover = !1, clearTimeout(h), h = window.setTimeout(() => {
|
|
57
52
|
!t.overlayHover && !t.triggerHover && e.onChange(!1);
|
|
58
53
|
}, 10);
|
|
59
54
|
};
|
|
60
55
|
return D(() => {
|
|
61
|
-
|
|
56
|
+
r.value.addEventListener("mouseenter", y), r.value.addEventListener("mouseleave", s), n.value.addEventListener("mouseenter", m), n.value.addEventListener("mouseleave", s);
|
|
62
57
|
}), $(() => {
|
|
63
|
-
|
|
58
|
+
r.value.removeEventListener("mouseenter", y), r.value.removeEventListener("mouseleave", s), n.value.removeEventListener("mouseenter", m), n.value.removeEventListener("mouseleave", s);
|
|
64
59
|
}), () => {
|
|
65
|
-
const
|
|
60
|
+
const o = d({
|
|
66
61
|
ctx: a
|
|
67
|
-
}), l =
|
|
62
|
+
}), l = d({
|
|
68
63
|
props: e,
|
|
69
64
|
ctx: a
|
|
70
|
-
}, "overlay"),
|
|
71
|
-
ref:
|
|
72
|
-
}),
|
|
65
|
+
}, "overlay"), v = O(o instanceof Array ? o[0] : o, {
|
|
66
|
+
ref: r
|
|
67
|
+
}), u = c("div", {
|
|
73
68
|
class: [`${g}-dropdown`, t.overlayClass],
|
|
74
69
|
style: t.overlayStyle,
|
|
75
70
|
ref: n
|
|
76
|
-
}, [
|
|
71
|
+
}, [c("div", {
|
|
77
72
|
class: `${g}-dropdown-overlay`
|
|
78
73
|
}, [l instanceof Array ? l[0] : l])]);
|
|
79
|
-
return [
|
|
74
|
+
return [v, u];
|
|
80
75
|
};
|
|
81
76
|
}
|
|
82
77
|
}), A = {
|
|
@@ -98,29 +93,29 @@ const B = {
|
|
|
98
93
|
overlay: {
|
|
99
94
|
type: [String, Object]
|
|
100
95
|
}
|
|
101
|
-
},
|
|
96
|
+
}, f = /* @__PURE__ */ H({
|
|
102
97
|
name: "DropdownToolbar",
|
|
103
98
|
props: A,
|
|
104
99
|
emits: ["onChange"],
|
|
105
100
|
setup(e, a) {
|
|
106
|
-
const
|
|
101
|
+
const i = j("editorId");
|
|
107
102
|
return () => {
|
|
108
|
-
const t =
|
|
103
|
+
const t = d({
|
|
109
104
|
props: e,
|
|
110
105
|
ctx: a
|
|
111
|
-
}, "trigger"),
|
|
106
|
+
}, "trigger"), r = d({
|
|
112
107
|
props: e,
|
|
113
108
|
ctx: a
|
|
114
109
|
}, "overlay");
|
|
115
|
-
return
|
|
116
|
-
relative: `#${
|
|
110
|
+
return c(I, {
|
|
111
|
+
relative: `#${i}-toolbar-wrapper`,
|
|
117
112
|
visible: e.visible,
|
|
118
113
|
onChange: (n) => {
|
|
119
114
|
e.onChange instanceof Function ? e.onChange(n) : a.emit("onChange", n);
|
|
120
115
|
},
|
|
121
|
-
overlay:
|
|
116
|
+
overlay: r
|
|
122
117
|
}, {
|
|
123
|
-
default: () => [
|
|
118
|
+
default: () => [c("div", {
|
|
124
119
|
class: `${g}-toolbar-item`,
|
|
125
120
|
title: e.title || ""
|
|
126
121
|
}, [t])]
|
|
@@ -128,8 +123,8 @@ const B = {
|
|
|
128
123
|
};
|
|
129
124
|
}
|
|
130
125
|
});
|
|
131
|
-
|
|
126
|
+
f.install = (e) => (e.component(f.name, f), e);
|
|
132
127
|
export {
|
|
133
|
-
|
|
128
|
+
f as D,
|
|
134
129
|
I as a
|
|
135
130
|
};
|
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -9,7 +9,7 @@ class u {
|
|
|
9
9
|
// 移除事件监听
|
|
10
10
|
remove(t, s, n) {
|
|
11
11
|
const i = this.pools[t] && this.pools[t][s];
|
|
12
|
-
i && (this.pools[t][s] = i.filter((
|
|
12
|
+
i && (this.pools[t][s] = i.filter((r) => r !== n));
|
|
13
13
|
}
|
|
14
14
|
// 清空全部事件,由于单一实例,多次注册会被共享内容
|
|
15
15
|
clear(t) {
|
|
@@ -23,27 +23,27 @@ class u {
|
|
|
23
23
|
emit(t, s, ...n) {
|
|
24
24
|
this.pools[t] || (this.pools[t] = {});
|
|
25
25
|
const i = this.pools[t][s];
|
|
26
|
-
i && i.forEach((
|
|
26
|
+
i && i.forEach((r) => {
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
console.error(`${s} monitor event exception!`,
|
|
28
|
+
r(...n);
|
|
29
|
+
} catch (l) {
|
|
30
|
+
console.error(`${s} monitor event exception!`, l);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
const g = new u(),
|
|
35
|
+
const g = new u(), f = (o, t = "image.png") => {
|
|
36
36
|
const s = o.split(","), n = s[0].match(/:(.*?);/);
|
|
37
37
|
if (n) {
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
const
|
|
41
|
-
for (;
|
|
42
|
-
r
|
|
43
|
-
return new File([
|
|
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
44
|
}
|
|
45
45
|
return null;
|
|
46
|
-
},
|
|
46
|
+
}, b = (o) => {
|
|
47
47
|
if (!o)
|
|
48
48
|
return o;
|
|
49
49
|
const t = o.split(`
|
|
@@ -51,17 +51,19 @@ const g = new u(), b = (o, t = "image.png") => {
|
|
|
51
51
|
return t.forEach(() => {
|
|
52
52
|
s.push("<span></span>");
|
|
53
53
|
}), s.push("</span>"), `<span class="code-block">${o}</span>${s.join("")}`;
|
|
54
|
-
},
|
|
54
|
+
}, R = (o, t) => {
|
|
55
|
+
if (!o || !t)
|
|
56
|
+
return 0;
|
|
55
57
|
const s = o == null ? void 0 : o.getBoundingClientRect();
|
|
56
58
|
if (t === document.documentElement)
|
|
57
59
|
return s.top - t.clientTop;
|
|
58
60
|
const n = t == null ? void 0 : t.getBoundingClientRect();
|
|
59
61
|
return s.top - n.top;
|
|
60
|
-
},
|
|
62
|
+
}, m = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
|
|
61
63
|
export {
|
|
62
|
-
|
|
64
|
+
f as a,
|
|
63
65
|
g as b,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
R as c,
|
|
67
|
+
b as g,
|
|
68
|
+
m as u
|
|
67
69
|
};
|
package/lib/es/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { M as
|
|
3
|
-
import { default as
|
|
4
|
-
import { D as
|
|
5
|
-
import { M as
|
|
6
|
-
import { default as
|
|
7
|
-
import { c as
|
|
1
|
+
import { default as v } from "./MdEditor.mjs";
|
|
2
|
+
import { M as E } from "./chunks/index.mjs";
|
|
3
|
+
import { default as P } from "./NormalToolbar.mjs";
|
|
4
|
+
import { D as j } from "./chunks/index2.mjs";
|
|
5
|
+
import { M as q } from "./chunks/index3.mjs";
|
|
6
|
+
import { default as z } from "./MdCatalog.mjs";
|
|
7
|
+
import { c as B } from "./chunks/config.mjs";
|
|
8
8
|
import "vue";
|
|
9
9
|
import "./chunks/index4.mjs";
|
|
10
10
|
import "@vavt/util";
|
|
@@ -13,7 +13,6 @@ import "codemirror";
|
|
|
13
13
|
import "@codemirror/view";
|
|
14
14
|
import "@codemirror/language-data";
|
|
15
15
|
import "@codemirror/lang-markdown";
|
|
16
|
-
import "@codemirror/lang-html";
|
|
17
16
|
import "@codemirror/commands";
|
|
18
17
|
import "@codemirror/language";
|
|
19
18
|
import "@lezer/highlight";
|
|
@@ -27,11 +26,11 @@ import "markdown-it-image-figures";
|
|
|
27
26
|
import "markdown-it-task-lists";
|
|
28
27
|
import "lru-cache";
|
|
29
28
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
j as DropdownToolbar,
|
|
30
|
+
z as MdCatalog,
|
|
31
|
+
v as MdEditor,
|
|
32
|
+
E as MdPreview,
|
|
33
|
+
q as ModalToolbar,
|
|
34
|
+
P as NormalToolbar,
|
|
35
|
+
B as config
|
|
37
36
|
};
|