md-editor-v3 7.1.0 → 7.1.2
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 +5 -2
- package/lib/cjs/MdEditor.cjs +1 -1
- package/lib/cjs/chunks/dom.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +1 -1
- package/lib/cjs/chunks/index2.cjs +1 -1
- package/lib/cjs/chunks/index4.cjs +36 -36
- package/lib/es/MdEditor.mjs +2 -3
- package/lib/es/chunks/dom.mjs +120 -110
- package/lib/es/chunks/index.mjs +180 -86
- package/lib/es/chunks/index2.mjs +182 -145
- package/lib/es/chunks/index4.mjs +88 -86
- package/lib/style.css +13 -2
- package/lib/types/index.d.ts +66 -66
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { p as
|
|
3
|
-
import { g as
|
|
4
|
-
|
|
1
|
+
import { defineComponent as N, computed as F, useId as O, ref as S, watchPostEffect as R, cloneVNode as $, createVNode as w, mergeProps as B, inject as L } from "vue";
|
|
2
|
+
import { p as g } from "./config.mjs";
|
|
3
|
+
import { g as K } from "./dom.mjs";
|
|
4
|
+
import { g as v } from "./vue-tsx.mjs";
|
|
5
|
+
const U = {
|
|
5
6
|
overlay: {
|
|
6
7
|
type: [String, Object],
|
|
7
8
|
default: ""
|
|
@@ -24,67 +25,160 @@ const O = {
|
|
|
24
25
|
type: Boolean,
|
|
25
26
|
default: void 0
|
|
26
27
|
}
|
|
27
|
-
}, j = /* @__PURE__ */
|
|
28
|
-
name: `${
|
|
29
|
-
props:
|
|
30
|
-
setup(
|
|
31
|
-
const d =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
t.
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
}, j = `${g}-dropdown-hidden`, p = '[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]', I = (t) => Array.from(t.querySelectorAll(p)).filter((l) => !l.matches(':disabled, [aria-disabled="true"]') && !l.closest('[hidden], [inert], [aria-hidden="true"]') && l.getClientRects().length > 0 && getComputedStyle(l).visibility === "visible"), H = /* @__PURE__ */ N({
|
|
29
|
+
name: `${g}-dropdown`,
|
|
30
|
+
props: U,
|
|
31
|
+
setup(t, l) {
|
|
32
|
+
const d = F(() => t.visible && !t.disabled), b = O(), c = S({}), i = S(), s = S();
|
|
33
|
+
let y = null, m = -1;
|
|
34
|
+
const T = (e) => {
|
|
35
|
+
const n = s.value, o = I(n), a = e === "last" ? o.at(-1) : o[0];
|
|
36
|
+
a && (a.tabIndex = -1), (a || K(n)[0] || n).focus({
|
|
37
|
+
preventScroll: !0
|
|
38
|
+
});
|
|
39
|
+
}, h = (e) => {
|
|
40
|
+
if (t.disabled) return;
|
|
41
|
+
if (clearTimeout(m), d.value && e) {
|
|
42
|
+
T(e);
|
|
42
43
|
return;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
}
|
|
45
|
+
const n = i.value, o = s.value;
|
|
46
|
+
if (!n || !o) return;
|
|
47
|
+
const {
|
|
48
|
+
width: a,
|
|
49
|
+
height: r
|
|
50
|
+
} = n.getBoundingClientRect(), f = n.getRootNode().querySelector(t.relative), x = f?.scrollLeft || 0, A = o.offsetWidth, M = n.offsetLeft + (a - A) / 2 - x, P = x + (f?.clientWidth || 0) - A;
|
|
51
|
+
c.value = {
|
|
52
|
+
insetBlockStart: n.offsetTop + r + "px",
|
|
53
|
+
insetInlineStart: Math.max(0, Math.min(M, P)) + "px"
|
|
54
|
+
}, y = e || null, t.onChange(!0);
|
|
55
|
+
}, k = () => {
|
|
56
|
+
d.value && (clearTimeout(m), m = window.setTimeout(() => {
|
|
57
|
+
const n = i.value?.getRootNode()?.activeElement || null;
|
|
58
|
+
!i.value?.contains(n) && !s.value?.contains(n) && t.onChange(!1);
|
|
59
|
+
}, 10));
|
|
60
|
+
}, E = (e) => {
|
|
61
|
+
const n = e.relatedTarget;
|
|
62
|
+
d.value && !i.value?.contains(n) && !s.value?.contains(n) && t.onChange(!1);
|
|
54
63
|
};
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
R((e) => {
|
|
65
|
+
e(() => clearTimeout(m));
|
|
66
|
+
const n = s.value;
|
|
67
|
+
if (n)
|
|
68
|
+
if (d.value)
|
|
69
|
+
n.querySelectorAll(p).forEach((o) => {
|
|
70
|
+
o.tabIndex = -1;
|
|
71
|
+
}), y && (T(y), y = null);
|
|
72
|
+
else {
|
|
73
|
+
y = null;
|
|
74
|
+
const o = n.getRootNode();
|
|
75
|
+
n.contains(o.activeElement) && i.value?.focus({
|
|
76
|
+
preventScroll: !0
|
|
77
|
+
}), t.disabled && t.visible && t.onChange(!1);
|
|
78
|
+
}
|
|
57
79
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
const D = (e) => {
|
|
81
|
+
if (t.disabled || e.defaultPrevented || e.isComposing || e.ctrlKey || e.metaKey || e.altKey && e.key !== "Tab") return;
|
|
82
|
+
const n = e.currentTarget === i.value;
|
|
83
|
+
if (n && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
84
|
+
e.preventDefault(), h(e.key === "ArrowUp" ? "last" : "first");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!d.value) return;
|
|
88
|
+
if (e.key === "Escape") {
|
|
89
|
+
e.preventDefault(), e.stopPropagation(), i.value?.focus({
|
|
90
|
+
preventScroll: !0
|
|
91
|
+
}), t.onChange(!1);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const o = e.target;
|
|
95
|
+
if (!n && !o.matches(p)) return;
|
|
96
|
+
if (e.key === "Tab") {
|
|
97
|
+
i.value?.focus({
|
|
98
|
+
preventScroll: !0
|
|
99
|
+
}), t.onChange(!1);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (n) return;
|
|
103
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
104
|
+
e.preventDefault(), e.stopPropagation(), e.repeat || o.click();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) return;
|
|
108
|
+
const a = I(e.currentTarget), r = a.indexOf(o);
|
|
109
|
+
let u;
|
|
110
|
+
switch (e.key) {
|
|
111
|
+
case "ArrowDown":
|
|
112
|
+
u = (r + 1) % a.length;
|
|
113
|
+
break;
|
|
114
|
+
case "ArrowUp":
|
|
115
|
+
u = (r - 1 + a.length) % a.length;
|
|
116
|
+
break;
|
|
117
|
+
case "Home":
|
|
118
|
+
u = 0;
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
u = a.length - 1;
|
|
122
|
+
}
|
|
123
|
+
e.preventDefault(), e.stopPropagation();
|
|
124
|
+
const f = a[u];
|
|
125
|
+
f && (f.tabIndex = -1, f.focus({
|
|
126
|
+
preventScroll: !0
|
|
127
|
+
}));
|
|
63
128
|
};
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
129
|
+
return () => {
|
|
130
|
+
const e = v({
|
|
131
|
+
ctx: l
|
|
132
|
+
}), n = v({
|
|
133
|
+
props: t,
|
|
134
|
+
ctx: l
|
|
135
|
+
}, "overlay"), o = $(e instanceof Array ? e[0] : e, {
|
|
136
|
+
ref: i,
|
|
137
|
+
key: "cloned-dropdown-trigger",
|
|
138
|
+
"aria-haspopup": "menu",
|
|
139
|
+
"aria-expanded": d.value,
|
|
140
|
+
"aria-controls": b,
|
|
141
|
+
onMouseenter: (r) => {
|
|
142
|
+
r.defaultPrevented || h();
|
|
143
|
+
},
|
|
144
|
+
onMouseleave: k,
|
|
145
|
+
// Vue 使用原生 focusout 接收子控件的失焦冒泡。
|
|
146
|
+
onFocusout: E,
|
|
147
|
+
onKeydown: D,
|
|
148
|
+
onClick: (r) => {
|
|
149
|
+
r.defaultPrevented || (r.detail === 0 ? h("first") : d.value || h());
|
|
150
|
+
}
|
|
151
|
+
}, !0), a = w("div", B({
|
|
152
|
+
id: b,
|
|
153
|
+
class: [`${g}-dropdown`, !d.value && j],
|
|
154
|
+
style: c.value,
|
|
155
|
+
ref: s,
|
|
156
|
+
tabindex: -1,
|
|
157
|
+
"aria-hidden": !d.value,
|
|
158
|
+
onMouseenter: () => clearTimeout(m),
|
|
159
|
+
onMouseleave: k,
|
|
160
|
+
onFocusout: E,
|
|
161
|
+
onKeydown: D
|
|
162
|
+
}, {
|
|
163
|
+
onClickCapture: (r) => {
|
|
164
|
+
const u = r.target.closest(p);
|
|
165
|
+
if (!(!u || !r.currentTarget.contains(u))) {
|
|
166
|
+
if (t.disabled || u.matches(':disabled, [aria-disabled="true"]')) {
|
|
167
|
+
r.preventDefault(), r.stopPropagation();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
i.value?.focus({
|
|
171
|
+
preventScroll: !0
|
|
172
|
+
}), t.onChange(!1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}), [w("div", {
|
|
176
|
+
class: `${g}-dropdown-overlay`
|
|
177
|
+
}, [n instanceof Array ? n[0] : n])]);
|
|
178
|
+
return [o, a];
|
|
85
179
|
};
|
|
86
180
|
}
|
|
87
|
-
}),
|
|
181
|
+
}), q = {
|
|
88
182
|
title: {
|
|
89
183
|
type: String,
|
|
90
184
|
default: ""
|
|
@@ -145,44 +239,44 @@ const O = {
|
|
|
145
239
|
/**
|
|
146
240
|
* ==结束
|
|
147
241
|
*/
|
|
148
|
-
},
|
|
242
|
+
}, C = /* @__PURE__ */ N({
|
|
149
243
|
name: "DropdownToolbar",
|
|
150
|
-
props:
|
|
244
|
+
props: q,
|
|
151
245
|
emits: ["onChange"],
|
|
152
|
-
setup(
|
|
153
|
-
const d =
|
|
154
|
-
|
|
246
|
+
setup(t, l) {
|
|
247
|
+
const d = L("editorId"), b = (c) => {
|
|
248
|
+
t.onChange?.(c), l.emit("onChange", c);
|
|
155
249
|
};
|
|
156
250
|
return () => {
|
|
157
|
-
const
|
|
158
|
-
props:
|
|
159
|
-
ctx:
|
|
160
|
-
}, "trigger"),
|
|
161
|
-
props:
|
|
162
|
-
ctx:
|
|
163
|
-
}, "overlay"),
|
|
164
|
-
props:
|
|
165
|
-
ctx:
|
|
251
|
+
const c = v({
|
|
252
|
+
props: t,
|
|
253
|
+
ctx: l
|
|
254
|
+
}, "trigger"), i = v({
|
|
255
|
+
props: t,
|
|
256
|
+
ctx: l
|
|
257
|
+
}, "overlay"), s = v({
|
|
258
|
+
props: t,
|
|
259
|
+
ctx: l
|
|
166
260
|
});
|
|
167
|
-
return
|
|
261
|
+
return w(H, {
|
|
168
262
|
relative: `#${d}-toolbar-wrapper`,
|
|
169
|
-
visible:
|
|
170
|
-
onChange:
|
|
171
|
-
overlay:
|
|
172
|
-
disabled:
|
|
263
|
+
visible: t.visible,
|
|
264
|
+
onChange: b,
|
|
265
|
+
overlay: i,
|
|
266
|
+
disabled: t.disabled
|
|
173
267
|
}, {
|
|
174
|
-
default: () => [
|
|
175
|
-
class: [`${
|
|
176
|
-
title:
|
|
177
|
-
disabled:
|
|
268
|
+
default: () => [w("button", {
|
|
269
|
+
class: [`${g}-toolbar-item`, t.disabled && `${g}-disabled`],
|
|
270
|
+
title: t.title || "",
|
|
271
|
+
disabled: t.disabled,
|
|
178
272
|
type: "button"
|
|
179
|
-
}, [
|
|
273
|
+
}, [s || c])]
|
|
180
274
|
});
|
|
181
275
|
};
|
|
182
276
|
}
|
|
183
277
|
});
|
|
184
|
-
|
|
278
|
+
C.install = (t) => (t.component(C.name, C), t);
|
|
185
279
|
export {
|
|
186
|
-
|
|
187
|
-
|
|
280
|
+
C as D,
|
|
281
|
+
H as a
|
|
188
282
|
};
|