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