editate 0.6.19 → 0.6.20

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
@@ -1,14 +1,14 @@
1
1
  var {min: t, max: e} = Math, {keys: n, is: r} = Object, o = t => "string" == typeof t, c = t => "function" == typeof t, s = c(queueMicrotask) ? queueMicrotask : t => {
2
2
  Promise.resolve().then(t);
3
- }, i = t => "text" in t, a = t => "children" in t, l = t => t.some(a), f = /* @__PURE__ */ new WeakMap, u = ({children: t}, e = 0, n = t.length) => {
3
+ }, i = t => "text" in t, l = t => "children" in t, a = t => t.some(l), f = /* @__PURE__ */ new WeakMap, u = ({children: t}, e = 0, n = t.length) => {
4
4
  let r = 0, o = 0;
5
5
  for (let c = e; c < n; c++) {
6
6
  const e = t[c];
7
- r += d(e), 0 !== o && a(e) && r++, o++;
7
+ r += d(e), 0 !== o && l(e) && r++, o++;
8
8
  }
9
9
  return r;
10
10
  }, d = t => {
11
- if (a(t)) {
11
+ if (l(t)) {
12
12
  let e = f.get(t);
13
13
  return null == e && f.set(t, e = u(t)), e;
14
14
  }
@@ -16,38 +16,38 @@ var {min: t, max: e} = Math, {keys: n, is: r} = Object, o = t => "string" == typ
16
16
  }, p = ({children: t}, e, n) => {
17
17
  const r = t.length;
18
18
  for (let o = 0; o < r; o++) {
19
- const r = t[o], c = a(r);
19
+ const r = t[o], c = l(r);
20
20
  let s = d(r);
21
21
  const i = 0 === s;
22
22
  if (c && s++, s > e || s === e && !c && (n || i)) return [ r, e, o ];
23
23
  e -= s;
24
24
  }
25
25
  return null;
26
- }, h = (t, e) => {
26
+ }, y = (t, e) => {
27
27
  const n = [];
28
28
  for (;t; ) {
29
29
  const r = p(t, e);
30
30
  if (!r) break;
31
31
  const o = r[0];
32
- if (!a(o)) break;
32
+ if (!l(o)) break;
33
33
  e = r[1], t = o, n.push(r[2]);
34
34
  }
35
35
  return [ t, e, n ];
36
- }, y = (t, e, n) => {
37
- const [r, o, c] = h(t, e), s = p(r, o, n);
36
+ }, h = (t, e, n) => {
37
+ const [r, o, c] = y(t, e), s = p(r, o, n);
38
38
  return s ? (c.push(s[2]), [ s[0], s[1], c ]) : null;
39
39
  }, k = (t, e) => {
40
40
  const n = t.children, r = p(t, e);
41
41
  if (r) {
42
42
  const [e, o, c] = r;
43
- if (a(e)) {
44
- const [r, s] = k(e, o), i = n.slice(0, c), a = n.slice(c + 1);
45
- return i.push(r), a.unshift(s), [ {
43
+ if (l(e)) {
44
+ const [r, s] = k(e, o), i = n.slice(0, c), l = n.slice(c + 1);
45
+ return i.push(r), l.unshift(s), [ {
46
46
  ...t,
47
47
  children: i
48
48
  }, {
49
49
  ...t,
50
- children: a
50
+ children: l
51
51
  } ];
52
52
  }
53
53
  {
@@ -84,56 +84,66 @@ var {min: t, max: e} = Math, {keys: n, is: r} = Object, o = t => "string" == typ
84
84
  for (const o of e) r += u(t, 0, o), 0 !== o && r++, t = t.children[o];
85
85
  return r + n;
86
86
  }, m = (t, e) => {
87
- const [, n, r] = h(t, e);
87
+ const [, n, r] = y(t, e);
88
88
  return [ r, n ];
89
89
  }, x = (t, [e, n]) => [ g(t, e), g(t, n) ];
90
90
 
91
- function* _(t, e) {
92
- if (a(t)) for (const [n, r] of function*(t, [e, n]) {
93
- if (e >= n) return;
94
- if (!a(t)) return;
95
- const r = p(t, e);
96
- if (r) {
97
- let o = e - r[1], c = r[2];
98
- const s = t.children, i = s.length;
99
- for (;o <= n && c < i; ) {
100
- const t = s[c];
101
- yield [ t, o ], c++, o += d(t), a(t) && o++;
102
- }
91
+ function* _(t, [e, n]) {
92
+ if (e >= n) return;
93
+ if (!l(t)) return;
94
+ const r = p(t, e);
95
+ if (r) {
96
+ let o = e - r[1], c = r[2];
97
+ const s = t.children, i = s.length;
98
+ for (;o <= n && c < i; ) {
99
+ const t = s[c];
100
+ yield [ t, o ], c++, o += d(t), l(t) && o++;
103
101
  }
104
- }(t, e)) for (const t of _(n, [ 0, d(n) ])) t[1] += r, yield t; else yield [ t, 0 ];
102
+ }
103
+ }
104
+
105
+ function* b(t, e) {
106
+ if (!l(t) || a(t.children)) for (const n of _(t, e)) {
107
+ const [t, e] = n;
108
+ for (const n of b(t, [ 0, d(t) ])) n[1] += e, yield n;
109
+ } else yield [ t, 0 ];
105
110
  }
106
111
 
107
- var b = (n, r = 0, o = 1 / 0, c) => {
108
- let s = "", a = r;
109
- for (const [l, f] of _(n, [ r, o ])) {
110
- for (let t = f - a; t > 0; t--) s += "\n";
111
- const n = d(l), u = f + n;
112
- if (i(l)) {
112
+ function* v(t, e) {
113
+ if (l(t)) for (const [n, r] of _(t, e)) for (const t of v(n, [ 0, d(n) ])) t[1] += r,
114
+ yield t; else yield [ t, 0 ];
115
+ }
116
+
117
+ var T = (n, r = 0, o = 1 / 0, c) => {
118
+ let s = "", l = r;
119
+ for (const [a, f] of v(n, [ r, o ])) {
120
+ for (let t = f - l; t > 0; t--) s += "\n";
121
+ const n = d(a), u = f + n;
122
+ if (i(a)) {
113
123
  const c = e(f, r) - f, i = t(u, o) - f;
114
- s += 0 === c && i === n ? l.text : l.text.slice(c, i);
115
- } else c && (s += c(l));
116
- a = u;
124
+ s += 0 === c && i === n ? a.text : a.text.slice(c, i);
125
+ } else c && (s += c(a));
126
+ l = u;
117
127
  }
118
- for (let e = t(o, d(n)) - a; e > 0; e--) s += "\n";
128
+ for (let e = t(o, d(n)) - l; e > 0; e--) s += "\n";
119
129
  return s;
120
- }, v = (t, e, n) => e >= n ? [] : k(k(t, n)[0], e)[1].children, T = ([t, e]) => t > e ? [ e, t ] : [ t, e ], E = ([t, e]) => t === e, M = ([t, e], [n, r]) => t < r && n < e;
130
+ }, E = (t, e, n) => e >= n ? [] : k(k(t, n)[0], e)[1].children, M = ([t, e]) => t > e ? [ e, t ] : [ t, e ], S = ([t, e]) => t === e, w = ([t, e], [n, r]) => t < r && n < e;
121
131
 
122
- function* S(t, e = T(t.selection)) {
123
- if (E(e)) {
124
- const n = y(t.doc, e[0])?.[0];
132
+ function* A(t, e = M(t.selection)) {
133
+ if (S(e)) {
134
+ const n = h(t.doc, e[0])?.[0];
125
135
  n && (yield n);
126
- } else for (const [n, r] of _(t.doc, e)) M(e, [ r, r + d(n) ]) && (yield n);
136
+ } else for (const [n, r] of v(t.doc, e)) w(e, [ r, r + d(n) ]) && (yield n);
127
137
  }
128
138
 
129
- function w(t, e = T(t.selection)) {
139
+ function O(t, e = M(t.selection)) {
130
140
  t.apply({
131
141
  type: "delete",
132
142
  range: e
133
143
  });
134
144
  }
135
145
 
136
- function A(t, e, n = t.selection[0]) {
146
+ function R(t, e, n = t.selection[0]) {
137
147
  t.apply({
138
148
  type: "insert_text",
139
149
  at: n,
@@ -141,7 +151,7 @@ function A(t, e, n = t.selection[0]) {
141
151
  });
142
152
  }
143
153
 
144
- function O(t, e, n = t.selection[0]) {
154
+ function D(t, e, n = t.selection[0]) {
145
155
  t.apply({
146
156
  type: "insert_node",
147
157
  at: n,
@@ -151,7 +161,7 @@ function O(t, e, n = t.selection[0]) {
151
161
  });
152
162
  }
153
163
 
154
- function R(t, e, n = T(t.selection)) {
164
+ function B(t, e, n = M(t.selection)) {
155
165
  t.apply({
156
166
  type: "delete",
157
167
  range: n
@@ -162,7 +172,7 @@ function R(t, e, n = T(t.selection)) {
162
172
  });
163
173
  }
164
174
 
165
- function D(t, e) {
175
+ function I(t, e) {
166
176
  t.apply({
167
177
  type: "patch_node",
168
178
  path: [],
@@ -171,7 +181,7 @@ function D(t, e) {
171
181
  });
172
182
  }
173
183
 
174
- function B(t, e, n, r = T(t.selection)) {
184
+ function P(t, e, n, r = M(t.selection)) {
175
185
  t.apply({
176
186
  type: "format",
177
187
  range: r,
@@ -180,9 +190,9 @@ function B(t, e, n, r = T(t.selection)) {
180
190
  });
181
191
  }
182
192
 
183
- function I(t, e, n = T(t.selection)) {
193
+ function N(t, e, n = M(t.selection)) {
184
194
  let r = !1, o = !1;
185
- for (const c of t.exec(S, n)) if (i(c) && (o = !0, !c[e])) {
195
+ for (const c of t.exec(A, n)) if (i(c) && (o = !0, !c[e])) {
186
196
  r = !0;
187
197
  break;
188
198
  }
@@ -194,8 +204,8 @@ function I(t, e, n = T(t.selection)) {
194
204
  });
195
205
  }
196
206
 
197
- function P(t, e, n, r = t.selection[0]) {
198
- const o = h(t.doc, r)[2];
207
+ function L(t, e, n, r = t.selection[0]) {
208
+ const o = y(t.doc, r)[2];
199
209
  t.apply({
200
210
  type: "patch_node",
201
211
  path: o,
@@ -204,8 +214,8 @@ function P(t, e, n, r = t.selection[0]) {
204
214
  });
205
215
  }
206
216
 
207
- function N(t, e, n, r, o = t.selection[0]) {
208
- const [c, , s] = h(t.doc, o);
217
+ function C(t, e, n, r, o = t.selection[0]) {
218
+ const [c, , s] = y(t.doc, o);
209
219
  t.apply({
210
220
  type: "patch_node",
211
221
  path: s,
@@ -214,8 +224,8 @@ function N(t, e, n, r, o = t.selection[0]) {
214
224
  });
215
225
  }
216
226
 
217
- function L(t, e, n, r = t.selection[0]) {
218
- const o = y(t.doc, r, !0);
227
+ function H(t, e, n, r = t.selection[0]) {
228
+ const o = h(t.doc, r, !0);
219
229
  o && !i(o[0]) && t.apply({
220
230
  type: "patch_node",
221
231
  path: o[2],
@@ -224,53 +234,53 @@ function L(t, e, n, r = t.selection[0]) {
224
234
  });
225
235
  }
226
236
 
227
- var C = t => 1 === t.nodeType, H = t => 8 === t.nodeType, F = 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 ] ]), U = new Set([ "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE", "LI", "DT", "DD", "TH", "TD" ]), V = t => U.has(t.tagName), W = (t, e) => t.compareDocumentPosition(e), q = t => t.ownerDocument, z = t => q(t).getSelection(), G = (t, e) => {
237
+ var F = t => 1 === t.nodeType, U = t => 8 === t.nodeType, V = 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 ] ]), W = new Set([ "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE", "LI", "DT", "DD", "TH", "TD" ]), q = t => W.has(t.tagName), z = (t, e) => t.compareDocumentPosition(e), G = t => t.ownerDocument, J = t => G(t).getSelection(), X = (t, e) => {
228
238
  if (t.rangeCount) {
229
239
  const n = t.getRangeAt(0);
230
240
  if (e.contains(n.commonAncestorContainer)) return n;
231
241
  }
232
- }, J = (t, e, n, r) => {
233
- const [o, c] = ((t, [e, n]) => [ m(t, e), m(t, n) ])(n, r), s = q(t), i = E(r), a = r[0] - r[1] > 0, l = a ? o : c, f = Y(t, e, a ? c : o), u = i ? f : Y(t, e, l), d = s.createRange(), [p, h] = f, [y, k] = u;
234
- return C(p) && t !== p ? h < 1 ? d.setStartBefore(p) : d.setStartAfter(p) : d.setStart(p, h),
235
- C(y) && t !== y ? k < 1 ? d.setEndBefore(y) : d.setEndAfter(y) : d.setEnd(y, k),
242
+ }, Y = (t, e, n, r) => {
243
+ const [o, c] = ((t, [e, n]) => [ m(t, e), m(t, n) ])(n, r), s = G(t), i = S(r), l = r[0] - r[1] > 0, a = l ? o : c, f = j(t, e, l ? c : o), u = i ? f : j(t, e, a), d = s.createRange(), [p, y] = f, [h, k] = u;
244
+ return F(p) && t !== p ? y < 1 ? d.setStartBefore(p) : d.setStartAfter(p) : d.setStart(p, y),
245
+ F(h) && t !== h ? k < 1 ? d.setEndBefore(h) : d.setEndAfter(h) : d.setEnd(h, k),
236
246
  d;
237
- }, X = (t, e, n, r, o) => {
238
- const c = z(t);
239
- if (o || G(c, t)) {
240
- const o = J(t, e, n, r), s = r[0] - r[1] > 0;
247
+ }, Z = (t, e, n, r, o) => {
248
+ const c = J(t);
249
+ if (o || X(c, t)) {
250
+ const o = Y(t, e, n, r), s = r[0] - r[1] > 0;
241
251
  c.removeAllRanges(), c.addRange(o), s && (c.collapseToEnd(), c.extend(o.startContainer, o.startOffset));
242
252
  }
243
- }, Y = (t, e, [n, r]) => e(({t: e, o, i: c, l: s}) => {
244
- let i, a = 0;
253
+ }, j = (t, e, [n, r]) => e(({t: e, o, i: c, l: s}) => {
254
+ let i, l = 0;
245
255
  for (;i = e(); ) if (4 === i) {
246
- if (a < n.length) for (let t = n[a++]; t > 0; t--) o();
256
+ if (l < n.length) for (let t = n[l++]; t > 0; t--) o();
247
257
  } else {
248
258
  const t = s();
249
259
  if (r <= t) return [ c(), r ];
250
260
  r -= t;
251
261
  }
252
262
  return [ t, 0 ];
253
- }, t), Z = (e, n, r, o) => {
263
+ }, t), K = (e, n, r, o) => {
254
264
  let c = !0;
255
265
  if (e === r && !r.hasChildNodes()) return [ [], 0 ];
256
- if (C(r) && r.hasChildNodes()) {
266
+ if (F(r) && r.hasChildNodes()) {
257
267
  const e = t(o, r.childNodes.length - 1);
258
268
  r = r.childNodes[e], c = e === o, o = 0;
259
269
  }
260
- return n(({t, u: s, p: i, h: a, i: l, l: f, k: u}) => {
270
+ return n(({t, u: s, p: i, h: l, i: a, l: f, k: u}) => {
261
271
  s(r), 4 !== u() && i();
262
272
  const d = n(() => {
263
273
  const t = [];
264
- for (;u() && l() !== e; ) {
274
+ for (;u() && a() !== e; ) {
265
275
  let e = 0;
266
- for (;a(), u(); ) e++;
276
+ for (;l(), u(); ) e++;
267
277
  t.unshift(e), i();
268
278
  }
269
279
  return t;
270
280
  });
271
281
  let p = 0;
272
282
  for (;t(); ) {
273
- const t = W(r, l());
283
+ const t = z(r, a());
274
284
  if (0 === t || 16 & t) {
275
285
  if (c) break;
276
286
  } else if (4 & t) break;
@@ -278,34 +288,34 @@ var C = t => 1 === t.nodeType, H = t => 8 === t.nodeType, F = new Map([ [ "BR",
278
288
  }
279
289
  return [ d, p + o ];
280
290
  }, e);
281
- }, j = (t, e, {startOffset: n, startContainer: r, endOffset: o, endContainer: c}) => {
282
- const s = Z(t, e, r, n);
283
- return [ s, r === c && n === o ? s : Z(t, e, c, o) ];
284
- }, K = (t, e, n) => t.split("\n").map(t => ({
291
+ }, Q = (t, e, {startOffset: n, startContainer: r, endOffset: o, endContainer: c}) => {
292
+ const s = K(t, e, r, n);
293
+ return [ s, r === c && n === o ? s : K(t, e, c, o) ];
294
+ }, $ = (t, e, n) => t.split("\n").map(t => ({
285
295
  ...n,
286
296
  children: [ {
287
297
  ...e,
288
298
  text: t
289
299
  } ]
290
- })), Q = "delete", $ = "insert_text", tt = "insert_node", et = (t, e) => {
300
+ })), tt = "delete", et = "insert_text", nt = "insert_node", rt = (t, e) => {
291
301
  const o = n(t);
292
302
  return o.length === n(e).length && o.every(n => n in e && ("text" === n || r(t[n], e[n])));
293
- }, nt = (t, e) => {
303
+ }, ot = (t, e) => {
294
304
  if (e.length) {
295
305
  const n = t.length;
296
306
  if (t.push(...e), n) {
297
- const e = t[n - 1], r = t[n], o = a(e), c = a(r);
307
+ const e = t[n - 1], r = t[n], o = l(e), c = l(r);
298
308
  o ? c && ((t, e = 0, n = t.length - 1) => {
299
309
  let r = e + 1;
300
310
  for (;r <= n; ) {
301
311
  const e = t[r - 1], o = t[r];
302
- t[r - 1] = rt(e, o), t.splice(r, 1), n--;
312
+ t[r - 1] = ct(e, o), t.splice(r, 1), n--;
303
313
  }
304
314
  })(t, n - 1, n) : o || c || ((t, e = 0, n = t.length - 1) => {
305
315
  let r = e + 1;
306
316
  for (;r <= n; ) {
307
317
  const e = t[r - 1], o = t[r];
308
- i(e) && i(o) && et(e, o) ? (t[r - 1] = {
318
+ i(e) && i(o) && rt(e, o) ? (t[r - 1] = {
309
319
  ...e,
310
320
  text: e.text + o.text
311
321
  }, t.splice(r, 1), n--) : r++;
@@ -320,10 +330,10 @@ var C = t => 1 === t.nodeType, H = t => 8 === t.nodeType, F = new Map([ [ "BR",
320
330
  t.length || t.push({
321
331
  text: ""
322
332
  });
323
- }, rt = (...t) => ({
333
+ }, ct = (...t) => ({
324
334
  ...t[0],
325
- children: t.reduce((t, e) => (nt(t, e.children), t), [])
326
- }), ot = (t, e, n, r = 0) => {
335
+ children: t.reduce((t, e) => (ot(t, e.children), t), [])
336
+ }), st = (t, e, n, r = 0) => {
327
337
  if (r < e.length) {
328
338
  const o = e[r];
329
339
  return ((t, e, n, r) => {
@@ -332,36 +342,36 @@ var C = t => 1 === t.nodeType, H = t => 8 === t.nodeType, F = new Map([ [ "BR",
332
342
  ...t,
333
343
  children: o
334
344
  };
335
- })(t, o, o, [ ot(t.children[o], e, n, r + 1) ]);
345
+ })(t, o, o, [ st(t.children[o], e, n, r + 1) ]);
336
346
  }
337
347
  return n;
338
- }, ct = (t, e, n, r) => {
339
- const [o, c] = k(t, e), s = e < n ? k(t, n)[1] : c, i = l(t.children);
340
- l(r) ? i || (r = rt(...r).children) : i && (r = [ {
348
+ }, it = (t, e, n, r) => {
349
+ const [o, c] = k(t, e), s = e < n ? k(t, n)[1] : c, i = a(t.children);
350
+ a(r) ? i || (r = ct(...r).children) : i && (r = [ {
341
351
  children: r
342
352
  } ]);
343
- const a = o.children.slice();
344
- return nt(a, r), nt(a, s.children), {
353
+ const l = o.children.slice();
354
+ return ot(l, r), ot(l, s.children), {
345
355
  ...t,
346
- children: a
356
+ children: l
347
357
  };
348
- }, st = (t, e) => e >= 0 && e <= d(t), it = (t, e) => e.reduce((t, e) => at(t, e), t), at = (t, e) => {
358
+ }, lt = (t, e) => e >= 0 && e <= d(t), at = (t, e) => e.reduce((t, e) => ft(t, e), t), ft = (t, e) => {
349
359
  switch (e.type) {
350
- case Q:
360
+ case tt:
351
361
  {
352
362
  const [n, r] = e.range;
353
363
  if (t >= n) return r >= t ? n : t + n - r;
354
364
  break;
355
365
  }
356
366
 
357
- case $:
367
+ case et:
358
368
  {
359
369
  const {at: n, text: r} = e;
360
370
  if (t >= n) return t + r.length;
361
371
  break;
362
372
  }
363
373
 
364
- case tt:
374
+ case nt:
365
375
  {
366
376
  const {at: n, fragment: r} = e;
367
377
  if (t >= n) return t + d({
@@ -371,9 +381,9 @@ var C = t => 1 === t.nodeType, H = t => 8 === t.nodeType, F = new Map([ [ "BR",
371
381
  }
372
382
  }
373
383
  return t;
374
- }, lt = ([t, e], n) => [ at(t, n), at(e, n) ], ft = "undefined" != typeof navigator && /Mac|iP(hone|od|ad)/.test(navigator.platform), ut = (t, e) => {
384
+ }, ut = ([t, e], n) => [ ft(t, n), ft(e, n) ], dt = "undefined" != typeof navigator && /Mac|iP(hone|od|ad)/.test(navigator.platform), pt = (t, e) => {
375
385
  const n = t.endsWith("+"), r = (n ? t.slice(0, -2) : t).split("+"), o = n ? "+" : r.pop(), c = "Space" === o ? " " : o.toLowerCase();
376
- let s = !1, i = !1, a = !1, l = !1;
386
+ let s = !1, i = !1, l = !1, a = !1;
377
387
  return r.forEach(t => {
378
388
  switch (t) {
379
389
  case "Ctrl":
@@ -381,97 +391,97 @@ var C = t => 1 === t.nodeType, H = t => 8 === t.nodeType, F = new Map([ [ "BR",
381
391
  break;
382
392
 
383
393
  case "Meta":
384
- a = !0;
394
+ l = !0;
385
395
  break;
386
396
 
387
397
  case "Mod":
388
- ft ? a = !0 : i = !0;
398
+ dt ? l = !0 : i = !0;
389
399
  break;
390
400
 
391
401
  case "Alt":
392
- l = !0;
402
+ a = !0;
393
403
  break;
394
404
 
395
405
  case "Shift":
396
406
  s = !0;
397
407
  }
398
408
  }), t => {
399
- if (t.key.toLowerCase() === c && i === t.ctrlKey && a === t.metaKey && s === t.shiftKey && l === t.altKey) return !1 !== e(t);
409
+ if (t.key.toLowerCase() === c && i === t.ctrlKey && l === t.metaKey && s === t.shiftKey && a === t.altKey) return !1 !== e(t);
400
410
  };
401
411
  };
402
412
 
403
- function dt(t) {
413
+ function yt(t) {
404
414
  let e = 0, n = 0, r = !1;
405
- const o = Date.now, c = [ [ t.doc, t.selection, [] ] ], s = () => c[e], i = () => e > 0, a = () => e < c.length - 1, l = () => {
415
+ const o = Date.now, c = [ [ t.doc, t.selection, [] ] ], s = () => c[e], i = () => e > 0, l = () => e < c.length - 1, a = () => {
406
416
  if (i()) {
407
417
  const n = s()[1];
408
418
  e--;
409
419
  const o = t.doc;
410
- r = !0, t.exec(D, s()[0].children), r = !1, o !== t.doc && (t.selection = n);
420
+ r = !0, t.exec(I, s()[0].children), r = !1, o !== t.doc && (t.selection = n);
411
421
  }
412
422
  }, f = () => {
413
- if (a()) {
423
+ if (l()) {
414
424
  e++;
415
425
  const [n, o, c] = s(), i = t.doc;
416
- r = !0, t.exec(D, n.children), r = !1, i !== t.doc && (t.selection = [ it(o[0], c), it(o[1], c) ]);
426
+ r = !0, t.exec(I, n.children), r = !1, i !== t.doc && (t.selection = [ at(o[0], c), at(o[1], c) ]);
417
427
  }
418
428
  };
419
429
  t.hook("apply", (s, i) => {
420
430
  if (r) return;
421
- const a = t.doc, l = t.selection;
431
+ const l = t.doc, a = t.selection;
422
432
  i(s);
423
433
  const f = t.doc;
424
- if (a !== f) {
434
+ if (l !== f) {
425
435
  const t = o();
426
436
  if (0 === e || t - n >= 500) {
427
437
  e++;
428
- const t = [ a, l, [] ];
438
+ const t = [ l, a, [] ];
429
439
  e >= c.length ? c.push(t) : c[e] = t;
430
440
  }
431
441
  n = t, c[e][0] = f, c[e][2].push(s), c.length > e + 1 && (c.length = e + 1), e > 500 && (e--,
432
442
  c.shift());
433
443
  }
434
- }), t.hook("keyboard", ut("Mod+Z", l)), t.hook("keyboard", ut("Shift+Mod+Z", f)),
435
- t.set(dt, {
436
- undo: l,
444
+ }), t.hook("keyboard", pt("Mod+Z", a)), t.hook("keyboard", pt("Shift+Mod+Z", f)),
445
+ t.set(yt, {
446
+ undo: a,
437
447
  redo: f,
438
448
  undoable: i,
439
- redoable: a
449
+ redoable: l
440
450
  });
441
451
  }
442
452
 
443
- function pt(t) {
444
- t.get(dt).undo();
453
+ function ht(t) {
454
+ t.get(yt).undo();
445
455
  }
446
456
 
447
- function ht(t) {
448
- t.get(dt).redo();
457
+ function kt(t) {
458
+ t.get(yt).redo();
449
459
  }
450
460
 
451
- function yt(t) {
452
- return t.get(dt).undoable();
461
+ function gt(t) {
462
+ return t.get(yt).undoable();
453
463
  }
454
464
 
455
- function kt(t) {
456
- return t.get(dt).redoable();
465
+ function mt(t) {
466
+ return t.get(yt).redoable();
457
467
  }
458
468
 
459
- var gt = [], mt = () => {}, xt = t => {
469
+ var xt = [], _t = () => {}, bt = t => {
460
470
  throw Error(t);
461
- }, _t = ({doc: t, readonly: e = !1, schema: n, isBlock: r = V, onWarn: l = console.warn, onError: f = xt}) => {
471
+ }, vt = ({doc: t, readonly: e = !1, schema: n, isBlock: r = q, onWarn: a = console.warn, onError: f = bt}) => {
462
472
  let u = [ 0, 0 ];
463
473
  const d = t => {
464
- if (!n) return l("An unsafe operation was detected. We recommend using schema option."),
474
+ if (!n) return a("An unsafe operation was detected. We recommend using schema option."),
465
475
  !0;
466
476
  const e = n["~standard"].validate(t);
467
477
  if (e instanceof Promise) f("async validate is not supported"); else {
468
478
  if (!e.issues) return !0;
469
- l(e.issues.map(t => t.message).join("\n"));
479
+ a(e.issues.map(t => t.message).join("\n"));
470
480
  }
471
481
  return !1;
472
482
  };
473
483
  n && !d(t) && f("Invalid document");
474
- const y = /* @__PURE__ */ new Map, k = /* @__PURE__ */ new WeakMap, m = t => y.get(t) || gt, _ = /* @__PURE__ */ new Map, b = /* @__PURE__ */ new Set, M = t => {
484
+ const h = /* @__PURE__ */ new Map, k = /* @__PURE__ */ new WeakMap, m = t => h.get(t) || xt, _ = /* @__PURE__ */ new Map, b = /* @__PURE__ */ new Set, v = t => {
475
485
  const e = _.get(t);
476
486
  e && (b.size || s(() => {
477
487
  b.forEach(t => {
@@ -480,7 +490,7 @@ var gt = [], mt = () => {}, xt = t => {
480
490
  }), e.forEach(t => {
481
491
  b.add(t);
482
492
  }));
483
- }, S = t => {
493
+ }, T = t => {
484
494
  if (!e) if (Array.isArray(t)) for (const e of t) w(e); else w(t);
485
495
  return O;
486
496
  }, w = e => {
@@ -495,56 +505,56 @@ var gt = [], mt = () => {}, xt = t => {
495
505
  try {
496
506
  const [n, r] = ((t, e, n) => {
497
507
  switch (n.type) {
498
- case Q:
508
+ case tt:
499
509
  {
500
510
  const [r, o] = n.range;
501
- st(t, r) && st(t, o) && r < o && (t = ct(t, r, o, []), e = lt(e, n));
511
+ lt(t, r) && lt(t, o) && r < o && (t = it(t, r, o, []), e = ut(e, n));
502
512
  break;
503
513
  }
504
514
 
505
- case $:
515
+ case et:
506
516
  {
507
517
  const {at: r, text: o} = n;
508
- if (st(t, r) && o) {
509
- const [c, s] = h(t, r), a = p(c, s, !0);
510
- let l;
511
- if (a) {
512
- const t = a[0];
513
- i(t) && (l = t);
518
+ if (lt(t, r) && o) {
519
+ const [c, s] = y(t, r), l = p(c, s, !0);
520
+ let a;
521
+ if (l) {
522
+ const t = l[0];
523
+ i(t) && (a = t);
514
524
  }
515
- t = ct(t, r, r, K(o, l, c)), e = lt(e, n);
525
+ t = it(t, r, r, $(o, a, c)), e = ut(e, n);
516
526
  }
517
527
  break;
518
528
  }
519
529
 
520
- case tt:
530
+ case nt:
521
531
  {
522
532
  const {at: r, fragment: o} = n;
523
- st(t, r) && o.length && (t = ct(t, r, r, o), e = lt(e, n));
533
+ lt(t, r) && o.length && (t = it(t, r, r, o), e = ut(e, n));
524
534
  break;
525
535
  }
526
536
 
527
537
  case "format":
528
538
  {
529
539
  const {range: [e, r], key: o, value: c} = n;
530
- if (st(t, e) && st(t, r) && e <= r) if (e === r) {
531
- const [{children: n}, , r] = h(t, e);
540
+ if (lt(t, e) && lt(t, r) && e <= r) if (e === r) {
541
+ const [{children: n}, , r] = y(t, e);
532
542
  if (1 === n.length) {
533
543
  const e = n[0];
534
- i(e) && !e.text && (t = ot(t, [ ...r, 0 ], {
544
+ i(e) && !e.text && (t = st(t, [ ...r, 0 ], {
535
545
  ...e,
536
546
  [o]: c
537
547
  }));
538
548
  }
539
549
  } else {
540
- const n = t => a(t) ? {
550
+ const n = t => l(t) ? {
541
551
  ...t,
542
552
  children: t.children.map(n)
543
553
  } : i(t) ? {
544
554
  ...t,
545
555
  [o]: c
546
556
  } : t;
547
- t = ct(t, e, r, v(t, e, r).map(n));
557
+ t = it(t, e, r, E(t, e, r).map(n));
548
558
  }
549
559
  break;
550
560
  }
@@ -555,7 +565,7 @@ var gt = [], mt = () => {}, xt = t => {
555
565
  for (let n = 0; n < e.length; n++) t = t.children[e[n]];
556
566
  return t;
557
567
  })(t, e);
558
- c && (t = ot(t, e, {
568
+ c && (t = st(t, e, {
559
569
  ...c,
560
570
  [r]: o
561
571
  }));
@@ -564,18 +574,18 @@ var gt = [], mt = () => {}, xt = t => {
564
574
  }
565
575
  return [ t, e ];
566
576
  })(t, u, e);
567
- (({type: t}) => t !== $ && t !== Q)(e) && !d(n) || (t = n, A(r));
577
+ (({type: t}) => t !== et && t !== tt)(e) && !d(n) || (t = n, A(r));
568
578
  } catch (n) {
569
- l("rollback operation: " + n);
579
+ a("rollback operation: " + n);
570
580
  }
571
581
  }
572
582
  }, f = t => {
573
583
  t && (e = t), c++, s();
574
584
  };
575
- s(), n !== t && M("change");
585
+ s(), n !== t && v("change");
576
586
  }, A = e => {
577
- !((t, [e, n]) => st(t, e) && st(t, n))(t, e) || u[0] === e[0] && u[1] === e[1] || (u = e,
578
- M("selectionchange"));
587
+ !((t, [e, n]) => lt(t, e) && lt(t, n))(t, e) || u[0] === e[0] && u[1] === e[1] || (u = e,
588
+ v("selectionchange"));
579
589
  }, O = {
580
590
  get doc() {
581
591
  return t;
@@ -590,9 +600,9 @@ var gt = [], mt = () => {}, xt = t => {
590
600
  return e;
591
601
  },
592
602
  set readonly(t) {
593
- e = t, M("readonly");
603
+ e = t, v("readonly");
594
604
  },
595
- apply: S,
605
+ apply: T,
596
606
  on: (t, e) => {
597
607
  let n = _.get(t);
598
608
  return n || _.set(t, n = /* @__PURE__ */ new Set), n.add(e), () => {
@@ -600,8 +610,8 @@ var gt = [], mt = () => {}, xt = t => {
600
610
  };
601
611
  },
602
612
  hook: (t, e) => {
603
- let n = y.get(t);
604
- return n || y.set(t, n = []), n.push(e), () => {
613
+ let n = h.get(t);
614
+ return n || h.set(t, n = []), n.push(e), () => {
605
615
  const t = n.indexOf(e);
606
616
  -1 !== t && n.splice(t, 1);
607
617
  };
@@ -613,22 +623,22 @@ var gt = [], mt = () => {}, xt = t => {
613
623
  get: t => (k.has(t) || f("No value found for key"), k.get(t)),
614
624
  set: (t, e) => (k.set(t, e), O),
615
625
  input: n => {
616
- if (!window.InputEvent || !c(InputEvent.prototype.getTargetRanges)) return l("beforeinput event is not supported."),
617
- mt;
618
- const {contentEditable: s, role: i, ariaMultiLine: a, ariaReadOnly: f} = n, d = n.style.whiteSpace;
626
+ if (!window.InputEvent || !c(InputEvent.prototype.getTargetRanges)) return a("beforeinput event is not supported."),
627
+ _t;
628
+ const {contentEditable: s, role: i, ariaMultiLine: l, ariaReadOnly: f} = n, d = n.style.whiteSpace;
619
629
  n.role = "textbox", n.style.whiteSpace = "pre-wrap", n.ariaMultiLine = "true";
620
- let p = !1, h = null, y = !1, k = !1, _ = !1, b = u, v = null;
621
- const M = q(n), w = ((t, e) => {
630
+ let p = !1, y = null, h = !1, k = !1, _ = !1, b = u, v = null;
631
+ const E = G(n), w = ((t, e) => {
622
632
  let n = null, r = null, o = null;
623
633
  const c = () => {
624
634
  if (null != o) return o;
625
635
  if (r) if ((t => 3 === t.nodeType)(r)) {
626
636
  const t = r.data;
627
637
  if (t) return o = "\n" === t ? i() ? 3 : 5 : 1;
628
- } else if (C(r)) {
638
+ } else if (F(r)) {
629
639
  if ("false" === r.contentEditable) return o = 2;
630
640
  {
631
- const t = F.get(r.tagName);
641
+ const t = V.get(r.tagName);
632
642
  if (null != t) return o = 1 === t ? i() ? 3 : 5 : 3 === t ? 2 : 6;
633
643
  if (e(r)) return o = 4;
634
644
  }
@@ -644,14 +654,14 @@ var gt = [], mt = () => {}, xt = t => {
644
654
  return r = n.nextNode();
645
655
  }, i = () => {
646
656
  const t = r.parentNode;
647
- return l(() => {
657
+ return a(() => {
648
658
  for (o = 0; s(); ) {
649
659
  if (c()) return !0;
650
660
  if (!t.contains(r)) break;
651
661
  }
652
662
  return !1;
653
663
  });
654
- }, a = {
664
+ }, l = {
655
665
  t: () => {
656
666
  for (;s(); ) {
657
667
  const t = c();
@@ -676,16 +686,16 @@ var gt = [], mt = () => {}, xt = t => {
676
686
  p: () => {
677
687
  for (;(o = null) || (r = n.parentNode()); ) if (4 === c()) return;
678
688
  }
679
- }, l = (e, c) => {
680
- const s = n, i = r, l = o;
689
+ }, a = (e, c) => {
690
+ const s = n, i = r, a = o;
681
691
  try {
682
- return n || (n = t.createTreeWalker(r = c, 5)), e(a);
692
+ return n || (n = t.createTreeWalker(r = c, 5)), e(l);
683
693
  } finally {
684
- n = s, r = i, o = l, n && i && (n.currentNode = i);
694
+ n = s, r = i, o = a, n && i && (n.currentNode = i);
685
695
  }
686
696
  };
687
- return l;
688
- })(M, r), R = () => {
697
+ return a;
698
+ })(E, r), R = () => {
689
699
  n.contentEditable = e ? "false" : "true", n.ariaReadOnly = e ? "true" : null;
690
700
  };
691
701
  R();
@@ -694,20 +704,20 @@ var gt = [], mt = () => {}, xt = t => {
694
704
  preventScroll: !0
695
705
  });
696
706
  }, B = () => {
697
- v = null, u[0] === b[0] && u[1] === b[1] || (X(n, w, t, u), b = u);
707
+ v = null, u[0] === b[0] && u[1] === b[1] || (Z(n, w, t, u), b = u);
698
708
  }, I = () => {
699
709
  null != v && clearTimeout(v);
700
710
  }, P = O.on("change", () => {
701
711
  k || requestAnimationFrame(D);
702
712
  }), N = O.on("selectionchange", () => {
703
713
  u[0] === b[0] && u[1] === b[1] || (I(), v = setTimeout(B, 50));
704
- }), L = O.on("readonly", R), H = t => {
714
+ }), L = O.on("readonly", R), C = t => {
705
715
  for (const e of m("paste")) {
706
716
  const n = e(t);
707
717
  if (n) return n;
708
718
  }
709
- l("failed to serialize pasted data");
710
- }, U = ((t, e) => {
719
+ a("failed to serialize pasted data");
720
+ }, H = ((t, e) => {
711
721
  let n = !1, r = [];
712
722
  const o = t => {
713
723
  n && r.push(...t);
@@ -744,28 +754,28 @@ var gt = [], mt = () => {}, xt = t => {
744
754
  }
745
755
  };
746
756
  })(n, () => {
747
- I(), X(n, w, t, u);
748
- }), V = () => {
757
+ I(), Z(n, w, t, u);
758
+ }), U = () => {
749
759
  A(b = x(t, ((t, e) => {
750
- const n = z(t), r = G(n, t);
760
+ const n = J(t), r = X(n, t);
751
761
  if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
752
- const o = j(t, e, r), c = W(n.anchorNode, n.focusNode);
762
+ const o = Q(t, e, r), c = z(n.anchorNode, n.focusNode);
753
763
  return (0 === c ? n.anchorOffset > n.focusOffset : 2 & c) ? [ o[1], o[0] ] : o;
754
764
  })(n, w)));
755
- }, J = () => {
756
- const e = U.v();
757
- U._(!1), e.length && (U.m(e), M.removeEventListener("selectionchange", rt), X(n, w, t, u, !0),
758
- M.addEventListener("selectionchange", rt)), h && (A(h[1]), S(h[0]), h = null), y = !1;
759
- }, Y = t => {
760
- if (!y) for (const e of m("keyboard")) if (e(t)) return t.preventDefault(), void U._(!1);
761
- }, K = () => {
762
- y || J();
763
- }, Q = e => {
765
+ }, W = () => {
766
+ const e = H.v();
767
+ H._(!1), e.length && (H.m(e), E.removeEventListener("selectionchange", rt), Z(n, w, t, u, !0),
768
+ E.addEventListener("selectionchange", rt)), y && (A(y[1]), T(y[0]), y = null), h = !1;
769
+ }, q = t => {
770
+ if (!h) for (const e of m("keyboard")) if (e(t)) return t.preventDefault(), void H._(!1);
771
+ }, Y = () => {
772
+ h || W();
773
+ }, j = e => {
764
774
  e.preventDefault();
765
775
  const r = e.inputType;
766
776
  if (r.startsWith("format")) return;
767
777
  if ("historyUndo" === r || "historyRedo" === r) return;
768
- y ? U._(!0) : V();
778
+ h ? H._(!0) : U();
769
779
  const o = e.getTargetRanges()[0];
770
780
  if (o) {
771
781
  let c = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : e.data;
@@ -773,9 +783,9 @@ var gt = [], mt = () => {}, xt = t => {
773
783
  const t = e.dataTransfer;
774
784
  t && (c = t.getData("text/plain"));
775
785
  }
776
- h || (h = [ [], u ]);
777
- const s = h[0], i = x(t, j(n, w, o));
778
- E(i) || s.push({
786
+ y || (y = [ [], u ]);
787
+ const s = y[0], i = x(t, Q(n, w, o));
788
+ S(i) || s.push({
779
789
  type: "delete",
780
790
  range: i
781
791
  }), c && s.push({
@@ -784,31 +794,31 @@ var gt = [], mt = () => {}, xt = t => {
784
794
  text: c
785
795
  });
786
796
  }
787
- y || J();
797
+ h || W();
788
798
  }, $ = () => {
789
- y || V(), y = !0;
799
+ h || U(), h = !0;
790
800
  }, tt = () => {
791
- J();
801
+ W();
792
802
  }, et = () => {
793
- k = !0, V();
803
+ k = !0, U();
794
804
  }, nt = () => {
795
805
  k = !1;
796
806
  }, rt = () => {
797
- k && !_ && V();
807
+ !k || h || _ || U();
798
808
  }, ot = t => {
799
- if (V(), !E(u)) for (const e of m("copy")) e(t);
809
+ if (U(), !S(u)) for (const e of m("copy")) e(t);
800
810
  }, ct = t => {
801
811
  t.preventDefault(), ot(t.clipboardData);
802
812
  }, st = t => {
803
- t.preventDefault(), e || (ot(t.clipboardData), S({
813
+ t.preventDefault(), e || (ot(t.clipboardData), T({
804
814
  type: "delete",
805
- range: T(u)
815
+ range: M(u)
806
816
  }));
807
- }, at = t => {
817
+ }, it = t => {
808
818
  t.preventDefault();
809
- const e = H(t.clipboardData);
819
+ const e = C(t.clipboardData);
810
820
  if (e) {
811
- const t = T(u), n = t[0], r = [ {
821
+ const t = M(u), n = t[0], r = [ {
812
822
  type: "delete",
813
823
  range: t
814
824
  } ];
@@ -820,18 +830,18 @@ var gt = [], mt = () => {}, xt = t => {
820
830
  type: "insert_node",
821
831
  at: n,
822
832
  fragment: e
823
- }), S(r);
833
+ }), T(r);
824
834
  }
825
835
  }, lt = e => {
826
836
  e.preventDefault();
827
837
  const r = e.dataTransfer, c = ((t, e, {clientX: n, clientY: r}) => {
828
- const o = q(t);
838
+ const o = G(t);
829
839
  if (o.caretPositionFromPoint) {
830
840
  const c = o.caretPositionFromPoint(n, r);
831
- if (c) return Z(t, e, c.offsetNode, c.offset);
841
+ if (c) return K(t, e, c.offsetNode, c.offset);
832
842
  } else if (o.caretRangeFromPoint) {
833
843
  const c = o.caretRangeFromPoint(n, r);
834
- if (c) return Z(t, e, c.startContainer, c.startOffset);
844
+ if (c) return K(t, e, c.startContainer, c.startOffset);
835
845
  }
836
846
  })(n, w, e);
837
847
  if (r && c) {
@@ -839,11 +849,11 @@ var gt = [], mt = () => {}, xt = t => {
839
849
  const n = [];
840
850
  _ && n.push({
841
851
  type: "delete",
842
- range: T(u)
852
+ range: M(u)
843
853
  });
844
- const s = H(r);
854
+ const s = C(r);
845
855
  if (s) {
846
- const r = g(t, c), i = it(r, n);
856
+ const r = g(t, c), i = at(r, n);
847
857
  n.push(o(s) ? {
848
858
  type: "insert_text",
849
859
  at: i,
@@ -852,9 +862,9 @@ var gt = [], mt = () => {}, xt = t => {
852
862
  type: "insert_node",
853
863
  at: i,
854
864
  fragment: s
855
- }), e = [ i, it(r, n) ];
865
+ }), e = [ i, at(r, n) ];
856
866
  }
857
- S(n), e && A(e);
867
+ T(n), e && A(e);
858
868
  }
859
869
  _ = !1;
860
870
  }, ft = t => {
@@ -862,30 +872,30 @@ var gt = [], mt = () => {}, xt = t => {
862
872
  }, ut = () => {
863
873
  _ = !1;
864
874
  };
865
- M.addEventListener("selectionchange", rt), n.addEventListener("keydown", Y), n.addEventListener("input", K),
866
- n.addEventListener("beforeinput", Q), n.addEventListener("compositionstart", $),
875
+ E.addEventListener("selectionchange", rt), n.addEventListener("keydown", q), n.addEventListener("input", Y),
876
+ n.addEventListener("beforeinput", j), n.addEventListener("compositionstart", $),
867
877
  n.addEventListener("compositionend", tt), n.addEventListener("focus", et), n.addEventListener("blur", nt),
868
- n.addEventListener("copy", ct), n.addEventListener("cut", st), n.addEventListener("paste", at),
878
+ n.addEventListener("copy", ct), n.addEventListener("cut", st), n.addEventListener("paste", it),
869
879
  n.addEventListener("drop", lt), n.addEventListener("dragstart", ft), n.addEventListener("dragend", ut);
870
880
  const dt = [];
871
881
  return m("mount").forEach(t => {
872
882
  const e = t(n, w);
873
883
  e && dt.push(e);
874
884
  }), () => {
875
- p || (p = !0, P(), N(), L(), n.contentEditable = s, n.role = i, n.ariaMultiLine = a,
876
- n.ariaReadOnly = f, n.style.whiteSpace = d, U.T(), M.removeEventListener("selectionchange", rt),
877
- n.removeEventListener("keydown", Y), n.removeEventListener("input", K), n.removeEventListener("beforeinput", Q),
885
+ p || (p = !0, P(), N(), L(), n.contentEditable = s, n.role = i, n.ariaMultiLine = l,
886
+ n.ariaReadOnly = f, n.style.whiteSpace = d, H.T(), E.removeEventListener("selectionchange", rt),
887
+ n.removeEventListener("keydown", q), n.removeEventListener("input", Y), n.removeEventListener("beforeinput", j),
878
888
  n.removeEventListener("compositionstart", $), n.removeEventListener("compositionend", tt),
879
889
  n.removeEventListener("focus", et), n.removeEventListener("blur", nt), n.removeEventListener("copy", ct),
880
- n.removeEventListener("cut", st), n.removeEventListener("paste", at), n.removeEventListener("drop", lt),
890
+ n.removeEventListener("cut", st), n.removeEventListener("paste", it), n.removeEventListener("drop", lt),
881
891
  n.removeEventListener("dragstart", ft), n.removeEventListener("dragend", ut), dt.forEach(t => {
882
892
  t();
883
893
  }));
884
894
  };
885
895
  }
886
896
  };
887
- return O.exec(dt), O;
888
- }, bt = (t, e) => {
897
+ return O.exec(yt), O;
898
+ }, Tt = (t, e) => {
889
899
  t.hook("paste", t => {
890
900
  for (const n of t.items) if ("file" === n.kind) {
891
901
  const t = e[n.type];
@@ -900,18 +910,18 @@ var gt = [], mt = () => {}, xt = t => {
900
910
  });
901
911
  };
902
912
 
903
- function vt(t, e) {
913
+ function Et(t, e) {
904
914
  const n = e && e.voidToString;
905
915
  t.hook("copy", e => {
906
- e.setData("text/plain", b(t.doc, ...T(t.selection), n));
916
+ e.setData("text/plain", T(t.doc, ...M(t.selection), n));
907
917
  }), t.hook("paste", t => t.getData("text/plain"));
908
918
  }
909
919
 
910
- function Tt(t, e) {
920
+ function Mt(t, e) {
911
921
  t.hook("mount", (n, r) => {
912
922
  const o = t.hook("copy", t => {
913
923
  const e = document.createElement("div");
914
- e.appendChild(G(z(n), n).cloneContents()), t.setData("text/html", e.innerHTML);
924
+ e.appendChild(X(J(n), n).cloneContents()), t.setData("text/html", e.innerHTML);
915
925
  }), c = t.hook("paste", t => {
916
926
  const n = t.getData("text/html");
917
927
  return n ? ((t, e, n) => {
@@ -923,25 +933,25 @@ function Tt(t, e) {
923
933
  }
924
934
  };
925
935
  let c = (new DOMParser).parseFromString(t, "text/html").body, s = !1;
926
- for (const i of [ ...c.childNodes ]) H(i) ? "StartFragment" === i.data ? (s = !0,
936
+ for (const i of [ ...c.childNodes ]) U(i) ? "StartFragment" === i.data ? (s = !0,
927
937
  c = new DocumentFragment) : "EndFragment" === i.data && (s = !1) : s && c.appendChild(i);
928
938
  return e(({t, i: e}) => {
929
939
  let n, c = null, s = "", i = !1;
930
- const a = [], l = () => {
940
+ const l = [], a = () => {
931
941
  s && (c || (c = []), c.push(r(s)), s = "");
932
942
  }, f = () => {
933
- l(), !c && i && (c = []), c && a.push({
943
+ a(), !c && i && (c = []), c && l.push({
934
944
  children: c
935
945
  }), c = null, i = !1;
936
946
  };
937
947
  for (;n = t(); ) if (4 === n) f(); else if (i = !0, 1 === n) s += e().data; else if (2 === n) {
938
- l();
948
+ a();
939
949
  const t = o(e());
940
950
  t && c.push(t);
941
951
  } else 3 === n && f();
942
- return f(), a.length || a.push({
952
+ return f(), l.length || l.push({
943
953
  children: []
944
- }), a;
954
+ }), l;
945
955
  }, c);
946
956
  })(n, r, e.serializers) : null;
947
957
  });
@@ -951,21 +961,21 @@ function Tt(t, e) {
951
961
  });
952
962
  }
953
963
 
954
- var Et = "application/x-editate-editor";
964
+ var St = "application/x-editate-editor";
955
965
 
956
- function Mt(t) {
966
+ function wt(t) {
957
967
  t.hook("copy", e => {
958
- e.setData(Et, JSON.stringify(v(t.doc, ...T(t.selection))));
968
+ e.setData(St, JSON.stringify(E(t.doc, ...M(t.selection))));
959
969
  }), t.hook("paste", t => {
960
970
  try {
961
- return JSON.parse(t.getData(Et));
971
+ return JSON.parse(t.getData(St));
962
972
  } catch (e) {
963
973
  return null;
964
974
  }
965
975
  });
966
976
  }
967
977
 
968
- function St(t) {
978
+ function At(t) {
969
979
  t.hook("apply", t => {
970
980
  console.log("apply", t);
971
981
  }), t.on("change", () => {
@@ -975,21 +985,21 @@ function St(t) {
975
985
  });
976
986
  }
977
987
 
978
- function wt(t, e) {
988
+ function Ot(t, e) {
979
989
  n(e).forEach(n => {
980
990
  const r = e[n];
981
- t.hook("keyboard", ut(n, r));
991
+ t.hook("keyboard", pt(n, r));
982
992
  });
983
993
  }
984
994
 
985
- function At(t, e) {
995
+ function Rt(t, e) {
986
996
  t.hook("mount", (n, r) => {
987
997
  let o = !0, c = !1;
988
998
  const s = t.on("selectionchange", () => {
989
999
  c || (c = !0, requestAnimationFrame(() => {
990
1000
  c = !1, o && e(() => {
991
1001
  const e = t.selection;
992
- return J(n, r, t.doc, e).getBoundingClientRect();
1002
+ return Y(n, r, t.doc, e).getBoundingClientRect();
993
1003
  });
994
1004
  }));
995
1005
  });
@@ -999,7 +1009,7 @@ function At(t, e) {
999
1009
  });
1000
1010
  }
1001
1011
 
1002
- function Ot(t) {
1012
+ function Dt(t) {
1003
1013
  t.hook("mount", t => {
1004
1014
  t.ariaMultiLine = null;
1005
1015
  }), t.hook("apply", (t, e) => {
@@ -1010,24 +1020,24 @@ function Ot(t) {
1010
1020
  const e = t.fragment;
1011
1021
  t = {
1012
1022
  ...t,
1013
- fragment: l(e) ? [ rt(...e) ] : e
1023
+ fragment: a(e) ? [ ct(...e) ] : e
1014
1024
  };
1015
1025
  }
1016
1026
  e(t);
1017
1027
  });
1018
1028
  }
1019
1029
 
1020
- var Rt = ({text: t, singleline: e, onChange: n, ...r}) => {
1021
- const o = _t({
1030
+ var Bt = ({text: t, singleline: e, onChange: n, ...r}) => {
1031
+ const o = vt({
1022
1032
  ...r,
1023
1033
  doc: {
1024
- children: K(t)
1034
+ children: $(t)
1025
1035
  }
1026
- }).exec(vt);
1027
- return e && o.exec(Ot), o.on("change", () => {
1028
- n(b(o.doc));
1036
+ }).exec(Et);
1037
+ return e && o.exec(Dt), o.on("change", () => {
1038
+ n(T(o.doc));
1029
1039
  }), o;
1030
1040
  };
1031
1041
 
1032
- export { w as Delete, B as Format, O as InsertNode, A as InsertText, S as LeavesInRange, ht as Redo, kt as Redoable, D as ReplaceDoc, R as ReplaceText, P as SetBlockAttr, L as SetVoidAttr, N as ToggleBlockAttr, I as ToggleFormat, pt as Undo, yt as Undoable, _t as createEditor, Rt as createPlainEditor, St as debugPlugin, bt as fileTransferPlugin, h as getBlockAt, p as getChildAt, y as getLeafAt, d as getNodeSize, Tt as htmlTransferPlugin, Mt as internalTranferPlugin, _ as iterLeaves, wt as keymapPlugin, vt as plainTransferPlugin, At as selectionRectPlugin, Ot as singlelinePlugin, b as sliceText };
1042
+ export { O as Delete, P as Format, D as InsertNode, R as InsertText, A as LeavesInRange, kt as Redo, mt as Redoable, I as ReplaceDoc, B as ReplaceText, L as SetBlockAttr, H as SetVoidAttr, C as ToggleBlockAttr, N as ToggleFormat, ht as Undo, gt as Undoable, vt as createEditor, Bt as createPlainEditor, At as debugPlugin, Tt as fileTransferPlugin, p as getChildAt, h as getLeafAt, y as getLeafBlockAt, d as getNodeSize, Mt as htmlTransferPlugin, wt as internalTranferPlugin, b as iterLeafBlocks, v as iterLeaves, Ot as keymapPlugin, Et as plainTransferPlugin, Rt as selectionRectPlugin, Dt as singlelinePlugin, T as sliceText };
1033
1043
  //# sourceMappingURL=index.js.map