editate 0.6.16 → 0.6.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands.d.ts +2 -2
- package/lib/doc/node.d.ts +2 -2
- package/lib/dom/index.d.ts +2 -2
- package/lib/index.cjs +194 -192
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +199 -197
- package/lib/index.js.map +1 -1
- package/lib/plugins/selectionRect.d.ts +1 -1
- package/lib/queries.d.ts +7 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var {min: e, max: t} = Math, {keys: n, is: r} = Object, o = e => "string" == typ
|
|
|
22
22
|
t -= o;
|
|
23
23
|
}
|
|
24
24
|
return null;
|
|
25
|
-
},
|
|
25
|
+
}, y = (e, t) => {
|
|
26
26
|
const n = [];
|
|
27
27
|
for (;e; ) {
|
|
28
28
|
const r = p(e, t);
|
|
@@ -32,8 +32,8 @@ var {min: e, max: t} = Math, {keys: n, is: r} = Object, o = e => "string" == typ
|
|
|
32
32
|
t = r[1], e = o, n.push(r[2]);
|
|
33
33
|
}
|
|
34
34
|
return [ e, t, n ];
|
|
35
|
-
},
|
|
36
|
-
const [n, r] =
|
|
35
|
+
}, h = (e, t) => {
|
|
36
|
+
const [n, r] = y(e, t), o = p(n, r);
|
|
37
37
|
return o ? [ o[0], o[1] ] : null;
|
|
38
38
|
}, g = (e, t) => {
|
|
39
39
|
const n = e.children, r = p(e, t);
|
|
@@ -83,11 +83,11 @@ var {min: e, max: t} = Math, {keys: n, is: r} = Object, o = e => "string" == typ
|
|
|
83
83
|
for (const o of t) r += u(e, 0, o), 0 !== o && r++, e = e.children[o];
|
|
84
84
|
return r + n;
|
|
85
85
|
}, m = (e, t) => {
|
|
86
|
-
const [, n, r] =
|
|
86
|
+
const [, n, r] = y(e, t);
|
|
87
87
|
return [ r, n ];
|
|
88
|
-
}, x = (e, [t, n]) => [ k(e, t), k(e, n) ]
|
|
88
|
+
}, x = (e, [t, n]) => [ k(e, t), k(e, n) ];
|
|
89
89
|
|
|
90
|
-
function*
|
|
90
|
+
function* _(e, t, n) {
|
|
91
91
|
if (l(e)) for (const r of function*(e, t, n) {
|
|
92
92
|
if (t >= n) return;
|
|
93
93
|
if (!l(e)) return;
|
|
@@ -100,12 +100,12 @@ function* b(e, t, n) {
|
|
|
100
100
|
yield [ e, o ], c++, o += d(e), l(e) && o++;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
}(e, t, n)) if (l(r[0])) for (const e of
|
|
103
|
+
}(e, t, n)) if (l(r[0])) for (const e of _(r[0], 0, d(r[0]))) yield [ e[0], e[1] + r[1] ]; else yield r; else yield [ e, 0 ];
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
var
|
|
106
|
+
var b = (n, r = 0, o = 1 / 0, c) => {
|
|
107
107
|
let i = "", l = r;
|
|
108
|
-
for (const [a, f] of
|
|
108
|
+
for (const [a, f] of _(n, r, o)) {
|
|
109
109
|
for (let e = f - l; e > 0; e--) i += "\n";
|
|
110
110
|
const n = d(a), u = f + n;
|
|
111
111
|
if (s(a)) {
|
|
@@ -116,9 +116,16 @@ var v = (n, r = 0, o = 1 / 0, c) => {
|
|
|
116
116
|
}
|
|
117
117
|
for (let t = e(o, d(n)) - l; t > 0; t--) i += "\n";
|
|
118
118
|
return i;
|
|
119
|
-
},
|
|
119
|
+
}, v = (e, t, n) => t >= n ? [] : g(g(e, n)[0], t)[1].children, T = ([e, t]) => e > t ? [ t, e ] : [ e, t ], E = ([e, t]) => e === t, M = ([e, t], [n, r]) => e < r && n < t;
|
|
120
|
+
|
|
121
|
+
function* S(e, t = T(e.selection)) {
|
|
122
|
+
if (E(t)) {
|
|
123
|
+
const n = h(e.doc, t[0])?.[0];
|
|
124
|
+
n && (yield n);
|
|
125
|
+
} else for (const [n, r] of _(e.doc, ...t)) M(t, [ r, r + d(n) ]) && (yield n);
|
|
126
|
+
}
|
|
120
127
|
|
|
121
|
-
function w(e, t =
|
|
128
|
+
function w(e, t = T(e.selection)) {
|
|
122
129
|
e.apply({
|
|
123
130
|
type: "delete",
|
|
124
131
|
range: t
|
|
@@ -143,7 +150,7 @@ function O(e, t, n = e.selection[0]) {
|
|
|
143
150
|
});
|
|
144
151
|
}
|
|
145
152
|
|
|
146
|
-
function R(e, t, n =
|
|
153
|
+
function R(e, t, n = T(e.selection)) {
|
|
147
154
|
e.apply({
|
|
148
155
|
type: "delete",
|
|
149
156
|
range: n
|
|
@@ -163,7 +170,7 @@ function D(e, t) {
|
|
|
163
170
|
});
|
|
164
171
|
}
|
|
165
172
|
|
|
166
|
-
function B(e, t, n, r =
|
|
173
|
+
function B(e, t, n, r = T(e.selection)) {
|
|
167
174
|
e.apply({
|
|
168
175
|
type: "format",
|
|
169
176
|
range: r,
|
|
@@ -172,22 +179,13 @@ function B(e, t, n, r = E(e.selection)) {
|
|
|
172
179
|
});
|
|
173
180
|
}
|
|
174
181
|
|
|
175
|
-
function I(e, t, n =
|
|
176
|
-
let r = !1;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
r = !o[t];
|
|
181
|
-
} else {
|
|
182
|
-
let o = !1;
|
|
183
|
-
for (const [c, i] of b(e.doc, ...n)) if (S(n, [ i, i + d(c) ]) && s(c) && (o = !0,
|
|
184
|
-
!c[t])) {
|
|
185
|
-
r = !0;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
if (!o) return;
|
|
182
|
+
function I(e, t, n = T(e.selection)) {
|
|
183
|
+
let r = !1, o = !1;
|
|
184
|
+
for (const c of e.exec(S, n)) if (s(c) && (o = !0, !c[t])) {
|
|
185
|
+
r = !0;
|
|
186
|
+
break;
|
|
189
187
|
}
|
|
190
|
-
e.apply({
|
|
188
|
+
o && e.apply({
|
|
191
189
|
type: "format",
|
|
192
190
|
range: n,
|
|
193
191
|
key: t,
|
|
@@ -196,7 +194,7 @@ function I(e, t, n = E(e.selection)) {
|
|
|
196
194
|
}
|
|
197
195
|
|
|
198
196
|
function P(e, t, n, r = e.selection[0]) {
|
|
199
|
-
const o =
|
|
197
|
+
const o = y(e.doc, r)[2];
|
|
200
198
|
e.apply({
|
|
201
199
|
type: "patch_node",
|
|
202
200
|
path: o,
|
|
@@ -206,7 +204,7 @@ function P(e, t, n, r = e.selection[0]) {
|
|
|
206
204
|
}
|
|
207
205
|
|
|
208
206
|
function N(e, t, n, r, o = e.selection[0]) {
|
|
209
|
-
const [c, , i] =
|
|
207
|
+
const [c, , i] = y(e.doc, o);
|
|
210
208
|
e.apply({
|
|
211
209
|
type: "patch_node",
|
|
212
210
|
path: i,
|
|
@@ -220,15 +218,15 @@ var L = e => 1 === e.nodeType, C = e => 8 === e.nodeType, H = new Map([ [ "BR",
|
|
|
220
218
|
const n = e.getRangeAt(0);
|
|
221
219
|
if (t.contains(n.commonAncestorContainer)) return n;
|
|
222
220
|
}
|
|
223
|
-
}, G = (e, t,
|
|
224
|
-
const c =
|
|
225
|
-
return L(
|
|
226
|
-
L(h) && e !== h ?
|
|
227
|
-
|
|
221
|
+
}, G = (e, t, n, r) => {
|
|
222
|
+
const [o, c] = ((e, [t, n]) => [ m(e, t), m(e, n) ])(n, r), i = W(e), s = E(r), l = r[0] - r[1] > 0, a = l ? o : c, f = X(e, t, l ? c : o), u = s ? f : X(e, t, a), d = i.createRange(), [p, y] = f, [h, g] = u;
|
|
223
|
+
return L(p) && e !== p ? y < 1 ? d.setStartBefore(p) : d.setStartAfter(p) : d.setStart(p, y),
|
|
224
|
+
L(h) && e !== h ? g < 1 ? d.setEndBefore(h) : d.setEndAfter(h) : d.setEnd(h, g),
|
|
225
|
+
d;
|
|
228
226
|
}, J = (e, t, n, r, o) => {
|
|
229
227
|
const c = q(e);
|
|
230
228
|
if (o || z(c, e)) {
|
|
231
|
-
const o = G(e, t, n, r), i = r > 0;
|
|
229
|
+
const o = G(e, t, n, r), i = r[0] - r[1] > 0;
|
|
232
230
|
c.removeAllRanges(), c.addRange(o), i && (c.collapseToEnd(), c.extend(o.startContainer, o.startOffset));
|
|
233
231
|
}
|
|
234
232
|
}, X = (e, t, [n, r]) => t(({t, o, i: c, l: i}) => {
|
|
@@ -285,14 +283,14 @@ var L = e => 1 === e.nodeType, C = e => 8 === e.nodeType, H = new Map([ [ "BR",
|
|
|
285
283
|
if (t.length) {
|
|
286
284
|
const n = e.length;
|
|
287
285
|
if (e.push(...t), n) {
|
|
288
|
-
const t = e[n - 1], r = e[n];
|
|
289
|
-
|
|
286
|
+
const t = e[n - 1], r = e[n], o = l(t), c = l(r);
|
|
287
|
+
o ? c && ((e, t = 0, n = e.length - 1) => {
|
|
290
288
|
let r = t + 1;
|
|
291
289
|
for (;r <= n; ) {
|
|
292
290
|
const t = e[r - 1], o = e[r];
|
|
293
291
|
e[r - 1] = ne(t, o), e.splice(r, 1), n--;
|
|
294
292
|
}
|
|
295
|
-
})(e, n - 1, n) :
|
|
293
|
+
})(e, n - 1, n) : o || c || ((e, t = 0, n = e.length - 1) => {
|
|
296
294
|
let r = t + 1;
|
|
297
295
|
for (;r <= n; ) {
|
|
298
296
|
const t = e[r - 1], o = e[r];
|
|
@@ -308,6 +306,9 @@ var L = e => 1 === e.nodeType, C = e => 8 === e.nodeType, H = new Map([ [ "BR",
|
|
|
308
306
|
})(e, n - 1, n);
|
|
309
307
|
}
|
|
310
308
|
}
|
|
309
|
+
e.length || e.push({
|
|
310
|
+
text: ""
|
|
311
|
+
});
|
|
311
312
|
}, ne = (...e) => ({
|
|
312
313
|
...e[0],
|
|
313
314
|
children: e.reduce((e, t) => (te(e, t.children), e), [])
|
|
@@ -389,42 +390,42 @@ var L = e => 1 === e.nodeType, C = e => 8 === e.nodeType, H = new Map([ [ "BR",
|
|
|
389
390
|
};
|
|
390
391
|
|
|
391
392
|
function ue(e) {
|
|
392
|
-
let t = 0, n = 0,
|
|
393
|
-
const
|
|
394
|
-
if (
|
|
395
|
-
const n =
|
|
393
|
+
let t = 0, n = 0, r = !1;
|
|
394
|
+
const o = Date.now, c = [ [ e.doc, e.selection, [] ] ], i = () => c[t], s = () => t > 0, l = () => t < c.length - 1, a = () => {
|
|
395
|
+
if (s()) {
|
|
396
|
+
const n = i()[1];
|
|
396
397
|
t--;
|
|
397
|
-
const
|
|
398
|
-
|
|
398
|
+
const o = e.doc;
|
|
399
|
+
r = !0, e.exec(D, i()[0].children), r = !1, o !== e.doc && (e.selection = n);
|
|
399
400
|
}
|
|
400
|
-
},
|
|
401
|
-
if (
|
|
401
|
+
}, f = () => {
|
|
402
|
+
if (l()) {
|
|
402
403
|
t++;
|
|
403
|
-
const [n,
|
|
404
|
-
|
|
404
|
+
const [n, o, c] = i(), s = e.doc;
|
|
405
|
+
r = !0, e.exec(D, n.children), r = !1, s !== e.doc && (e.selection = [ ie(o[0], c), ie(o[1], c) ]);
|
|
405
406
|
}
|
|
406
407
|
};
|
|
407
|
-
e.hook("apply", (
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
const e =
|
|
408
|
+
e.hook("apply", (i, s) => {
|
|
409
|
+
if (r) return;
|
|
410
|
+
const l = e.doc, a = e.selection;
|
|
411
|
+
s(i);
|
|
412
|
+
const f = e.doc;
|
|
413
|
+
if (l !== f) {
|
|
414
|
+
const e = o();
|
|
414
415
|
if (0 === t || e - n >= 500) {
|
|
415
416
|
t++;
|
|
416
|
-
const e = [
|
|
417
|
-
t >=
|
|
417
|
+
const e = [ l, a, [] ];
|
|
418
|
+
t >= c.length ? c.push(e) : c[t] = e;
|
|
418
419
|
}
|
|
419
|
-
n = e,
|
|
420
|
-
|
|
420
|
+
n = e, c[t][0] = f, c[t][2].push(i), c.length > t + 1 && (c.length = t + 1), t > 500 && (t--,
|
|
421
|
+
c.shift());
|
|
421
422
|
}
|
|
422
|
-
}), e.hook("keyboard", fe("Mod+Z",
|
|
423
|
+
}), e.hook("keyboard", fe("Mod+Z", a)), e.hook("keyboard", fe("Shift+Mod+Z", f)),
|
|
423
424
|
e.set(ue, {
|
|
424
|
-
undo:
|
|
425
|
-
redo:
|
|
426
|
-
undoable:
|
|
427
|
-
redoable:
|
|
425
|
+
undo: a,
|
|
426
|
+
redo: f,
|
|
427
|
+
undoable: s,
|
|
428
|
+
redoable: l
|
|
428
429
|
});
|
|
429
430
|
}
|
|
430
431
|
|
|
@@ -436,50 +437,50 @@ function pe(e) {
|
|
|
436
437
|
e.get(ue).redo();
|
|
437
438
|
}
|
|
438
439
|
|
|
439
|
-
function
|
|
440
|
+
function ye(e) {
|
|
440
441
|
return e.get(ue).undoable();
|
|
441
442
|
}
|
|
442
443
|
|
|
443
|
-
function
|
|
444
|
+
function he(e) {
|
|
444
445
|
return e.get(ue).redoable();
|
|
445
446
|
}
|
|
446
447
|
|
|
447
448
|
var ge = [], ke = () => {}, me = e => {
|
|
448
449
|
throw Error(e);
|
|
449
|
-
}, xe = ({doc: e, readonly: t = !1, schema: n, isBlock:
|
|
450
|
-
let
|
|
451
|
-
const
|
|
452
|
-
if (!n) return
|
|
450
|
+
}, xe = ({doc: e, readonly: t = !1, schema: n, isBlock: r = U, onWarn: a = console.warn, onError: f = me}) => {
|
|
451
|
+
let u = [ 0, 0 ];
|
|
452
|
+
const d = e => {
|
|
453
|
+
if (!n) return a("An unsafe operation was detected. We recommend using schema option."),
|
|
453
454
|
!0;
|
|
454
455
|
const t = n["~standard"].validate(e);
|
|
455
|
-
if (t instanceof Promise)
|
|
456
|
+
if (t instanceof Promise) f("async validate is not supported"); else {
|
|
456
457
|
if (!t.issues) return !0;
|
|
457
|
-
|
|
458
|
+
a(t.issues.map(e => e.message).join("\n"));
|
|
458
459
|
}
|
|
459
460
|
return !1;
|
|
460
461
|
};
|
|
461
|
-
n && !
|
|
462
|
-
const
|
|
463
|
-
const t =
|
|
464
|
-
t && (
|
|
465
|
-
|
|
462
|
+
n && !d(e) && f("Invalid document");
|
|
463
|
+
const h = /* @__PURE__ */ new Map, g = /* @__PURE__ */ new WeakMap, m = e => h.get(e) || ge, _ = /* @__PURE__ */ new Map, b = /* @__PURE__ */ new Set, M = e => {
|
|
464
|
+
const t = _.get(e);
|
|
465
|
+
t && (b.size || i(() => {
|
|
466
|
+
b.forEach(e => {
|
|
466
467
|
e();
|
|
467
|
-
}),
|
|
468
|
+
}), b.clear();
|
|
468
469
|
}), t.forEach(e => {
|
|
469
|
-
|
|
470
|
+
b.add(e);
|
|
470
471
|
}));
|
|
471
|
-
},
|
|
472
|
-
if (!t) if (Array.isArray(e)) for (const t of e)
|
|
473
|
-
return
|
|
474
|
-
},
|
|
475
|
-
const n = e,
|
|
476
|
-
let
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
const e =
|
|
480
|
-
|
|
481
|
-
} else if (
|
|
482
|
-
|
|
472
|
+
}, S = e => {
|
|
473
|
+
if (!t) if (Array.isArray(e)) for (const t of e) w(t); else w(e);
|
|
474
|
+
return O;
|
|
475
|
+
}, w = t => {
|
|
476
|
+
const n = e, r = m("apply"), o = r.length;
|
|
477
|
+
let c = 0;
|
|
478
|
+
const i = () => {
|
|
479
|
+
if (c < o) {
|
|
480
|
+
const e = c;
|
|
481
|
+
r[c](t, f), e === c && f();
|
|
482
|
+
} else if (c === o) {
|
|
483
|
+
c++;
|
|
483
484
|
try {
|
|
484
485
|
const [n, r] = ((e, t, n) => {
|
|
485
486
|
switch (n.type) {
|
|
@@ -494,7 +495,7 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
494
495
|
{
|
|
495
496
|
const {at: r, text: o} = n;
|
|
496
497
|
if (ce(e, r) && o) {
|
|
497
|
-
const [c, i] =
|
|
498
|
+
const [c, i] = y(e, r), l = p(c, i - 1);
|
|
498
499
|
let a;
|
|
499
500
|
if (l) {
|
|
500
501
|
const e = l[0];
|
|
@@ -516,7 +517,7 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
516
517
|
{
|
|
517
518
|
const {range: [t, r], key: o, value: c} = n;
|
|
518
519
|
if (ce(e, t) && ce(e, r) && t <= r) if (t === r) {
|
|
519
|
-
const [{children: n}, , r] =
|
|
520
|
+
const [{children: n}, , r] = y(e, t);
|
|
520
521
|
if (1 === n.length) {
|
|
521
522
|
const t = n[0];
|
|
522
523
|
s(t) && !t.text && (e = re(e, [ ...r, 0 ], {
|
|
@@ -532,7 +533,7 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
532
533
|
...e,
|
|
533
534
|
[o]: c
|
|
534
535
|
} : e;
|
|
535
|
-
e = oe(e, t, r,
|
|
536
|
+
e = oe(e, t, r, v(e, t, r).map(n));
|
|
536
537
|
}
|
|
537
538
|
break;
|
|
538
539
|
}
|
|
@@ -551,62 +552,62 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
551
552
|
}
|
|
552
553
|
}
|
|
553
554
|
return [ e, t ];
|
|
554
|
-
})(e,
|
|
555
|
-
(({type: e}) => e !== Q && e !== K)(t) && !
|
|
555
|
+
})(e, u, t);
|
|
556
|
+
(({type: e}) => e !== Q && e !== K)(t) && !d(n) || (e = n, A(r));
|
|
556
557
|
} catch (n) {
|
|
557
|
-
|
|
558
|
+
a("rollback operation: " + n);
|
|
558
559
|
}
|
|
559
560
|
}
|
|
560
|
-
},
|
|
561
|
-
e && (t = e),
|
|
561
|
+
}, f = e => {
|
|
562
|
+
e && (t = e), c++, i();
|
|
562
563
|
};
|
|
563
|
-
|
|
564
|
-
},
|
|
565
|
-
!((e, [t, n]) => ce(e, t) && ce(e, n))(e, t) ||
|
|
566
|
-
|
|
567
|
-
},
|
|
564
|
+
i(), n !== e && M("change");
|
|
565
|
+
}, A = t => {
|
|
566
|
+
!((e, [t, n]) => ce(e, t) && ce(e, n))(e, t) || u[0] === t[0] && u[1] === t[1] || (u = t,
|
|
567
|
+
M("selectionchange"));
|
|
568
|
+
}, O = {
|
|
568
569
|
get doc() {
|
|
569
570
|
return e;
|
|
570
571
|
},
|
|
571
572
|
get selection() {
|
|
572
|
-
return
|
|
573
|
+
return u;
|
|
573
574
|
},
|
|
574
575
|
set selection(e) {
|
|
575
|
-
|
|
576
|
+
A(e);
|
|
576
577
|
},
|
|
577
578
|
get readonly() {
|
|
578
579
|
return t;
|
|
579
580
|
},
|
|
580
581
|
set readonly(e) {
|
|
581
|
-
t = e,
|
|
582
|
+
t = e, M("readonly");
|
|
582
583
|
},
|
|
583
|
-
apply:
|
|
584
|
+
apply: S,
|
|
584
585
|
on: (e, t) => {
|
|
585
|
-
let n =
|
|
586
|
-
return n ||
|
|
586
|
+
let n = _.get(e);
|
|
587
|
+
return n || _.set(e, n = /* @__PURE__ */ new Set), n.add(t), () => {
|
|
587
588
|
n.delete(t);
|
|
588
589
|
};
|
|
589
590
|
},
|
|
590
591
|
hook: (e, t) => {
|
|
591
|
-
let n =
|
|
592
|
-
return n ||
|
|
592
|
+
let n = h.get(e);
|
|
593
|
+
return n || h.set(e, n = []), n.push(t), () => {
|
|
593
594
|
const e = n.indexOf(t);
|
|
594
595
|
-1 !== e && n.splice(e, 1);
|
|
595
596
|
};
|
|
596
597
|
},
|
|
597
598
|
exec: (e, ...t) => {
|
|
598
|
-
const n = e(
|
|
599
|
-
return void 0 === n ?
|
|
599
|
+
const n = e(O, ...t);
|
|
600
|
+
return void 0 === n ? O : n;
|
|
600
601
|
},
|
|
601
|
-
get: e => (
|
|
602
|
-
set: (e, t) => (
|
|
602
|
+
get: e => (g.has(e) || f("No value found for key"), g.get(e)),
|
|
603
|
+
set: (e, t) => (g.set(e, t), O),
|
|
603
604
|
input: n => {
|
|
604
|
-
if (!window.InputEvent || !c(InputEvent.prototype.getTargetRanges)) return
|
|
605
|
+
if (!window.InputEvent || !c(InputEvent.prototype.getTargetRanges)) return a("beforeinput event is not supported."),
|
|
605
606
|
ke;
|
|
606
|
-
const {contentEditable:
|
|
607
|
+
const {contentEditable: i, role: s, ariaMultiLine: l, ariaReadOnly: f} = n, d = n.style.whiteSpace;
|
|
607
608
|
n.role = "textbox", n.style.whiteSpace = "pre-wrap", n.ariaMultiLine = "true";
|
|
608
|
-
let p = !1,
|
|
609
|
-
const
|
|
609
|
+
let p = !1, y = null, h = !1, g = !1, _ = !1, b = u, v = null;
|
|
610
|
+
const M = W(n), w = ((e, t) => {
|
|
610
611
|
let n = null, r = null, o = null;
|
|
611
612
|
const c = () => {
|
|
612
613
|
if (null != o) return o;
|
|
@@ -673,29 +674,29 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
673
674
|
}
|
|
674
675
|
};
|
|
675
676
|
return a;
|
|
676
|
-
})(
|
|
677
|
+
})(M, r), R = () => {
|
|
677
678
|
n.contentEditable = t ? "false" : "true", n.ariaReadOnly = t ? "true" : null;
|
|
678
679
|
};
|
|
679
|
-
|
|
680
|
-
const
|
|
680
|
+
R();
|
|
681
|
+
const D = () => {
|
|
681
682
|
g || n.focus({
|
|
682
683
|
preventScroll: !0
|
|
683
684
|
});
|
|
685
|
+
}, B = () => {
|
|
686
|
+
v = null, u[0] === b[0] && u[1] === b[1] || (J(n, w, e, u), b = u);
|
|
684
687
|
}, I = () => {
|
|
685
|
-
|
|
686
|
-
}, P = () => {
|
|
687
|
-
|
|
688
|
-
}, N =
|
|
689
|
-
|
|
690
|
-
}), C =
|
|
691
|
-
|
|
692
|
-
}), F = D.on("readonly", O), U = e => {
|
|
693
|
-
for (const t of b("paste")) {
|
|
688
|
+
null != v && clearTimeout(v);
|
|
689
|
+
}, P = O.on("change", () => {
|
|
690
|
+
g || requestAnimationFrame(D);
|
|
691
|
+
}), N = O.on("selectionchange", () => {
|
|
692
|
+
u[0] === b[0] && u[1] === b[1] || (I(), v = setTimeout(B, 50));
|
|
693
|
+
}), C = O.on("readonly", R), F = e => {
|
|
694
|
+
for (const t of m("paste")) {
|
|
694
695
|
const n = t(e);
|
|
695
696
|
if (n) return n;
|
|
696
697
|
}
|
|
697
|
-
|
|
698
|
-
},
|
|
698
|
+
a("failed to serialize pasted data");
|
|
699
|
+
}, U = ((e, t) => {
|
|
699
700
|
let n = !1, r = [];
|
|
700
701
|
const o = e => {
|
|
701
702
|
n && r.push(...e);
|
|
@@ -732,28 +733,28 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
732
733
|
}
|
|
733
734
|
};
|
|
734
735
|
})(n, () => {
|
|
735
|
-
|
|
736
|
-
}),
|
|
737
|
-
|
|
736
|
+
I(), J(n, w, e, u);
|
|
737
|
+
}), G = () => {
|
|
738
|
+
A(b = x(e, ((e, t) => {
|
|
738
739
|
const n = q(e), r = z(n, e);
|
|
739
740
|
if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
|
|
740
741
|
const o = Z(e, t, r), c = V(n.anchorNode, n.focusNode);
|
|
741
742
|
return (0 === c ? n.anchorOffset > n.focusOffset : 2 & c) ? [ o[1], o[0] ] : o;
|
|
742
743
|
})(n, w)));
|
|
743
|
-
},
|
|
744
|
-
const t =
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
},
|
|
748
|
-
if (!
|
|
749
|
-
},
|
|
750
|
-
|
|
751
|
-
},
|
|
744
|
+
}, X = () => {
|
|
745
|
+
const t = U.v();
|
|
746
|
+
U._(!1), t.length && (U.m(t), M.removeEventListener("selectionchange", re), J(n, w, e, u, !0),
|
|
747
|
+
M.addEventListener("selectionchange", re)), y && (A(y[1]), S(y[0]), y = null), h = !1;
|
|
748
|
+
}, j = e => {
|
|
749
|
+
if (!h) for (const t of m("keyboard")) if (t(e)) return e.preventDefault(), void U._(!1);
|
|
750
|
+
}, K = () => {
|
|
751
|
+
h || X();
|
|
752
|
+
}, Q = t => {
|
|
752
753
|
t.preventDefault();
|
|
753
754
|
const r = t.inputType;
|
|
754
755
|
if (r.startsWith("format")) return;
|
|
755
756
|
if ("historyUndo" === r || "historyRedo" === r) return;
|
|
756
|
-
|
|
757
|
+
h ? U._(!0) : G();
|
|
757
758
|
const o = t.getTargetRanges()[0];
|
|
758
759
|
if (o) {
|
|
759
760
|
let c = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : t.data;
|
|
@@ -761,9 +762,9 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
761
762
|
const e = t.dataTransfer;
|
|
762
763
|
e && (c = e.getData("text/plain"));
|
|
763
764
|
}
|
|
764
|
-
|
|
765
|
-
const i =
|
|
766
|
-
|
|
765
|
+
y || (y = [ [], u ]);
|
|
766
|
+
const i = y[0], s = x(e, Z(n, w, o));
|
|
767
|
+
E(s) || i.push({
|
|
767
768
|
type: "delete",
|
|
768
769
|
range: s
|
|
769
770
|
}), c && i.push({
|
|
@@ -772,31 +773,31 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
772
773
|
text: c
|
|
773
774
|
});
|
|
774
775
|
}
|
|
775
|
-
|
|
776
|
+
h || X();
|
|
777
|
+
}, $ = () => {
|
|
778
|
+
h || G(), h = !0;
|
|
776
779
|
}, ee = () => {
|
|
777
|
-
|
|
780
|
+
X();
|
|
778
781
|
}, te = () => {
|
|
779
|
-
|
|
782
|
+
g = !0, G();
|
|
780
783
|
}, ne = () => {
|
|
781
|
-
g = !0, X();
|
|
782
|
-
}, re = () => {
|
|
783
784
|
g = !1;
|
|
784
|
-
},
|
|
785
|
-
g && !
|
|
785
|
+
}, re = () => {
|
|
786
|
+
g && !_ && G();
|
|
787
|
+
}, oe = e => {
|
|
788
|
+
if (G(), !E(u)) for (const t of m("copy")) t(e);
|
|
786
789
|
}, ce = e => {
|
|
787
|
-
|
|
790
|
+
e.preventDefault(), oe(e.clipboardData);
|
|
788
791
|
}, se = e => {
|
|
789
|
-
e.preventDefault(),
|
|
790
|
-
}, le = e => {
|
|
791
|
-
e.preventDefault(), t || (ce(e.clipboardData), A({
|
|
792
|
+
e.preventDefault(), t || (oe(e.clipboardData), S({
|
|
792
793
|
type: "delete",
|
|
793
|
-
range:
|
|
794
|
+
range: T(u)
|
|
794
795
|
}));
|
|
795
|
-
},
|
|
796
|
+
}, le = e => {
|
|
796
797
|
e.preventDefault();
|
|
797
|
-
const t =
|
|
798
|
+
const t = F(e.clipboardData);
|
|
798
799
|
if (t) {
|
|
799
|
-
const e =
|
|
800
|
+
const e = T(u), n = e[0], r = [ {
|
|
800
801
|
type: "delete",
|
|
801
802
|
range: e
|
|
802
803
|
} ];
|
|
@@ -808,9 +809,9 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
808
809
|
type: "insert_node",
|
|
809
810
|
at: n,
|
|
810
811
|
fragment: t
|
|
811
|
-
}),
|
|
812
|
+
}), S(r);
|
|
812
813
|
}
|
|
813
|
-
},
|
|
814
|
+
}, ae = t => {
|
|
814
815
|
t.preventDefault();
|
|
815
816
|
const r = t.dataTransfer, c = ((e, t, {clientX: n, clientY: r}) => {
|
|
816
817
|
const o = W(e);
|
|
@@ -825,11 +826,11 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
825
826
|
if (r && c) {
|
|
826
827
|
let t;
|
|
827
828
|
const n = [];
|
|
828
|
-
|
|
829
|
+
_ && n.push({
|
|
829
830
|
type: "delete",
|
|
830
|
-
range:
|
|
831
|
+
range: T(u)
|
|
831
832
|
});
|
|
832
|
-
const i =
|
|
833
|
+
const i = F(r);
|
|
833
834
|
if (i) {
|
|
834
835
|
const r = k(e, c), s = ie(r, n);
|
|
835
836
|
n.push(o(i) ? {
|
|
@@ -842,36 +843,37 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
842
843
|
fragment: i
|
|
843
844
|
}), t = [ s, ie(r, n) ];
|
|
844
845
|
}
|
|
845
|
-
|
|
846
|
+
S(n), t && A(t);
|
|
846
847
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
848
|
+
_ = !1;
|
|
849
|
+
}, fe = e => {
|
|
850
|
+
_ = !0, oe(e.dataTransfer);
|
|
851
|
+
}, ue = () => {
|
|
852
|
+
_ = !1;
|
|
851
853
|
};
|
|
852
|
-
|
|
853
|
-
n.addEventListener("beforeinput",
|
|
854
|
-
n.addEventListener("compositionend",
|
|
855
|
-
n.addEventListener("copy",
|
|
856
|
-
n.addEventListener("drop",
|
|
857
|
-
const
|
|
858
|
-
return
|
|
854
|
+
M.addEventListener("selectionchange", re), n.addEventListener("keydown", j), n.addEventListener("input", K),
|
|
855
|
+
n.addEventListener("beforeinput", Q), n.addEventListener("compositionstart", $),
|
|
856
|
+
n.addEventListener("compositionend", ee), n.addEventListener("focus", te), n.addEventListener("blur", ne),
|
|
857
|
+
n.addEventListener("copy", ce), n.addEventListener("cut", se), n.addEventListener("paste", le),
|
|
858
|
+
n.addEventListener("drop", ae), n.addEventListener("dragstart", fe), n.addEventListener("dragend", ue);
|
|
859
|
+
const de = [];
|
|
860
|
+
return m("mount").forEach(e => {
|
|
859
861
|
const t = e(n, w);
|
|
860
|
-
t &&
|
|
862
|
+
t && de.push(t);
|
|
861
863
|
}), () => {
|
|
862
|
-
p || (p = !0,
|
|
863
|
-
n.ariaReadOnly =
|
|
864
|
-
n.removeEventListener("keydown",
|
|
865
|
-
n.removeEventListener("compositionstart",
|
|
866
|
-
n.removeEventListener("focus",
|
|
867
|
-
n.removeEventListener("cut",
|
|
868
|
-
n.removeEventListener("dragstart",
|
|
864
|
+
p || (p = !0, P(), N(), C(), n.contentEditable = i, n.role = s, n.ariaMultiLine = l,
|
|
865
|
+
n.ariaReadOnly = f, n.style.whiteSpace = d, U.T(), M.removeEventListener("selectionchange", re),
|
|
866
|
+
n.removeEventListener("keydown", j), n.removeEventListener("input", K), n.removeEventListener("beforeinput", Q),
|
|
867
|
+
n.removeEventListener("compositionstart", $), n.removeEventListener("compositionend", ee),
|
|
868
|
+
n.removeEventListener("focus", te), n.removeEventListener("blur", ne), n.removeEventListener("copy", ce),
|
|
869
|
+
n.removeEventListener("cut", se), n.removeEventListener("paste", le), n.removeEventListener("drop", ae),
|
|
870
|
+
n.removeEventListener("dragstart", fe), n.removeEventListener("dragend", ue), de.forEach(e => {
|
|
869
871
|
e();
|
|
870
872
|
}));
|
|
871
873
|
};
|
|
872
874
|
}
|
|
873
875
|
};
|
|
874
|
-
return
|
|
876
|
+
return O.exec(ue), O;
|
|
875
877
|
}, _e = (e, t) => {
|
|
876
878
|
e.hook("paste", e => {
|
|
877
879
|
for (const n of e.items) if ("file" === n.kind) {
|
|
@@ -890,7 +892,7 @@ var ge = [], ke = () => {}, me = e => {
|
|
|
890
892
|
function be(e, t) {
|
|
891
893
|
const n = t && t.voidToString;
|
|
892
894
|
e.hook("copy", t => {
|
|
893
|
-
t.setData("text/plain",
|
|
895
|
+
t.setData("text/plain", b(e.doc, ...T(e.selection), n));
|
|
894
896
|
}), e.hook("paste", e => e.getData("text/plain"));
|
|
895
897
|
}
|
|
896
898
|
|
|
@@ -942,7 +944,7 @@ var Te = "application/x-editate-editor";
|
|
|
942
944
|
|
|
943
945
|
function Ee(e) {
|
|
944
946
|
e.hook("copy", t => {
|
|
945
|
-
t.setData(Te, JSON.stringify(
|
|
947
|
+
t.setData(Te, JSON.stringify(v(e.doc, ...T(e.selection))));
|
|
946
948
|
}), e.hook("paste", e => {
|
|
947
949
|
try {
|
|
948
950
|
return JSON.parse(e.getData(Te));
|
|
@@ -976,7 +978,7 @@ function we(e, t) {
|
|
|
976
978
|
c || (c = !0, requestAnimationFrame(() => {
|
|
977
979
|
c = !1, o && t(() => {
|
|
978
980
|
const t = e.selection;
|
|
979
|
-
return G(n, r,
|
|
981
|
+
return G(n, r, e.doc, t).getBoundingClientRect();
|
|
980
982
|
});
|
|
981
983
|
}));
|
|
982
984
|
});
|
|
@@ -1012,9 +1014,9 @@ var Oe = ({text: e, singleline: t, onChange: n, ...r}) => {
|
|
|
1012
1014
|
}
|
|
1013
1015
|
}).exec(be);
|
|
1014
1016
|
return t && o.exec(Ae), o.on("change", () => {
|
|
1015
|
-
n(
|
|
1017
|
+
n(b(o.doc));
|
|
1016
1018
|
}), o;
|
|
1017
1019
|
};
|
|
1018
1020
|
|
|
1019
|
-
export { w as Delete, B as Format, O as InsertNode, A as InsertText, pe as Redo,
|
|
1021
|
+
export { w as Delete, B as Format, O as InsertNode, A as InsertText, S as LeafsInRange, pe as Redo, he as Redoable, D as ReplaceDoc, R as ReplaceText, P as SetBlockAttr, N as ToggleBlockAttr, I as ToggleFormat, de as Undo, ye as Undoable, xe as createEditor, Oe as createPlainEditor, Me as debugPlugin, _e as fileTransferPlugin, y as getBlockAt, p as getChildAt, h as getLeafAt, d as getNodeSize, ve as htmlTransferPlugin, Ee as internalTranferPlugin, _ as iterLeafs, Se as keymapPlugin, be as plainTransferPlugin, we as selectionRectPlugin, Ae as singlelinePlugin, b as sliceText };
|
|
1020
1022
|
//# sourceMappingURL=index.js.map
|