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