editate 0.6.21 → 0.6.22

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