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