editate 0.6.22 → 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/index.cjs +208 -196
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +196 -184
- package/lib/index.js.map +1 -1
- package/lib/plugins/transfer/index.d.ts +1 -1
- package/lib/plugins/transfer/internalTransfer.d.ts +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -37,11 +37,23 @@ var {min: t, max: e} = Math, {keys: n, is: r} = Object, o = t => "string" == typ
|
|
|
37
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
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;
|
|
51
|
+
}, m = (t, e) => {
|
|
40
52
|
const n = t.children, r = p(t, e);
|
|
41
53
|
if (r) {
|
|
42
54
|
const [e, o, c] = r;
|
|
43
55
|
if (l(e)) {
|
|
44
|
-
const [r, s] =
|
|
56
|
+
const [r, s] = m(e, o), i = n.slice(0, c), l = n.slice(c + 1);
|
|
45
57
|
return i.push(r), l.unshift(s), [ {
|
|
46
58
|
...t,
|
|
47
59
|
children: i
|
|
@@ -79,16 +91,16 @@ var {min: t, max: e} = Math, {keys: n, is: r} = Object, o = t => "string" == typ
|
|
|
79
91
|
text: ""
|
|
80
92
|
} ] : []
|
|
81
93
|
} ];
|
|
82
|
-
},
|
|
94
|
+
}, g = (t, [e, n]) => {
|
|
83
95
|
let r = 0;
|
|
84
96
|
for (const o of e) r += u(t, 0, o), 0 !== o && r++, t = t.children[o];
|
|
85
97
|
return r + n;
|
|
86
|
-
},
|
|
98
|
+
}, _ = (t, e) => {
|
|
87
99
|
const [, n, r] = h(t, e);
|
|
88
100
|
return [ r, n ];
|
|
89
|
-
},
|
|
101
|
+
}, b = (t, [e, n]) => [ g(t, e), g(t, n) ];
|
|
90
102
|
|
|
91
|
-
function*
|
|
103
|
+
function* x(t, [e, n]) {
|
|
92
104
|
if (e >= n) return;
|
|
93
105
|
if (!l(t)) return;
|
|
94
106
|
const r = p(t, e);
|
|
@@ -102,21 +114,21 @@ function* b(t, [e, n]) {
|
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
function*
|
|
106
|
-
if (!l(t) || a(t.children)) for (const n of
|
|
117
|
+
function* v(t, e) {
|
|
118
|
+
if (!l(t) || a(t.children)) for (const n of x(t, e)) {
|
|
107
119
|
const [t, e] = n;
|
|
108
|
-
for (const n of
|
|
120
|
+
for (const n of v(t, [ 0, d(t) ])) n[1] += e, yield n;
|
|
109
121
|
} else yield [ t, 0 ];
|
|
110
122
|
}
|
|
111
123
|
|
|
112
|
-
function*
|
|
113
|
-
if (l(t)) for (const [n, r] of
|
|
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
|
|
129
|
+
var E = (n, r = 0, o = 1 / 0, c) => {
|
|
118
130
|
let s = "", l = r;
|
|
119
|
-
for (const [a, f] of
|
|
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)) {
|
|
@@ -127,16 +139,16 @@ var T = (n, r = 0, o = 1 / 0, c) => {
|
|
|
127
139
|
}
|
|
128
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 => ({
|
|
131
143
|
...n,
|
|
132
144
|
children: [ {
|
|
133
145
|
...e,
|
|
134
146
|
text: t
|
|
135
147
|
} ]
|
|
136
|
-
})),
|
|
148
|
+
})), S = "delete", A = "insert_text", O = "insert_node", R = (t, e) => {
|
|
137
149
|
const o = n(t);
|
|
138
150
|
return o.length === n(e).length && o.every(n => n in e && ("text" === n || r(t[n], e[n])));
|
|
139
|
-
},
|
|
151
|
+
}, D = (t, e) => {
|
|
140
152
|
if (e.length) {
|
|
141
153
|
const n = t.length;
|
|
142
154
|
if (t.push(...e), n) {
|
|
@@ -145,13 +157,13 @@ var T = (n, r = 0, o = 1 / 0, c) => {
|
|
|
145
157
|
let r = e + 1;
|
|
146
158
|
for (;r <= n; ) {
|
|
147
159
|
const e = t[r - 1], o = t[r];
|
|
148
|
-
t[r - 1] =
|
|
160
|
+
t[r - 1] = B(e, o), t.splice(r, 1), n--;
|
|
149
161
|
}
|
|
150
162
|
})(t, n - 1, n) : o || c || ((t, e = 0, n = t.length - 1) => {
|
|
151
163
|
let r = e + 1;
|
|
152
164
|
for (;r <= n; ) {
|
|
153
165
|
const e = t[r - 1], o = t[r];
|
|
154
|
-
i(e) && i(o) &&
|
|
166
|
+
i(e) && i(o) && R(e, o) ? (t[r - 1] = {
|
|
155
167
|
...e,
|
|
156
168
|
text: e.text + o.text
|
|
157
169
|
}, t.splice(r, 1), n--) : r++;
|
|
@@ -166,45 +178,45 @@ var T = (n, r = 0, o = 1 / 0, c) => {
|
|
|
166
178
|
t.length || t.push({
|
|
167
179
|
text: ""
|
|
168
180
|
});
|
|
169
|
-
},
|
|
181
|
+
}, B = (...t) => ({
|
|
170
182
|
...t[0],
|
|
171
|
-
children: t.reduce((t, e) => (
|
|
172
|
-
}),
|
|
183
|
+
children: t.reduce((t, e) => (D(t, e.children), t), [])
|
|
184
|
+
}), I = (t, e, n, r = 0) => {
|
|
173
185
|
if (r < e.length) {
|
|
174
186
|
const o = e[r], c = t.children, s = c.slice();
|
|
175
|
-
return s.splice(o, 1,
|
|
187
|
+
return s.splice(o, 1, I(c[o], e, n, r + 1)), {
|
|
176
188
|
...t,
|
|
177
189
|
children: s
|
|
178
190
|
};
|
|
179
191
|
}
|
|
180
192
|
return n;
|
|
181
|
-
},
|
|
182
|
-
const [o, c] =
|
|
183
|
-
a(r) ? i || (r =
|
|
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 = [ {
|
|
184
196
|
children: r
|
|
185
197
|
} ]);
|
|
186
198
|
const l = o.children.slice();
|
|
187
|
-
return
|
|
199
|
+
return D(l, r), D(l, s.children), {
|
|
188
200
|
...t,
|
|
189
201
|
children: l
|
|
190
202
|
};
|
|
191
|
-
},
|
|
203
|
+
}, P = (t, e) => e >= 0 && e <= d(t), H = (t, e) => e.reduce((t, e) => N(t, e), t), N = (t, e, n) => {
|
|
192
204
|
switch (e.type) {
|
|
193
|
-
case
|
|
205
|
+
case S:
|
|
194
206
|
{
|
|
195
207
|
const [n, r] = e.range;
|
|
196
208
|
if (t >= n) return r >= t ? n : t + n - r;
|
|
197
209
|
break;
|
|
198
210
|
}
|
|
199
211
|
|
|
200
|
-
case
|
|
212
|
+
case A:
|
|
201
213
|
{
|
|
202
214
|
const {at: r, text: o} = e;
|
|
203
215
|
if (n ? t > r : t >= r) return t + o.length;
|
|
204
216
|
break;
|
|
205
217
|
}
|
|
206
218
|
|
|
207
|
-
case
|
|
219
|
+
case O:
|
|
208
220
|
{
|
|
209
221
|
const {at: r, fragment: o} = e;
|
|
210
222
|
if (n ? t > r : t >= r) return t + d({
|
|
@@ -214,23 +226,23 @@ var T = (n, r = 0, o = 1 / 0, c) => {
|
|
|
214
226
|
}
|
|
215
227
|
}
|
|
216
228
|
return t;
|
|
217
|
-
},
|
|
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;
|
|
218
230
|
|
|
219
|
-
function*
|
|
220
|
-
if (
|
|
231
|
+
function* V(t, e = W(t.selection)) {
|
|
232
|
+
if (F(e)) {
|
|
221
233
|
const n = y(t.doc, e[0])?.[0];
|
|
222
234
|
n && (yield n);
|
|
223
|
-
} else for (const [n, r] of
|
|
235
|
+
} else for (const [n, r] of T(t.doc, e)) U(e, [ r, r + d(n) ]) && (yield n);
|
|
224
236
|
}
|
|
225
237
|
|
|
226
|
-
function
|
|
238
|
+
function q(t, e = W(t.selection)) {
|
|
227
239
|
t.apply({
|
|
228
240
|
type: "delete",
|
|
229
241
|
range: e
|
|
230
242
|
});
|
|
231
243
|
}
|
|
232
244
|
|
|
233
|
-
function
|
|
245
|
+
function z(t, e, n = t.selection[0]) {
|
|
234
246
|
t.apply({
|
|
235
247
|
type: "insert_text",
|
|
236
248
|
at: n,
|
|
@@ -238,7 +250,7 @@ function q(t, e, n = t.selection[0]) {
|
|
|
238
250
|
});
|
|
239
251
|
}
|
|
240
252
|
|
|
241
|
-
function
|
|
253
|
+
function G(t, e, n = t.selection[0]) {
|
|
242
254
|
t.apply({
|
|
243
255
|
type: "insert_node",
|
|
244
256
|
at: n,
|
|
@@ -248,7 +260,7 @@ function z(t, e, n = t.selection[0]) {
|
|
|
248
260
|
});
|
|
249
261
|
}
|
|
250
262
|
|
|
251
|
-
function
|
|
263
|
+
function J(t, e, n = W(t.selection)) {
|
|
252
264
|
t.apply({
|
|
253
265
|
type: "delete",
|
|
254
266
|
range: n
|
|
@@ -259,7 +271,7 @@ function G(t, e, n = C(t.selection)) {
|
|
|
259
271
|
});
|
|
260
272
|
}
|
|
261
273
|
|
|
262
|
-
function
|
|
274
|
+
function Y(t, e) {
|
|
263
275
|
t.apply({
|
|
264
276
|
type: "patch_node",
|
|
265
277
|
path: [],
|
|
@@ -268,7 +280,7 @@ function J(t, e) {
|
|
|
268
280
|
});
|
|
269
281
|
}
|
|
270
282
|
|
|
271
|
-
function
|
|
283
|
+
function X(t, e, n, r = W(t.selection)) {
|
|
272
284
|
t.apply({
|
|
273
285
|
type: "format",
|
|
274
286
|
range: r,
|
|
@@ -277,9 +289,9 @@ function Y(t, e, n, r = C(t.selection)) {
|
|
|
277
289
|
});
|
|
278
290
|
}
|
|
279
291
|
|
|
280
|
-
function
|
|
292
|
+
function Z(t, e, n = W(t.selection)) {
|
|
281
293
|
let r = !1, o = !1;
|
|
282
|
-
for (const c of t.exec(
|
|
294
|
+
for (const c of t.exec(V, n)) if (i(c) && (o = !0, !c[e])) {
|
|
283
295
|
r = !0;
|
|
284
296
|
break;
|
|
285
297
|
}
|
|
@@ -291,7 +303,7 @@ function X(t, e, n = C(t.selection)) {
|
|
|
291
303
|
});
|
|
292
304
|
}
|
|
293
305
|
|
|
294
|
-
function
|
|
306
|
+
function j(t, e, n, r = t.selection[0]) {
|
|
295
307
|
const o = h(t.doc, r)[2];
|
|
296
308
|
t.apply({
|
|
297
309
|
type: "patch_node",
|
|
@@ -301,7 +313,7 @@ function Z(t, e, n, r = t.selection[0]) {
|
|
|
301
313
|
});
|
|
302
314
|
}
|
|
303
315
|
|
|
304
|
-
function
|
|
316
|
+
function K(t, e, n, r, o = t.selection[0]) {
|
|
305
317
|
const [c, , s] = h(t.doc, o);
|
|
306
318
|
t.apply({
|
|
307
319
|
type: "patch_node",
|
|
@@ -311,7 +323,7 @@ function j(t, e, n, r, o = t.selection[0]) {
|
|
|
311
323
|
});
|
|
312
324
|
}
|
|
313
325
|
|
|
314
|
-
function
|
|
326
|
+
function Q(t, e, n, r = t.selection[0]) {
|
|
315
327
|
const o = y(t.doc, r, !0);
|
|
316
328
|
o && !i(o[0]) && t.apply({
|
|
317
329
|
type: "patch_node",
|
|
@@ -321,23 +333,23 @@ function K(t, e, n, r = t.selection[0]) {
|
|
|
321
333
|
});
|
|
322
334
|
}
|
|
323
335
|
|
|
324
|
-
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) => {
|
|
325
337
|
if (t.rangeCount) {
|
|
326
338
|
const n = t.getRangeAt(0);
|
|
327
339
|
if (e.contains(n.commonAncestorContainer)) return n;
|
|
328
340
|
}
|
|
329
|
-
},
|
|
330
|
-
const [o, c] = ((t, [e, n]) => [
|
|
331
|
-
return
|
|
332
|
-
|
|
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),
|
|
333
345
|
d;
|
|
334
|
-
},
|
|
335
|
-
const c =
|
|
336
|
-
if (o ||
|
|
337
|
-
const o =
|
|
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;
|
|
338
350
|
c.removeAllRanges(), c.addRange(o), s && (c.collapseToEnd(), c.extend(o.startContainer, o.startOffset));
|
|
339
351
|
}
|
|
340
|
-
},
|
|
352
|
+
}, ft = (t, e, [n, r]) => e(({t: e, o, i: c, l: s}) => {
|
|
341
353
|
let i, l = 0;
|
|
342
354
|
for (;i = e(); ) if (4 === i) {
|
|
343
355
|
if (l < n.length) for (let t = n[l++]; t > 0; t--) o();
|
|
@@ -347,10 +359,10 @@ var Q = t => 1 === t.nodeType, $ = t => 8 === t.nodeType, tt = new Map([ [ "BR",
|
|
|
347
359
|
r -= t;
|
|
348
360
|
}
|
|
349
361
|
return [ t, 0 ];
|
|
350
|
-
}, t),
|
|
362
|
+
}, t), ut = (e, n, r, o) => {
|
|
351
363
|
let c = !0;
|
|
352
364
|
if (e === r && !r.hasChildNodes()) return [ [], 0 ];
|
|
353
|
-
if (
|
|
365
|
+
if ($(r) && r.hasChildNodes()) {
|
|
354
366
|
const e = t(o, r.childNodes.length - 1);
|
|
355
367
|
r = r.childNodes[e], c = e === o, o = 0;
|
|
356
368
|
}
|
|
@@ -367,7 +379,7 @@ var Q = t => 1 === t.nodeType, $ = t => 8 === t.nodeType, tt = new Map([ [ "BR",
|
|
|
367
379
|
});
|
|
368
380
|
let p = 0;
|
|
369
381
|
for (;t(); ) {
|
|
370
|
-
const t =
|
|
382
|
+
const t = ot(r, a());
|
|
371
383
|
if (0 === t || 16 & t) {
|
|
372
384
|
if (c) break;
|
|
373
385
|
} else if (4 & t) break;
|
|
@@ -375,10 +387,10 @@ var Q = t => 1 === t.nodeType, $ = t => 8 === t.nodeType, tt = new Map([ [ "BR",
|
|
|
375
387
|
}
|
|
376
388
|
return [ d, p + o ];
|
|
377
389
|
}, e);
|
|
378
|
-
},
|
|
379
|
-
const s =
|
|
380
|
-
return [ s, r === c && n === o ? s :
|
|
381
|
-
},
|
|
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) => {
|
|
382
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
396
|
return r.forEach(t => {
|
|
@@ -392,7 +404,7 @@ var Q = t => 1 === t.nodeType, $ = t => 8 === t.nodeType, tt = 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,10 +419,10 @@ var Q = t => 1 === t.nodeType, $ = t => 8 === t.nodeType, tt = new Map([ [ "BR",
|
|
|
407
419
|
};
|
|
408
420
|
};
|
|
409
421
|
|
|
410
|
-
function
|
|
422
|
+
function yt(t) {
|
|
411
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(
|
|
425
|
+
t.exec(Y, e.children);
|
|
414
426
|
const r = e, o = t.doc;
|
|
415
427
|
for (const c of n(r)) "children" !== c && o[c] !== r[c] && t.apply({
|
|
416
428
|
type: "patch_node",
|
|
@@ -435,7 +447,7 @@ function ht(t) {
|
|
|
435
447
|
if (a()) {
|
|
436
448
|
e++;
|
|
437
449
|
const [n, r, c] = i(), s = t.doc;
|
|
438
|
-
o = !0, f(n), o = !1, s !== t.doc && (t.selection = [
|
|
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) => {
|
|
@@ -453,8 +465,8 @@ function ht(t) {
|
|
|
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 yt(t) {
|
|
466
|
-
t.get(ht).undo();
|
|
467
|
-
}
|
|
468
|
-
|
|
469
477
|
function kt(t) {
|
|
470
|
-
t.get(
|
|
478
|
+
t.get(yt).undo();
|
|
471
479
|
}
|
|
472
480
|
|
|
473
481
|
function mt(t) {
|
|
474
|
-
|
|
482
|
+
t.get(yt).redo();
|
|
475
483
|
}
|
|
476
484
|
|
|
477
485
|
function gt(t) {
|
|
478
|
-
return t.get(
|
|
486
|
+
return t.get(yt).undoable();
|
|
479
487
|
}
|
|
480
488
|
|
|
481
|
-
|
|
489
|
+
function _t(t) {
|
|
490
|
+
return t.get(yt).redoable();
|
|
491
|
+
}
|
|
492
|
+
|
|
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,8 +505,8 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
493
505
|
return !1;
|
|
494
506
|
};
|
|
495
507
|
n && !d(t) && f("Invalid document");
|
|
496
|
-
const y = /* @__PURE__ */ new Map, k = /* @__PURE__ */ new WeakMap,
|
|
497
|
-
const e =
|
|
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);
|
|
498
510
|
e && (x.size || s(() => {
|
|
499
511
|
x.forEach(t => {
|
|
500
512
|
t();
|
|
@@ -503,10 +515,10 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
503
515
|
x.add(t);
|
|
504
516
|
}));
|
|
505
517
|
}, T = t => {
|
|
506
|
-
if (!e) if (Array.isArray(t)) for (const e of t)
|
|
518
|
+
if (!e) if (Array.isArray(t)) for (const e of t) E(e); else E(t);
|
|
507
519
|
return D;
|
|
508
|
-
},
|
|
509
|
-
const n = t, r =
|
|
520
|
+
}, E = e => {
|
|
521
|
+
const n = t, r = m("apply"), o = r.length;
|
|
510
522
|
let c = 0;
|
|
511
523
|
const s = () => {
|
|
512
524
|
if (c < o) {
|
|
@@ -517,43 +529,43 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
517
529
|
try {
|
|
518
530
|
const [n, r] = ((t, e, n) => {
|
|
519
531
|
switch (n.type) {
|
|
520
|
-
case
|
|
532
|
+
case S:
|
|
521
533
|
{
|
|
522
534
|
const [r, o] = n.range;
|
|
523
|
-
|
|
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
541
|
const {at: r, text: o} = n;
|
|
530
|
-
if (
|
|
542
|
+
if (P(t, r) && o) {
|
|
531
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
556
|
const {at: r, fragment: o} = n;
|
|
545
|
-
|
|
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
563
|
const {range: [e, r], key: o, value: c} = n;
|
|
552
|
-
if (
|
|
564
|
+
if (P(t, e) && P(t, r) && e <= r) if (e === r) {
|
|
553
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
|
}));
|
|
@@ -566,7 +578,7 @@ var _t = [], bt = () => {}, xt = 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
|
}
|
|
@@ -577,7 +589,7 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
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
|
}));
|
|
@@ -586,7 +598,7 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
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
|
}
|
|
@@ -596,7 +608,7 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
596
608
|
};
|
|
597
609
|
s(), n !== t && v("change");
|
|
598
610
|
}, R = e => {
|
|
599
|
-
!((t, [e, n]) =>
|
|
611
|
+
!((t, [e, n]) => P(t, e) && P(t, n))(t, e) || u[0] === e[0] && u[1] === e[1] || (u = e,
|
|
600
612
|
v("selectionchange"));
|
|
601
613
|
}, D = {
|
|
602
614
|
get doc() {
|
|
@@ -616,8 +628,8 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
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
|
},
|
|
@@ -636,21 +648,21 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
636
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, k = !1,
|
|
643
|
-
const E =
|
|
654
|
+
let p = !1, h = null, y = !1, k = !1, _ = !1, x = u, v = null;
|
|
655
|
+
const E = ct(n), M = ((t, e) => {
|
|
644
656
|
let n = null, r = null, o = null;
|
|
645
657
|
const c = () => {
|
|
646
658
|
if (null != o) return o;
|
|
647
659
|
if (r) if ((t => 3 === t.nodeType)(r)) {
|
|
648
660
|
const t = r.data;
|
|
649
661
|
if (t) return o = "\n" === t ? i() ? 3 : 5 : 1;
|
|
650
|
-
} else if (
|
|
662
|
+
} else if ($(r)) {
|
|
651
663
|
if ("false" === r.contentEditable) return o = 2;
|
|
652
664
|
{
|
|
653
|
-
const t =
|
|
665
|
+
const t = et.get(r.tagName);
|
|
654
666
|
if (null != t) return o = 1 === t ? i() ? 3 : 5 : 3 === t ? 2 : 6;
|
|
655
667
|
if (e(r)) return o = 4;
|
|
656
668
|
}
|
|
@@ -716,15 +728,15 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
716
728
|
preventScroll: !0
|
|
717
729
|
});
|
|
718
730
|
}, A = () => {
|
|
719
|
-
v = null, u[0] === x[0] && u[1] === x[1] || (
|
|
731
|
+
v = null, u[0] === x[0] && u[1] === x[1] || (at(n, M, t, u), x = u);
|
|
720
732
|
}, O = () => {
|
|
721
733
|
null != v && clearTimeout(v);
|
|
722
734
|
}, B = D.on("change", () => {
|
|
723
735
|
k || requestAnimationFrame(S);
|
|
724
736
|
}), I = D.on("selectionchange", () => {
|
|
725
737
|
u[0] === x[0] && u[1] === x[1] || (O(), v = setTimeout(A, 50));
|
|
726
|
-
}), L = D.on("readonly", w),
|
|
727
|
-
for (const e of
|
|
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
|
}
|
|
@@ -766,20 +778,20 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
766
778
|
}
|
|
767
779
|
};
|
|
768
780
|
})(n, () => {
|
|
769
|
-
O(),
|
|
770
|
-
}),
|
|
771
|
-
R(x =
|
|
772
|
-
const n =
|
|
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);
|
|
773
785
|
if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
|
|
774
|
-
const o =
|
|
786
|
+
const o = dt(t, e, r), c = ot(n.anchorNode, n.focusNode);
|
|
775
787
|
return (0 === c ? n.anchorOffset > n.focusOffset : 2 & c) ? [ o[1], o[0] ] : o;
|
|
776
788
|
})(n, M)));
|
|
777
789
|
}, U = () => {
|
|
778
790
|
const e = N.v();
|
|
779
|
-
N._(!1), e.length && (N.m(e), E.removeEventListener("selectionchange", Z),
|
|
791
|
+
N._(!1), e.length && (N.m(e), E.removeEventListener("selectionchange", Z), at(n, M, t, u, !0),
|
|
780
792
|
E.addEventListener("selectionchange", Z)), h && (R(h[1]), T(h[0]), h = null), y = !1;
|
|
781
793
|
}, V = t => {
|
|
782
|
-
if (!y) for (const e of
|
|
794
|
+
if (!y) for (const e of m("keyboard")) if (e(t)) return t.preventDefault(), void N._(!1);
|
|
783
795
|
}, q = () => {
|
|
784
796
|
y || U();
|
|
785
797
|
}, z = e => {
|
|
@@ -787,7 +799,7 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
787
799
|
const r = e.inputType;
|
|
788
800
|
if (r.startsWith("format")) return;
|
|
789
801
|
if ("historyUndo" === r || "historyRedo" === r) return;
|
|
790
|
-
y ? N._(!0) :
|
|
802
|
+
y ? N._(!0) : C();
|
|
791
803
|
const o = e.getTargetRanges()[0];
|
|
792
804
|
if (o) {
|
|
793
805
|
let c = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : e.data;
|
|
@@ -796,8 +808,8 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
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({
|
|
@@ -808,29 +820,29 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
808
820
|
}
|
|
809
821
|
y || U();
|
|
810
822
|
}, G = () => {
|
|
811
|
-
y ||
|
|
823
|
+
y || C(), y = !0;
|
|
812
824
|
}, J = () => {
|
|
813
825
|
U();
|
|
814
826
|
}, Y = () => {
|
|
815
|
-
k = !0,
|
|
827
|
+
k = !0, C();
|
|
816
828
|
}, X = () => {
|
|
817
829
|
k = !1;
|
|
818
830
|
}, Z = () => {
|
|
819
|
-
!k || y ||
|
|
831
|
+
!k || y || _ || C();
|
|
820
832
|
}, j = t => {
|
|
821
|
-
if (
|
|
833
|
+
if (C(), !F(u)) for (const e of m("copy")) e(t);
|
|
822
834
|
}, K = t => {
|
|
823
835
|
t.preventDefault(), j(t.clipboardData);
|
|
824
|
-
},
|
|
836
|
+
}, Q = t => {
|
|
825
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
|
} ];
|
|
@@ -847,25 +859,25 @@ var _t = [], bt = () => {}, xt = t => {
|
|
|
847
859
|
}, nt = e => {
|
|
848
860
|
e.preventDefault();
|
|
849
861
|
const r = e.dataTransfer, c = ((t, e, {clientX: n, clientY: r}) => {
|
|
850
|
-
const o =
|
|
862
|
+
const o = ct(t);
|
|
851
863
|
if (o.caretPositionFromPoint) {
|
|
852
864
|
const c = o.caretPositionFromPoint(n, r);
|
|
853
|
-
if (c) return
|
|
865
|
+
if (c) return ut(t, e, c.offsetNode, c.offset);
|
|
854
866
|
} else if (o.caretRangeFromPoint) {
|
|
855
867
|
const c = o.caretRangeFromPoint(n, r);
|
|
856
|
-
if (c) return
|
|
868
|
+
if (c) return ut(t, e, c.startContainer, c.startOffset);
|
|
857
869
|
}
|
|
858
870
|
})(n, M, e);
|
|
859
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 r =
|
|
880
|
+
const r = g(t, c), i = H(r, n);
|
|
869
881
|
n.push(o(s) ? {
|
|
870
882
|
type: "insert_text",
|
|
871
883
|
at: i,
|
|
@@ -874,40 +886,40 @@ var _t = [], bt = () => {}, xt = 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
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
899
|
E.addEventListener("selectionchange", Z), n.addEventListener("keydown", V), n.addEventListener("input", q),
|
|
888
900
|
n.addEventListener("beforeinput", z), n.addEventListener("compositionstart", G),
|
|
889
901
|
n.addEventListener("compositionend", J), n.addEventListener("focus", Y), n.addEventListener("blur", X),
|
|
890
|
-
n.addEventListener("copy", K), n.addEventListener("cut",
|
|
891
|
-
n.addEventListener("drop", nt), n.addEventListener("dragstart",
|
|
892
|
-
const
|
|
893
|
-
return
|
|
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 => {
|
|
894
906
|
const e = t(n, M);
|
|
895
|
-
e &&
|
|
907
|
+
e && ft.push(e);
|
|
896
908
|
}), () => {
|
|
897
909
|
p || (p = !0, B(), I(), L(), n.contentEditable = s, n.role = i, n.ariaMultiLine = l,
|
|
898
910
|
n.ariaReadOnly = f, n.style.whiteSpace = d, N.T(), E.removeEventListener("selectionchange", Z),
|
|
899
911
|
n.removeEventListener("keydown", V), n.removeEventListener("input", q), n.removeEventListener("beforeinput", z),
|
|
900
912
|
n.removeEventListener("compositionstart", G), n.removeEventListener("compositionend", J),
|
|
901
913
|
n.removeEventListener("focus", Y), n.removeEventListener("blur", X), n.removeEventListener("copy", K),
|
|
902
|
-
n.removeEventListener("cut",
|
|
903
|
-
n.removeEventListener("dragstart",
|
|
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 D.exec(
|
|
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,18 +934,18 @@ var _t = [], bt = () => {}, xt = 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
|
|
944
|
+
function wt(t, e) {
|
|
933
945
|
t.hook("mount", (n, r) => {
|
|
934
946
|
const o = t.hook("copy", t => {
|
|
935
947
|
const e = document.createElement("div");
|
|
936
|
-
e.appendChild(st(
|
|
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) => {
|
|
@@ -945,7 +957,7 @@ 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;
|
|
@@ -973,24 +985,24 @@ function Mt(t, e) {
|
|
|
973
985
|
});
|
|
974
986
|
}
|
|
975
987
|
|
|
976
|
-
var
|
|
988
|
+
var St = "application/x-editate-editor";
|
|
977
989
|
|
|
978
|
-
function
|
|
990
|
+
function At(t) {
|
|
979
991
|
t.hook("copy", e => {
|
|
980
|
-
e.setData(
|
|
992
|
+
e.setData(St, JSON.stringify(M(t.doc, ...W(t.selection))));
|
|
981
993
|
}), t.hook("paste", t => {
|
|
982
994
|
try {
|
|
983
|
-
return JSON.parse(t.getData(
|
|
995
|
+
return JSON.parse(t.getData(St));
|
|
984
996
|
} catch (e) {
|
|
985
997
|
return null;
|
|
986
998
|
}
|
|
987
999
|
});
|
|
988
1000
|
}
|
|
989
1001
|
|
|
990
|
-
function
|
|
1002
|
+
function Ot(t, e) {
|
|
991
1003
|
const n = e.isLocked, r = e => n(h(t.doc, e)[0]), o = (e, r) => {
|
|
992
1004
|
const [o, c] = e;
|
|
993
|
-
for (const [s, i] of
|
|
1005
|
+
for (const [s, i] of v(t.doc, e)) {
|
|
994
1006
|
const t = i + d(s);
|
|
995
1007
|
if ((r ? c >= i && o <= t : c > i && o < t) && n(s)) return !0;
|
|
996
1008
|
}
|
|
@@ -1001,7 +1013,7 @@ function At(t, e) {
|
|
|
1001
1013
|
const a = c;
|
|
1002
1014
|
switch (c = !1, e.type) {
|
|
1003
1015
|
case "delete":
|
|
1004
|
-
if (o(
|
|
1016
|
+
if (o(W(e.range), !0)) return c = !0, s(() => {
|
|
1005
1017
|
c = !1;
|
|
1006
1018
|
}), i(null);
|
|
1007
1019
|
break;
|
|
@@ -1013,8 +1025,8 @@ function At(t, e) {
|
|
|
1013
1025
|
|
|
1014
1026
|
case "format":
|
|
1015
1027
|
{
|
|
1016
|
-
const t =
|
|
1017
|
-
if (
|
|
1028
|
+
const t = W(e.range);
|
|
1029
|
+
if (F(t) ? r(t[0]) : o(t, !1)) return i(null);
|
|
1018
1030
|
break;
|
|
1019
1031
|
}
|
|
1020
1032
|
|
|
@@ -1035,16 +1047,16 @@ function At(t, e) {
|
|
|
1035
1047
|
}
|
|
1036
1048
|
}
|
|
1037
1049
|
i(e);
|
|
1038
|
-
}), t.set(
|
|
1039
|
-
locked: t =>
|
|
1050
|
+
}), t.set(Ot, {
|
|
1051
|
+
locked: t => F(t) ? r(t[0]) : o(t, !0)
|
|
1040
1052
|
});
|
|
1041
1053
|
}
|
|
1042
1054
|
|
|
1043
|
-
function
|
|
1044
|
-
return t.get(
|
|
1055
|
+
function Rt(t, e = W(t.selection)) {
|
|
1056
|
+
return t.get(Ot).locked(e);
|
|
1045
1057
|
}
|
|
1046
1058
|
|
|
1047
|
-
function
|
|
1059
|
+
function Dt(t) {
|
|
1048
1060
|
t.hook("apply", t => {
|
|
1049
1061
|
console.log("apply", t);
|
|
1050
1062
|
}), t.on("change", () => {
|
|
@@ -1054,20 +1066,20 @@ function Rt(t) {
|
|
|
1054
1066
|
});
|
|
1055
1067
|
}
|
|
1056
1068
|
|
|
1057
|
-
function
|
|
1069
|
+
function Bt(t, e) {
|
|
1058
1070
|
n(e).forEach(n => {
|
|
1059
1071
|
const r = e[n];
|
|
1060
|
-
t.hook("keyboard",
|
|
1072
|
+
t.hook("keyboard", ht(n, r));
|
|
1061
1073
|
});
|
|
1062
1074
|
}
|
|
1063
1075
|
|
|
1064
|
-
var
|
|
1076
|
+
var It = (t, e) => {
|
|
1065
1077
|
const n = parseFloat(t);
|
|
1066
1078
|
return n ? t.endsWith("%") ? n / 100 * e : n : 0;
|
|
1067
|
-
},
|
|
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 => {
|
|
1068
1080
|
const e = "auto";
|
|
1069
1081
|
t.hook("mount", (n, r) => {
|
|
1070
|
-
const o =
|
|
1082
|
+
const o = ct(n), c = o.defaultView, s = ((t, e, n) => {
|
|
1071
1083
|
const {body: r, documentElement: o} = e;
|
|
1072
1084
|
let c = t;
|
|
1073
1085
|
for (;c && c !== r && c !== o; ) {
|
|
@@ -1081,14 +1093,14 @@ var Bt = (t, e) => {
|
|
|
1081
1093
|
const l = t.on("change", () => {
|
|
1082
1094
|
null == i && (i = setTimeout(() => {
|
|
1083
1095
|
i = null;
|
|
1084
|
-
const o =
|
|
1096
|
+
const o = lt(n, r, t.doc, t.selection);
|
|
1085
1097
|
let l = o.getBoundingClientRect();
|
|
1086
1098
|
if (!l.height) {
|
|
1087
|
-
const t = o.startContainer, e =
|
|
1099
|
+
const t = o.startContainer, e = $(t) ? t : t.parentElement;
|
|
1088
1100
|
e && (l = e.getBoundingClientRect());
|
|
1089
1101
|
}
|
|
1090
1102
|
const a = s ? ((t, e, n, r) => {
|
|
1091
|
-
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 = Pt(
|
|
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);
|
|
1092
1104
|
return (h || y) && e.scrollBy({
|
|
1093
1105
|
top: h,
|
|
1094
1106
|
left: y,
|
|
@@ -1096,7 +1108,7 @@ var Bt = (t, e) => {
|
|
|
1096
1108
|
}), [ y, h ];
|
|
1097
1109
|
})(c, s, l, e) : [ 0, 0 ];
|
|
1098
1110
|
((t, e, [n, r], o) => {
|
|
1099
|
-
const {documentElement: c} = t.document, {clientWidth: s, clientHeight: i} = c, l = t.getComputedStyle(c), a =
|
|
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));
|
|
1100
1112
|
(a || f) && t.scrollBy({
|
|
1101
1113
|
top: a,
|
|
1102
1114
|
left: f,
|
|
@@ -1111,14 +1123,14 @@ var Bt = (t, e) => {
|
|
|
1111
1123
|
});
|
|
1112
1124
|
};
|
|
1113
1125
|
|
|
1114
|
-
function
|
|
1126
|
+
function Ct(t, e) {
|
|
1115
1127
|
t.hook("mount", (n, r) => {
|
|
1116
1128
|
let o = !0, c = !1;
|
|
1117
1129
|
const s = t.on("selectionchange", () => {
|
|
1118
1130
|
c || (c = !0, requestAnimationFrame(() => {
|
|
1119
1131
|
c = !1, o && e(() => {
|
|
1120
1132
|
const e = t.selection;
|
|
1121
|
-
return
|
|
1133
|
+
return lt(n, r, t.doc, e).getBoundingClientRect();
|
|
1122
1134
|
});
|
|
1123
1135
|
}));
|
|
1124
1136
|
});
|
|
@@ -1128,7 +1140,7 @@ function Nt(t, e) {
|
|
|
1128
1140
|
});
|
|
1129
1141
|
}
|
|
1130
1142
|
|
|
1131
|
-
function
|
|
1143
|
+
function Wt(t) {
|
|
1132
1144
|
t.hook("mount", t => {
|
|
1133
1145
|
t.ariaMultiLine = null;
|
|
1134
1146
|
}), t.hook("apply", (t, e) => {
|
|
@@ -1139,24 +1151,24 @@ function Ct(t) {
|
|
|
1139
1151
|
const e = t.fragment;
|
|
1140
1152
|
t = {
|
|
1141
1153
|
...t,
|
|
1142
|
-
fragment: a(e) ? [
|
|
1154
|
+
fragment: a(e) ? [ B(...e) ] : e
|
|
1143
1155
|
};
|
|
1144
1156
|
}
|
|
1145
1157
|
e(t);
|
|
1146
1158
|
});
|
|
1147
1159
|
}
|
|
1148
1160
|
|
|
1149
|
-
var
|
|
1150
|
-
const o =
|
|
1161
|
+
var Ft = ({text: t, singleline: e, onChange: n, ...r}) => {
|
|
1162
|
+
const o = Tt({
|
|
1151
1163
|
...r,
|
|
1152
1164
|
doc: {
|
|
1153
|
-
children:
|
|
1165
|
+
children: w(t)
|
|
1154
1166
|
}
|
|
1155
|
-
}).exec(
|
|
1156
|
-
return e && o.exec(
|
|
1157
|
-
n(
|
|
1167
|
+
}).exec(Mt);
|
|
1168
|
+
return e && o.exec(Wt), o.on("change", () => {
|
|
1169
|
+
n(E(o.doc));
|
|
1158
1170
|
}), o;
|
|
1159
1171
|
};
|
|
1160
1172
|
|
|
1161
|
-
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 };
|
|
1162
1174
|
//# sourceMappingURL=index.js.map
|