md-editor-v3 4.5.0 → 4.6.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 +1 -0
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +11 -11
- package/lib/cjs/chunks/index.cjs +6 -6
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/es/MdCatalog.mjs +28 -28
- package/lib/es/MdEditor.mjs +708 -702
- package/lib/es/chunks/index.mjs +206 -201
- package/lib/es/chunks/index4.mjs +64 -46
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/Editor.d.ts +8 -1
- package/lib/types/MdEditor/index.d.ts +18 -2
- package/lib/types/MdEditor/layouts/Content/index.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +4 -0
- package/lib/types/MdEditor/props.d.ts +3 -0
- package/lib/types/MdEditor/static/event-name.d.ts +9 -0
- package/lib/types/MdEditor/type.d.ts +1 -1
- package/lib/types/MdPreview/MdPreview.d.ts +2 -1
- package/lib/types/MdPreview/index.d.ts +6 -2
- package/lib/umd/index.js +41 -41
- package/package.json +2 -2
package/lib/es/MdCatalog.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as y, createVNode as f, reactive as H, shallowRef as $, computed as b, onMounted as x, onBeforeUnmount as
|
|
2
|
-
import { throttle as
|
|
1
|
+
import { defineComponent as y, createVNode as f, reactive as H, shallowRef as $, computed as b, onMounted as x, onBeforeUnmount as O } from "vue";
|
|
2
|
+
import { throttle as w } from "@vavt/util";
|
|
3
3
|
import { p as h } from "./chunks/config.mjs";
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
4
|
+
import { l as S, b as I, h as L, P as N } from "./chunks/index4.mjs";
|
|
5
|
+
const A = {
|
|
6
6
|
tocItem: {
|
|
7
7
|
type: Object,
|
|
8
8
|
default: () => ({})
|
|
@@ -26,7 +26,7 @@ const M = {
|
|
|
26
26
|
default: 0
|
|
27
27
|
}
|
|
28
28
|
}, C = /* @__PURE__ */ y({
|
|
29
|
-
props:
|
|
29
|
+
props: A,
|
|
30
30
|
setup(l) {
|
|
31
31
|
return () => {
|
|
32
32
|
const {
|
|
@@ -34,7 +34,7 @@ const M = {
|
|
|
34
34
|
mdHeadingId: i,
|
|
35
35
|
scrollElement: n,
|
|
36
36
|
onClick: u,
|
|
37
|
-
scrollElementOffsetTop:
|
|
37
|
+
scrollElementOffsetTop: p
|
|
38
38
|
} = l;
|
|
39
39
|
return f("div", {
|
|
40
40
|
class: [`${h}-catalog-link`, o.active && `${h}-catalog-active`],
|
|
@@ -47,7 +47,7 @@ const M = {
|
|
|
47
47
|
for (; t && e != t; )
|
|
48
48
|
c += t == null ? void 0 : t.offsetTop, t = t == null ? void 0 : t.offsetParent;
|
|
49
49
|
e == null || e.scrollTo({
|
|
50
|
-
top: c -
|
|
50
|
+
top: c - p,
|
|
51
51
|
behavior: "smooth"
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -62,11 +62,11 @@ const M = {
|
|
|
62
62
|
tocItem: s,
|
|
63
63
|
scrollElement: n,
|
|
64
64
|
onClick: u,
|
|
65
|
-
scrollElementOffsetTop:
|
|
65
|
+
scrollElementOffsetTop: p
|
|
66
66
|
}, null))])]);
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
}),
|
|
69
|
+
}), M = C, F = {
|
|
70
70
|
/**
|
|
71
71
|
* 编辑器的Id,务必与需要绑定的编辑器Id相同
|
|
72
72
|
*/
|
|
@@ -115,24 +115,24 @@ const M = {
|
|
|
115
115
|
onClick: {
|
|
116
116
|
type: Function
|
|
117
117
|
}
|
|
118
|
-
},
|
|
118
|
+
}, P = /* @__PURE__ */ y({
|
|
119
119
|
name: "MdCatalog",
|
|
120
|
-
props:
|
|
120
|
+
props: F,
|
|
121
121
|
emits: ["onClick"],
|
|
122
122
|
setup(l, o) {
|
|
123
123
|
const i = l.editorId, n = H({
|
|
124
124
|
list: [],
|
|
125
125
|
show: !1,
|
|
126
126
|
scrollElement: l.scrollElement || `#${i}-preview-wrapper`
|
|
127
|
-
}), u = $(),
|
|
127
|
+
}), u = $(), p = b(() => {
|
|
128
128
|
const e = [];
|
|
129
129
|
return n.list.forEach((t, c) => {
|
|
130
130
|
const {
|
|
131
|
-
text:
|
|
132
|
-
level:
|
|
131
|
+
text: E,
|
|
132
|
+
level: T
|
|
133
133
|
} = t, a = {
|
|
134
|
-
level:
|
|
135
|
-
text:
|
|
134
|
+
level: T,
|
|
135
|
+
text: E,
|
|
136
136
|
index: c + 1,
|
|
137
137
|
active: u.value === t
|
|
138
138
|
};
|
|
@@ -158,18 +158,18 @@ const M = {
|
|
|
158
158
|
e.push(a);
|
|
159
159
|
}
|
|
160
160
|
}), e;
|
|
161
|
-
}), s = () => n.scrollElement instanceof HTMLElement ? n.scrollElement : document.querySelector(n.scrollElement), g =
|
|
161
|
+
}), s = () => n.scrollElement instanceof HTMLElement ? n.scrollElement : document.querySelector(n.scrollElement), g = w((e) => {
|
|
162
162
|
if (e.length === 0)
|
|
163
163
|
return n.list = [], !1;
|
|
164
164
|
const {
|
|
165
165
|
activeHead: t
|
|
166
|
-
} = e.reduce((c,
|
|
167
|
-
const a = document.getElementById(l.mdHeadingId(
|
|
166
|
+
} = e.reduce((c, E, T) => {
|
|
167
|
+
const a = document.getElementById(l.mdHeadingId(E.text, E.level, T + 1));
|
|
168
168
|
if (a instanceof HTMLElement) {
|
|
169
169
|
const r = s(), m = S(a, r);
|
|
170
170
|
if (m < l.offsetTop && m > c.minTop)
|
|
171
171
|
return {
|
|
172
|
-
activeHead:
|
|
172
|
+
activeHead: E,
|
|
173
173
|
minTop: m
|
|
174
174
|
};
|
|
175
175
|
}
|
|
@@ -185,19 +185,19 @@ const M = {
|
|
|
185
185
|
return x(() => {
|
|
186
186
|
var t;
|
|
187
187
|
const e = s();
|
|
188
|
-
(t = e === document.documentElement ? window : e) == null || t.addEventListener("scroll", d),
|
|
189
|
-
name:
|
|
188
|
+
(t = e === document.documentElement ? window : e) == null || t.addEventListener("scroll", d), I.on(i, {
|
|
189
|
+
name: L,
|
|
190
190
|
callback: (c) => {
|
|
191
191
|
g(c);
|
|
192
192
|
}
|
|
193
|
-
}),
|
|
194
|
-
}),
|
|
193
|
+
}), I.emit(i, N);
|
|
194
|
+
}), O(() => {
|
|
195
195
|
var t;
|
|
196
196
|
const e = s();
|
|
197
197
|
(t = e === document.documentElement ? window : e) == null || t.removeEventListener("scroll", d);
|
|
198
198
|
}), () => f("div", {
|
|
199
199
|
class: `${h}-catalog${l.theme === "dark" ? "-dark" : ""} ${l.class}`
|
|
200
|
-
}, [
|
|
200
|
+
}, [p.value.map((e) => f(M, {
|
|
201
201
|
mdHeadingId: l.mdHeadingId,
|
|
202
202
|
tocItem: e,
|
|
203
203
|
key: `link-${e.level}-${e.text}`,
|
|
@@ -208,8 +208,8 @@ const M = {
|
|
|
208
208
|
scrollElementOffsetTop: l.scrollElementOffsetTop
|
|
209
209
|
}, null))]);
|
|
210
210
|
}
|
|
211
|
-
}),
|
|
212
|
-
|
|
211
|
+
}), k = P;
|
|
212
|
+
k.install = (l) => (l.component(k.name, k), l);
|
|
213
213
|
export {
|
|
214
|
-
|
|
214
|
+
k as default
|
|
215
215
|
};
|