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