editate 0.6.21 → 0.6.23

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