editate 0.6.4 → 0.6.6
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/edit.d.ts +4 -4
- package/lib/dom/index.d.ts +1 -1
- package/lib/index.cjs +232 -225
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +258 -251
- package/lib/index.js.map +1 -1
- package/lib/keyboard.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -9,30 +9,30 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
9
9
|
...e,
|
|
10
10
|
text: t
|
|
11
11
|
} ]
|
|
12
|
-
})), f = "delete", u = "insert_text", d = "insert_node", p = "
|
|
12
|
+
})), f = "delete", u = "insert_text", d = "insert_node", p = "format", h = "set_node_attr", y = t => "text" in t, x = t => "children" in t, g = (t, e) => {
|
|
13
13
|
const n = r(t);
|
|
14
14
|
return n.length === r(e).length && n.every(n => n in e && ("text" === n || o(t[n], e[n])));
|
|
15
15
|
}, _ = new WeakMap, k = ({children: t}, e = 0, n = t.length) => {
|
|
16
16
|
let r = 0, o = 0;
|
|
17
17
|
for (let s = e; s < n; s++) {
|
|
18
18
|
const e = t[s];
|
|
19
|
-
r +=
|
|
19
|
+
r += m(e), 0 !== o && x(e) && r++, o++;
|
|
20
20
|
}
|
|
21
21
|
return r;
|
|
22
|
-
},
|
|
22
|
+
}, m = t => {
|
|
23
23
|
if (x(t)) {
|
|
24
24
|
let e = _.get(t);
|
|
25
25
|
return null == e && _.set(t, e = k(t)), e;
|
|
26
26
|
}
|
|
27
27
|
return y(t) ? t.text.length : 1;
|
|
28
|
-
},
|
|
28
|
+
}, b = (t, [e, n]) => {
|
|
29
29
|
let r = 0;
|
|
30
30
|
for (const n of e) r += k(t, 0, n), 0 !== n && r++, t = t.children[n];
|
|
31
31
|
return r + n;
|
|
32
|
-
},
|
|
33
|
-
const n =
|
|
32
|
+
}, E = (t, e) => {
|
|
33
|
+
const n = O(t, e);
|
|
34
34
|
return [ n.t, n.o ];
|
|
35
|
-
},
|
|
35
|
+
}, M = (t, [e, n]) => [ b(t, e), b(t, n) ], v = (t, [e, n]) => [ E(t, e), E(t, n) ], w = (t, e = 0, n = t.length - 1) => {
|
|
36
36
|
let r = e + 1;
|
|
37
37
|
for (;r <= n; ) {
|
|
38
38
|
const e = t[r - 1], o = t[r];
|
|
@@ -45,25 +45,25 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
45
45
|
const e = t[r];
|
|
46
46
|
y(e) && !e.text && t.length > 1 ? (t.splice(r, 1), n--) : r++;
|
|
47
47
|
}
|
|
48
|
-
},
|
|
48
|
+
}, T = (t, e = 0, n = t.length - 1) => {
|
|
49
49
|
let r = e + 1;
|
|
50
50
|
for (;r <= n; ) {
|
|
51
51
|
const e = t[r - 1], o = t[r];
|
|
52
|
-
t[r - 1] =
|
|
52
|
+
t[r - 1] = A(e, o), t.splice(r, 1), n--;
|
|
53
53
|
}
|
|
54
|
-
},
|
|
54
|
+
}, S = (t, e, n) => {
|
|
55
55
|
if (e.length) {
|
|
56
56
|
const r = t.length;
|
|
57
57
|
t.push(...e), r && n(t, r - 1, r);
|
|
58
58
|
}
|
|
59
|
-
},
|
|
59
|
+
}, A = (...t) => ({
|
|
60
60
|
...t[0],
|
|
61
|
-
children: t.reduce((t, e) => (
|
|
62
|
-
}),
|
|
61
|
+
children: t.reduce((t, e) => (S(t, e.children, w), t), [])
|
|
62
|
+
}), R = ({children: t}, e) => {
|
|
63
63
|
const n = t.length;
|
|
64
64
|
for (let r = 0; r < n; r++) {
|
|
65
65
|
const n = t[r];
|
|
66
|
-
let o =
|
|
66
|
+
let o = m(n);
|
|
67
67
|
if (x(n) && o++, o > e || o === e && y(n) && !n.text) return {
|
|
68
68
|
i: n,
|
|
69
69
|
l: r,
|
|
@@ -72,10 +72,10 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
72
72
|
e -= o;
|
|
73
73
|
}
|
|
74
74
|
return null;
|
|
75
|
-
},
|
|
75
|
+
}, O = (t, e) => {
|
|
76
76
|
const n = [];
|
|
77
77
|
for (;t; ) {
|
|
78
|
-
const r =
|
|
78
|
+
const r = R(t, e);
|
|
79
79
|
if (!r) break;
|
|
80
80
|
const o = r.i;
|
|
81
81
|
if (!x(o)) break;
|
|
@@ -86,12 +86,12 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
86
86
|
t: n,
|
|
87
87
|
o: e
|
|
88
88
|
};
|
|
89
|
-
},
|
|
90
|
-
const n = t.children, r =
|
|
89
|
+
}, D = (t, e) => {
|
|
90
|
+
const n = t.children, r = R(t, e);
|
|
91
91
|
if (r) {
|
|
92
92
|
const {i: e, o, l: s} = r;
|
|
93
93
|
if (x(e)) {
|
|
94
|
-
const [r, c] =
|
|
94
|
+
const [r, c] = D(e, o), i = n.slice(0, s), a = n.slice(s + 1);
|
|
95
95
|
return i.push(r), a.unshift(c), [ {
|
|
96
96
|
...t,
|
|
97
97
|
children: i
|
|
@@ -129,7 +129,7 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
129
129
|
text: ""
|
|
130
130
|
} ] : []
|
|
131
131
|
} ];
|
|
132
|
-
},
|
|
132
|
+
}, I = (t, e, n, r = 0) => {
|
|
133
133
|
if (r < e.length) {
|
|
134
134
|
const o = e[r];
|
|
135
135
|
return ((t, e, n, r) => {
|
|
@@ -138,16 +138,16 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
138
138
|
...t,
|
|
139
139
|
children: o
|
|
140
140
|
};
|
|
141
|
-
})(t, o, o, [
|
|
141
|
+
})(t, o, o, [ I(t.children[o], e, n, r + 1) ]);
|
|
142
142
|
}
|
|
143
143
|
return n;
|
|
144
|
-
},
|
|
145
|
-
const [o, s] =
|
|
146
|
-
return
|
|
144
|
+
}, P = (t, e, n, r) => {
|
|
145
|
+
const [o, s] = D(t, e), c = e < n ? D(t, n)[1] : s, i = o.children.slice();
|
|
146
|
+
return S(i, r, T), S(i, c.children, T), {
|
|
147
147
|
...t,
|
|
148
148
|
children: i
|
|
149
149
|
};
|
|
150
|
-
},
|
|
150
|
+
}, L = (t, e, n) => e >= n ? [] : D(D(t, n)[0], e)[1].children, C = (t, e) => e >= 0 && e <= m(t), B = (t, e) => e.reduce((t, e) => H(t, e), t), H = (t, e) => {
|
|
151
151
|
switch (e.type) {
|
|
152
152
|
case f:
|
|
153
153
|
{
|
|
@@ -166,113 +166,114 @@ const t = ([t, e]) => t > e ? [ e, t ] : [ t, e ], e = ([t, e]) => t === e, n =
|
|
|
166
166
|
case d:
|
|
167
167
|
{
|
|
168
168
|
const {at: n, fragment: r} = e;
|
|
169
|
-
if (t >= n) return t +
|
|
169
|
+
if (t >= n) return t + m({
|
|
170
170
|
children: r
|
|
171
171
|
});
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
return t;
|
|
176
|
-
}, N = ([t, e], n) => [
|
|
176
|
+
}, N = ([t, e], n) => [ H(t, n), H(e, n) ];
|
|
177
177
|
|
|
178
|
-
function
|
|
178
|
+
function U(t, e) {
|
|
179
179
|
t.apply({
|
|
180
|
-
type: "
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
at: 0,
|
|
185
|
-
fragment: e
|
|
180
|
+
type: "set_node_attr",
|
|
181
|
+
path: [],
|
|
182
|
+
key: "children",
|
|
183
|
+
value: e
|
|
186
184
|
});
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
let F = null,
|
|
187
|
+
let F = null, V = null, W = null, G = null, q = null;
|
|
190
188
|
|
|
191
|
-
const J = t => 1 === t.nodeType, Y = t => 8 === t.nodeType, Z = () =>
|
|
189
|
+
const 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 ] ]), X = t => 1 === t.nodeType, Y = t => 8 === t.nodeType, Z = () => V, j = () => {
|
|
192
190
|
const t = z();
|
|
193
|
-
return 1 === t ?
|
|
191
|
+
return 1 === t ? V.data.length : 2 === t ? 1 : 0;
|
|
194
192
|
}, z = () => {
|
|
195
193
|
if (null != W) return W;
|
|
196
|
-
if (
|
|
197
|
-
const t =
|
|
194
|
+
if (V) if ((t => 3 === t.nodeType)(V)) {
|
|
195
|
+
const t = V.data;
|
|
198
196
|
if (t) return W = "\n" === t ? et() ? 3 : 5 : 1;
|
|
199
|
-
} else
|
|
200
|
-
if (
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
197
|
+
} else {
|
|
198
|
+
if (!X(V)) return W = 6;
|
|
199
|
+
if ("false" === V.contentEditable) return W = 2;
|
|
200
|
+
{
|
|
201
|
+
const t = J.get(V.tagName);
|
|
202
|
+
if (null != t) return W = 1 === t ? et() ? 3 : 5 : 3 === t ? 2 : 6;
|
|
203
|
+
if (G.u(V)) return W = 4;
|
|
204
|
+
}
|
|
204
205
|
}
|
|
205
206
|
return W = 0;
|
|
206
|
-
},
|
|
207
|
+
}, K = () => {
|
|
207
208
|
const t = z();
|
|
208
209
|
if (W = null, 2 === t || 6 === t) {
|
|
209
|
-
const t =
|
|
210
|
-
if (
|
|
211
|
-
return
|
|
210
|
+
const t = V;
|
|
211
|
+
if (V = F.nextSibling(), !V) for (;(V = F.nextNode()) && t.contains(V); ) ;
|
|
212
|
+
return V;
|
|
212
213
|
}
|
|
213
|
-
return
|
|
214
|
-
}, K = () => {
|
|
215
|
-
for (;(W = null) || (U = F.nextSibling()); ) if (4 === z()) return;
|
|
214
|
+
return V = F.nextNode();
|
|
216
215
|
}, Q = () => {
|
|
217
|
-
for (;(W = null) || (
|
|
218
|
-
}, $ =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
for (;(W = null) || (V = F.nextSibling()); ) if (4 === z()) return;
|
|
217
|
+
}, $ = () => {
|
|
218
|
+
for (;(W = null) || (V = F.parentNode()); ) if (4 === z()) return;
|
|
219
|
+
}, tt = t => 2 === J.get(t.tagName), et = () => {
|
|
220
|
+
const t = V.parentNode;
|
|
221
|
+
return q(() => {
|
|
222
|
+
for (W = 0; K(); ) {
|
|
222
223
|
if (z()) return !0;
|
|
223
|
-
if (!t.contains(
|
|
224
|
+
if (!t.contains(V)) break;
|
|
224
225
|
}
|
|
225
226
|
return !1;
|
|
226
227
|
});
|
|
227
228
|
}, nt = () => {
|
|
228
|
-
for (;
|
|
229
|
+
for (;K(); ) {
|
|
229
230
|
const t = z();
|
|
230
231
|
if (t && 6 !== t) return t;
|
|
231
232
|
}
|
|
232
|
-
}, rt = new Set([ "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE", "LI", "DT", "DD", "TR" ]), ot = t => rt.has(t.tagName), st =
|
|
233
|
+
}, rt = new Set([ "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE", "LI", "DT", "DD", "TR" ]), ot = t => rt.has(t.tagName), st = (t, e) => t.compareDocumentPosition(e), ct = t => t.ownerDocument, it = t => ct(t).getSelection(), at = (t, e) => {
|
|
233
234
|
if (t.rangeCount) {
|
|
234
235
|
const n = t.getRangeAt(0);
|
|
235
236
|
if (e.contains(n.commonAncestorContainer)) return n;
|
|
236
237
|
}
|
|
237
|
-
},
|
|
238
|
-
const o =
|
|
239
|
-
(n ||
|
|
238
|
+
}, lt = (t, e, n, r) => {
|
|
239
|
+
const o = it(t);
|
|
240
|
+
(n || at(o, t)) && (o.removeAllRanges(), o.addRange(e), r && (o.collapseToEnd(),
|
|
240
241
|
o.extend(e.startContainer, e.startOffset)));
|
|
241
|
-
},
|
|
242
|
+
}, ft = (t, e, [n, r], o, s, c) => {
|
|
242
243
|
const i = 0 === o, a = o > 0, l = a ? r : n, f = a ? n : r;
|
|
243
244
|
if (0 === l[0].length && 0 === l[1] && i && !e.hasChildNodes()) {
|
|
244
245
|
const n = t.createRange();
|
|
245
|
-
return n.setStart(e, 0), n.setEnd(e, 0),
|
|
246
|
+
return n.setStart(e, 0), n.setEnd(e, 0), lt(e, n, c);
|
|
246
247
|
}
|
|
247
|
-
const u =
|
|
248
|
+
const u = ut(e, l, s);
|
|
248
249
|
if (!u) return;
|
|
249
|
-
const d = i ? u :
|
|
250
|
+
const d = i ? u : ut(e, f, s);
|
|
250
251
|
if (!d) return;
|
|
251
252
|
const p = t.createRange(), [h, y] = u, [x, g] = d;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
},
|
|
253
|
+
X(h) ? y < 1 ? p.setStartBefore(h) : p.setStartAfter(h) : p.setStart(h, y), X(x) ? g < 1 ? p.setEndBefore(x) : p.setEndAfter(x) : p.setEnd(x, g),
|
|
254
|
+
lt(e, p, c, a);
|
|
255
|
+
}, ut = (t, [e, n], r) => r(() => {
|
|
255
256
|
let t, r = 0;
|
|
256
257
|
for (;t = nt(); ) if (4 === t) {
|
|
257
|
-
if (r < e.length) for (let t = e[r++]; t > 0; t--)
|
|
258
|
+
if (r < e.length) for (let t = e[r++]; t > 0; t--) Q();
|
|
258
259
|
} else {
|
|
259
260
|
const t = j();
|
|
260
261
|
if (n <= t) return [ Z(), n ];
|
|
261
262
|
n -= t;
|
|
262
263
|
}
|
|
263
|
-
}, t),
|
|
264
|
+
}, t), dt = (t, e, r, o) => {
|
|
264
265
|
let s = !0;
|
|
265
266
|
if (t === e && !e.hasChildNodes()) return [ [ 0 ], 0 ];
|
|
266
|
-
if (
|
|
267
|
+
if (X(e) && e.hasChildNodes()) {
|
|
267
268
|
const t = n(r, e.childNodes.length - 1);
|
|
268
269
|
e = e.childNodes[t], s = t === r, r = 0;
|
|
269
270
|
}
|
|
270
271
|
return o(() => {
|
|
271
|
-
4 !== z() &&
|
|
272
|
+
4 !== z() && $();
|
|
272
273
|
const n = o(() => {
|
|
273
274
|
const e = [];
|
|
274
275
|
let n;
|
|
275
|
-
for (;(n = Z()) && n !== t; ) e.unshift(n),
|
|
276
|
+
for (;(n = Z()) && n !== t; ) e.unshift(n), $();
|
|
276
277
|
if (!e.length) return [ 0 ];
|
|
277
278
|
let r = 0, o = e[e.length - 1];
|
|
278
279
|
for (;o = o.previousElementSibling; ) tt(o) || r++;
|
|
@@ -280,7 +281,7 @@ const J = t => 1 === t.nodeType, Y = t => 8 === t.nodeType, Z = () => U, j = ()
|
|
|
280
281
|
});
|
|
281
282
|
let c = 0;
|
|
282
283
|
for (;nt(); ) {
|
|
283
|
-
const t =
|
|
284
|
+
const t = st(e, Z());
|
|
284
285
|
if (0 === t || 16 & t) {
|
|
285
286
|
if (s) break;
|
|
286
287
|
} else if (4 & t) break;
|
|
@@ -288,10 +289,10 @@ const J = t => 1 === t.nodeType, Y = t => 8 === t.nodeType, Z = () => U, j = ()
|
|
|
288
289
|
}
|
|
289
290
|
return [ n, c + r ];
|
|
290
291
|
}, t, e);
|
|
291
|
-
},
|
|
292
|
-
const c =
|
|
293
|
-
return [ c, r === s && n === o ? c :
|
|
294
|
-
},
|
|
292
|
+
}, pt = (t, e, {startOffset: n, startContainer: r, endOffset: o, endContainer: s}) => {
|
|
293
|
+
const c = dt(t, r, n, e);
|
|
294
|
+
return [ c, r === s && n === o ? c : dt(t, s, o, e) ];
|
|
295
|
+
}, ht = "undefined" != typeof navigator && /Mac|iP(hone|od|ad)/.test(navigator.platform), yt = (t, e) => {
|
|
295
296
|
const n = t.endsWith("+"), r = (n ? t.slice(0, -2) : t).split("+"), o = n ? "+" : r.pop(), s = "Space" === o ? " " : o.toLowerCase();
|
|
296
297
|
let c = !1, i = !1, a = !1, l = !1;
|
|
297
298
|
return r.forEach(t => {
|
|
@@ -305,7 +306,7 @@ const J = t => 1 === t.nodeType, Y = t => 8 === t.nodeType, Z = () => U, j = ()
|
|
|
305
306
|
break;
|
|
306
307
|
|
|
307
308
|
case "Mod":
|
|
308
|
-
|
|
309
|
+
ht ? a = !0 : i = !0;
|
|
309
310
|
break;
|
|
310
311
|
|
|
311
312
|
case "Alt":
|
|
@@ -321,20 +322,20 @@ const J = t => 1 === t.nodeType, Y = t => 8 === t.nodeType, Z = () => U, j = ()
|
|
|
321
322
|
};
|
|
322
323
|
};
|
|
323
324
|
|
|
324
|
-
function
|
|
325
|
+
function xt(t) {
|
|
325
326
|
let e = 0, n = 0, r = !1;
|
|
326
327
|
const s = Date.now, c = [ [ t.doc, t.selection, [] ] ], i = () => c[e], a = () => e > 0, l = () => e < c.length - 1, f = () => {
|
|
327
328
|
if (a()) {
|
|
328
329
|
const n = i()[1];
|
|
329
330
|
e--;
|
|
330
331
|
const s = t.doc;
|
|
331
|
-
r = !0, t.exec(
|
|
332
|
+
r = !0, t.exec(U, i()[0].children), r = !1, o(s, t.doc) || (t.selection = n);
|
|
332
333
|
}
|
|
333
334
|
}, u = () => {
|
|
334
335
|
if (l()) {
|
|
335
336
|
e++;
|
|
336
337
|
const [n, s, c] = i(), a = t.doc;
|
|
337
|
-
r = !0, t.exec(
|
|
338
|
+
r = !0, t.exec(U, n.children), r = !1, o(a, t.doc) || (t.selection = [ B(s[0], c), B(s[1], c) ]);
|
|
338
339
|
}
|
|
339
340
|
};
|
|
340
341
|
t.hook("apply", (i, a) => {
|
|
@@ -349,10 +350,11 @@ function _t(t) {
|
|
|
349
350
|
const t = [ l, f, [] ];
|
|
350
351
|
e >= c.length ? c.push(t) : c[e] = t;
|
|
351
352
|
}
|
|
352
|
-
n = t, c[e][0] = u, c[e][2].push(i), c.
|
|
353
|
+
n = t, c[e][0] = u, c[e][2].push(i), c.length > e + 1 && (c.length = e + 1), e > 500 && (e--,
|
|
354
|
+
c.shift());
|
|
353
355
|
}
|
|
354
|
-
}), t.hook("keyboard",
|
|
355
|
-
t.set(
|
|
356
|
+
}), t.hook("keyboard", yt("Mod+Z", f)), t.hook("keyboard", yt("Shift+Mod+Z", u)),
|
|
357
|
+
t.set(xt, {
|
|
356
358
|
undo: f,
|
|
357
359
|
redo: u,
|
|
358
360
|
undoable: a,
|
|
@@ -360,11 +362,11 @@ function _t(t) {
|
|
|
360
362
|
});
|
|
361
363
|
}
|
|
362
364
|
|
|
363
|
-
const
|
|
365
|
+
const gt = [], _t = () => {}, kt = t => {
|
|
364
366
|
throw Error(t);
|
|
365
|
-
},
|
|
367
|
+
}, mt = ({doc: n, readonly: r = !1, schema: a, isBlock: x = ot, onWarn: g = console.warn, onError: _ = kt}) => {
|
|
366
368
|
let k = [ 0, 0 ];
|
|
367
|
-
const
|
|
369
|
+
const m = t => {
|
|
368
370
|
if (!a) return g("An unsafe operation was detected. We recommend using schema option."),
|
|
369
371
|
!0;
|
|
370
372
|
const e = a["~standard"].validate(t);
|
|
@@ -374,19 +376,21 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
374
376
|
}
|
|
375
377
|
return !1;
|
|
376
378
|
};
|
|
377
|
-
a && !
|
|
378
|
-
const
|
|
379
|
-
const e =
|
|
380
|
-
e && (
|
|
381
|
-
|
|
379
|
+
a && !m(n) && _("Invalid document");
|
|
380
|
+
const E = new Map, w = new WeakMap, T = t => E.get(t) || gt, S = new Map, A = new Set, D = t => {
|
|
381
|
+
const e = S.get(t);
|
|
382
|
+
e && (A.size || i(() => {
|
|
383
|
+
A.forEach(t => {
|
|
382
384
|
t();
|
|
383
|
-
}),
|
|
384
|
-
}),
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
}), A.clear();
|
|
386
|
+
}), e.forEach(t => {
|
|
387
|
+
A.add(t);
|
|
388
|
+
}));
|
|
389
|
+
}, H = t => {
|
|
390
|
+
if (!r) if (Array.isArray(t)) for (const e of t) U(e); else U(t);
|
|
391
|
+
return X;
|
|
392
|
+
}, U = t => {
|
|
393
|
+
const e = n, r = T("apply"), s = r.length;
|
|
390
394
|
let c = 0;
|
|
391
395
|
const i = () => {
|
|
392
396
|
if (c < s) {
|
|
@@ -400,21 +404,21 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
400
404
|
case f:
|
|
401
405
|
{
|
|
402
406
|
const [r, o] = n.range;
|
|
403
|
-
|
|
407
|
+
C(t, r) && C(t, o) && r < o && (t = P(t, r, o, []), e = N(e, n));
|
|
404
408
|
break;
|
|
405
409
|
}
|
|
406
410
|
|
|
407
411
|
case u:
|
|
408
412
|
{
|
|
409
413
|
const {at: r, text: o} = n;
|
|
410
|
-
if (
|
|
411
|
-
const {i: s, o: c} =
|
|
414
|
+
if (C(t, r) && o) {
|
|
415
|
+
const {i: s, o: c} = O(t, r), i = R(s, c - 1);
|
|
412
416
|
let a;
|
|
413
417
|
if (i) {
|
|
414
418
|
const t = i.i;
|
|
415
419
|
y(t) && (a = t);
|
|
416
420
|
}
|
|
417
|
-
t =
|
|
421
|
+
t = P(t, r, r, l(o, a, s)), e = N(e, n);
|
|
418
422
|
}
|
|
419
423
|
break;
|
|
420
424
|
}
|
|
@@ -422,23 +426,23 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
422
426
|
case d:
|
|
423
427
|
{
|
|
424
428
|
const {at: r, fragment: o} = n;
|
|
425
|
-
|
|
429
|
+
C(t, r) && o.length && (t = P(t, r, r, o), e = N(e, n));
|
|
426
430
|
break;
|
|
427
431
|
}
|
|
428
432
|
|
|
429
433
|
case p:
|
|
430
434
|
{
|
|
431
435
|
const {range: [e, r], key: o, value: s} = n;
|
|
432
|
-
if (
|
|
433
|
-
const {i: {children: n}, t: r} =
|
|
436
|
+
if (C(t, e) && C(t, r) && e <= r) if (e === r) {
|
|
437
|
+
const {i: {children: n}, t: r} = O(t, e);
|
|
434
438
|
if (1 === n.length) {
|
|
435
439
|
const e = n[0];
|
|
436
|
-
y(e) && !e.text && (t =
|
|
440
|
+
y(e) && !e.text && (t = I(t, [ ...r, 0 ], {
|
|
437
441
|
...e,
|
|
438
442
|
[o]: s
|
|
439
443
|
}));
|
|
440
444
|
}
|
|
441
|
-
} else t =
|
|
445
|
+
} else t = P(t, e, r, L(t, e, r).map(t => ({
|
|
442
446
|
...t,
|
|
443
447
|
children: t.children.map(t => y(t) ? {
|
|
444
448
|
...t,
|
|
@@ -454,7 +458,7 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
454
458
|
for (let n = 0; n < e.length; n++) t = t.children[e[n]];
|
|
455
459
|
return t;
|
|
456
460
|
})(t, e);
|
|
457
|
-
s && (t =
|
|
461
|
+
s && (t = I(t, e, {
|
|
458
462
|
...s,
|
|
459
463
|
[r]: o
|
|
460
464
|
}));
|
|
@@ -463,7 +467,7 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
463
467
|
}
|
|
464
468
|
return [ t, e ];
|
|
465
469
|
})(n, k, t);
|
|
466
|
-
(({type: t}) => t === d || t === p || t === h)(t) && !
|
|
470
|
+
(({type: t}) => t === d || t === p || t === h)(t) && !m(e) || (n = e, k = r);
|
|
467
471
|
} catch (t) {
|
|
468
472
|
g("rollback operation: " + t);
|
|
469
473
|
}
|
|
@@ -471,11 +475,11 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
471
475
|
}, a = e => {
|
|
472
476
|
e && (t = e), c++, i();
|
|
473
477
|
};
|
|
474
|
-
i(), o(e, n) ||
|
|
478
|
+
i(), o(e, n) || D("change");
|
|
475
479
|
}, J = t => {
|
|
476
|
-
!((t, [e, n]) =>
|
|
477
|
-
|
|
478
|
-
},
|
|
480
|
+
!((t, [e, n]) => C(t, e) && C(t, n))(n, t) || k[0] === t[0] && k[1] === t[1] || (k = t,
|
|
481
|
+
D("selectionchange"));
|
|
482
|
+
}, X = {
|
|
479
483
|
get doc() {
|
|
480
484
|
return n;
|
|
481
485
|
},
|
|
@@ -489,81 +493,84 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
489
493
|
return r;
|
|
490
494
|
},
|
|
491
495
|
set readonly(t) {
|
|
492
|
-
r = t,
|
|
496
|
+
r = t, D("readonly");
|
|
493
497
|
},
|
|
494
|
-
apply:
|
|
498
|
+
apply: H,
|
|
495
499
|
on: (t, e) => {
|
|
496
|
-
let n =
|
|
497
|
-
return n ||
|
|
500
|
+
let n = S.get(t);
|
|
501
|
+
return n || S.set(t, n = new Set), n.add(e), () => {
|
|
498
502
|
n.delete(e);
|
|
499
503
|
};
|
|
500
504
|
},
|
|
501
505
|
hook: (t, e) => {
|
|
502
|
-
let n =
|
|
503
|
-
return n ||
|
|
506
|
+
let n = E.get(t);
|
|
507
|
+
return n || E.set(t, n = []), n.push(e), () => {
|
|
504
508
|
const t = n.indexOf(e);
|
|
505
509
|
-1 !== t && n.splice(t, 1);
|
|
506
510
|
};
|
|
507
511
|
},
|
|
508
512
|
exec: (t, ...e) => {
|
|
509
|
-
const n = t(
|
|
510
|
-
return void 0 === n ?
|
|
513
|
+
const n = t(X, ...e);
|
|
514
|
+
return void 0 === n ? X : n;
|
|
511
515
|
},
|
|
512
|
-
get: t => (
|
|
513
|
-
set: (t, e) => (
|
|
516
|
+
get: t => (w.has(t) || _("No value found for key"), w.get(t)),
|
|
517
|
+
set: (t, e) => (w.set(t, e), X),
|
|
514
518
|
input: o => {
|
|
515
519
|
if (!window.InputEvent || !c(InputEvent.prototype.getTargetRanges)) return g("beforeinput event is not supported."),
|
|
516
|
-
|
|
520
|
+
_t;
|
|
517
521
|
const {contentEditable: i, role: a, ariaMultiLine: l, ariaReadOnly: f} = o, u = o.style.whiteSpace;
|
|
518
522
|
o.role = "textbox", o.style.whiteSpace = "pre-wrap", o.ariaMultiLine = "true";
|
|
519
523
|
let d = !1, p = null, h = !1, y = !1, _ = !1;
|
|
520
|
-
const
|
|
524
|
+
const m = ct(o), E = (t => {
|
|
521
525
|
const e = (n, r, o) => {
|
|
522
|
-
const s =
|
|
526
|
+
const s = G, c = q, i = F, a = V, l = W;
|
|
523
527
|
try {
|
|
524
|
-
return F || (
|
|
528
|
+
return F || (G = t, q = e, F = G.p.createTreeWalker(r, 5)), o && (F.currentNode = V = o),
|
|
525
529
|
n();
|
|
526
530
|
} finally {
|
|
527
|
-
|
|
531
|
+
G = s, q = c, F = i, V = a, W = l, F && a && (F.currentNode = a);
|
|
528
532
|
}
|
|
529
533
|
};
|
|
530
534
|
return e;
|
|
531
535
|
})({
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}), S = () => {
|
|
536
|
+
p: m,
|
|
537
|
+
u: x
|
|
538
|
+
}), w = () => {
|
|
536
539
|
o.contentEditable = r ? "false" : "true", o.ariaReadOnly = r ? "true" : null;
|
|
537
540
|
};
|
|
538
|
-
|
|
539
|
-
const
|
|
541
|
+
w();
|
|
542
|
+
const S = X.on("change", () => {
|
|
540
543
|
y || requestAnimationFrame(() => {
|
|
541
544
|
y || o.focus({
|
|
542
545
|
preventScroll: !0
|
|
543
546
|
});
|
|
544
547
|
});
|
|
545
|
-
}),
|
|
546
|
-
for (const e of
|
|
547
|
-
const n = e(t,
|
|
548
|
+
}), A = X.on("readonly", w), R = t => {
|
|
549
|
+
for (const e of T("paste")) {
|
|
550
|
+
const n = e(t, E);
|
|
548
551
|
if (n) return n;
|
|
549
552
|
}
|
|
550
553
|
g("failed to serialize pasted data");
|
|
551
|
-
},
|
|
552
|
-
let n = !1;
|
|
553
|
-
const
|
|
554
|
+
}, O = ((t, e) => {
|
|
555
|
+
let n = !1, r = [];
|
|
556
|
+
const o = t => {
|
|
554
557
|
n && r.push(...t);
|
|
555
558
|
}, s = new MutationObserver(t => {
|
|
556
559
|
o(t), n || e();
|
|
557
560
|
}), c = () => {
|
|
558
561
|
o(s.takeRecords());
|
|
559
|
-
}, i = () =>
|
|
562
|
+
}, i = () => {
|
|
563
|
+
c();
|
|
564
|
+
const t = r;
|
|
565
|
+
return r = [], t;
|
|
566
|
+
};
|
|
560
567
|
return s.observe(t, {
|
|
561
568
|
characterData: !0,
|
|
562
569
|
characterDataOldValue: !0,
|
|
563
570
|
childList: !0,
|
|
564
571
|
subtree: !0
|
|
565
572
|
}), {
|
|
566
|
-
|
|
573
|
+
h: t => {
|
|
567
574
|
let e;
|
|
568
575
|
for (;e = t.pop(); ) if ("childList" === e.type) {
|
|
569
576
|
const {target: t, removedNodes: n, addedNodes: r, nextSibling: o} = e;
|
|
@@ -572,40 +579,40 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
572
579
|
} else e.target.data = e.oldValue;
|
|
573
580
|
i();
|
|
574
581
|
},
|
|
575
|
-
|
|
582
|
+
_: t => {
|
|
576
583
|
!n && t && c(), n = t;
|
|
577
584
|
},
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
r.
|
|
585
|
+
k: i,
|
|
586
|
+
m: () => {
|
|
587
|
+
r.length = 0, s.disconnect();
|
|
581
588
|
}
|
|
582
589
|
};
|
|
583
590
|
})(o, () => {
|
|
584
|
-
|
|
585
|
-
}),
|
|
586
|
-
J(
|
|
587
|
-
const n =
|
|
591
|
+
ft(m, o, v(n, k), k[0] - k[1], E);
|
|
592
|
+
}), D = () => {
|
|
593
|
+
J(M(n, ((t, e) => {
|
|
594
|
+
const n = it(t), r = at(n, t);
|
|
588
595
|
if (!r) return [ [ [ 0 ], 0 ], [ [ 0 ], 0 ] ];
|
|
589
|
-
const o =
|
|
596
|
+
const o = pt(t, e, r), s = st(n.anchorNode, n.focusNode);
|
|
590
597
|
return (0 === s ? n.anchorOffset > n.focusOffset : 2 & s) ? [ o[1], o[0] ] : o;
|
|
591
|
-
})(o,
|
|
592
|
-
},
|
|
593
|
-
const t =
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
},
|
|
597
|
-
if (!h) for (const e of
|
|
598
|
-
},
|
|
599
|
-
h ||
|
|
600
|
-
},
|
|
598
|
+
})(o, E)));
|
|
599
|
+
}, I = () => {
|
|
600
|
+
const t = O.k();
|
|
601
|
+
O._(!1), t.length && (O.h(t), m.removeEventListener("selectionchange", j), ft(m, o, v(n, k), k[0] - k[1], E, !0),
|
|
602
|
+
m.addEventListener("selectionchange", j)), p && (J(p[1]), H(p[0]), p = null), h = !1;
|
|
603
|
+
}, P = t => {
|
|
604
|
+
if (!h) for (const e of T("keyboard")) if (e(t)) return t.preventDefault(), void O._(!1);
|
|
605
|
+
}, L = () => {
|
|
606
|
+
h || I();
|
|
607
|
+
}, C = t => {
|
|
601
608
|
t.preventDefault();
|
|
602
609
|
const r = t.inputType;
|
|
603
610
|
if (r.startsWith("format")) return;
|
|
604
611
|
if ("historyUndo" === r || "historyRedo" === r) return;
|
|
605
|
-
h ?
|
|
612
|
+
h ? O._(!0) : D();
|
|
606
613
|
const s = t.getTargetRanges()[0];
|
|
607
614
|
if (s) {
|
|
608
|
-
const c =
|
|
615
|
+
const c = M(n, pt(o, E, s));
|
|
609
616
|
let i, a = "insertParagraph" === r || "insertLineBreak" === r ? "\n" : t.data;
|
|
610
617
|
if (null == a) {
|
|
611
618
|
const e = t.dataTransfer;
|
|
@@ -620,29 +627,29 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
620
627
|
text: a
|
|
621
628
|
});
|
|
622
629
|
}
|
|
623
|
-
h ||
|
|
630
|
+
h || I();
|
|
624
631
|
}, N = () => {
|
|
625
|
-
h ||
|
|
626
|
-
},
|
|
627
|
-
|
|
632
|
+
h || D(), h = !0;
|
|
633
|
+
}, U = () => {
|
|
634
|
+
I();
|
|
635
|
+
}, Y = () => {
|
|
636
|
+
y = !0, D();
|
|
628
637
|
}, Z = () => {
|
|
629
|
-
y = !0, I();
|
|
630
|
-
}, j = () => {
|
|
631
638
|
y = !1;
|
|
632
|
-
},
|
|
633
|
-
!y || h || _ ||
|
|
634
|
-
},
|
|
635
|
-
if (
|
|
639
|
+
}, j = () => {
|
|
640
|
+
!y || h || _ || D();
|
|
641
|
+
}, z = t => {
|
|
642
|
+
if (D(), !e(k)) for (const e of T("copy")) e(t);
|
|
636
643
|
}, K = t => {
|
|
637
|
-
t.preventDefault(),
|
|
644
|
+
t.preventDefault(), z(t.clipboardData);
|
|
638
645
|
}, Q = e => {
|
|
639
|
-
e.preventDefault(), r || (
|
|
646
|
+
e.preventDefault(), r || (z(e.clipboardData), H({
|
|
640
647
|
type: "delete",
|
|
641
648
|
range: t(k)
|
|
642
649
|
}));
|
|
643
650
|
}, $ = e => {
|
|
644
651
|
e.preventDefault();
|
|
645
|
-
const n =
|
|
652
|
+
const n = R(e.clipboardData);
|
|
646
653
|
if (n) {
|
|
647
654
|
const e = t(k), r = e[0], o = [ {
|
|
648
655
|
type: "delete",
|
|
@@ -656,19 +663,19 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
656
663
|
type: "insert_node",
|
|
657
664
|
at: r,
|
|
658
665
|
fragment: n
|
|
659
|
-
}),
|
|
666
|
+
}), H(o);
|
|
660
667
|
}
|
|
661
668
|
}, tt = e => {
|
|
662
669
|
e.preventDefault();
|
|
663
670
|
const r = e.dataTransfer, c = ((t, e, {clientX: n, clientY: r}, o) => {
|
|
664
671
|
if (t.caretPositionFromPoint) {
|
|
665
672
|
const s = t.caretPositionFromPoint(n, r);
|
|
666
|
-
if (s) return
|
|
673
|
+
if (s) return dt(e, s.offsetNode, s.offset, o);
|
|
667
674
|
} else if (t.caretRangeFromPoint) {
|
|
668
675
|
const s = t.caretRangeFromPoint(n, r);
|
|
669
|
-
if (s) return
|
|
676
|
+
if (s) return dt(e, s.startContainer, s.startOffset, o);
|
|
670
677
|
}
|
|
671
|
-
})(
|
|
678
|
+
})(m, o, e, E);
|
|
672
679
|
if (r && c) {
|
|
673
680
|
let e;
|
|
674
681
|
const o = [];
|
|
@@ -676,9 +683,9 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
676
683
|
type: "delete",
|
|
677
684
|
range: t(k)
|
|
678
685
|
});
|
|
679
|
-
const i =
|
|
686
|
+
const i = R(r);
|
|
680
687
|
if (i) {
|
|
681
|
-
const t =
|
|
688
|
+
const t = b(n, c), r = B(t, o);
|
|
682
689
|
o.push(s(i) ? {
|
|
683
690
|
type: "insert_text",
|
|
684
691
|
at: r,
|
|
@@ -687,30 +694,30 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
687
694
|
type: "insert_node",
|
|
688
695
|
at: r,
|
|
689
696
|
fragment: i
|
|
690
|
-
}), e = [ r,
|
|
697
|
+
}), e = [ r, B(t, o) ];
|
|
691
698
|
}
|
|
692
|
-
|
|
699
|
+
H(o), e && J(e);
|
|
693
700
|
}
|
|
694
701
|
}, et = t => {
|
|
695
|
-
_ = !0,
|
|
702
|
+
_ = !0, z(t.dataTransfer);
|
|
696
703
|
}, nt = () => {
|
|
697
704
|
_ = !1;
|
|
698
705
|
};
|
|
699
|
-
|
|
700
|
-
o.addEventListener("beforeinput",
|
|
701
|
-
o.addEventListener("compositionend",
|
|
706
|
+
m.addEventListener("selectionchange", j), o.addEventListener("keydown", P), o.addEventListener("input", L),
|
|
707
|
+
o.addEventListener("beforeinput", C), o.addEventListener("compositionstart", N),
|
|
708
|
+
o.addEventListener("compositionend", U), o.addEventListener("focus", Y), o.addEventListener("blur", Z),
|
|
702
709
|
o.addEventListener("copy", K), o.addEventListener("cut", Q), o.addEventListener("paste", $),
|
|
703
710
|
o.addEventListener("drop", tt), o.addEventListener("dragstart", et), o.addEventListener("dragend", nt);
|
|
704
711
|
const rt = [];
|
|
705
|
-
return
|
|
712
|
+
return T("mount").forEach(t => {
|
|
706
713
|
const e = t(o);
|
|
707
714
|
e && rt.push(e);
|
|
708
715
|
}), () => {
|
|
709
|
-
d || (d = !0,
|
|
710
|
-
o.ariaReadOnly = f, o.style.whiteSpace = u,
|
|
711
|
-
o.removeEventListener("keydown",
|
|
712
|
-
o.removeEventListener("compositionstart", N), o.removeEventListener("compositionend",
|
|
713
|
-
o.removeEventListener("focus",
|
|
716
|
+
d || (d = !0, S(), A(), o.contentEditable = i, o.role = a, o.ariaMultiLine = l,
|
|
717
|
+
o.ariaReadOnly = f, o.style.whiteSpace = u, O.m(), m.removeEventListener("selectionchange", j),
|
|
718
|
+
o.removeEventListener("keydown", P), o.removeEventListener("input", L), o.removeEventListener("beforeinput", C),
|
|
719
|
+
o.removeEventListener("compositionstart", N), o.removeEventListener("compositionend", U),
|
|
720
|
+
o.removeEventListener("focus", Y), o.removeEventListener("blur", Z), o.removeEventListener("copy", K),
|
|
714
721
|
o.removeEventListener("cut", Q), o.removeEventListener("paste", $), o.removeEventListener("drop", tt),
|
|
715
722
|
o.removeEventListener("dragstart", et), o.removeEventListener("dragend", nt), rt.forEach(t => {
|
|
716
723
|
t();
|
|
@@ -718,21 +725,21 @@ const kt = [], bt = () => {}, mt = t => {
|
|
|
718
725
|
};
|
|
719
726
|
}
|
|
720
727
|
};
|
|
721
|
-
return
|
|
728
|
+
return X.exec(xt), X;
|
|
722
729
|
};
|
|
723
730
|
|
|
724
|
-
function
|
|
731
|
+
function bt(e, n) {
|
|
725
732
|
const r = n && n.serializer;
|
|
726
733
|
e.hook("copy", n => {
|
|
727
734
|
n.setData("text/plain", a({
|
|
728
|
-
children:
|
|
735
|
+
children: L(e.doc, ...t(e.selection))
|
|
729
736
|
}, r));
|
|
730
737
|
}), e.hook("paste", t => t.getData("text/plain"));
|
|
731
738
|
}
|
|
732
739
|
|
|
733
|
-
const
|
|
740
|
+
const Et = "application/x-editate-editor";
|
|
734
741
|
|
|
735
|
-
function
|
|
742
|
+
function Mt(t) {
|
|
736
743
|
t.hook("mount", t => {
|
|
737
744
|
t.ariaMultiLine = null;
|
|
738
745
|
}), t.hook("apply", (t, e) => {
|
|
@@ -741,7 +748,7 @@ function St(t) {
|
|
|
741
748
|
text: t.text.replaceAll("\n", "")
|
|
742
749
|
} : "insert_node" === t.type && (t = {
|
|
743
750
|
...t,
|
|
744
|
-
fragment: [
|
|
751
|
+
fragment: [ A(...t.fragment) ]
|
|
745
752
|
}), e(t);
|
|
746
753
|
});
|
|
747
754
|
}
|
|
@@ -753,7 +760,7 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
753
760
|
});
|
|
754
761
|
}, exports.Format = function(e, n, r, o = t(e.selection)) {
|
|
755
762
|
e.apply({
|
|
756
|
-
type: "
|
|
763
|
+
type: "format",
|
|
757
764
|
range: o,
|
|
758
765
|
key: n,
|
|
759
766
|
value: r
|
|
@@ -773,10 +780,10 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
773
780
|
text: e
|
|
774
781
|
});
|
|
775
782
|
}, exports.Redo = function(t) {
|
|
776
|
-
t.get(
|
|
783
|
+
t.get(xt).redo();
|
|
777
784
|
}, exports.Redoable = function(t) {
|
|
778
|
-
return t.get(
|
|
779
|
-
}, exports.ReplaceDoc =
|
|
785
|
+
return t.get(xt).redoable();
|
|
786
|
+
}, exports.ReplaceDoc = U, exports.ReplaceText = function(e, n) {
|
|
780
787
|
const r = t(e.selection);
|
|
781
788
|
e.apply({
|
|
782
789
|
type: "delete",
|
|
@@ -787,7 +794,7 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
787
794
|
text: n
|
|
788
795
|
});
|
|
789
796
|
}, exports.SetBlockAttr = function(t, e, n, r = t.selection[0]) {
|
|
790
|
-
const {t: o} =
|
|
797
|
+
const {t: o} = O(t.doc, r);
|
|
791
798
|
t.apply({
|
|
792
799
|
type: "set_node_attr",
|
|
793
800
|
path: o,
|
|
@@ -795,7 +802,7 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
795
802
|
value: n
|
|
796
803
|
});
|
|
797
804
|
}, exports.ToggleBlockAttr = function(t, e, n, r, o = t.selection[0]) {
|
|
798
|
-
const {i: s, t: c} =
|
|
805
|
+
const {i: s, t: c} = O(t.doc, o);
|
|
799
806
|
t.apply({
|
|
800
807
|
type: "set_node_attr",
|
|
801
808
|
path: c,
|
|
@@ -806,33 +813,33 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
806
813
|
let s;
|
|
807
814
|
if (e(o)) {
|
|
808
815
|
const t = ((t, e) => {
|
|
809
|
-
const n =
|
|
810
|
-
return
|
|
816
|
+
const n = O(t, e);
|
|
817
|
+
return R(n.i, n.o);
|
|
811
818
|
})(n.doc, o[0]);
|
|
812
819
|
if (!t) return;
|
|
813
820
|
s = [ t.i ];
|
|
814
|
-
} else s =
|
|
821
|
+
} else s = L(n.doc, ...o).flatMap(t => t.children);
|
|
815
822
|
const c = s.filter(y);
|
|
816
823
|
c.length && n.apply({
|
|
817
|
-
type: "
|
|
824
|
+
type: "format",
|
|
818
825
|
range: o,
|
|
819
826
|
key: r,
|
|
820
827
|
value: !!c.some(t => !t[r])
|
|
821
828
|
});
|
|
822
829
|
}, exports.Undo = function(t) {
|
|
823
|
-
t.get(
|
|
830
|
+
t.get(xt).undo();
|
|
824
831
|
}, exports.Undoable = function(t) {
|
|
825
|
-
return t.get(
|
|
826
|
-
}, exports.createEditor =
|
|
827
|
-
const o =
|
|
832
|
+
return t.get(xt).undoable();
|
|
833
|
+
}, exports.createEditor = mt, exports.createPlainEditor = ({text: t, singleline: e, onChange: n, ...r}) => {
|
|
834
|
+
const o = mt({
|
|
828
835
|
...r,
|
|
829
836
|
doc: {
|
|
830
837
|
children: l(t)
|
|
831
838
|
}
|
|
832
|
-
}).exec(
|
|
833
|
-
return o.on("change", () => {
|
|
839
|
+
}).exec(bt);
|
|
840
|
+
return e && o.exec(Mt), o.on("change", () => {
|
|
834
841
|
n(a(o.doc));
|
|
835
|
-
}),
|
|
842
|
+
}), o;
|
|
836
843
|
}, exports.debugPlugin = function(t) {
|
|
837
844
|
t.hook("apply", t => {
|
|
838
845
|
console.log("apply", t);
|
|
@@ -861,7 +868,7 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
861
868
|
})), t.hook("copy", t => {
|
|
862
869
|
if (!n) return;
|
|
863
870
|
const e = document.createElement("div");
|
|
864
|
-
e.appendChild(
|
|
871
|
+
e.appendChild(at(it(n), n).cloneContents()), t.setData("text/html", e.innerHTML);
|
|
865
872
|
}), t.hook("paste", ((t, e = []) => (n, r) => {
|
|
866
873
|
const o = n.getData("text/html");
|
|
867
874
|
if (o) {
|
|
@@ -896,10 +903,10 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
896
903
|
})(e.serializeText, e.serializers));
|
|
897
904
|
}, exports.internalTranferPlugin = function(e) {
|
|
898
905
|
e.hook("copy", n => {
|
|
899
|
-
n.setData(
|
|
906
|
+
n.setData(Et, JSON.stringify(L(e.doc, ...t(e.selection))));
|
|
900
907
|
}), e.hook("paste", t => {
|
|
901
908
|
try {
|
|
902
|
-
return JSON.parse(t.getData(
|
|
909
|
+
return JSON.parse(t.getData(Et));
|
|
903
910
|
} catch (t) {
|
|
904
911
|
return null;
|
|
905
912
|
}
|
|
@@ -907,9 +914,9 @@ exports.Delete = function(e, n = t(e.selection)) {
|
|
|
907
914
|
}, exports.keymapPlugin = function(t, e) {
|
|
908
915
|
r(e).forEach(n => {
|
|
909
916
|
const r = e[n];
|
|
910
|
-
t.hook("keyboard",
|
|
917
|
+
t.hook("keyboard", yt(n, () => {
|
|
911
918
|
r();
|
|
912
919
|
}));
|
|
913
920
|
});
|
|
914
|
-
}, exports.plainTransferPlugin =
|
|
921
|
+
}, exports.plainTransferPlugin = bt, exports.singlelinePlugin = Mt;
|
|
915
922
|
//# sourceMappingURL=index.cjs.map
|