editate 0.6.5 → 0.6.6

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