editate 0.6.17 → 0.6.19
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/commands.d.ts +7 -3
- package/lib/doc/node.d.ts +5 -6
- package/lib/dom/index.d.ts +2 -2
- package/lib/index.cjs +570 -562
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +636 -626
- package/lib/index.js.map +1 -1
- package/lib/plugins/selectionRect.d.ts +1 -1
- package/lib/queries.d.ts +7 -0
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -2,287 +2,295 @@ Object.defineProperty(exports, Symbol.toStringTag, {
|
|
|
2
2
|
value: "Module"
|
|
3
3
|
});
|
|
4
4
|
|
|
5
|
-
var {min:
|
|
6
|
-
Promise.resolve().then(
|
|
7
|
-
}, i =
|
|
5
|
+
var {min: t, max: e} = Math, {keys: n, is: r} = Object, o = t => "string" == typeof t, s = t => "function" == typeof t, c = s(queueMicrotask) ? queueMicrotask : t => {
|
|
6
|
+
Promise.resolve().then(t);
|
|
7
|
+
}, i = t => "text" in t, l = t => "children" in t, a = t => t.some(l), f = new WeakMap, u = ({children: t}, e = 0, n = t.length) => {
|
|
8
8
|
let r = 0, o = 0;
|
|
9
|
-
for (let s =
|
|
10
|
-
const
|
|
11
|
-
r +=
|
|
9
|
+
for (let s = e; s < n; s++) {
|
|
10
|
+
const e = t[s];
|
|
11
|
+
r += p(e), 0 !== o && l(e) && r++, o++;
|
|
12
12
|
}
|
|
13
13
|
return r;
|
|
14
|
-
},
|
|
15
|
-
if (l(
|
|
16
|
-
let
|
|
17
|
-
return null ==
|
|
14
|
+
}, p = t => {
|
|
15
|
+
if (l(t)) {
|
|
16
|
+
let e = f.get(t);
|
|
17
|
+
return null == e && f.set(t, e = u(t)), e;
|
|
18
18
|
}
|
|
19
|
-
return i(
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
for (let
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return i(t) ? t.text.length : 1;
|
|
20
|
+
}, d = ({children: t}, e, n) => {
|
|
21
|
+
const r = t.length;
|
|
22
|
+
for (let o = 0; o < r; o++) {
|
|
23
|
+
const r = t[o], s = l(r);
|
|
24
|
+
let c = p(r);
|
|
25
|
+
const i = 0 === c;
|
|
26
|
+
if (s && c++, c > e || c === e && !s && (n || i)) return [ r, e, o ];
|
|
27
|
+
e -= c;
|
|
27
28
|
}
|
|
28
29
|
return null;
|
|
29
|
-
}, x = (
|
|
30
|
+
}, x = (t, e) => {
|
|
30
31
|
const n = [];
|
|
31
|
-
for (;
|
|
32
|
-
const r =
|
|
32
|
+
for (;t; ) {
|
|
33
|
+
const r = d(t, e);
|
|
33
34
|
if (!r) break;
|
|
34
35
|
const o = r[0];
|
|
35
36
|
if (!l(o)) break;
|
|
36
|
-
|
|
37
|
+
e = r[1], t = o, n.push(r[2]);
|
|
37
38
|
}
|
|
38
|
-
return [
|
|
39
|
-
},
|
|
40
|
-
const [
|
|
41
|
-
return
|
|
42
|
-
},
|
|
43
|
-
const n =
|
|
39
|
+
return [ t, e, n ];
|
|
40
|
+
}, y = (t, e, n) => {
|
|
41
|
+
const [r, o, s] = x(t, e), c = d(r, o, n);
|
|
42
|
+
return c ? (s.push(c[2]), [ c[0], c[1], s ]) : null;
|
|
43
|
+
}, h = (t, e) => {
|
|
44
|
+
const n = t.children, r = d(t, e);
|
|
44
45
|
if (r) {
|
|
45
|
-
const [
|
|
46
|
-
if (l(
|
|
47
|
-
const [r, c] =
|
|
46
|
+
const [e, o, s] = r;
|
|
47
|
+
if (l(e)) {
|
|
48
|
+
const [r, c] = h(e, o), i = n.slice(0, s), l = n.slice(s + 1);
|
|
48
49
|
return i.push(r), l.unshift(c), [ {
|
|
49
|
-
...
|
|
50
|
+
...t,
|
|
50
51
|
children: i
|
|
51
52
|
}, {
|
|
52
|
-
...
|
|
53
|
+
...t,
|
|
53
54
|
children: l
|
|
54
55
|
} ];
|
|
55
56
|
}
|
|
56
57
|
{
|
|
57
58
|
const r = n.slice(0, s), c = n.slice(s + 1);
|
|
58
|
-
if (i(
|
|
59
|
-
const
|
|
60
|
-
!
|
|
61
|
-
...
|
|
62
|
-
text:
|
|
59
|
+
if (i(e)) {
|
|
60
|
+
const t = e.text.slice(0, o), n = e.text.slice(o);
|
|
61
|
+
!t && r.length || r.push({
|
|
62
|
+
...e,
|
|
63
|
+
text: t
|
|
63
64
|
}), !n && c.length || c.unshift({
|
|
64
|
-
...
|
|
65
|
+
...e,
|
|
65
66
|
text: n
|
|
66
67
|
});
|
|
67
|
-
} else c.unshift(
|
|
68
|
+
} else c.unshift(e);
|
|
68
69
|
return [ {
|
|
69
|
-
...
|
|
70
|
+
...t,
|
|
70
71
|
children: r
|
|
71
72
|
}, {
|
|
72
|
-
...
|
|
73
|
+
...t,
|
|
73
74
|
children: c
|
|
74
75
|
} ];
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
const o = n[n.length - 1];
|
|
78
|
-
return [
|
|
79
|
-
...
|
|
79
|
+
return [ t, {
|
|
80
|
+
...t,
|
|
80
81
|
children: i(o) ? [ {
|
|
81
82
|
...o,
|
|
82
83
|
text: ""
|
|
83
84
|
} ] : []
|
|
84
85
|
} ];
|
|
85
|
-
},
|
|
86
|
+
}, k = (t, [e, n]) => {
|
|
86
87
|
let r = 0;
|
|
87
|
-
for (const o of
|
|
88
|
+
for (const o of e) r += u(t, 0, o), 0 !== o && r++, t = t.children[o];
|
|
88
89
|
return r + n;
|
|
89
|
-
},
|
|
90
|
-
const [, n, r] = x(
|
|
90
|
+
}, g = (t, e) => {
|
|
91
|
+
const [, n, r] = x(t, e);
|
|
91
92
|
return [ r, n ];
|
|
92
|
-
}, m = (
|
|
93
|
+
}, m = (t, [e, n]) => [ k(t, e), k(t, n) ];
|
|
93
94
|
|
|
94
|
-
function*
|
|
95
|
-
if (l(
|
|
96
|
-
if (
|
|
97
|
-
if (!l(
|
|
98
|
-
const r =
|
|
95
|
+
function* _(t, e) {
|
|
96
|
+
if (l(t)) for (const [n, r] of function*(t, [e, n]) {
|
|
97
|
+
if (e >= n) return;
|
|
98
|
+
if (!l(t)) return;
|
|
99
|
+
const r = d(t, e);
|
|
99
100
|
if (r) {
|
|
100
|
-
let o =
|
|
101
|
-
const c =
|
|
101
|
+
let o = e - r[1], s = r[2];
|
|
102
|
+
const c = t.children, i = c.length;
|
|
102
103
|
for (;o <= n && s < i; ) {
|
|
103
|
-
const
|
|
104
|
-
yield [
|
|
104
|
+
const t = c[s];
|
|
105
|
+
yield [ t, o ], s++, o += p(t), l(t) && o++;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
}(
|
|
108
|
+
}(t, e)) for (const t of _(n, [ 0, p(n) ])) t[1] += r, yield t; else yield [ t, 0 ];
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
var
|
|
111
|
+
var b = (n, r = 0, o = 1 / 0, s) => {
|
|
111
112
|
let c = "", l = r;
|
|
112
|
-
for (const [a, f] of
|
|
113
|
-
for (let
|
|
114
|
-
const n =
|
|
113
|
+
for (const [a, f] of _(n, [ r, o ])) {
|
|
114
|
+
for (let t = f - l; t > 0; t--) c += "\n";
|
|
115
|
+
const n = p(a), u = f + n;
|
|
115
116
|
if (i(a)) {
|
|
116
|
-
const s =
|
|
117
|
+
const s = e(f, r) - f, i = t(u, o) - f;
|
|
117
118
|
c += 0 === s && i === n ? a.text : a.text.slice(s, i);
|
|
118
119
|
} else s && (c += s(a));
|
|
119
120
|
l = u;
|
|
120
121
|
}
|
|
121
|
-
for (let
|
|
122
|
+
for (let e = t(o, p(n)) - l; e > 0; e--) c += "\n";
|
|
122
123
|
return c;
|
|
123
|
-
},
|
|
124
|
+
}, v = (t, e, n) => e >= n ? [] : h(h(t, n)[0], e)[1].children, T = ([t, e]) => t > e ? [ e, t ] : [ t, e ], E = ([t, e]) => t === e, M = ([t, e], [n, r]) => t < r && n < e;
|
|
124
125
|
|
|
125
|
-
function
|
|
126
|
-
e
|
|
126
|
+
function* S(t, e = T(t.selection)) {
|
|
127
|
+
if (E(e)) {
|
|
128
|
+
const n = y(t.doc, e[0])?.[0];
|
|
129
|
+
n && (yield n);
|
|
130
|
+
} else for (const [n, r] of _(t.doc, e)) M(e, [ r, r + p(n) ]) && (yield n);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function w(t, e) {
|
|
134
|
+
t.apply({
|
|
127
135
|
type: "patch_node",
|
|
128
136
|
path: [],
|
|
129
137
|
key: "children",
|
|
130
|
-
value:
|
|
138
|
+
value: e
|
|
131
139
|
});
|
|
132
140
|
}
|
|
133
141
|
|
|
134
|
-
var A =
|
|
135
|
-
if (
|
|
136
|
-
const n =
|
|
137
|
-
if (
|
|
142
|
+
var A = t => 1 === t.nodeType, O = t => 8 === t.nodeType, R = new Map([ [ "BR", 1 ], [ "WBR", 1 ], [ "AREA", 2 ], [ "BASE", 2 ], [ "DATALIST", 2 ], [ "HEAD", 2 ], [ "LINK", 2 ], [ "META", 2 ], [ "RP", 2 ], [ "SCRIPT", 2 ], [ "STYLE", 2 ], [ "TEMPLATE", 2 ], [ "TITLE", 2 ], [ "COLGROUP", 2 ], [ "HR", 3 ], [ "AUDIO", 3 ], [ "CANVAS", 3 ], [ "EMBED", 3 ], [ "IFRAME", 3 ], [ "IMG", 3 ], [ "OBJECT", 3 ], [ "PICTURE", 3 ], [ "VIDEO", 3 ], [ "SVG", 3 ], [ "MATH", 3 ], [ "BUTTON", 3 ], [ "INPUT", 3 ], [ "METER", 3 ], [ "PROGRESS", 3 ], [ "SELECT", 3 ], [ "TEXTAREA", 3 ] ]), D = new Set([ "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE", "LI", "DT", "DD", "TH", "TD" ]), B = t => D.has(t.tagName), I = (t, e) => t.compareDocumentPosition(e), P = t => t.ownerDocument, N = t => P(t).getSelection(), L = (t, e) => {
|
|
143
|
+
if (t.rangeCount) {
|
|
144
|
+
const n = t.getRangeAt(0);
|
|
145
|
+
if (e.contains(n.commonAncestorContainer)) return n;
|
|
138
146
|
}
|
|
139
|
-
}, C = (
|
|
140
|
-
const s =
|
|
141
|
-
return A(d) &&
|
|
142
|
-
A(
|
|
143
|
-
|
|
144
|
-
}, H = (
|
|
145
|
-
const s = N(
|
|
146
|
-
if (o || L(s,
|
|
147
|
-
const o = C(
|
|
147
|
+
}, C = (t, e, n, r) => {
|
|
148
|
+
const [o, s] = ((t, [e, n]) => [ g(t, e), g(t, n) ])(n, r), c = P(t), i = E(r), l = r[0] - r[1] > 0, a = l ? o : s, f = F(t, e, l ? s : o), u = i ? f : F(t, e, a), p = c.createRange(), [d, x] = f, [y, h] = u;
|
|
149
|
+
return A(d) && t !== d ? x < 1 ? p.setStartBefore(d) : p.setStartAfter(d) : p.setStart(d, x),
|
|
150
|
+
A(y) && t !== y ? h < 1 ? p.setEndBefore(y) : p.setEndAfter(y) : p.setEnd(y, h),
|
|
151
|
+
p;
|
|
152
|
+
}, H = (t, e, n, r, o) => {
|
|
153
|
+
const s = N(t);
|
|
154
|
+
if (o || L(s, t)) {
|
|
155
|
+
const o = C(t, e, n, r), c = r[0] - r[1] > 0;
|
|
148
156
|
s.removeAllRanges(), s.addRange(o), c && (s.collapseToEnd(), s.extend(o.startContainer, o.startOffset));
|
|
149
157
|
}
|
|
150
|
-
}, F = (
|
|
158
|
+
}, F = (t, e, [n, r]) => e(({t: e, o, i: s, l: c}) => {
|
|
151
159
|
let i, l = 0;
|
|
152
|
-
for (;i =
|
|
153
|
-
if (l < n.length) for (let
|
|
160
|
+
for (;i = e(); ) if (4 === i) {
|
|
161
|
+
if (l < n.length) for (let t = n[l++]; t > 0; t--) o();
|
|
154
162
|
} else {
|
|
155
|
-
const
|
|
156
|
-
if (r <=
|
|
157
|
-
r -=
|
|
163
|
+
const t = c();
|
|
164
|
+
if (r <= t) return [ s(), r ];
|
|
165
|
+
r -= t;
|
|
158
166
|
}
|
|
159
|
-
return [
|
|
160
|
-
},
|
|
167
|
+
return [ t, 0 ];
|
|
168
|
+
}, t), U = (e, n, r, o) => {
|
|
161
169
|
let s = !0;
|
|
162
|
-
if (
|
|
170
|
+
if (e === r && !r.hasChildNodes()) return [ [], 0 ];
|
|
163
171
|
if (A(r) && r.hasChildNodes()) {
|
|
164
|
-
const
|
|
165
|
-
r = r.childNodes[
|
|
172
|
+
const e = t(o, r.childNodes.length - 1);
|
|
173
|
+
r = r.childNodes[e], s = e === o, o = 0;
|
|
166
174
|
}
|
|
167
|
-
return n(({t
|
|
175
|
+
return n(({t, u: c, p: i, h: l, i: a, l: f, k: u}) => {
|
|
168
176
|
c(r), 4 !== u() && i();
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
for (;u() && a() !==
|
|
172
|
-
let
|
|
173
|
-
for (;l(), u(); )
|
|
174
|
-
|
|
177
|
+
const p = n(() => {
|
|
178
|
+
const t = [];
|
|
179
|
+
for (;u() && a() !== e; ) {
|
|
180
|
+
let e = 0;
|
|
181
|
+
for (;l(), u(); ) e++;
|
|
182
|
+
t.unshift(e), i();
|
|
175
183
|
}
|
|
176
|
-
return
|
|
184
|
+
return t;
|
|
177
185
|
});
|
|
178
|
-
let
|
|
179
|
-
for (;
|
|
180
|
-
const
|
|
181
|
-
if (0 ===
|
|
186
|
+
let d = 0;
|
|
187
|
+
for (;t(); ) {
|
|
188
|
+
const t = I(r, a());
|
|
189
|
+
if (0 === t || 16 & t) {
|
|
182
190
|
if (s) break;
|
|
183
|
-
} else if (4 &
|
|
184
|
-
|
|
191
|
+
} else if (4 & t) break;
|
|
192
|
+
d += f();
|
|
185
193
|
}
|
|
186
|
-
return [
|
|
187
|
-
},
|
|
188
|
-
}, V = (
|
|
189
|
-
const c = U(
|
|
190
|
-
return [ c, r === s && n === o ? c : U(
|
|
191
|
-
}, W = (
|
|
194
|
+
return [ p, d + o ];
|
|
195
|
+
}, e);
|
|
196
|
+
}, V = (t, e, {startOffset: n, startContainer: r, endOffset: o, endContainer: s}) => {
|
|
197
|
+
const c = U(t, e, r, n);
|
|
198
|
+
return [ c, r === s && n === o ? c : U(t, e, s, o) ];
|
|
199
|
+
}, W = (t, e, n) => t.split("\n").map(t => ({
|
|
192
200
|
...n,
|
|
193
201
|
children: [ {
|
|
194
|
-
...
|
|
195
|
-
text:
|
|
202
|
+
...e,
|
|
203
|
+
text: t
|
|
196
204
|
} ]
|
|
197
|
-
})), q = "delete", z = "insert_text", G = "insert_node", J = (
|
|
198
|
-
const o = n(
|
|
199
|
-
return o.length === n(
|
|
200
|
-
}, j = (
|
|
201
|
-
if (
|
|
202
|
-
const n =
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
o ? s && ((
|
|
206
|
-
let r =
|
|
205
|
+
})), q = "delete", z = "insert_text", G = "insert_node", J = (t, e) => {
|
|
206
|
+
const o = n(t);
|
|
207
|
+
return o.length === n(e).length && o.every(n => n in e && ("text" === n || r(t[n], e[n])));
|
|
208
|
+
}, j = (t, e) => {
|
|
209
|
+
if (e.length) {
|
|
210
|
+
const n = t.length;
|
|
211
|
+
if (t.push(...e), n) {
|
|
212
|
+
const e = t[n - 1], r = t[n], o = l(e), s = l(r);
|
|
213
|
+
o ? s && ((t, e = 0, n = t.length - 1) => {
|
|
214
|
+
let r = e + 1;
|
|
207
215
|
for (;r <= n; ) {
|
|
208
|
-
const
|
|
209
|
-
|
|
216
|
+
const e = t[r - 1], o = t[r];
|
|
217
|
+
t[r - 1] = X(e, o), t.splice(r, 1), n--;
|
|
210
218
|
}
|
|
211
|
-
})(
|
|
212
|
-
let r =
|
|
219
|
+
})(t, n - 1, n) : o || s || ((t, e = 0, n = t.length - 1) => {
|
|
220
|
+
let r = e + 1;
|
|
213
221
|
for (;r <= n; ) {
|
|
214
|
-
const
|
|
215
|
-
i(
|
|
216
|
-
...
|
|
217
|
-
text:
|
|
218
|
-
},
|
|
222
|
+
const e = t[r - 1], o = t[r];
|
|
223
|
+
i(e) && i(o) && J(e, o) ? (t[r - 1] = {
|
|
224
|
+
...e,
|
|
225
|
+
text: e.text + o.text
|
|
226
|
+
}, t.splice(r, 1), n--) : r++;
|
|
219
227
|
}
|
|
220
|
-
for (r =
|
|
221
|
-
const
|
|
222
|
-
i(
|
|
228
|
+
for (r = e; r <= n; ) {
|
|
229
|
+
const e = t[r];
|
|
230
|
+
i(e) && !e.text && t.length > 1 ? (t.splice(r, 1), n--) : r++;
|
|
223
231
|
}
|
|
224
|
-
})(
|
|
232
|
+
})(t, n - 1, n);
|
|
225
233
|
}
|
|
226
234
|
}
|
|
227
|
-
|
|
235
|
+
t.length || t.push({
|
|
228
236
|
text: ""
|
|
229
237
|
});
|
|
230
|
-
}, X = (...
|
|
231
|
-
...
|
|
232
|
-
children:
|
|
233
|
-
}), Y = (
|
|
234
|
-
if (r <
|
|
235
|
-
const o =
|
|
236
|
-
return ((
|
|
237
|
-
const o =
|
|
238
|
-
return o.splice(
|
|
239
|
-
...
|
|
238
|
+
}, X = (...t) => ({
|
|
239
|
+
...t[0],
|
|
240
|
+
children: t.reduce((t, e) => (j(t, e.children), t), [])
|
|
241
|
+
}), Y = (t, e, n, r = 0) => {
|
|
242
|
+
if (r < e.length) {
|
|
243
|
+
const o = e[r];
|
|
244
|
+
return ((t, e, n, r) => {
|
|
245
|
+
const o = t.children.slice();
|
|
246
|
+
return o.splice(e, n - e + 1, ...r), {
|
|
247
|
+
...t,
|
|
240
248
|
children: o
|
|
241
249
|
};
|
|
242
|
-
})(
|
|
250
|
+
})(t, o, o, [ Y(t.children[o], e, n, r + 1) ]);
|
|
243
251
|
}
|
|
244
252
|
return n;
|
|
245
|
-
}, Z = (
|
|
246
|
-
const [o, s] =
|
|
253
|
+
}, Z = (t, e, n, r) => {
|
|
254
|
+
const [o, s] = h(t, e), c = e < n ? h(t, n)[1] : s, i = a(t.children);
|
|
247
255
|
a(r) ? i || (r = X(...r).children) : i && (r = [ {
|
|
248
256
|
children: r
|
|
249
257
|
} ]);
|
|
250
258
|
const l = o.children.slice();
|
|
251
259
|
return j(l, r), j(l, c.children), {
|
|
252
|
-
...
|
|
260
|
+
...t,
|
|
253
261
|
children: l
|
|
254
262
|
};
|
|
255
|
-
}, K = (
|
|
256
|
-
switch (
|
|
263
|
+
}, K = (t, e) => e >= 0 && e <= p(t), Q = (t, e) => e.reduce((t, e) => $(t, e), t), $ = (t, e) => {
|
|
264
|
+
switch (e.type) {
|
|
257
265
|
case q:
|
|
258
266
|
{
|
|
259
|
-
const [n, r] =
|
|
260
|
-
if (
|
|
267
|
+
const [n, r] = e.range;
|
|
268
|
+
if (t >= n) return r >= t ? n : t + n - r;
|
|
261
269
|
break;
|
|
262
270
|
}
|
|
263
271
|
|
|
264
272
|
case z:
|
|
265
273
|
{
|
|
266
|
-
const {at: n, text: r} =
|
|
267
|
-
if (
|
|
274
|
+
const {at: n, text: r} = e;
|
|
275
|
+
if (t >= n) return t + r.length;
|
|
268
276
|
break;
|
|
269
277
|
}
|
|
270
278
|
|
|
271
279
|
case G:
|
|
272
280
|
{
|
|
273
|
-
const {at: n, fragment: r} =
|
|
274
|
-
if (
|
|
281
|
+
const {at: n, fragment: r} = e;
|
|
282
|
+
if (t >= n) return t + p({
|
|
275
283
|
children: r
|
|
276
284
|
});
|
|
277
285
|
break;
|
|
278
286
|
}
|
|
279
287
|
}
|
|
280
|
-
return
|
|
281
|
-
},
|
|
282
|
-
const n =
|
|
288
|
+
return t;
|
|
289
|
+
}, tt = ([t, e], n) => [ $(t, n), $(e, n) ], et = "undefined" != typeof navigator && /Mac|iP(hone|od|ad)/.test(navigator.platform), nt = (t, e) => {
|
|
290
|
+
const n = t.endsWith("+"), r = (n ? t.slice(0, -2) : t).split("+"), o = n ? "+" : r.pop(), s = "Space" === o ? " " : o.toLowerCase();
|
|
283
291
|
let c = !1, i = !1, l = !1, a = !1;
|
|
284
|
-
return r.forEach(
|
|
285
|
-
switch (
|
|
292
|
+
return r.forEach(t => {
|
|
293
|
+
switch (t) {
|
|
286
294
|
case "Ctrl":
|
|
287
295
|
i = !0;
|
|
288
296
|
break;
|
|
@@ -292,7 +300,7 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
292
300
|
break;
|
|
293
301
|
|
|
294
302
|
case "Mod":
|
|
295
|
-
|
|
303
|
+
et ? l = !0 : i = !0;
|
|
296
304
|
break;
|
|
297
305
|
|
|
298
306
|
case "Alt":
|
|
@@ -302,108 +310,108 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
302
310
|
case "Shift":
|
|
303
311
|
c = !0;
|
|
304
312
|
}
|
|
305
|
-
}),
|
|
306
|
-
if (
|
|
313
|
+
}), t => {
|
|
314
|
+
if (t.key.toLowerCase() === s && i === t.ctrlKey && l === t.metaKey && c === t.shiftKey && a === t.altKey) return !1 !== e(t);
|
|
307
315
|
};
|
|
308
316
|
};
|
|
309
317
|
|
|
310
|
-
function
|
|
311
|
-
let
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
const n =
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
+
function rt(t) {
|
|
319
|
+
let e = 0, n = 0, r = !1;
|
|
320
|
+
const o = Date.now, s = [ [ t.doc, t.selection, [] ] ], c = () => s[e], i = () => e > 0, l = () => e < s.length - 1, a = () => {
|
|
321
|
+
if (i()) {
|
|
322
|
+
const n = c()[1];
|
|
323
|
+
e--;
|
|
324
|
+
const o = t.doc;
|
|
325
|
+
r = !0, t.exec(w, c()[0].children), r = !1, o !== t.doc && (t.selection = n);
|
|
318
326
|
}
|
|
319
|
-
},
|
|
320
|
-
if (
|
|
321
|
-
|
|
322
|
-
const [n,
|
|
323
|
-
|
|
327
|
+
}, f = () => {
|
|
328
|
+
if (l()) {
|
|
329
|
+
e++;
|
|
330
|
+
const [n, o, s] = c(), i = t.doc;
|
|
331
|
+
r = !0, t.exec(w, n.children), r = !1, i !== t.doc && (t.selection = [ Q(o[0], s), Q(o[1], s) ]);
|
|
324
332
|
}
|
|
325
333
|
};
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
if (
|
|
332
|
-
const
|
|
333
|
-
if (0 ===
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
334
|
+
t.hook("apply", (c, i) => {
|
|
335
|
+
if (r) return;
|
|
336
|
+
const l = t.doc, a = t.selection;
|
|
337
|
+
i(c);
|
|
338
|
+
const f = t.doc;
|
|
339
|
+
if (l !== f) {
|
|
340
|
+
const t = o();
|
|
341
|
+
if (0 === e || t - n >= 500) {
|
|
342
|
+
e++;
|
|
343
|
+
const t = [ l, a, [] ];
|
|
344
|
+
e >= s.length ? s.push(t) : s[e] = t;
|
|
337
345
|
}
|
|
338
|
-
n =
|
|
339
|
-
|
|
346
|
+
n = t, s[e][0] = f, s[e][2].push(c), s.length > e + 1 && (s.length = e + 1), e > 500 && (e--,
|
|
347
|
+
s.shift());
|
|
340
348
|
}
|
|
341
|
-
}),
|
|
342
|
-
|
|
343
|
-
undo:
|
|
344
|
-
redo:
|
|
345
|
-
undoable:
|
|
346
|
-
redoable:
|
|
349
|
+
}), t.hook("keyboard", nt("Mod+Z", a)), t.hook("keyboard", nt("Shift+Mod+Z", f)),
|
|
350
|
+
t.set(rt, {
|
|
351
|
+
undo: a,
|
|
352
|
+
redo: f,
|
|
353
|
+
undoable: i,
|
|
354
|
+
redoable: l
|
|
347
355
|
});
|
|
348
356
|
}
|
|
349
357
|
|
|
350
|
-
var
|
|
351
|
-
throw Error(
|
|
352
|
-
},
|
|
353
|
-
let
|
|
354
|
-
const
|
|
355
|
-
if (!n) return
|
|
358
|
+
var ot = [], st = () => {}, ct = t => {
|
|
359
|
+
throw Error(t);
|
|
360
|
+
}, it = ({doc: t, readonly: e = !1, schema: n, isBlock: r = B, onWarn: a = console.warn, onError: f = ct}) => {
|
|
361
|
+
let u = [ 0, 0 ];
|
|
362
|
+
const p = t => {
|
|
363
|
+
if (!n) return a("An unsafe operation was detected. We recommend using schema option."),
|
|
356
364
|
!0;
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
359
|
-
if (!
|
|
360
|
-
|
|
365
|
+
const e = n["~standard"].validate(t);
|
|
366
|
+
if (e instanceof Promise) f("async validate is not supported"); else {
|
|
367
|
+
if (!e.issues) return !0;
|
|
368
|
+
a(e.issues.map(t => t.message).join("\n"));
|
|
361
369
|
}
|
|
362
370
|
return !1;
|
|
363
371
|
};
|
|
364
|
-
n && !
|
|
365
|
-
const y = new Map,
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}),
|
|
371
|
-
}),
|
|
372
|
-
|
|
372
|
+
n && !p(t) && f("Invalid document");
|
|
373
|
+
const y = new Map, h = new WeakMap, g = t => y.get(t) || ot, _ = new Map, b = new Set, M = t => {
|
|
374
|
+
const e = _.get(t);
|
|
375
|
+
e && (b.size || c(() => {
|
|
376
|
+
b.forEach(t => {
|
|
377
|
+
t();
|
|
378
|
+
}), b.clear();
|
|
379
|
+
}), e.forEach(t => {
|
|
380
|
+
b.add(t);
|
|
373
381
|
}));
|
|
374
|
-
},
|
|
375
|
-
if (!
|
|
376
|
-
return
|
|
377
|
-
},
|
|
378
|
-
const n =
|
|
379
|
-
let
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
} else if (
|
|
385
|
-
|
|
382
|
+
}, S = t => {
|
|
383
|
+
if (!e) if (Array.isArray(t)) for (const e of t) w(e); else w(t);
|
|
384
|
+
return D;
|
|
385
|
+
}, w = e => {
|
|
386
|
+
const n = t, r = g("apply"), o = r.length;
|
|
387
|
+
let s = 0;
|
|
388
|
+
const c = () => {
|
|
389
|
+
if (s < o) {
|
|
390
|
+
const t = s;
|
|
391
|
+
r[s](e, f), t === s && f();
|
|
392
|
+
} else if (s === o) {
|
|
393
|
+
s++;
|
|
386
394
|
try {
|
|
387
|
-
const [n, r] = ((
|
|
395
|
+
const [n, r] = ((t, e, n) => {
|
|
388
396
|
switch (n.type) {
|
|
389
397
|
case q:
|
|
390
398
|
{
|
|
391
399
|
const [r, o] = n.range;
|
|
392
|
-
K(
|
|
400
|
+
K(t, r) && K(t, o) && r < o && (t = Z(t, r, o, []), e = tt(e, n));
|
|
393
401
|
break;
|
|
394
402
|
}
|
|
395
403
|
|
|
396
404
|
case z:
|
|
397
405
|
{
|
|
398
406
|
const {at: r, text: o} = n;
|
|
399
|
-
if (K(
|
|
400
|
-
const [s, c] = x(
|
|
407
|
+
if (K(t, r) && o) {
|
|
408
|
+
const [s, c] = x(t, r), l = d(s, c, !0);
|
|
401
409
|
let a;
|
|
402
410
|
if (l) {
|
|
403
|
-
const
|
|
404
|
-
i(
|
|
411
|
+
const t = l[0];
|
|
412
|
+
i(t) && (a = t);
|
|
405
413
|
}
|
|
406
|
-
|
|
414
|
+
t = Z(t, r, r, W(o, a, s)), e = tt(e, n);
|
|
407
415
|
}
|
|
408
416
|
break;
|
|
409
417
|
}
|
|
@@ -411,152 +419,152 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
411
419
|
case G:
|
|
412
420
|
{
|
|
413
421
|
const {at: r, fragment: o} = n;
|
|
414
|
-
K(
|
|
422
|
+
K(t, r) && o.length && (t = Z(t, r, r, o), e = tt(e, n));
|
|
415
423
|
break;
|
|
416
424
|
}
|
|
417
425
|
|
|
418
426
|
case "format":
|
|
419
427
|
{
|
|
420
|
-
const {range: [
|
|
421
|
-
if (K(
|
|
422
|
-
const [{children: n}, , r] = x(
|
|
428
|
+
const {range: [e, r], key: o, value: s} = n;
|
|
429
|
+
if (K(t, e) && K(t, r) && e <= r) if (e === r) {
|
|
430
|
+
const [{children: n}, , r] = x(t, e);
|
|
423
431
|
if (1 === n.length) {
|
|
424
|
-
const
|
|
425
|
-
i(
|
|
426
|
-
...
|
|
432
|
+
const e = n[0];
|
|
433
|
+
i(e) && !e.text && (t = Y(t, [ ...r, 0 ], {
|
|
434
|
+
...e,
|
|
427
435
|
[o]: s
|
|
428
436
|
}));
|
|
429
437
|
}
|
|
430
438
|
} else {
|
|
431
|
-
const n =
|
|
432
|
-
...
|
|
433
|
-
children:
|
|
434
|
-
} : i(
|
|
435
|
-
...
|
|
439
|
+
const n = t => l(t) ? {
|
|
440
|
+
...t,
|
|
441
|
+
children: t.children.map(n)
|
|
442
|
+
} : i(t) ? {
|
|
443
|
+
...t,
|
|
436
444
|
[o]: s
|
|
437
|
-
} :
|
|
438
|
-
|
|
445
|
+
} : t;
|
|
446
|
+
t = Z(t, e, r, v(t, e, r).map(n));
|
|
439
447
|
}
|
|
440
448
|
break;
|
|
441
449
|
}
|
|
442
450
|
|
|
443
451
|
case "patch_node":
|
|
444
452
|
{
|
|
445
|
-
const {path:
|
|
446
|
-
for (let n = 0; n <
|
|
447
|
-
return
|
|
448
|
-
})(
|
|
449
|
-
s && (
|
|
453
|
+
const {path: e, key: r, value: o} = n, s = ((t, e) => {
|
|
454
|
+
for (let n = 0; n < e.length; n++) t = t.children[e[n]];
|
|
455
|
+
return t;
|
|
456
|
+
})(t, e);
|
|
457
|
+
s && (t = Y(t, e, {
|
|
450
458
|
...s,
|
|
451
459
|
[r]: o
|
|
452
460
|
}));
|
|
453
461
|
break;
|
|
454
462
|
}
|
|
455
463
|
}
|
|
456
|
-
return [
|
|
457
|
-
})(
|
|
458
|
-
(({type:
|
|
464
|
+
return [ t, e ];
|
|
465
|
+
})(t, u, e);
|
|
466
|
+
(({type: t}) => t !== z && t !== q)(e) && !p(n) || (t = n, O(r));
|
|
459
467
|
} catch (n) {
|
|
460
|
-
|
|
468
|
+
a("rollback operation: " + n);
|
|
461
469
|
}
|
|
462
470
|
}
|
|
463
|
-
},
|
|
464
|
-
|
|
471
|
+
}, f = t => {
|
|
472
|
+
t && (e = t), s++, c();
|
|
465
473
|
};
|
|
466
|
-
|
|
467
|
-
},
|
|
468
|
-
!((
|
|
469
|
-
|
|
470
|
-
},
|
|
474
|
+
c(), n !== t && M("change");
|
|
475
|
+
}, O = e => {
|
|
476
|
+
!((t, [e, n]) => K(t, e) && K(t, n))(t, e) || u[0] === e[0] && u[1] === e[1] || (u = e,
|
|
477
|
+
M("selectionchange"));
|
|
478
|
+
}, D = {
|
|
471
479
|
get doc() {
|
|
472
|
-
return
|
|
480
|
+
return t;
|
|
473
481
|
},
|
|
474
482
|
get selection() {
|
|
475
|
-
return
|
|
483
|
+
return u;
|
|
476
484
|
},
|
|
477
|
-
set selection(
|
|
478
|
-
|
|
485
|
+
set selection(t) {
|
|
486
|
+
O(t);
|
|
479
487
|
},
|
|
480
488
|
get readonly() {
|
|
481
|
-
return
|
|
489
|
+
return e;
|
|
482
490
|
},
|
|
483
|
-
set readonly(
|
|
484
|
-
|
|
491
|
+
set readonly(t) {
|
|
492
|
+
e = t, M("readonly");
|
|
485
493
|
},
|
|
486
|
-
apply:
|
|
487
|
-
on: (
|
|
488
|
-
let n =
|
|
489
|
-
return n ||
|
|
490
|
-
n.delete(
|
|
494
|
+
apply: S,
|
|
495
|
+
on: (t, e) => {
|
|
496
|
+
let n = _.get(t);
|
|
497
|
+
return n || _.set(t, n = new Set), n.add(e), () => {
|
|
498
|
+
n.delete(e);
|
|
491
499
|
};
|
|
492
500
|
},
|
|
493
|
-
hook: (
|
|
494
|
-
let n = y.get(
|
|
495
|
-
return n || y.set(
|
|
496
|
-
const
|
|
497
|
-
-1 !==
|
|
501
|
+
hook: (t, e) => {
|
|
502
|
+
let n = y.get(t);
|
|
503
|
+
return n || y.set(t, n = []), n.push(e), () => {
|
|
504
|
+
const t = n.indexOf(e);
|
|
505
|
+
-1 !== t && n.splice(t, 1);
|
|
498
506
|
};
|
|
499
507
|
},
|
|
500
|
-
exec: (
|
|
501
|
-
const n =
|
|
502
|
-
return void 0 === n ?
|
|
508
|
+
exec: (t, ...e) => {
|
|
509
|
+
const n = t(D, ...e);
|
|
510
|
+
return void 0 === n ? D : n;
|
|
503
511
|
},
|
|
504
|
-
get:
|
|
505
|
-
set: (
|
|
512
|
+
get: t => (h.has(t) || f("No value found for key"), h.get(t)),
|
|
513
|
+
set: (t, e) => (h.set(t, e), D),
|
|
506
514
|
input: n => {
|
|
507
|
-
if (!window.InputEvent || !s(InputEvent.prototype.getTargetRanges)) return
|
|
508
|
-
|
|
509
|
-
const {contentEditable:
|
|
515
|
+
if (!window.InputEvent || !s(InputEvent.prototype.getTargetRanges)) return a("beforeinput event is not supported."),
|
|
516
|
+
st;
|
|
517
|
+
const {contentEditable: c, role: i, ariaMultiLine: l, ariaReadOnly: f} = n, p = n.style.whiteSpace;
|
|
510
518
|
n.role = "textbox", n.style.whiteSpace = "pre-wrap", n.ariaMultiLine = "true";
|
|
511
|
-
let
|
|
512
|
-
const
|
|
519
|
+
let d = !1, x = null, y = !1, h = !1, _ = !1, b = u, v = null;
|
|
520
|
+
const M = P(n), w = ((t, e) => {
|
|
513
521
|
let n = null, r = null, o = null;
|
|
514
522
|
const s = () => {
|
|
515
523
|
if (null != o) return o;
|
|
516
|
-
if (r) if ((
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
524
|
+
if (r) if ((t => 3 === t.nodeType)(r)) {
|
|
525
|
+
const t = r.data;
|
|
526
|
+
if (t) return o = "\n" === t ? i() ? 3 : 5 : 1;
|
|
519
527
|
} else if (A(r)) {
|
|
520
528
|
if ("false" === r.contentEditable) return o = 2;
|
|
521
529
|
{
|
|
522
|
-
const
|
|
523
|
-
if (null !=
|
|
524
|
-
if (
|
|
530
|
+
const t = R.get(r.tagName);
|
|
531
|
+
if (null != t) return o = 1 === t ? i() ? 3 : 5 : 3 === t ? 2 : 6;
|
|
532
|
+
if (e(r)) return o = 4;
|
|
525
533
|
}
|
|
526
|
-
} else if (!(
|
|
534
|
+
} else if (!(t => 11 === t.nodeType)(r)) return o = 6;
|
|
527
535
|
return o = 0;
|
|
528
536
|
}, c = () => {
|
|
529
|
-
const
|
|
530
|
-
if (o = null, 2 ===
|
|
531
|
-
const
|
|
532
|
-
if (r = n.nextSibling(), !r) for (;(r = n.nextNode()) &&
|
|
537
|
+
const t = s();
|
|
538
|
+
if (o = null, 2 === t || 6 === t) {
|
|
539
|
+
const t = r;
|
|
540
|
+
if (r = n.nextSibling(), !r) for (;(r = n.nextNode()) && t.contains(r); ) ;
|
|
533
541
|
return r;
|
|
534
542
|
}
|
|
535
543
|
return r = n.nextNode();
|
|
536
544
|
}, i = () => {
|
|
537
|
-
const
|
|
545
|
+
const t = r.parentNode;
|
|
538
546
|
return a(() => {
|
|
539
547
|
for (o = 0; c(); ) {
|
|
540
548
|
if (s()) return !0;
|
|
541
|
-
if (!
|
|
549
|
+
if (!t.contains(r)) break;
|
|
542
550
|
}
|
|
543
551
|
return !1;
|
|
544
552
|
});
|
|
545
553
|
}, l = {
|
|
546
554
|
t: () => {
|
|
547
555
|
for (;c(); ) {
|
|
548
|
-
const
|
|
549
|
-
if (
|
|
556
|
+
const t = s();
|
|
557
|
+
if (t && 6 !== t) return t;
|
|
550
558
|
}
|
|
551
559
|
},
|
|
552
560
|
k: s,
|
|
553
561
|
i: () => r,
|
|
554
562
|
l: () => {
|
|
555
|
-
const
|
|
556
|
-
return 1 ===
|
|
563
|
+
const t = s();
|
|
564
|
+
return 1 === t ? r.data.length : 2 === t ? 1 : 0;
|
|
557
565
|
},
|
|
558
|
-
u:
|
|
559
|
-
o = null, n.currentNode = r =
|
|
566
|
+
u: t => {
|
|
567
|
+
o = null, n.currentNode = r = t;
|
|
560
568
|
},
|
|
561
569
|
h: () => {
|
|
562
570
|
for (;(o = null) || (r = n.previousSibling()); ) if (4 === s()) return;
|
|
@@ -567,67 +575,67 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
567
575
|
p: () => {
|
|
568
576
|
for (;(o = null) || (r = n.parentNode()); ) if (4 === s()) return;
|
|
569
577
|
}
|
|
570
|
-
}, a = (
|
|
578
|
+
}, a = (e, s) => {
|
|
571
579
|
const c = n, i = r, a = o;
|
|
572
580
|
try {
|
|
573
|
-
return n || (n =
|
|
581
|
+
return n || (n = t.createTreeWalker(r = s, 5)), e(l);
|
|
574
582
|
} finally {
|
|
575
583
|
n = c, r = i, o = a, n && i && (n.currentNode = i);
|
|
576
584
|
}
|
|
577
585
|
};
|
|
578
586
|
return a;
|
|
579
|
-
})(
|
|
580
|
-
n.contentEditable =
|
|
587
|
+
})(M, r), B = () => {
|
|
588
|
+
n.contentEditable = e ? "false" : "true", n.ariaReadOnly = e ? "true" : null;
|
|
581
589
|
};
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
|
|
590
|
+
B();
|
|
591
|
+
const C = () => {
|
|
592
|
+
h || n.focus({
|
|
585
593
|
preventScroll: !0
|
|
586
594
|
});
|
|
595
|
+
}, F = () => {
|
|
596
|
+
v = null, u[0] === b[0] && u[1] === b[1] || (H(n, w, t, u), b = u);
|
|
587
597
|
}, W = () => {
|
|
588
|
-
|
|
589
|
-
}, q = () => {
|
|
590
|
-
|
|
591
|
-
}, z =
|
|
592
|
-
|
|
593
|
-
}), G =
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
for (const t of b("paste")) {
|
|
597
|
-
const n = t(e);
|
|
598
|
+
null != v && clearTimeout(v);
|
|
599
|
+
}, q = D.on("change", () => {
|
|
600
|
+
h || requestAnimationFrame(C);
|
|
601
|
+
}), z = D.on("selectionchange", () => {
|
|
602
|
+
u[0] === b[0] && u[1] === b[1] || (W(), v = setTimeout(F, 50));
|
|
603
|
+
}), G = D.on("readonly", B), J = t => {
|
|
604
|
+
for (const e of g("paste")) {
|
|
605
|
+
const n = e(t);
|
|
598
606
|
if (n) return n;
|
|
599
607
|
}
|
|
600
|
-
|
|
601
|
-
},
|
|
608
|
+
a("failed to serialize pasted data");
|
|
609
|
+
}, j = ((t, e) => {
|
|
602
610
|
let n = !1, r = [];
|
|
603
|
-
const o =
|
|
604
|
-
n && r.push(...
|
|
605
|
-
}, s = new MutationObserver(
|
|
606
|
-
o(
|
|
611
|
+
const o = t => {
|
|
612
|
+
n && r.push(...t);
|
|
613
|
+
}, s = new MutationObserver(t => {
|
|
614
|
+
o(t), n || e();
|
|
607
615
|
}), c = () => {
|
|
608
616
|
o(s.takeRecords());
|
|
609
617
|
}, i = () => {
|
|
610
618
|
c();
|
|
611
|
-
const
|
|
612
|
-
return r = [],
|
|
619
|
+
const t = r;
|
|
620
|
+
return r = [], t;
|
|
613
621
|
};
|
|
614
|
-
return s.observe(
|
|
622
|
+
return s.observe(t, {
|
|
615
623
|
characterData: !0,
|
|
616
624
|
characterDataOldValue: !0,
|
|
617
625
|
childList: !0,
|
|
618
626
|
subtree: !0
|
|
619
627
|
}), {
|
|
620
|
-
m:
|
|
621
|
-
let
|
|
622
|
-
for (;
|
|
623
|
-
const {target:
|
|
624
|
-
for (let
|
|
625
|
-
for (let
|
|
626
|
-
} else
|
|
628
|
+
m: t => {
|
|
629
|
+
let e;
|
|
630
|
+
for (;e = t.pop(); ) if ("childList" === e.type) {
|
|
631
|
+
const {target: t, removedNodes: n, addedNodes: r, nextSibling: o} = e;
|
|
632
|
+
for (let e = n.length - 1; e >= 0; e--) t.insertBefore(n[e], o);
|
|
633
|
+
for (let e = r.length - 1; e >= 0; e--) t.removeChild(r[e]);
|
|
634
|
+
} else e.target.data = e.oldValue;
|
|
627
635
|
i();
|
|
628
636
|
},
|
|
629
|
-
_:
|
|
630
|
-
!n &&
|
|
637
|
+
_: t => {
|
|
638
|
+
!n && t && c(), n = t;
|
|
631
639
|
},
|
|
632
640
|
v: i,
|
|
633
641
|
T: () => {
|
|
@@ -635,38 +643,38 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
635
643
|
}
|
|
636
644
|
};
|
|
637
645
|
})(n, () => {
|
|
638
|
-
|
|
639
|
-
}),
|
|
640
|
-
|
|
641
|
-
const n = N(
|
|
646
|
+
W(), H(n, w, t, u);
|
|
647
|
+
}), X = () => {
|
|
648
|
+
O(b = m(t, ((t, e) => {
|
|
649
|
+
const n = N(t), r = L(n, t);
|
|
642
650
|
if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
|
|
643
|
-
const o = V(
|
|
651
|
+
const o = V(t, e, r), s = I(n.anchorNode, n.focusNode);
|
|
644
652
|
return (0 === s ? n.anchorOffset > n.focusOffset : 2 & s) ? [ o[1], o[0] ] : o;
|
|
645
653
|
})(n, w)));
|
|
646
|
-
},
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
},
|
|
651
|
-
if (!
|
|
652
|
-
},
|
|
653
|
-
|
|
654
|
-
},
|
|
655
|
-
|
|
656
|
-
const r =
|
|
654
|
+
}, Y = () => {
|
|
655
|
+
const e = j.v();
|
|
656
|
+
j._(!1), e.length && (j.m(e), M.removeEventListener("selectionchange", ot), H(n, w, t, u, !0),
|
|
657
|
+
M.addEventListener("selectionchange", ot)), x && (O(x[1]), S(x[0]), x = null), y = !1;
|
|
658
|
+
}, Z = t => {
|
|
659
|
+
if (!y) for (const e of g("keyboard")) if (e(t)) return t.preventDefault(), void j._(!1);
|
|
660
|
+
}, K = () => {
|
|
661
|
+
y || Y();
|
|
662
|
+
}, $ = e => {
|
|
663
|
+
e.preventDefault();
|
|
664
|
+
const r = e.inputType;
|
|
657
665
|
if (r.startsWith("format")) return;
|
|
658
666
|
if ("historyUndo" === r || "historyRedo" === r) return;
|
|
659
|
-
|
|
660
|
-
const o =
|
|
667
|
+
y ? j._(!0) : X();
|
|
668
|
+
const o = e.getTargetRanges()[0];
|
|
661
669
|
if (o) {
|
|
662
|
-
let s = "insertParagraph" === r || "insertLineBreak" === r ? "\n" :
|
|
670
|
+
let s = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : e.data;
|
|
663
671
|
if (null == s) {
|
|
664
|
-
const
|
|
665
|
-
|
|
672
|
+
const t = e.dataTransfer;
|
|
673
|
+
t && (s = t.getData("text/plain"));
|
|
666
674
|
}
|
|
667
|
-
x || (x = [ [],
|
|
668
|
-
const c = x[0], i = m(
|
|
669
|
-
|
|
675
|
+
x || (x = [ [], u ]);
|
|
676
|
+
const c = x[0], i = m(t, V(n, w, o));
|
|
677
|
+
E(i) || c.push({
|
|
670
678
|
type: "delete",
|
|
671
679
|
range: i
|
|
672
680
|
}), s && c.push({
|
|
@@ -675,66 +683,66 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
675
683
|
text: s
|
|
676
684
|
});
|
|
677
685
|
}
|
|
678
|
-
|
|
679
|
-
},
|
|
680
|
-
|
|
681
|
-
},
|
|
682
|
-
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
},
|
|
686
|
-
|
|
687
|
-
},
|
|
688
|
-
|
|
689
|
-
},
|
|
690
|
-
if (
|
|
691
|
-
},
|
|
692
|
-
|
|
693
|
-
},
|
|
694
|
-
|
|
686
|
+
y || Y();
|
|
687
|
+
}, tt = () => {
|
|
688
|
+
y || X(), y = !0;
|
|
689
|
+
}, et = () => {
|
|
690
|
+
Y();
|
|
691
|
+
}, nt = () => {
|
|
692
|
+
h = !0, X();
|
|
693
|
+
}, rt = () => {
|
|
694
|
+
h = !1;
|
|
695
|
+
}, ot = () => {
|
|
696
|
+
h && !_ && X();
|
|
697
|
+
}, ct = t => {
|
|
698
|
+
if (X(), !E(u)) for (const e of g("copy")) e(t);
|
|
699
|
+
}, it = t => {
|
|
700
|
+
t.preventDefault(), ct(t.clipboardData);
|
|
701
|
+
}, lt = t => {
|
|
702
|
+
t.preventDefault(), e || (ct(t.clipboardData), S({
|
|
695
703
|
type: "delete",
|
|
696
|
-
range:
|
|
704
|
+
range: T(u)
|
|
697
705
|
}));
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
const
|
|
701
|
-
if (
|
|
702
|
-
const
|
|
706
|
+
}, at = t => {
|
|
707
|
+
t.preventDefault();
|
|
708
|
+
const e = J(t.clipboardData);
|
|
709
|
+
if (e) {
|
|
710
|
+
const t = T(u), n = t[0], r = [ {
|
|
703
711
|
type: "delete",
|
|
704
|
-
range:
|
|
712
|
+
range: t
|
|
705
713
|
} ];
|
|
706
|
-
r.push(o(
|
|
714
|
+
r.push(o(e) ? {
|
|
707
715
|
type: "insert_text",
|
|
708
716
|
at: n,
|
|
709
|
-
text:
|
|
717
|
+
text: e
|
|
710
718
|
} : {
|
|
711
719
|
type: "insert_node",
|
|
712
720
|
at: n,
|
|
713
|
-
fragment:
|
|
714
|
-
}),
|
|
721
|
+
fragment: e
|
|
722
|
+
}), S(r);
|
|
715
723
|
}
|
|
716
|
-
},
|
|
717
|
-
|
|
718
|
-
const r =
|
|
719
|
-
const o = P(
|
|
724
|
+
}, ft = e => {
|
|
725
|
+
e.preventDefault();
|
|
726
|
+
const r = e.dataTransfer, s = ((t, e, {clientX: n, clientY: r}) => {
|
|
727
|
+
const o = P(t);
|
|
720
728
|
if (o.caretPositionFromPoint) {
|
|
721
729
|
const s = o.caretPositionFromPoint(n, r);
|
|
722
|
-
if (s) return U(
|
|
730
|
+
if (s) return U(t, e, s.offsetNode, s.offset);
|
|
723
731
|
} else if (o.caretRangeFromPoint) {
|
|
724
732
|
const s = o.caretRangeFromPoint(n, r);
|
|
725
|
-
if (s) return U(
|
|
733
|
+
if (s) return U(t, e, s.startContainer, s.startOffset);
|
|
726
734
|
}
|
|
727
|
-
})(n, w,
|
|
735
|
+
})(n, w, e);
|
|
728
736
|
if (r && s) {
|
|
729
|
-
let
|
|
737
|
+
let e;
|
|
730
738
|
const n = [];
|
|
731
|
-
|
|
739
|
+
_ && n.push({
|
|
732
740
|
type: "delete",
|
|
733
|
-
range:
|
|
741
|
+
range: T(u)
|
|
734
742
|
});
|
|
735
|
-
const c =
|
|
743
|
+
const c = J(r);
|
|
736
744
|
if (c) {
|
|
737
|
-
const r =
|
|
745
|
+
const r = k(t, s), i = Q(r, n);
|
|
738
746
|
n.push(o(c) ? {
|
|
739
747
|
type: "insert_text",
|
|
740
748
|
at: i,
|
|
@@ -743,198 +751,198 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
743
751
|
type: "insert_node",
|
|
744
752
|
at: i,
|
|
745
753
|
fragment: c
|
|
746
|
-
}),
|
|
754
|
+
}), e = [ i, Q(r, n) ];
|
|
747
755
|
}
|
|
748
|
-
|
|
756
|
+
S(n), e && O(e);
|
|
749
757
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
758
|
+
_ = !1;
|
|
759
|
+
}, ut = t => {
|
|
760
|
+
_ = !0, ct(t.dataTransfer);
|
|
761
|
+
}, pt = () => {
|
|
762
|
+
_ = !1;
|
|
754
763
|
};
|
|
755
|
-
|
|
756
|
-
n.addEventListener("beforeinput",
|
|
757
|
-
n.addEventListener("compositionend",
|
|
758
|
-
n.addEventListener("copy",
|
|
759
|
-
n.addEventListener("drop",
|
|
760
|
-
const
|
|
761
|
-
return
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
+
M.addEventListener("selectionchange", ot), n.addEventListener("keydown", Z), n.addEventListener("input", K),
|
|
765
|
+
n.addEventListener("beforeinput", $), n.addEventListener("compositionstart", tt),
|
|
766
|
+
n.addEventListener("compositionend", et), n.addEventListener("focus", nt), n.addEventListener("blur", rt),
|
|
767
|
+
n.addEventListener("copy", it), n.addEventListener("cut", lt), n.addEventListener("paste", at),
|
|
768
|
+
n.addEventListener("drop", ft), n.addEventListener("dragstart", ut), n.addEventListener("dragend", pt);
|
|
769
|
+
const dt = [];
|
|
770
|
+
return g("mount").forEach(t => {
|
|
771
|
+
const e = t(n, w);
|
|
772
|
+
e && dt.push(e);
|
|
764
773
|
}), () => {
|
|
765
|
-
|
|
766
|
-
n.ariaReadOnly =
|
|
767
|
-
n.removeEventListener("keydown",
|
|
768
|
-
n.removeEventListener("compositionstart",
|
|
769
|
-
n.removeEventListener("focus",
|
|
770
|
-
n.removeEventListener("cut",
|
|
771
|
-
n.removeEventListener("dragstart",
|
|
772
|
-
|
|
774
|
+
d || (d = !0, q(), z(), G(), n.contentEditable = c, n.role = i, n.ariaMultiLine = l,
|
|
775
|
+
n.ariaReadOnly = f, n.style.whiteSpace = p, j.T(), M.removeEventListener("selectionchange", ot),
|
|
776
|
+
n.removeEventListener("keydown", Z), n.removeEventListener("input", K), n.removeEventListener("beforeinput", $),
|
|
777
|
+
n.removeEventListener("compositionstart", tt), n.removeEventListener("compositionend", et),
|
|
778
|
+
n.removeEventListener("focus", nt), n.removeEventListener("blur", rt), n.removeEventListener("copy", it),
|
|
779
|
+
n.removeEventListener("cut", lt), n.removeEventListener("paste", at), n.removeEventListener("drop", ft),
|
|
780
|
+
n.removeEventListener("dragstart", ut), n.removeEventListener("dragend", pt), dt.forEach(t => {
|
|
781
|
+
t();
|
|
773
782
|
}));
|
|
774
783
|
};
|
|
775
784
|
}
|
|
776
785
|
};
|
|
777
|
-
return
|
|
786
|
+
return D.exec(rt), D;
|
|
778
787
|
};
|
|
779
788
|
|
|
780
|
-
function
|
|
781
|
-
const n =
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
}),
|
|
789
|
+
function lt(t, e) {
|
|
790
|
+
const n = e && e.voidToString;
|
|
791
|
+
t.hook("copy", e => {
|
|
792
|
+
e.setData("text/plain", b(t.doc, ...T(t.selection), n));
|
|
793
|
+
}), t.hook("paste", t => t.getData("text/plain"));
|
|
785
794
|
}
|
|
786
795
|
|
|
787
|
-
var
|
|
796
|
+
var at = "application/x-editate-editor";
|
|
788
797
|
|
|
789
|
-
function
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}),
|
|
793
|
-
if ("insert_text" ===
|
|
794
|
-
...
|
|
795
|
-
text:
|
|
796
|
-
}; else if ("insert_node" ===
|
|
797
|
-
const
|
|
798
|
-
|
|
799
|
-
...
|
|
800
|
-
fragment: a(
|
|
798
|
+
function ft(t) {
|
|
799
|
+
t.hook("mount", t => {
|
|
800
|
+
t.ariaMultiLine = null;
|
|
801
|
+
}), t.hook("apply", (t, e) => {
|
|
802
|
+
if ("insert_text" === t.type) t = {
|
|
803
|
+
...t,
|
|
804
|
+
text: t.text.replaceAll("\n", "")
|
|
805
|
+
}; else if ("insert_node" === t.type) {
|
|
806
|
+
const e = t.fragment;
|
|
807
|
+
t = {
|
|
808
|
+
...t,
|
|
809
|
+
fragment: a(e) ? [ X(...e) ] : e
|
|
801
810
|
};
|
|
802
811
|
}
|
|
803
|
-
t
|
|
812
|
+
e(t);
|
|
804
813
|
});
|
|
805
814
|
}
|
|
806
815
|
|
|
807
|
-
exports.Delete = function(
|
|
808
|
-
|
|
816
|
+
exports.Delete = function(t, e = T(t.selection)) {
|
|
817
|
+
t.apply({
|
|
809
818
|
type: "delete",
|
|
810
|
-
range:
|
|
819
|
+
range: e
|
|
811
820
|
});
|
|
812
|
-
}, exports.Format = function(
|
|
813
|
-
|
|
821
|
+
}, exports.Format = function(t, e, n, r = T(t.selection)) {
|
|
822
|
+
t.apply({
|
|
814
823
|
type: "format",
|
|
815
824
|
range: r,
|
|
816
|
-
key:
|
|
825
|
+
key: e,
|
|
817
826
|
value: n
|
|
818
827
|
});
|
|
819
|
-
}, exports.InsertNode = function(
|
|
820
|
-
|
|
828
|
+
}, exports.InsertNode = function(t, e, n = t.selection[0]) {
|
|
829
|
+
t.apply({
|
|
821
830
|
type: "insert_node",
|
|
822
831
|
at: n,
|
|
823
832
|
fragment: [ {
|
|
824
|
-
children: [
|
|
833
|
+
children: [ e ]
|
|
825
834
|
} ]
|
|
826
835
|
});
|
|
827
|
-
}, exports.InsertText = function(
|
|
828
|
-
|
|
836
|
+
}, exports.InsertText = function(t, e, n = t.selection[0]) {
|
|
837
|
+
t.apply({
|
|
829
838
|
type: "insert_text",
|
|
830
839
|
at: n,
|
|
831
|
-
text:
|
|
840
|
+
text: e
|
|
832
841
|
});
|
|
833
|
-
}, exports.Redo = function(
|
|
834
|
-
|
|
835
|
-
}, exports.Redoable = function(
|
|
836
|
-
return
|
|
837
|
-
}, exports.ReplaceDoc = w, exports.ReplaceText = function(
|
|
838
|
-
|
|
842
|
+
}, exports.LeavesInRange = S, exports.Redo = function(t) {
|
|
843
|
+
t.get(rt).redo();
|
|
844
|
+
}, exports.Redoable = function(t) {
|
|
845
|
+
return t.get(rt).redoable();
|
|
846
|
+
}, exports.ReplaceDoc = w, exports.ReplaceText = function(t, e, n = T(t.selection)) {
|
|
847
|
+
t.apply({
|
|
839
848
|
type: "delete",
|
|
840
849
|
range: n
|
|
841
850
|
}).apply({
|
|
842
851
|
type: "insert_text",
|
|
843
852
|
at: n[0],
|
|
844
|
-
text:
|
|
853
|
+
text: e
|
|
845
854
|
});
|
|
846
|
-
}, exports.SetBlockAttr = function(
|
|
847
|
-
const o = x(
|
|
848
|
-
|
|
855
|
+
}, exports.SetBlockAttr = function(t, e, n, r = t.selection[0]) {
|
|
856
|
+
const o = x(t.doc, r)[2];
|
|
857
|
+
t.apply({
|
|
849
858
|
type: "patch_node",
|
|
850
859
|
path: o,
|
|
851
|
-
key:
|
|
860
|
+
key: e,
|
|
852
861
|
value: n
|
|
853
862
|
});
|
|
854
|
-
}, exports.
|
|
855
|
-
const
|
|
856
|
-
|
|
863
|
+
}, exports.SetVoidAttr = function(t, e, n, r = t.selection[0]) {
|
|
864
|
+
const o = y(t.doc, r, !0);
|
|
865
|
+
o && !i(o[0]) && t.apply({
|
|
866
|
+
type: "patch_node",
|
|
867
|
+
path: o[2],
|
|
868
|
+
key: e,
|
|
869
|
+
value: n
|
|
870
|
+
});
|
|
871
|
+
}, exports.ToggleBlockAttr = function(t, e, n, r, o = t.selection[0]) {
|
|
872
|
+
const [s, , c] = x(t.doc, o);
|
|
873
|
+
t.apply({
|
|
857
874
|
type: "patch_node",
|
|
858
875
|
path: c,
|
|
859
|
-
key:
|
|
860
|
-
value: s[
|
|
876
|
+
key: e,
|
|
877
|
+
value: s[e] === n ? r : n
|
|
861
878
|
});
|
|
862
|
-
}, exports.ToggleFormat = function(
|
|
863
|
-
let r = !1;
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
r = !o[t];
|
|
868
|
-
} else {
|
|
869
|
-
let o = !1;
|
|
870
|
-
for (const [s, c] of b(e.doc, ...n)) if (S(n, [ c, c + d(s) ]) && i(s) && (o = !0,
|
|
871
|
-
!s[t])) {
|
|
872
|
-
r = !0;
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
if (!o) return;
|
|
879
|
+
}, exports.ToggleFormat = function(t, e, n = T(t.selection)) {
|
|
880
|
+
let r = !1, o = !1;
|
|
881
|
+
for (const s of t.exec(S, n)) if (i(s) && (o = !0, !s[e])) {
|
|
882
|
+
r = !0;
|
|
883
|
+
break;
|
|
876
884
|
}
|
|
877
|
-
|
|
885
|
+
o && t.apply({
|
|
878
886
|
type: "format",
|
|
879
887
|
range: n,
|
|
880
|
-
key:
|
|
888
|
+
key: e,
|
|
881
889
|
value: r
|
|
882
890
|
});
|
|
883
|
-
}, exports.Undo = function(
|
|
884
|
-
|
|
885
|
-
}, exports.Undoable = function(
|
|
886
|
-
return
|
|
887
|
-
}, exports.createEditor =
|
|
888
|
-
const o =
|
|
891
|
+
}, exports.Undo = function(t) {
|
|
892
|
+
t.get(rt).undo();
|
|
893
|
+
}, exports.Undoable = function(t) {
|
|
894
|
+
return t.get(rt).undoable();
|
|
895
|
+
}, exports.createEditor = it, exports.createPlainEditor = ({text: t, singleline: e, onChange: n, ...r}) => {
|
|
896
|
+
const o = it({
|
|
889
897
|
...r,
|
|
890
898
|
doc: {
|
|
891
|
-
children: W(
|
|
899
|
+
children: W(t)
|
|
892
900
|
}
|
|
893
|
-
}).exec(
|
|
894
|
-
return
|
|
895
|
-
n(
|
|
901
|
+
}).exec(lt);
|
|
902
|
+
return e && o.exec(ft), o.on("change", () => {
|
|
903
|
+
n(b(o.doc));
|
|
896
904
|
}), o;
|
|
897
|
-
}, exports.debugPlugin = function(
|
|
898
|
-
|
|
899
|
-
console.log("apply",
|
|
900
|
-
}),
|
|
901
|
-
console.log("change",
|
|
902
|
-
}),
|
|
903
|
-
console.log("selectionchange",
|
|
905
|
+
}, exports.debugPlugin = function(t) {
|
|
906
|
+
t.hook("apply", t => {
|
|
907
|
+
console.log("apply", t);
|
|
908
|
+
}), t.on("change", () => {
|
|
909
|
+
console.log("change", t.doc);
|
|
910
|
+
}), t.on("selectionchange", () => {
|
|
911
|
+
console.log("selectionchange", t.selection);
|
|
904
912
|
});
|
|
905
|
-
}, exports.fileTransferPlugin = (
|
|
906
|
-
|
|
907
|
-
for (const n of
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
children: [ e
|
|
913
|
+
}, exports.fileTransferPlugin = (t, e) => {
|
|
914
|
+
t.hook("paste", t => {
|
|
915
|
+
for (const n of t.items) if ("file" === n.kind) {
|
|
916
|
+
const t = e[n.type];
|
|
917
|
+
if (t) {
|
|
918
|
+
const e = n.getAsFile();
|
|
919
|
+
if (e) return [ {
|
|
920
|
+
children: [ t(e) ]
|
|
913
921
|
} ];
|
|
914
922
|
}
|
|
915
923
|
}
|
|
916
924
|
return null;
|
|
917
925
|
});
|
|
918
|
-
}, exports.getBlockAt = x, exports.getChildAt =
|
|
919
|
-
exports.htmlTransferPlugin = function(
|
|
920
|
-
|
|
921
|
-
const o =
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
}), s =
|
|
925
|
-
const n =
|
|
926
|
-
return n ? ((
|
|
927
|
-
const r = n.text, o =
|
|
928
|
-
const
|
|
929
|
-
if (
|
|
930
|
-
const n = t
|
|
926
|
+
}, exports.getBlockAt = x, exports.getChildAt = d, exports.getLeafAt = y, exports.getNodeSize = p,
|
|
927
|
+
exports.htmlTransferPlugin = function(t, e) {
|
|
928
|
+
t.hook("mount", (n, r) => {
|
|
929
|
+
const o = t.hook("copy", t => {
|
|
930
|
+
const e = document.createElement("div");
|
|
931
|
+
e.appendChild(L(N(n), n).cloneContents()), t.setData("text/html", e.innerHTML);
|
|
932
|
+
}), s = t.hook("paste", t => {
|
|
933
|
+
const n = t.getData("text/html");
|
|
934
|
+
return n ? ((t, e, n) => {
|
|
935
|
+
const r = n.text, o = t => {
|
|
936
|
+
const e = n[t.tagName.toLowerCase()];
|
|
937
|
+
if (e) {
|
|
938
|
+
const n = e(t);
|
|
931
939
|
if (n) return n;
|
|
932
940
|
}
|
|
933
941
|
};
|
|
934
|
-
let s = (new DOMParser).parseFromString(
|
|
942
|
+
let s = (new DOMParser).parseFromString(t, "text/html").body, c = !1;
|
|
935
943
|
for (const i of [ ...s.childNodes ]) O(i) ? "StartFragment" === i.data ? (c = !0,
|
|
936
944
|
s = new DocumentFragment) : "EndFragment" === i.data && (c = !1) : c && s.appendChild(i);
|
|
937
|
-
return
|
|
945
|
+
return e(({t, i: e}) => {
|
|
938
946
|
let n, s = null, c = "", i = !1;
|
|
939
947
|
const l = [], a = () => {
|
|
940
948
|
c && (s || (s = []), s.push(r(c)), c = "");
|
|
@@ -943,44 +951,44 @@ exports.htmlTransferPlugin = function(e, t) {
|
|
|
943
951
|
children: s
|
|
944
952
|
}), s = null, i = !1;
|
|
945
953
|
};
|
|
946
|
-
for (;n =
|
|
954
|
+
for (;n = t(); ) if (4 === n) f(); else if (i = !0, 1 === n) c += e().data; else if (2 === n) {
|
|
947
955
|
a();
|
|
948
|
-
const
|
|
949
|
-
|
|
956
|
+
const t = o(e());
|
|
957
|
+
t && s.push(t);
|
|
950
958
|
} else 3 === n && f();
|
|
951
959
|
return f(), l.length || l.push({
|
|
952
960
|
children: []
|
|
953
961
|
}), l;
|
|
954
962
|
}, s);
|
|
955
|
-
})(n, r,
|
|
963
|
+
})(n, r, e.serializers) : null;
|
|
956
964
|
});
|
|
957
965
|
return () => {
|
|
958
966
|
o(), s();
|
|
959
967
|
};
|
|
960
968
|
});
|
|
961
|
-
}, exports.internalTranferPlugin = function(
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}),
|
|
969
|
+
}, exports.internalTranferPlugin = function(t) {
|
|
970
|
+
t.hook("copy", e => {
|
|
971
|
+
e.setData(at, JSON.stringify(v(t.doc, ...T(t.selection))));
|
|
972
|
+
}), t.hook("paste", t => {
|
|
965
973
|
try {
|
|
966
|
-
return JSON.parse(
|
|
967
|
-
} catch (
|
|
974
|
+
return JSON.parse(t.getData(at));
|
|
975
|
+
} catch (e) {
|
|
968
976
|
return null;
|
|
969
977
|
}
|
|
970
978
|
});
|
|
971
|
-
}, exports.
|
|
972
|
-
n(
|
|
973
|
-
const r =
|
|
974
|
-
|
|
979
|
+
}, exports.iterLeaves = _, exports.keymapPlugin = function(t, e) {
|
|
980
|
+
n(e).forEach(n => {
|
|
981
|
+
const r = e[n];
|
|
982
|
+
t.hook("keyboard", nt(n, r));
|
|
975
983
|
});
|
|
976
|
-
}, exports.plainTransferPlugin =
|
|
977
|
-
|
|
984
|
+
}, exports.plainTransferPlugin = lt, exports.selectionRectPlugin = function(t, e) {
|
|
985
|
+
t.hook("mount", (n, r) => {
|
|
978
986
|
let o = !0, s = !1;
|
|
979
|
-
const c =
|
|
987
|
+
const c = t.on("selectionchange", () => {
|
|
980
988
|
s || (s = !0, requestAnimationFrame(() => {
|
|
981
|
-
s = !1, o &&
|
|
982
|
-
const
|
|
983
|
-
return C(n, r,
|
|
989
|
+
s = !1, o && e(() => {
|
|
990
|
+
const e = t.selection;
|
|
991
|
+
return C(n, r, t.doc, e).getBoundingClientRect();
|
|
984
992
|
});
|
|
985
993
|
}));
|
|
986
994
|
});
|
|
@@ -988,5 +996,5 @@ exports.htmlTransferPlugin = function(e, t) {
|
|
|
988
996
|
o = !1, c();
|
|
989
997
|
};
|
|
990
998
|
});
|
|
991
|
-
}, exports.singlelinePlugin =
|
|
999
|
+
}, exports.singlelinePlugin = ft, exports.sliceText = b;
|
|
992
1000
|
//# sourceMappingURL=index.cjs.map
|