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