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