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