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