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.cjs
CHANGED
|
@@ -36,15 +36,15 @@ var {min: e, max: t} = Math, {keys: n, is: r} = Object, o = e => "string" == typ
|
|
|
36
36
|
t = r[1], e = o, n.push(r[2]);
|
|
37
37
|
}
|
|
38
38
|
return [ e, t, n ];
|
|
39
|
-
},
|
|
39
|
+
}, y = (e, t) => {
|
|
40
40
|
const [n, r] = x(e, t), o = p(n, r);
|
|
41
41
|
return o ? [ o[0], o[1] ] : null;
|
|
42
|
-
},
|
|
42
|
+
}, h = (e, t) => {
|
|
43
43
|
const n = e.children, r = p(e, t);
|
|
44
44
|
if (r) {
|
|
45
45
|
const [t, o, s] = r;
|
|
46
46
|
if (l(t)) {
|
|
47
|
-
const [r, c] =
|
|
47
|
+
const [r, c] = h(t, o), i = n.slice(0, s), l = n.slice(s + 1);
|
|
48
48
|
return i.push(r), l.unshift(c), [ {
|
|
49
49
|
...e,
|
|
50
50
|
children: i
|
|
@@ -89,9 +89,9 @@ var {min: e, max: t} = Math, {keys: n, is: r} = Object, o = e => "string" == typ
|
|
|
89
89
|
}, k = (e, t) => {
|
|
90
90
|
const [, n, r] = x(e, t);
|
|
91
91
|
return [ r, n ];
|
|
92
|
-
}, m = (e, [t, n]) => [ g(e, t), g(e, n) ]
|
|
92
|
+
}, m = (e, [t, n]) => [ g(e, t), g(e, n) ];
|
|
93
93
|
|
|
94
|
-
function*
|
|
94
|
+
function* _(e, t, n) {
|
|
95
95
|
if (l(e)) for (const r of function*(e, t, n) {
|
|
96
96
|
if (t >= n) return;
|
|
97
97
|
if (!l(e)) return;
|
|
@@ -104,12 +104,12 @@ function* b(e, t, n) {
|
|
|
104
104
|
yield [ e, o ], s++, o += d(e), l(e) && o++;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
}(e, t, n)) if (l(r[0])) for (const e of
|
|
107
|
+
}(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 ];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
var
|
|
110
|
+
var b = (n, r = 0, o = 1 / 0, s) => {
|
|
111
111
|
let c = "", l = r;
|
|
112
|
-
for (const [a, f] of
|
|
112
|
+
for (const [a, f] of _(n, r, o)) {
|
|
113
113
|
for (let e = f - l; e > 0; e--) c += "\n";
|
|
114
114
|
const n = d(a), u = f + n;
|
|
115
115
|
if (i(a)) {
|
|
@@ -120,7 +120,14 @@ var v = (n, r = 0, o = 1 / 0, s) => {
|
|
|
120
120
|
}
|
|
121
121
|
for (let t = e(o, d(n)) - l; t > 0; t--) c += "\n";
|
|
122
122
|
return c;
|
|
123
|
-
},
|
|
123
|
+
}, v = (e, t, n) => t >= n ? [] : h(h(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;
|
|
124
|
+
|
|
125
|
+
function* S(e, t = T(e.selection)) {
|
|
126
|
+
if (E(t)) {
|
|
127
|
+
const n = y(e.doc, t[0])?.[0];
|
|
128
|
+
n && (yield n);
|
|
129
|
+
} else for (const [n, r] of _(e.doc, ...t)) M(t, [ r, r + d(n) ]) && (yield n);
|
|
130
|
+
}
|
|
124
131
|
|
|
125
132
|
function w(e, t) {
|
|
126
133
|
e.apply({
|
|
@@ -136,15 +143,15 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
136
143
|
const n = e.getRangeAt(0);
|
|
137
144
|
if (t.contains(n.commonAncestorContainer)) return n;
|
|
138
145
|
}
|
|
139
|
-
}, C = (e, t,
|
|
140
|
-
const s =
|
|
141
|
-
return A(
|
|
142
|
-
A(
|
|
143
|
-
|
|
146
|
+
}, C = (e, t, n, r) => {
|
|
147
|
+
const [o, s] = ((e, [t, n]) => [ k(e, t), k(e, n) ])(n, r), c = P(e), i = E(r), l = r[0] - r[1] > 0, a = l ? o : s, f = F(e, t, l ? s : o), u = i ? f : F(e, t, a), d = c.createRange(), [p, x] = f, [y, h] = u;
|
|
148
|
+
return A(p) && e !== p ? x < 1 ? d.setStartBefore(p) : d.setStartAfter(p) : d.setStart(p, x),
|
|
149
|
+
A(y) && e !== y ? h < 1 ? d.setEndBefore(y) : d.setEndAfter(y) : d.setEnd(y, h),
|
|
150
|
+
d;
|
|
144
151
|
}, H = (e, t, n, r, o) => {
|
|
145
152
|
const s = N(e);
|
|
146
153
|
if (o || L(s, e)) {
|
|
147
|
-
const o = C(e, t, n, r), c = r > 0;
|
|
154
|
+
const o = C(e, t, n, r), c = r[0] - r[1] > 0;
|
|
148
155
|
s.removeAllRanges(), s.addRange(o), c && (s.collapseToEnd(), s.extend(o.startContainer, o.startOffset));
|
|
149
156
|
}
|
|
150
157
|
}, F = (e, t, [n, r]) => t(({t, o, i: s, l: c}) => {
|
|
@@ -201,14 +208,14 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
201
208
|
if (t.length) {
|
|
202
209
|
const n = e.length;
|
|
203
210
|
if (e.push(...t), n) {
|
|
204
|
-
const t = e[n - 1], r = e[n];
|
|
205
|
-
|
|
211
|
+
const t = e[n - 1], r = e[n], o = l(t), s = l(r);
|
|
212
|
+
o ? s && ((e, t = 0, n = e.length - 1) => {
|
|
206
213
|
let r = t + 1;
|
|
207
214
|
for (;r <= n; ) {
|
|
208
215
|
const t = e[r - 1], o = e[r];
|
|
209
216
|
e[r - 1] = X(t, o), e.splice(r, 1), n--;
|
|
210
217
|
}
|
|
211
|
-
})(e, n - 1, n) :
|
|
218
|
+
})(e, n - 1, n) : o || s || ((e, t = 0, n = e.length - 1) => {
|
|
212
219
|
let r = t + 1;
|
|
213
220
|
for (;r <= n; ) {
|
|
214
221
|
const t = e[r - 1], o = e[r];
|
|
@@ -224,6 +231,9 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
224
231
|
})(e, n - 1, n);
|
|
225
232
|
}
|
|
226
233
|
}
|
|
234
|
+
e.length || e.push({
|
|
235
|
+
text: ""
|
|
236
|
+
});
|
|
227
237
|
}, X = (...e) => ({
|
|
228
238
|
...e[0],
|
|
229
239
|
children: e.reduce((e, t) => (j(e, t.children), e), [])
|
|
@@ -240,7 +250,7 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
240
250
|
}
|
|
241
251
|
return n;
|
|
242
252
|
}, Z = (e, t, n, r) => {
|
|
243
|
-
const [o, s] =
|
|
253
|
+
const [o, s] = h(e, t), c = t < n ? h(e, n)[1] : s, i = a(e.children);
|
|
244
254
|
a(r) ? i || (r = X(...r).children) : i && (r = [ {
|
|
245
255
|
children: r
|
|
246
256
|
} ]);
|
|
@@ -305,81 +315,81 @@ var A = e => 1 === e.nodeType, O = e => 8 === e.nodeType, R = new Map([ [ "BR",
|
|
|
305
315
|
};
|
|
306
316
|
|
|
307
317
|
function re(e) {
|
|
308
|
-
let t = 0, n = 0,
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
const n =
|
|
318
|
+
let t = 0, n = 0, r = !1;
|
|
319
|
+
const o = Date.now, s = [ [ e.doc, e.selection, [] ] ], c = () => s[t], i = () => t > 0, l = () => t < s.length - 1, a = () => {
|
|
320
|
+
if (i()) {
|
|
321
|
+
const n = c()[1];
|
|
312
322
|
t--;
|
|
313
|
-
const
|
|
314
|
-
|
|
323
|
+
const o = e.doc;
|
|
324
|
+
r = !0, e.exec(w, c()[0].children), r = !1, o !== e.doc && (e.selection = n);
|
|
315
325
|
}
|
|
316
|
-
},
|
|
317
|
-
if (
|
|
326
|
+
}, f = () => {
|
|
327
|
+
if (l()) {
|
|
318
328
|
t++;
|
|
319
|
-
const [n,
|
|
320
|
-
|
|
329
|
+
const [n, o, s] = c(), i = e.doc;
|
|
330
|
+
r = !0, e.exec(w, n.children), r = !1, i !== e.doc && (e.selection = [ Q(o[0], s), Q(o[1], s) ]);
|
|
321
331
|
}
|
|
322
332
|
};
|
|
323
|
-
e.hook("apply", (
|
|
324
|
-
if (
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
if (
|
|
329
|
-
const e =
|
|
333
|
+
e.hook("apply", (c, i) => {
|
|
334
|
+
if (r) return;
|
|
335
|
+
const l = e.doc, a = e.selection;
|
|
336
|
+
i(c);
|
|
337
|
+
const f = e.doc;
|
|
338
|
+
if (l !== f) {
|
|
339
|
+
const e = o();
|
|
330
340
|
if (0 === t || e - n >= 500) {
|
|
331
341
|
t++;
|
|
332
|
-
const e = [
|
|
333
|
-
t >=
|
|
342
|
+
const e = [ l, a, [] ];
|
|
343
|
+
t >= s.length ? s.push(e) : s[t] = e;
|
|
334
344
|
}
|
|
335
|
-
n = e,
|
|
336
|
-
|
|
345
|
+
n = e, s[t][0] = f, s[t][2].push(c), s.length > t + 1 && (s.length = t + 1), t > 500 && (t--,
|
|
346
|
+
s.shift());
|
|
337
347
|
}
|
|
338
|
-
}), e.hook("keyboard", ne("Mod+Z",
|
|
348
|
+
}), e.hook("keyboard", ne("Mod+Z", a)), e.hook("keyboard", ne("Shift+Mod+Z", f)),
|
|
339
349
|
e.set(re, {
|
|
340
|
-
undo:
|
|
341
|
-
redo:
|
|
342
|
-
undoable:
|
|
343
|
-
redoable:
|
|
350
|
+
undo: a,
|
|
351
|
+
redo: f,
|
|
352
|
+
undoable: i,
|
|
353
|
+
redoable: l
|
|
344
354
|
});
|
|
345
355
|
}
|
|
346
356
|
|
|
347
357
|
var oe = [], se = () => {}, ce = e => {
|
|
348
358
|
throw Error(e);
|
|
349
|
-
}, ie = ({doc: e, readonly: t = !1, schema: n, isBlock:
|
|
350
|
-
let
|
|
351
|
-
const
|
|
352
|
-
if (!n) return
|
|
359
|
+
}, ie = ({doc: e, readonly: t = !1, schema: n, isBlock: r = B, onWarn: a = console.warn, onError: f = ce}) => {
|
|
360
|
+
let u = [ 0, 0 ];
|
|
361
|
+
const d = e => {
|
|
362
|
+
if (!n) return a("An unsafe operation was detected. We recommend using schema option."),
|
|
353
363
|
!0;
|
|
354
364
|
const t = n["~standard"].validate(e);
|
|
355
|
-
if (t instanceof Promise)
|
|
365
|
+
if (t instanceof Promise) f("async validate is not supported"); else {
|
|
356
366
|
if (!t.issues) return !0;
|
|
357
|
-
|
|
367
|
+
a(t.issues.map(e => e.message).join("\n"));
|
|
358
368
|
}
|
|
359
369
|
return !1;
|
|
360
370
|
};
|
|
361
|
-
n && !
|
|
362
|
-
const y = new Map,
|
|
363
|
-
const t =
|
|
364
|
-
t && (
|
|
365
|
-
|
|
371
|
+
n && !d(e) && f("Invalid document");
|
|
372
|
+
const y = new Map, h = new WeakMap, k = e => y.get(e) || oe, _ = new Map, b = new Set, M = e => {
|
|
373
|
+
const t = _.get(e);
|
|
374
|
+
t && (b.size || c(() => {
|
|
375
|
+
b.forEach(e => {
|
|
366
376
|
e();
|
|
367
|
-
}),
|
|
377
|
+
}), b.clear();
|
|
368
378
|
}), t.forEach(e => {
|
|
369
|
-
|
|
379
|
+
b.add(e);
|
|
370
380
|
}));
|
|
371
|
-
},
|
|
372
|
-
if (!t) if (Array.isArray(e)) for (const t of e)
|
|
373
|
-
return
|
|
374
|
-
},
|
|
375
|
-
const n = e,
|
|
376
|
-
let
|
|
377
|
-
const
|
|
378
|
-
if (
|
|
379
|
-
const e =
|
|
380
|
-
|
|
381
|
-
} else if (
|
|
382
|
-
|
|
381
|
+
}, S = e => {
|
|
382
|
+
if (!t) if (Array.isArray(e)) for (const t of e) w(t); else w(e);
|
|
383
|
+
return D;
|
|
384
|
+
}, w = t => {
|
|
385
|
+
const n = e, r = k("apply"), o = r.length;
|
|
386
|
+
let s = 0;
|
|
387
|
+
const c = () => {
|
|
388
|
+
if (s < o) {
|
|
389
|
+
const e = s;
|
|
390
|
+
r[s](t, f), e === s && f();
|
|
391
|
+
} else if (s === o) {
|
|
392
|
+
s++;
|
|
383
393
|
try {
|
|
384
394
|
const [n, r] = ((e, t, n) => {
|
|
385
395
|
switch (n.type) {
|
|
@@ -432,7 +442,7 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
432
442
|
...e,
|
|
433
443
|
[o]: s
|
|
434
444
|
} : e;
|
|
435
|
-
e = Z(e, t, r,
|
|
445
|
+
e = Z(e, t, r, v(e, t, r).map(n));
|
|
436
446
|
}
|
|
437
447
|
break;
|
|
438
448
|
}
|
|
@@ -451,39 +461,39 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
451
461
|
}
|
|
452
462
|
}
|
|
453
463
|
return [ e, t ];
|
|
454
|
-
})(e,
|
|
455
|
-
(({type: e}) => e !== z && e !== q)(t) && !
|
|
464
|
+
})(e, u, t);
|
|
465
|
+
(({type: e}) => e !== z && e !== q)(t) && !d(n) || (e = n, O(r));
|
|
456
466
|
} catch (n) {
|
|
457
|
-
|
|
467
|
+
a("rollback operation: " + n);
|
|
458
468
|
}
|
|
459
469
|
}
|
|
460
|
-
},
|
|
461
|
-
e && (t = e),
|
|
470
|
+
}, f = e => {
|
|
471
|
+
e && (t = e), s++, c();
|
|
462
472
|
};
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
!((e, [t, n]) => K(e, t) && K(e, n))(e, t) ||
|
|
466
|
-
|
|
467
|
-
},
|
|
473
|
+
c(), n !== e && M("change");
|
|
474
|
+
}, O = t => {
|
|
475
|
+
!((e, [t, n]) => K(e, t) && K(e, n))(e, t) || u[0] === t[0] && u[1] === t[1] || (u = t,
|
|
476
|
+
M("selectionchange"));
|
|
477
|
+
}, D = {
|
|
468
478
|
get doc() {
|
|
469
479
|
return e;
|
|
470
480
|
},
|
|
471
481
|
get selection() {
|
|
472
|
-
return
|
|
482
|
+
return u;
|
|
473
483
|
},
|
|
474
484
|
set selection(e) {
|
|
475
|
-
|
|
485
|
+
O(e);
|
|
476
486
|
},
|
|
477
487
|
get readonly() {
|
|
478
488
|
return t;
|
|
479
489
|
},
|
|
480
490
|
set readonly(e) {
|
|
481
|
-
t = e,
|
|
491
|
+
t = e, M("readonly");
|
|
482
492
|
},
|
|
483
|
-
apply:
|
|
493
|
+
apply: S,
|
|
484
494
|
on: (e, t) => {
|
|
485
|
-
let n =
|
|
486
|
-
return n ||
|
|
495
|
+
let n = _.get(e);
|
|
496
|
+
return n || _.set(e, n = new Set), n.add(t), () => {
|
|
487
497
|
n.delete(t);
|
|
488
498
|
};
|
|
489
499
|
},
|
|
@@ -495,18 +505,18 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
495
505
|
};
|
|
496
506
|
},
|
|
497
507
|
exec: (e, ...t) => {
|
|
498
|
-
const n = e(
|
|
499
|
-
return void 0 === n ?
|
|
508
|
+
const n = e(D, ...t);
|
|
509
|
+
return void 0 === n ? D : n;
|
|
500
510
|
},
|
|
501
|
-
get: e => (
|
|
502
|
-
set: (e, t) => (
|
|
511
|
+
get: e => (h.has(e) || f("No value found for key"), h.get(e)),
|
|
512
|
+
set: (e, t) => (h.set(e, t), D),
|
|
503
513
|
input: n => {
|
|
504
|
-
if (!window.InputEvent || !s(InputEvent.prototype.getTargetRanges)) return
|
|
514
|
+
if (!window.InputEvent || !s(InputEvent.prototype.getTargetRanges)) return a("beforeinput event is not supported."),
|
|
505
515
|
se;
|
|
506
|
-
const {contentEditable:
|
|
516
|
+
const {contentEditable: c, role: i, ariaMultiLine: l, ariaReadOnly: f} = n, d = n.style.whiteSpace;
|
|
507
517
|
n.role = "textbox", n.style.whiteSpace = "pre-wrap", n.ariaMultiLine = "true";
|
|
508
|
-
let p = !1, x = null,
|
|
509
|
-
const
|
|
518
|
+
let p = !1, x = null, y = !1, h = !1, _ = !1, b = u, v = null;
|
|
519
|
+
const M = P(n), w = ((e, t) => {
|
|
510
520
|
let n = null, r = null, o = null;
|
|
511
521
|
const s = () => {
|
|
512
522
|
if (null != o) return o;
|
|
@@ -573,29 +583,29 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
573
583
|
}
|
|
574
584
|
};
|
|
575
585
|
return a;
|
|
576
|
-
})(
|
|
586
|
+
})(M, r), B = () => {
|
|
577
587
|
n.contentEditable = t ? "false" : "true", n.ariaReadOnly = t ? "true" : null;
|
|
578
588
|
};
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
589
|
+
B();
|
|
590
|
+
const C = () => {
|
|
591
|
+
h || n.focus({
|
|
582
592
|
preventScroll: !0
|
|
583
593
|
});
|
|
594
|
+
}, F = () => {
|
|
595
|
+
v = null, u[0] === b[0] && u[1] === b[1] || (H(n, w, e, u), b = u);
|
|
584
596
|
}, W = () => {
|
|
585
|
-
|
|
586
|
-
}, q = () => {
|
|
587
|
-
|
|
588
|
-
}, z =
|
|
589
|
-
|
|
590
|
-
}), G =
|
|
591
|
-
|
|
592
|
-
}), J = F.on("readonly", D), j = e => {
|
|
593
|
-
for (const t of b("paste")) {
|
|
597
|
+
null != v && clearTimeout(v);
|
|
598
|
+
}, q = D.on("change", () => {
|
|
599
|
+
h || requestAnimationFrame(C);
|
|
600
|
+
}), z = D.on("selectionchange", () => {
|
|
601
|
+
u[0] === b[0] && u[1] === b[1] || (W(), v = setTimeout(F, 50));
|
|
602
|
+
}), G = D.on("readonly", B), J = e => {
|
|
603
|
+
for (const t of k("paste")) {
|
|
594
604
|
const n = t(e);
|
|
595
605
|
if (n) return n;
|
|
596
606
|
}
|
|
597
|
-
|
|
598
|
-
},
|
|
607
|
+
a("failed to serialize pasted data");
|
|
608
|
+
}, j = ((e, t) => {
|
|
599
609
|
let n = !1, r = [];
|
|
600
610
|
const o = e => {
|
|
601
611
|
n && r.push(...e);
|
|
@@ -632,28 +642,28 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
632
642
|
}
|
|
633
643
|
};
|
|
634
644
|
})(n, () => {
|
|
635
|
-
|
|
636
|
-
}),
|
|
637
|
-
|
|
645
|
+
W(), H(n, w, e, u);
|
|
646
|
+
}), X = () => {
|
|
647
|
+
O(b = m(e, ((e, t) => {
|
|
638
648
|
const n = N(e), r = L(n, e);
|
|
639
649
|
if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
|
|
640
650
|
const o = V(e, t, r), s = I(n.anchorNode, n.focusNode);
|
|
641
651
|
return (0 === s ? n.anchorOffset > n.focusOffset : 2 & s) ? [ o[1], o[0] ] : o;
|
|
642
652
|
})(n, w)));
|
|
643
|
-
},
|
|
644
|
-
const t =
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
},
|
|
648
|
-
if (!
|
|
649
|
-
},
|
|
650
|
-
|
|
651
|
-
},
|
|
653
|
+
}, Y = () => {
|
|
654
|
+
const t = j.v();
|
|
655
|
+
j._(!1), t.length && (j.m(t), M.removeEventListener("selectionchange", oe), H(n, w, e, u, !0),
|
|
656
|
+
M.addEventListener("selectionchange", oe)), x && (O(x[1]), S(x[0]), x = null), y = !1;
|
|
657
|
+
}, Z = e => {
|
|
658
|
+
if (!y) for (const t of k("keyboard")) if (t(e)) return e.preventDefault(), void j._(!1);
|
|
659
|
+
}, K = () => {
|
|
660
|
+
y || Y();
|
|
661
|
+
}, $ = t => {
|
|
652
662
|
t.preventDefault();
|
|
653
663
|
const r = t.inputType;
|
|
654
664
|
if (r.startsWith("format")) return;
|
|
655
665
|
if ("historyUndo" === r || "historyRedo" === r) return;
|
|
656
|
-
|
|
666
|
+
y ? j._(!0) : X();
|
|
657
667
|
const o = t.getTargetRanges()[0];
|
|
658
668
|
if (o) {
|
|
659
669
|
let s = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : t.data;
|
|
@@ -661,9 +671,9 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
661
671
|
const e = t.dataTransfer;
|
|
662
672
|
e && (s = e.getData("text/plain"));
|
|
663
673
|
}
|
|
664
|
-
x || (x = [ [],
|
|
674
|
+
x || (x = [ [], u ]);
|
|
665
675
|
const c = x[0], i = m(e, V(n, w, o));
|
|
666
|
-
|
|
676
|
+
E(i) || c.push({
|
|
667
677
|
type: "delete",
|
|
668
678
|
range: i
|
|
669
679
|
}), s && c.push({
|
|
@@ -672,31 +682,31 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
672
682
|
text: s
|
|
673
683
|
});
|
|
674
684
|
}
|
|
675
|
-
|
|
685
|
+
y || Y();
|
|
686
|
+
}, ee = () => {
|
|
687
|
+
y || X(), y = !0;
|
|
676
688
|
}, te = () => {
|
|
677
|
-
|
|
689
|
+
Y();
|
|
678
690
|
}, ne = () => {
|
|
679
|
-
|
|
691
|
+
h = !0, X();
|
|
680
692
|
}, re = () => {
|
|
681
|
-
|
|
693
|
+
h = !1;
|
|
682
694
|
}, oe = () => {
|
|
683
|
-
|
|
684
|
-
}, ce =
|
|
685
|
-
|
|
695
|
+
h && !_ && X();
|
|
696
|
+
}, ce = e => {
|
|
697
|
+
if (X(), !E(u)) for (const t of k("copy")) t(e);
|
|
686
698
|
}, ie = e => {
|
|
687
|
-
|
|
699
|
+
e.preventDefault(), ce(e.clipboardData);
|
|
688
700
|
}, le = e => {
|
|
689
|
-
e.preventDefault(),
|
|
690
|
-
}, ae = e => {
|
|
691
|
-
e.preventDefault(), t || (ie(e.clipboardData), O({
|
|
701
|
+
e.preventDefault(), t || (ce(e.clipboardData), S({
|
|
692
702
|
type: "delete",
|
|
693
|
-
range:
|
|
703
|
+
range: T(u)
|
|
694
704
|
}));
|
|
695
|
-
},
|
|
705
|
+
}, ae = e => {
|
|
696
706
|
e.preventDefault();
|
|
697
|
-
const t =
|
|
707
|
+
const t = J(e.clipboardData);
|
|
698
708
|
if (t) {
|
|
699
|
-
const e =
|
|
709
|
+
const e = T(u), n = e[0], r = [ {
|
|
700
710
|
type: "delete",
|
|
701
711
|
range: e
|
|
702
712
|
} ];
|
|
@@ -708,9 +718,9 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
708
718
|
type: "insert_node",
|
|
709
719
|
at: n,
|
|
710
720
|
fragment: t
|
|
711
|
-
}),
|
|
721
|
+
}), S(r);
|
|
712
722
|
}
|
|
713
|
-
},
|
|
723
|
+
}, fe = t => {
|
|
714
724
|
t.preventDefault();
|
|
715
725
|
const r = t.dataTransfer, s = ((e, t, {clientX: n, clientY: r}) => {
|
|
716
726
|
const o = P(e);
|
|
@@ -725,11 +735,11 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
725
735
|
if (r && s) {
|
|
726
736
|
let t;
|
|
727
737
|
const n = [];
|
|
728
|
-
|
|
738
|
+
_ && n.push({
|
|
729
739
|
type: "delete",
|
|
730
|
-
range:
|
|
740
|
+
range: T(u)
|
|
731
741
|
});
|
|
732
|
-
const c =
|
|
742
|
+
const c = J(r);
|
|
733
743
|
if (c) {
|
|
734
744
|
const r = g(e, s), i = Q(r, n);
|
|
735
745
|
n.push(o(c) ? {
|
|
@@ -742,42 +752,43 @@ var oe = [], se = () => {}, ce = e => {
|
|
|
742
752
|
fragment: c
|
|
743
753
|
}), t = [ i, Q(r, n) ];
|
|
744
754
|
}
|
|
745
|
-
|
|
755
|
+
S(n), t && O(t);
|
|
746
756
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
757
|
+
_ = !1;
|
|
758
|
+
}, ue = e => {
|
|
759
|
+
_ = !0, ce(e.dataTransfer);
|
|
760
|
+
}, de = () => {
|
|
761
|
+
_ = !1;
|
|
751
762
|
};
|
|
752
|
-
|
|
753
|
-
n.addEventListener("beforeinput",
|
|
754
|
-
n.addEventListener("compositionend",
|
|
755
|
-
n.addEventListener("copy",
|
|
756
|
-
n.addEventListener("drop",
|
|
757
|
-
const
|
|
758
|
-
return
|
|
763
|
+
M.addEventListener("selectionchange", oe), n.addEventListener("keydown", Z), n.addEventListener("input", K),
|
|
764
|
+
n.addEventListener("beforeinput", $), n.addEventListener("compositionstart", ee),
|
|
765
|
+
n.addEventListener("compositionend", te), n.addEventListener("focus", ne), n.addEventListener("blur", re),
|
|
766
|
+
n.addEventListener("copy", ie), n.addEventListener("cut", le), n.addEventListener("paste", ae),
|
|
767
|
+
n.addEventListener("drop", fe), n.addEventListener("dragstart", ue), n.addEventListener("dragend", de);
|
|
768
|
+
const pe = [];
|
|
769
|
+
return k("mount").forEach(e => {
|
|
759
770
|
const t = e(n, w);
|
|
760
|
-
t &&
|
|
771
|
+
t && pe.push(t);
|
|
761
772
|
}), () => {
|
|
762
|
-
p || (p = !0,
|
|
763
|
-
n.ariaReadOnly =
|
|
764
|
-
n.removeEventListener("keydown",
|
|
765
|
-
n.removeEventListener("compositionstart",
|
|
766
|
-
n.removeEventListener("focus",
|
|
767
|
-
n.removeEventListener("cut",
|
|
768
|
-
n.removeEventListener("dragstart",
|
|
773
|
+
p || (p = !0, q(), z(), G(), n.contentEditable = c, n.role = i, n.ariaMultiLine = l,
|
|
774
|
+
n.ariaReadOnly = f, n.style.whiteSpace = d, j.T(), M.removeEventListener("selectionchange", oe),
|
|
775
|
+
n.removeEventListener("keydown", Z), n.removeEventListener("input", K), n.removeEventListener("beforeinput", $),
|
|
776
|
+
n.removeEventListener("compositionstart", ee), n.removeEventListener("compositionend", te),
|
|
777
|
+
n.removeEventListener("focus", ne), n.removeEventListener("blur", re), n.removeEventListener("copy", ie),
|
|
778
|
+
n.removeEventListener("cut", le), n.removeEventListener("paste", ae), n.removeEventListener("drop", fe),
|
|
779
|
+
n.removeEventListener("dragstart", ue), n.removeEventListener("dragend", de), pe.forEach(e => {
|
|
769
780
|
e();
|
|
770
781
|
}));
|
|
771
782
|
};
|
|
772
783
|
}
|
|
773
784
|
};
|
|
774
|
-
return
|
|
785
|
+
return D.exec(re), D;
|
|
775
786
|
};
|
|
776
787
|
|
|
777
788
|
function le(e, t) {
|
|
778
789
|
const n = t && t.voidToString;
|
|
779
790
|
e.hook("copy", t => {
|
|
780
|
-
t.setData("text/plain",
|
|
791
|
+
t.setData("text/plain", b(e.doc, ...T(e.selection), n));
|
|
781
792
|
}), e.hook("paste", e => e.getData("text/plain"));
|
|
782
793
|
}
|
|
783
794
|
|
|
@@ -801,12 +812,12 @@ function fe(e) {
|
|
|
801
812
|
});
|
|
802
813
|
}
|
|
803
814
|
|
|
804
|
-
exports.Delete = function(e, t =
|
|
815
|
+
exports.Delete = function(e, t = T(e.selection)) {
|
|
805
816
|
e.apply({
|
|
806
817
|
type: "delete",
|
|
807
818
|
range: t
|
|
808
819
|
});
|
|
809
|
-
}, exports.Format = function(e, t, n, r =
|
|
820
|
+
}, exports.Format = function(e, t, n, r = T(e.selection)) {
|
|
810
821
|
e.apply({
|
|
811
822
|
type: "format",
|
|
812
823
|
range: r,
|
|
@@ -827,11 +838,11 @@ exports.Delete = function(e, t = E(e.selection)) {
|
|
|
827
838
|
at: n,
|
|
828
839
|
text: t
|
|
829
840
|
});
|
|
830
|
-
}, exports.Redo = function(e) {
|
|
841
|
+
}, exports.LeafsInRange = S, exports.Redo = function(e) {
|
|
831
842
|
e.get(re).redo();
|
|
832
843
|
}, exports.Redoable = function(e) {
|
|
833
844
|
return e.get(re).redoable();
|
|
834
|
-
}, exports.ReplaceDoc = w, exports.ReplaceText = function(e, t, n =
|
|
845
|
+
}, exports.ReplaceDoc = w, exports.ReplaceText = function(e, t, n = T(e.selection)) {
|
|
835
846
|
e.apply({
|
|
836
847
|
type: "delete",
|
|
837
848
|
range: n
|
|
@@ -856,22 +867,13 @@ exports.Delete = function(e, t = E(e.selection)) {
|
|
|
856
867
|
key: t,
|
|
857
868
|
value: s[t] === n ? r : n
|
|
858
869
|
});
|
|
859
|
-
}, exports.ToggleFormat = function(e, t, n =
|
|
860
|
-
let r = !1;
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
r = !o[t];
|
|
865
|
-
} else {
|
|
866
|
-
let o = !1;
|
|
867
|
-
for (const [s, c] of b(e.doc, ...n)) if (S(n, [ c, c + d(s) ]) && i(s) && (o = !0,
|
|
868
|
-
!s[t])) {
|
|
869
|
-
r = !0;
|
|
870
|
-
break;
|
|
871
|
-
}
|
|
872
|
-
if (!o) return;
|
|
870
|
+
}, exports.ToggleFormat = function(e, t, n = T(e.selection)) {
|
|
871
|
+
let r = !1, o = !1;
|
|
872
|
+
for (const s of e.exec(S, n)) if (i(s) && (o = !0, !s[t])) {
|
|
873
|
+
r = !0;
|
|
874
|
+
break;
|
|
873
875
|
}
|
|
874
|
-
e.apply({
|
|
876
|
+
o && e.apply({
|
|
875
877
|
type: "format",
|
|
876
878
|
range: n,
|
|
877
879
|
key: t,
|
|
@@ -889,7 +891,7 @@ exports.Delete = function(e, t = E(e.selection)) {
|
|
|
889
891
|
}
|
|
890
892
|
}).exec(le);
|
|
891
893
|
return t && o.exec(fe), o.on("change", () => {
|
|
892
|
-
n(
|
|
894
|
+
n(b(o.doc));
|
|
893
895
|
}), o;
|
|
894
896
|
}, exports.debugPlugin = function(e) {
|
|
895
897
|
e.hook("apply", e => {
|
|
@@ -912,7 +914,7 @@ exports.Delete = function(e, t = E(e.selection)) {
|
|
|
912
914
|
}
|
|
913
915
|
return null;
|
|
914
916
|
});
|
|
915
|
-
}, exports.getBlockAt = x, exports.getChildAt = p, exports.getLeafAt =
|
|
917
|
+
}, exports.getBlockAt = x, exports.getChildAt = p, exports.getLeafAt = y, exports.getNodeSize = d,
|
|
916
918
|
exports.htmlTransferPlugin = function(e, t) {
|
|
917
919
|
e.hook("mount", (n, r) => {
|
|
918
920
|
const o = e.hook("copy", e => {
|
|
@@ -957,7 +959,7 @@ exports.htmlTransferPlugin = function(e, t) {
|
|
|
957
959
|
});
|
|
958
960
|
}, exports.internalTranferPlugin = function(e) {
|
|
959
961
|
e.hook("copy", t => {
|
|
960
|
-
t.setData(ae, JSON.stringify(
|
|
962
|
+
t.setData(ae, JSON.stringify(v(e.doc, ...T(e.selection))));
|
|
961
963
|
}), e.hook("paste", e => {
|
|
962
964
|
try {
|
|
963
965
|
return JSON.parse(e.getData(ae));
|
|
@@ -965,7 +967,7 @@ exports.htmlTransferPlugin = function(e, t) {
|
|
|
965
967
|
return null;
|
|
966
968
|
}
|
|
967
969
|
});
|
|
968
|
-
}, exports.iterLeafs =
|
|
970
|
+
}, exports.iterLeafs = _, exports.keymapPlugin = function(e, t) {
|
|
969
971
|
n(t).forEach(n => {
|
|
970
972
|
const r = t[n];
|
|
971
973
|
e.hook("keyboard", ne(n, r));
|
|
@@ -977,7 +979,7 @@ exports.htmlTransferPlugin = function(e, t) {
|
|
|
977
979
|
s || (s = !0, requestAnimationFrame(() => {
|
|
978
980
|
s = !1, o && t(() => {
|
|
979
981
|
const t = e.selection;
|
|
980
|
-
return C(n, r,
|
|
982
|
+
return C(n, r, e.doc, t).getBoundingClientRect();
|
|
981
983
|
});
|
|
982
984
|
}));
|
|
983
985
|
});
|
|
@@ -985,5 +987,5 @@ exports.htmlTransferPlugin = function(e, t) {
|
|
|
985
987
|
o = !1, c();
|
|
986
988
|
};
|
|
987
989
|
});
|
|
988
|
-
}, exports.singlelinePlugin = fe, exports.sliceText =
|
|
990
|
+
}, exports.singlelinePlugin = fe, exports.sliceText = b;
|
|
989
991
|
//# sourceMappingURL=index.cjs.map
|