@quoreadmin/ui 1.10.15 → 1.10.16
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/dist/index182.js +14 -14
- package/dist/index183.js +3 -3
- package/dist/index186.js +4 -4
- package/dist/index193.js +10 -10
- package/dist/index194.js +1 -1
- package/dist/index195.js +10 -10
- package/dist/index201.js +28 -28
- package/dist/index202.js +2 -2
- package/dist/index203.js +2 -2
- package/dist/index204.js +1 -1
- package/dist/index206.js +2 -2
- package/dist/index208.js +14 -14
- package/dist/index209.js +1 -1
- package/dist/index210.js +1 -1
- package/dist/index211.js +3 -3
- package/dist/index212.js +6 -6
- package/dist/index213.js +29 -84
- package/dist/index214.js +109 -400
- package/dist/index215.js +36 -22
- package/dist/index216.js +26 -33
- package/dist/index217.js +31 -111
- package/dist/index218.js +50 -35
- package/dist/index219.js +43 -26
- package/dist/index220.js +3 -35
- package/dist/index221.js +9 -51
- package/dist/index222.js +18 -42
- package/dist/index223.js +10 -4
- package/dist/index224.js +10 -9
- package/dist/index225.js +38 -18
- package/dist/index226.js +21 -10
- package/dist/index227.js +88 -10
- package/dist/index228.js +403 -35
- package/dist/index229.js +22 -21
- package/dist/index230.js +156 -122
- package/dist/index231.js +225 -35
- package/dist/index232.js +37 -80
- package/dist/index233.js +10 -20
- package/dist/index234.js +160 -19
- package/dist/index235.js +11 -11
- package/dist/index236.js +12 -12
- package/dist/index237.js +15 -13
- package/dist/index238.js +194 -156
- package/dist/index239.js +66 -224
- package/dist/index240.js +34 -37
- package/dist/index241.js +39 -9
- package/dist/index242.js +3624 -149
- package/dist/index243.js +55 -20
- package/dist/index244.js +77 -22
- package/dist/index245.js +43 -190
- package/dist/index246.js +211 -66
- package/dist/index247.js +9 -33
- package/dist/index248.js +53 -36
- package/dist/index249.js +61 -22
- package/dist/index250.js +54 -22
- package/dist/index251.js +75 -20
- package/dist/index252.js +681 -791
- package/dist/index253.js +33 -693
- package/dist/index254.js +56 -168
- package/dist/index255.js +11 -22
- package/dist/index256.js +705 -20
- package/dist/index257.js +820 -20
- package/dist/index258.js +22 -3
- package/dist/index259.js +21 -186
- package/dist/index260.js +19 -132
- package/dist/index261.js +744 -1131
- package/dist/index262.js +701 -19
- package/dist/index263.js +176 -22
- package/dist/index264.js +13 -15
- package/dist/index265.js +13 -22
- package/dist/index266.js +15 -13
- package/dist/index267.js +12 -12
- package/dist/index268.js +20 -2
- package/dist/index269.js +2 -1
- package/dist/index270.js +166 -3615
- package/dist/index271.js +128 -50
- package/dist/index272.js +1214 -68
- package/dist/index273.js +122 -47
- package/dist/index274.js +20 -215
- package/dist/index275.js +22 -10
- package/dist/index276.js +22 -57
- package/dist/index277.js +32 -55
- package/dist/index278.js +29 -54
- package/dist/index279.js +20 -75
- package/dist/index280.js +19 -725
- package/dist/index281.js +2 -42
- package/dist/index282.js +2 -64
- package/dist/index283.js +79 -10
- package/dist/index284.js +20 -705
- package/dist/index285.js +20 -820
- package/dist/index290.js +3 -2
- package/dist/index291.js +25 -77
- package/dist/index292.js +54 -3
- package/dist/index293.js +77 -25
- package/dist/index294.js +25 -53
- package/dist/index295.js +15 -19
- package/dist/index296.js +10 -10
- package/dist/index297.js +16 -22
- package/dist/index298.js +15 -14
- package/dist/index299.js +21 -15
- package/dist/index300.js +1534 -23
- package/dist/index301.js +346 -1494
- package/dist/index302.js +2675 -330
- package/dist/index303.js +72 -2717
- package/dist/index304.js +3782 -76
- package/dist/index305.js +49 -3781
- package/dist/index306.js +15 -60
- package/dist/index307.js +81 -76
- package/dist/index308.js +202 -22
- package/dist/index309.js +226 -915
- package/dist/index310.js +2 -22
- package/dist/index311.js +78 -19
- package/dist/index312.js +15 -13
- package/dist/index313.js +930 -64
- package/dist/index314.js +21 -18
- package/dist/index315.js +20 -19
- package/dist/index316.js +11 -13
- package/dist/index317.js +68 -21
- package/dist/index318.js +16 -60
- package/dist/index319.js +19 -15
- package/dist/index320.js +21 -83
- package/dist/index321.js +22 -202
- package/dist/index322.js +63 -246
- package/dist/index340.js +8 -36
- package/dist/index341.js +12 -8
- package/dist/index342.js +54 -12
- package/dist/index343.js +9 -52
- package/dist/index344.js +13 -11
- package/dist/index345.js +53 -9
- package/dist/index346.js +49 -55
- package/dist/index347.js +28 -49
- package/dist/index348.js +2 -31
- package/dist/index349.js +5 -2
- package/dist/index350.js +2 -5
- package/dist/index351.js +23 -2
- package/dist/index352.js +39 -21
- package/dist/index353.js +2 -41
- package/dist/index354.js +11 -2
- package/dist/index355.js +20 -11
- package/dist/index356.js +10 -20
- package/dist/index357.js +9 -9
- package/dist/index358.js +16 -9
- package/dist/index359.js +2 -17
- package/dist/index360.js +9 -2
- package/dist/index361.js +10 -9
- package/dist/index362.js +14 -10
- package/dist/index363.js +37 -14
- package/dist/index364.js +1 -1
- package/dist/index365.js +1 -1
- package/dist/index366.js +2 -2
- package/dist/index380.js +95 -98
- package/dist/index381.js +100 -90
- package/dist/index382.js +91 -17
- package/dist/index383.js +16 -97
- package/package.json +1 -1
package/dist/index301.js
CHANGED
|
@@ -1,1536 +1,388 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const V = 1, X = 2, J = 4, Y = 8;
|
|
13
|
-
class L {
|
|
14
|
-
/**
|
|
15
|
-
@internal
|
|
16
|
-
*/
|
|
17
|
-
constructor(e, t, r) {
|
|
18
|
-
this.pos = e, this.delInfo = t, this.recover = r;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
Tells you whether the position was deleted, that is, whether the
|
|
22
|
-
step removed the token on the side queried (via the `assoc`)
|
|
23
|
-
argument from the document.
|
|
24
|
-
*/
|
|
25
|
-
get deleted() {
|
|
26
|
-
return (this.delInfo & Y) > 0;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
Tells you whether the token before the mapped position was deleted.
|
|
30
|
-
*/
|
|
31
|
-
get deletedBefore() {
|
|
32
|
-
return (this.delInfo & (V | J)) > 0;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
True when the token after the mapped position was deleted.
|
|
36
|
-
*/
|
|
37
|
-
get deletedAfter() {
|
|
38
|
-
return (this.delInfo & (X | J)) > 0;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
Tells whether any of the steps mapped through deletes across the
|
|
42
|
-
position (including both the token before and after the
|
|
43
|
-
position).
|
|
44
|
-
*/
|
|
45
|
-
get deletedAcross() {
|
|
46
|
-
return (this.delInfo & J) > 0;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class S {
|
|
50
|
-
/**
|
|
51
|
-
Create a position map. The modifications to the document are
|
|
52
|
-
represented as an array of numbers, in which each group of three
|
|
53
|
-
represents a modified chunk as `[start, oldSize, newSize]`.
|
|
54
|
-
*/
|
|
55
|
-
constructor(e, t = !1) {
|
|
56
|
-
if (this.ranges = e, this.inverted = t, !e.length && S.empty)
|
|
57
|
-
return S.empty;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
@internal
|
|
61
|
-
*/
|
|
62
|
-
recover(e) {
|
|
63
|
-
let t = 0, r = H(e);
|
|
64
|
-
if (!this.inverted)
|
|
65
|
-
for (let n = 0; n < r; n++)
|
|
66
|
-
t += this.ranges[n * 3 + 2] - this.ranges[n * 3 + 1];
|
|
67
|
-
return this.ranges[r * 3] + t + he(e);
|
|
68
|
-
}
|
|
69
|
-
mapResult(e, t = 1) {
|
|
70
|
-
return this._map(e, t, !1);
|
|
71
|
-
}
|
|
72
|
-
map(e, t = 1) {
|
|
73
|
-
return this._map(e, t, !0);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
@internal
|
|
77
|
-
*/
|
|
78
|
-
_map(e, t, r) {
|
|
79
|
-
let n = 0, i = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2;
|
|
80
|
-
for (let l = 0; l < this.ranges.length; l += 3) {
|
|
81
|
-
let a = this.ranges[l] - (this.inverted ? n : 0);
|
|
82
|
-
if (a > e)
|
|
83
|
-
break;
|
|
84
|
-
let h = this.ranges[l + i], p = this.ranges[l + o], c = a + h;
|
|
85
|
-
if (e <= c) {
|
|
86
|
-
let f = h ? e == a ? -1 : e == c ? 1 : t : t, d = a + n + (f < 0 ? 0 : p);
|
|
87
|
-
if (r)
|
|
88
|
-
return d;
|
|
89
|
-
let u = e == (t < 0 ? a : c) ? null : ae(l / 3, e - a), m = e == a ? X : e == c ? V : J;
|
|
90
|
-
return (t < 0 ? e != a : e != c) && (m |= Y), new L(d, m, u);
|
|
91
|
-
}
|
|
92
|
-
n += p - h;
|
|
93
|
-
}
|
|
94
|
-
return r ? e + n : new L(e + n, 0, null);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
@internal
|
|
98
|
-
*/
|
|
99
|
-
touches(e, t) {
|
|
100
|
-
let r = 0, n = H(t), i = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2;
|
|
101
|
-
for (let l = 0; l < this.ranges.length; l += 3) {
|
|
102
|
-
let a = this.ranges[l] - (this.inverted ? r : 0);
|
|
103
|
-
if (a > e)
|
|
104
|
-
break;
|
|
105
|
-
let h = this.ranges[l + i], p = a + h;
|
|
106
|
-
if (e <= p && l == n * 3)
|
|
107
|
-
return !0;
|
|
108
|
-
r += this.ranges[l + o] - h;
|
|
109
|
-
}
|
|
1
|
+
import { canJoin as T, joinPoint as F, liftTarget as A, replaceStep as B, canSplit as h, findWrapping as J, ReplaceAroundStep as v, ReplaceStep as U } from "./index300.js";
|
|
2
|
+
import { Slice as y, Fragment as S } from "./index302.js";
|
|
3
|
+
import { AllSelection as P, TextSelection as I, Selection as V, NodeSelection as d } from "./index257.js";
|
|
4
|
+
const M = (t, e) => t.selection.empty ? !1 : (e && e(t.tr.deleteSelection().scrollIntoView()), !0);
|
|
5
|
+
function N(t, e) {
|
|
6
|
+
let { $cursor: r } = t.selection;
|
|
7
|
+
return !r || (e ? !e.endOfTextblock("backward", t) : r.parentOffset > 0) ? null : r;
|
|
8
|
+
}
|
|
9
|
+
const G = (t, e, r) => {
|
|
10
|
+
let n = N(t, r);
|
|
11
|
+
if (!n)
|
|
110
12
|
return !1;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*/
|
|
127
|
-
invert() {
|
|
128
|
-
return new S(this.ranges, !this.inverted);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
@internal
|
|
132
|
-
*/
|
|
133
|
-
toString() {
|
|
134
|
-
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
Create a map that moves all positions by offset `n` (which may be
|
|
138
|
-
negative). This can be useful when applying steps meant for a
|
|
139
|
-
sub-document to a larger document, or vice-versa.
|
|
140
|
-
*/
|
|
141
|
-
static offset(e) {
|
|
142
|
-
return e == 0 ? S.empty : new S(e < 0 ? [0, -e, 0] : [0, 0, e]);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
S.empty = new S([]);
|
|
146
|
-
class A {
|
|
147
|
-
/**
|
|
148
|
-
Create a new mapping with the given position maps.
|
|
149
|
-
*/
|
|
150
|
-
constructor(e, t, r = 0, n = e ? e.length : 0) {
|
|
151
|
-
this.mirror = t, this.from = r, this.to = n, this._maps = e || [], this.ownData = !(e || t);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
The step maps in this mapping.
|
|
155
|
-
*/
|
|
156
|
-
get maps() {
|
|
157
|
-
return this._maps;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
Create a mapping that maps only through a part of this one.
|
|
161
|
-
*/
|
|
162
|
-
slice(e = 0, t = this.maps.length) {
|
|
163
|
-
return new A(this._maps, this.mirror, e, t);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
Add a step map to the end of this mapping. If `mirrors` is
|
|
167
|
-
given, it should be the index of the step map that is the mirror
|
|
168
|
-
image of this one.
|
|
169
|
-
*/
|
|
170
|
-
appendMap(e, t) {
|
|
171
|
-
this.ownData || (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), this.ownData = !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
Add all the step maps in a given mapping to this one (preserving
|
|
175
|
-
mirroring information).
|
|
176
|
-
*/
|
|
177
|
-
appendMapping(e) {
|
|
178
|
-
for (let t = 0, r = this._maps.length; t < e._maps.length; t++) {
|
|
179
|
-
let n = e.getMirror(t);
|
|
180
|
-
this.appendMap(e._maps[t], n != null && n < t ? r + n : void 0);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
Finds the offset of the step map that mirrors the map at the
|
|
185
|
-
given offset, in this mapping (as per the second argument to
|
|
186
|
-
`appendMap`).
|
|
187
|
-
*/
|
|
188
|
-
getMirror(e) {
|
|
189
|
-
if (this.mirror) {
|
|
190
|
-
for (let t = 0; t < this.mirror.length; t++)
|
|
191
|
-
if (this.mirror[t] == e)
|
|
192
|
-
return this.mirror[t + (t % 2 ? -1 : 1)];
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
@internal
|
|
197
|
-
*/
|
|
198
|
-
setMirror(e, t) {
|
|
199
|
-
this.mirror || (this.mirror = []), this.mirror.push(e, t);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
Append the inverse of the given mapping to this one.
|
|
203
|
-
*/
|
|
204
|
-
appendMappingInverted(e) {
|
|
205
|
-
for (let t = e.maps.length - 1, r = this._maps.length + e._maps.length; t >= 0; t--) {
|
|
206
|
-
let n = e.getMirror(t);
|
|
207
|
-
this.appendMap(e._maps[t].invert(), n != null && n > t ? r - n - 1 : void 0);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
Create an inverted version of this mapping.
|
|
212
|
-
*/
|
|
213
|
-
invert() {
|
|
214
|
-
let e = new A();
|
|
215
|
-
return e.appendMappingInverted(this), e;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
Map a position through this mapping.
|
|
219
|
-
*/
|
|
220
|
-
map(e, t = 1) {
|
|
221
|
-
if (this.mirror)
|
|
222
|
-
return this._map(e, t, !0);
|
|
223
|
-
for (let r = this.from; r < this.to; r++)
|
|
224
|
-
e = this._maps[r].map(e, t);
|
|
225
|
-
return e;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
Map a position through this mapping, returning a mapping
|
|
229
|
-
result.
|
|
230
|
-
*/
|
|
231
|
-
mapResult(e, t = 1) {
|
|
232
|
-
return this._map(e, t, !1);
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
@internal
|
|
236
|
-
*/
|
|
237
|
-
_map(e, t, r) {
|
|
238
|
-
let n = 0;
|
|
239
|
-
for (let i = this.from; i < this.to; i++) {
|
|
240
|
-
let o = this._maps[i], l = o.mapResult(e, t);
|
|
241
|
-
if (l.recover != null) {
|
|
242
|
-
let a = this.getMirror(i);
|
|
243
|
-
if (a != null && a > i && a < this.to) {
|
|
244
|
-
i = a, e = this._maps[a].recover(l.recover);
|
|
245
|
-
continue;
|
|
13
|
+
let o = z(n);
|
|
14
|
+
if (!o) {
|
|
15
|
+
let i = n.blockRange(), f = i && A(i);
|
|
16
|
+
return f == null ? !1 : (e && e(t.tr.lift(i, f).scrollIntoView()), !0);
|
|
17
|
+
}
|
|
18
|
+
let l = o.nodeBefore;
|
|
19
|
+
if (D(t, o, e, -1))
|
|
20
|
+
return !0;
|
|
21
|
+
if (n.parent.content.size == 0 && (x(l, "end") || d.isSelectable(l)))
|
|
22
|
+
for (let i = n.depth; ; i--) {
|
|
23
|
+
let f = B(t.doc, n.before(i), n.after(i), y.empty);
|
|
24
|
+
if (f && f.slice.size < f.to - f.from) {
|
|
25
|
+
if (e) {
|
|
26
|
+
let c = t.tr.step(f);
|
|
27
|
+
c.setSelection(x(l, "end") ? V.findFrom(c.doc.resolve(c.mapping.map(o.pos, -1)), -1) : d.create(c.doc, o.pos - l.nodeSize)), e(c.scrollIntoView());
|
|
246
28
|
}
|
|
29
|
+
return !0;
|
|
247
30
|
}
|
|
248
|
-
n
|
|
249
|
-
|
|
250
|
-
return r ? e : new L(e, n, null);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
const B = /* @__PURE__ */ Object.create(null);
|
|
254
|
-
class k {
|
|
255
|
-
/**
|
|
256
|
-
Get the step map that represents the changes made by this step,
|
|
257
|
-
and which can be used to transform between positions in the old
|
|
258
|
-
and the new document.
|
|
259
|
-
*/
|
|
260
|
-
getMap() {
|
|
261
|
-
return S.empty;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
Try to merge this step with another one, to be applied directly
|
|
265
|
-
after it. Returns the merged step when possible, null if the
|
|
266
|
-
steps can't be merged.
|
|
267
|
-
*/
|
|
268
|
-
merge(e) {
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
Deserialize a step from its JSON representation. Will call
|
|
273
|
-
through to the step class' own implementation of this method.
|
|
274
|
-
*/
|
|
275
|
-
static fromJSON(e, t) {
|
|
276
|
-
if (!t || !t.stepType)
|
|
277
|
-
throw new RangeError("Invalid input for Step.fromJSON");
|
|
278
|
-
let r = B[t.stepType];
|
|
279
|
-
if (!r)
|
|
280
|
-
throw new RangeError(`No step type ${t.stepType} defined`);
|
|
281
|
-
return r.fromJSON(e, t);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
To be able to serialize steps to JSON, each step needs a string
|
|
285
|
-
ID to attach to its JSON representation. Use this method to
|
|
286
|
-
register an ID for your step classes. Try to pick something
|
|
287
|
-
that's unlikely to clash with steps from other modules.
|
|
288
|
-
*/
|
|
289
|
-
static jsonID(e, t) {
|
|
290
|
-
if (e in B)
|
|
291
|
-
throw new RangeError("Duplicate use of step JSON ID " + e);
|
|
292
|
-
return B[e] = t, t.prototype.jsonID = e, t;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
class y {
|
|
296
|
-
/**
|
|
297
|
-
@internal
|
|
298
|
-
*/
|
|
299
|
-
constructor(e, t) {
|
|
300
|
-
this.doc = e, this.failed = t;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
Create a successful step result.
|
|
304
|
-
*/
|
|
305
|
-
static ok(e) {
|
|
306
|
-
return new y(e, null);
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
Create a failed step result.
|
|
310
|
-
*/
|
|
311
|
-
static fail(e) {
|
|
312
|
-
return new y(null, e);
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
|
|
316
|
-
arguments. Create a successful result if it succeeds, and a
|
|
317
|
-
failed one if it throws a `ReplaceError`.
|
|
318
|
-
*/
|
|
319
|
-
static fromReplace(e, t, r, n) {
|
|
320
|
-
try {
|
|
321
|
-
return y.ok(e.replace(t, r, n));
|
|
322
|
-
} catch (i) {
|
|
323
|
-
if (i instanceof le)
|
|
324
|
-
return y.fail(i.message);
|
|
325
|
-
throw i;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function P(s, e, t) {
|
|
330
|
-
let r = [];
|
|
331
|
-
for (let n = 0; n < s.childCount; n++) {
|
|
332
|
-
let i = s.child(n);
|
|
333
|
-
i.content.size && (i = i.copy(P(i.content, e, i))), i.isInline && (i = e(i, t, n)), r.push(i);
|
|
334
|
-
}
|
|
335
|
-
return w.fromArray(r);
|
|
336
|
-
}
|
|
337
|
-
class C extends k {
|
|
338
|
-
/**
|
|
339
|
-
Create a mark step.
|
|
340
|
-
*/
|
|
341
|
-
constructor(e, t, r) {
|
|
342
|
-
super(), this.from = e, this.to = t, this.mark = r;
|
|
343
|
-
}
|
|
344
|
-
apply(e) {
|
|
345
|
-
let t = e.slice(this.from, this.to), r = e.resolve(this.from), n = r.node(r.sharedDepth(this.to)), i = new g(P(t.content, (o, l) => !o.isAtom || !l.type.allowsMarkType(this.mark.type) ? o : o.mark(this.mark.addToSet(o.marks)), n), t.openStart, t.openEnd);
|
|
346
|
-
return y.fromReplace(e, this.from, this.to, i);
|
|
347
|
-
}
|
|
348
|
-
invert() {
|
|
349
|
-
return new b(this.from, this.to, this.mark);
|
|
350
|
-
}
|
|
351
|
-
map(e) {
|
|
352
|
-
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
|
|
353
|
-
return t.deleted && r.deleted || t.pos >= r.pos ? null : new C(t.pos, r.pos, this.mark);
|
|
354
|
-
}
|
|
355
|
-
merge(e) {
|
|
356
|
-
return e instanceof C && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new C(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
|
|
357
|
-
}
|
|
358
|
-
toJSON() {
|
|
359
|
-
return {
|
|
360
|
-
stepType: "addMark",
|
|
361
|
-
mark: this.mark.toJSON(),
|
|
362
|
-
from: this.from,
|
|
363
|
-
to: this.to
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
@internal
|
|
368
|
-
*/
|
|
369
|
-
static fromJSON(e, t) {
|
|
370
|
-
if (typeof t.from != "number" || typeof t.to != "number")
|
|
371
|
-
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
|
|
372
|
-
return new C(t.from, t.to, e.markFromJSON(t.mark));
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
k.jsonID("addMark", C);
|
|
376
|
-
class b extends k {
|
|
377
|
-
/**
|
|
378
|
-
Create a mark-removing step.
|
|
379
|
-
*/
|
|
380
|
-
constructor(e, t, r) {
|
|
381
|
-
super(), this.from = e, this.to = t, this.mark = r;
|
|
382
|
-
}
|
|
383
|
-
apply(e) {
|
|
384
|
-
let t = e.slice(this.from, this.to), r = new g(P(t.content, (n) => n.mark(this.mark.removeFromSet(n.marks)), e), t.openStart, t.openEnd);
|
|
385
|
-
return y.fromReplace(e, this.from, this.to, r);
|
|
386
|
-
}
|
|
387
|
-
invert() {
|
|
388
|
-
return new C(this.from, this.to, this.mark);
|
|
389
|
-
}
|
|
390
|
-
map(e) {
|
|
391
|
-
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
|
|
392
|
-
return t.deleted && r.deleted || t.pos >= r.pos ? null : new b(t.pos, r.pos, this.mark);
|
|
393
|
-
}
|
|
394
|
-
merge(e) {
|
|
395
|
-
return e instanceof b && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new b(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
|
|
396
|
-
}
|
|
397
|
-
toJSON() {
|
|
398
|
-
return {
|
|
399
|
-
stepType: "removeMark",
|
|
400
|
-
mark: this.mark.toJSON(),
|
|
401
|
-
from: this.from,
|
|
402
|
-
to: this.to
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
@internal
|
|
407
|
-
*/
|
|
408
|
-
static fromJSON(e, t) {
|
|
409
|
-
if (typeof t.from != "number" || typeof t.to != "number")
|
|
410
|
-
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
411
|
-
return new b(t.from, t.to, e.markFromJSON(t.mark));
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
k.jsonID("removeMark", b);
|
|
415
|
-
class N extends k {
|
|
416
|
-
/**
|
|
417
|
-
Create a node mark step.
|
|
418
|
-
*/
|
|
419
|
-
constructor(e, t) {
|
|
420
|
-
super(), this.pos = e, this.mark = t;
|
|
421
|
-
}
|
|
422
|
-
apply(e) {
|
|
423
|
-
let t = e.nodeAt(this.pos);
|
|
424
|
-
if (!t)
|
|
425
|
-
return y.fail("No node at mark step's position");
|
|
426
|
-
let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
|
|
427
|
-
return y.fromReplace(e, this.pos, this.pos + 1, new g(w.from(r), 0, t.isLeaf ? 0 : 1));
|
|
428
|
-
}
|
|
429
|
-
invert(e) {
|
|
430
|
-
let t = e.nodeAt(this.pos);
|
|
431
|
-
if (t) {
|
|
432
|
-
let r = this.mark.addToSet(t.marks);
|
|
433
|
-
if (r.length == t.marks.length) {
|
|
434
|
-
for (let n = 0; n < t.marks.length; n++)
|
|
435
|
-
if (!t.marks[n].isInSet(r))
|
|
436
|
-
return new N(this.pos, t.marks[n]);
|
|
437
|
-
return new N(this.pos, this.mark);
|
|
438
|
-
}
|
|
31
|
+
if (i == 1 || n.node(i - 1).childCount > 1)
|
|
32
|
+
break;
|
|
439
33
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
constructor(e, t) {
|
|
464
|
-
super(), this.pos = e, this.mark = t;
|
|
465
|
-
}
|
|
466
|
-
apply(e) {
|
|
467
|
-
let t = e.nodeAt(this.pos);
|
|
468
|
-
if (!t)
|
|
469
|
-
return y.fail("No node at mark step's position");
|
|
470
|
-
let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
|
|
471
|
-
return y.fromReplace(e, this.pos, this.pos + 1, new g(w.from(r), 0, t.isLeaf ? 0 : 1));
|
|
472
|
-
}
|
|
473
|
-
invert(e) {
|
|
474
|
-
let t = e.nodeAt(this.pos);
|
|
475
|
-
return !t || !this.mark.isInSet(t.marks) ? this : new N(this.pos, this.mark);
|
|
476
|
-
}
|
|
477
|
-
map(e) {
|
|
478
|
-
let t = e.mapResult(this.pos, 1);
|
|
479
|
-
return t.deletedAfter ? null : new R(t.pos, this.mark);
|
|
480
|
-
}
|
|
481
|
-
toJSON() {
|
|
482
|
-
return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
@internal
|
|
486
|
-
*/
|
|
487
|
-
static fromJSON(e, t) {
|
|
488
|
-
if (typeof t.pos != "number")
|
|
489
|
-
throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
|
|
490
|
-
return new R(t.pos, e.markFromJSON(t.mark));
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
k.jsonID("removeNodeMark", R);
|
|
494
|
-
class v extends k {
|
|
495
|
-
/**
|
|
496
|
-
The given `slice` should fit the 'gap' between `from` and
|
|
497
|
-
`to`—the depths must line up, and the surrounding nodes must be
|
|
498
|
-
able to be joined with the open sides of the slice. When
|
|
499
|
-
`structure` is true, the step will fail if the content between
|
|
500
|
-
from and to is not just a sequence of closing and then opening
|
|
501
|
-
tokens (this is to guard against rebased replace steps
|
|
502
|
-
overwriting something they weren't supposed to).
|
|
503
|
-
*/
|
|
504
|
-
constructor(e, t, r, n = !1) {
|
|
505
|
-
super(), this.from = e, this.to = t, this.slice = r, this.structure = n;
|
|
506
|
-
}
|
|
507
|
-
apply(e) {
|
|
508
|
-
return this.structure && q(e, this.from, this.to) ? y.fail("Structure replace would overwrite content") : y.fromReplace(e, this.from, this.to, this.slice);
|
|
509
|
-
}
|
|
510
|
-
getMap() {
|
|
511
|
-
return new S([this.from, this.to - this.from, this.slice.size]);
|
|
512
|
-
}
|
|
513
|
-
invert(e) {
|
|
514
|
-
return new v(this.from, this.from + this.slice.size, e.slice(this.from, this.to));
|
|
515
|
-
}
|
|
516
|
-
map(e) {
|
|
517
|
-
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
|
|
518
|
-
return t.deletedAcross && r.deletedAcross ? null : new v(t.pos, Math.max(t.pos, r.pos), this.slice, this.structure);
|
|
519
|
-
}
|
|
520
|
-
merge(e) {
|
|
521
|
-
if (!(e instanceof v) || e.structure || this.structure)
|
|
522
|
-
return null;
|
|
523
|
-
if (this.from + this.slice.size == e.from && !this.slice.openEnd && !e.slice.openStart) {
|
|
524
|
-
let t = this.slice.size + e.slice.size == 0 ? g.empty : new g(this.slice.content.append(e.slice.content), this.slice.openStart, e.slice.openEnd);
|
|
525
|
-
return new v(this.from, this.to + (e.to - e.from), t, this.structure);
|
|
526
|
-
} else if (e.to == this.from && !this.slice.openStart && !e.slice.openEnd) {
|
|
527
|
-
let t = this.slice.size + e.slice.size == 0 ? g.empty : new g(e.slice.content.append(this.slice.content), e.slice.openStart, this.slice.openEnd);
|
|
528
|
-
return new v(e.from, this.to, t, this.structure);
|
|
529
|
-
} else
|
|
530
|
-
return null;
|
|
531
|
-
}
|
|
532
|
-
toJSON() {
|
|
533
|
-
let e = { stepType: "replace", from: this.from, to: this.to };
|
|
534
|
-
return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
@internal
|
|
538
|
-
*/
|
|
539
|
-
static fromJSON(e, t) {
|
|
540
|
-
if (typeof t.from != "number" || typeof t.to != "number")
|
|
541
|
-
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
|
|
542
|
-
return new v(t.from, t.to, g.fromJSON(e, t.slice), !!t.structure);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
k.jsonID("replace", v);
|
|
546
|
-
class M extends k {
|
|
547
|
-
/**
|
|
548
|
-
Create a replace-around step with the given range and gap.
|
|
549
|
-
`insert` should be the point in the slice into which the content
|
|
550
|
-
of the gap should be moved. `structure` has the same meaning as
|
|
551
|
-
it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
|
|
552
|
-
*/
|
|
553
|
-
constructor(e, t, r, n, i, o, l = !1) {
|
|
554
|
-
super(), this.from = e, this.to = t, this.gapFrom = r, this.gapTo = n, this.slice = i, this.insert = o, this.structure = l;
|
|
555
|
-
}
|
|
556
|
-
apply(e) {
|
|
557
|
-
if (this.structure && (q(e, this.from, this.gapFrom) || q(e, this.gapTo, this.to)))
|
|
558
|
-
return y.fail("Structure gap-replace would overwrite content");
|
|
559
|
-
let t = e.slice(this.gapFrom, this.gapTo);
|
|
560
|
-
if (t.openStart || t.openEnd)
|
|
561
|
-
return y.fail("Gap is not a flat range");
|
|
562
|
-
let r = this.slice.insertAt(this.insert, t.content);
|
|
563
|
-
return r ? y.fromReplace(e, this.from, this.to, r) : y.fail("Content does not fit in gap");
|
|
564
|
-
}
|
|
565
|
-
getMap() {
|
|
566
|
-
return new S([
|
|
567
|
-
this.from,
|
|
568
|
-
this.gapFrom - this.from,
|
|
569
|
-
this.insert,
|
|
570
|
-
this.gapTo,
|
|
571
|
-
this.to - this.gapTo,
|
|
572
|
-
this.slice.size - this.insert
|
|
573
|
-
]);
|
|
574
|
-
}
|
|
575
|
-
invert(e) {
|
|
576
|
-
let t = this.gapTo - this.gapFrom;
|
|
577
|
-
return new M(this.from, this.from + this.slice.size + t, this.from + this.insert, this.from + this.insert + t, e.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
578
|
-
}
|
|
579
|
-
map(e) {
|
|
580
|
-
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1), n = this.from == this.gapFrom ? t.pos : e.map(this.gapFrom, -1), i = this.to == this.gapTo ? r.pos : e.map(this.gapTo, 1);
|
|
581
|
-
return t.deletedAcross && r.deletedAcross || n < t.pos || i > r.pos ? null : new M(t.pos, r.pos, n, i, this.slice, this.insert, this.structure);
|
|
34
|
+
return l.isAtom && o.depth == n.depth - 1 ? (e && e(t.tr.delete(o.pos - l.nodeSize, o.pos).scrollIntoView()), !0) : !1;
|
|
35
|
+
}, oe = (t, e, r) => {
|
|
36
|
+
let n = N(t, r);
|
|
37
|
+
if (!n)
|
|
38
|
+
return !1;
|
|
39
|
+
let o = z(n);
|
|
40
|
+
return o ? E(t, o, e) : !1;
|
|
41
|
+
}, le = (t, e, r) => {
|
|
42
|
+
let n = W(t, r);
|
|
43
|
+
if (!n)
|
|
44
|
+
return !1;
|
|
45
|
+
let o = R(n);
|
|
46
|
+
return o ? E(t, o, e) : !1;
|
|
47
|
+
};
|
|
48
|
+
function E(t, e, r) {
|
|
49
|
+
let n = e.nodeBefore, o = n, l = e.pos - 1;
|
|
50
|
+
for (; !o.isTextblock; l--) {
|
|
51
|
+
if (o.type.spec.isolating)
|
|
52
|
+
return !1;
|
|
53
|
+
let s = o.lastChild;
|
|
54
|
+
if (!s)
|
|
55
|
+
return !1;
|
|
56
|
+
o = s;
|
|
582
57
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
};
|
|
592
|
-
return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
|
|
58
|
+
let i = e.nodeAfter, f = i, c = e.pos + 1;
|
|
59
|
+
for (; !f.isTextblock; c++) {
|
|
60
|
+
if (f.type.spec.isolating)
|
|
61
|
+
return !1;
|
|
62
|
+
let s = f.firstChild;
|
|
63
|
+
if (!s)
|
|
64
|
+
return !1;
|
|
65
|
+
f = s;
|
|
593
66
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
return new M(t.from, t.to, t.gapFrom, t.gapTo, g.fromJSON(e, t.slice), t.insert, !!t.structure);
|
|
67
|
+
let p = B(t.doc, l, c, y.empty);
|
|
68
|
+
if (!p || p.from != l || p instanceof U && p.slice.size >= c - l)
|
|
69
|
+
return !1;
|
|
70
|
+
if (r) {
|
|
71
|
+
let s = t.tr.step(p);
|
|
72
|
+
s.setSelection(I.create(s.doc, l)), r(s.scrollIntoView());
|
|
601
73
|
}
|
|
74
|
+
return !0;
|
|
602
75
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
let o = r.node(i).maybeChild(r.indexAfter(i));
|
|
610
|
-
for (; n > 0; ) {
|
|
611
|
-
if (!o || o.isLeaf)
|
|
612
|
-
return !0;
|
|
613
|
-
o = o.firstChild, n--;
|
|
614
|
-
}
|
|
76
|
+
function x(t, e, r = !1) {
|
|
77
|
+
for (let n = t; n; n = e == "start" ? n.firstChild : n.lastChild) {
|
|
78
|
+
if (n.isTextblock)
|
|
79
|
+
return !0;
|
|
80
|
+
if (r && n.childCount != 1)
|
|
81
|
+
return !1;
|
|
615
82
|
}
|
|
616
83
|
return !1;
|
|
617
84
|
}
|
|
618
|
-
|
|
619
|
-
let
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
for (let m = 0; m < c.length; m++)
|
|
627
|
-
c[m].isInSet(u) || (o && o.to == f && o.mark.eq(c[m]) ? o.to = d : n.push(o = new b(f, d, c[m])));
|
|
628
|
-
l && l.to == f ? l.to = d : i.push(l = new C(f, d, r));
|
|
629
|
-
}
|
|
630
|
-
}), n.forEach((a) => s.step(a)), i.forEach((a) => s.step(a));
|
|
631
|
-
}
|
|
632
|
-
function fe(s, e, t, r) {
|
|
633
|
-
let n = [], i = 0;
|
|
634
|
-
s.doc.nodesBetween(e, t, (o, l) => {
|
|
635
|
-
if (!o.isInline)
|
|
636
|
-
return;
|
|
637
|
-
i++;
|
|
638
|
-
let a = null;
|
|
639
|
-
if (r instanceof oe) {
|
|
640
|
-
let h = o.marks, p;
|
|
641
|
-
for (; p = r.isInSet(h); )
|
|
642
|
-
(a || (a = [])).push(p), h = p.removeFromSet(h);
|
|
643
|
-
} else r ? r.isInSet(o.marks) && (a = [r]) : a = o.marks;
|
|
644
|
-
if (a && a.length) {
|
|
645
|
-
let h = Math.min(l + o.nodeSize, t);
|
|
646
|
-
for (let p = 0; p < a.length; p++) {
|
|
647
|
-
let c = a[p], f;
|
|
648
|
-
for (let d = 0; d < n.length; d++) {
|
|
649
|
-
let u = n[d];
|
|
650
|
-
u.step == i - 1 && c.eq(n[d].style) && (f = u);
|
|
651
|
-
}
|
|
652
|
-
f ? (f.to = h, f.step = i) : n.push({ style: c, from: Math.max(l, e), to: h, step: i });
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}), n.forEach((o) => s.step(new b(o.from, o.to, o.style)));
|
|
656
|
-
}
|
|
657
|
-
function $(s, e, t, r = t.contentMatch, n = !0) {
|
|
658
|
-
let i = s.doc.nodeAt(e), o = [], l = e + 1;
|
|
659
|
-
for (let a = 0; a < i.childCount; a++) {
|
|
660
|
-
let h = i.child(a), p = l + h.nodeSize, c = r.matchType(h.type);
|
|
661
|
-
if (!c)
|
|
662
|
-
o.push(new v(l, p, g.empty));
|
|
663
|
-
else {
|
|
664
|
-
r = c;
|
|
665
|
-
for (let f = 0; f < h.marks.length; f++)
|
|
666
|
-
t.allowsMarkType(h.marks[f].type) || s.step(new b(l, p, h.marks[f]));
|
|
667
|
-
if (n && h.isText && t.whitespace != "pre") {
|
|
668
|
-
let f, d = /\r?\n|\r/g, u;
|
|
669
|
-
for (; f = d.exec(h.text); )
|
|
670
|
-
u || (u = new g(w.from(t.schema.text(" ", t.allowedMarks(h.marks))), 0, 0)), o.push(new v(l + f.index, l + f.index + f[0].length, u));
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
l = p;
|
|
674
|
-
}
|
|
675
|
-
if (!r.validEnd) {
|
|
676
|
-
let a = r.fillBefore(w.empty, !0);
|
|
677
|
-
s.replace(l, l, new g(a, 0, 0));
|
|
678
|
-
}
|
|
679
|
-
for (let a = o.length - 1; a >= 0; a--)
|
|
680
|
-
s.step(o[a]);
|
|
681
|
-
}
|
|
682
|
-
function ce(s, e, t) {
|
|
683
|
-
return (e == 0 || s.canReplace(e, s.childCount)) && (t == s.childCount || s.canReplace(0, t));
|
|
684
|
-
}
|
|
685
|
-
function Fe(s) {
|
|
686
|
-
let t = s.parent.content.cutByIndex(s.startIndex, s.endIndex);
|
|
687
|
-
for (let r = s.depth, n = 0, i = 0; ; --r) {
|
|
688
|
-
let o = s.$from.node(r), l = s.$from.index(r) + n, a = s.$to.indexAfter(r) - i;
|
|
689
|
-
if (r < s.depth && o.canReplace(l, a, t))
|
|
690
|
-
return r;
|
|
691
|
-
if (r == 0 || o.type.spec.isolating || !ce(o, l, a))
|
|
692
|
-
break;
|
|
693
|
-
l && (n = 1), a < o.childCount && (i = 1);
|
|
85
|
+
const H = (t, e, r) => {
|
|
86
|
+
let { $head: n, empty: o } = t.selection, l = n;
|
|
87
|
+
if (!o)
|
|
88
|
+
return !1;
|
|
89
|
+
if (n.parent.isTextblock) {
|
|
90
|
+
if (r ? !r.endOfTextblock("backward", t) : n.parentOffset > 0)
|
|
91
|
+
return !1;
|
|
92
|
+
l = z(n);
|
|
694
93
|
}
|
|
94
|
+
let i = l && l.nodeBefore;
|
|
95
|
+
return !i || !d.isSelectable(i) ? !1 : (e && e(t.tr.setSelection(d.create(t.doc, l.pos - i.nodeSize)).scrollIntoView()), !0);
|
|
96
|
+
};
|
|
97
|
+
function z(t) {
|
|
98
|
+
if (!t.parent.type.spec.isolating)
|
|
99
|
+
for (let e = t.depth - 1; e >= 0; e--) {
|
|
100
|
+
if (t.index(e) > 0)
|
|
101
|
+
return t.doc.resolve(t.before(e + 1));
|
|
102
|
+
if (t.node(e).type.spec.isolating)
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
695
105
|
return null;
|
|
696
106
|
}
|
|
697
|
-
function
|
|
698
|
-
let { $
|
|
699
|
-
|
|
700
|
-
m || r.index(u) > 0 ? (m = !0, p = w.from(r.node(u).copy(p)), c++) : a--;
|
|
701
|
-
let f = w.empty, d = 0;
|
|
702
|
-
for (let u = i, m = !1; u > t; u--)
|
|
703
|
-
m || n.after(u + 1) < n.end(u) ? (m = !0, f = w.from(n.node(u).copy(f)), d++) : h++;
|
|
704
|
-
s.step(new M(a, h, o, l, new g(p.append(f), c, d), p.size - c, !0));
|
|
705
|
-
}
|
|
706
|
-
function ze(s, e, t = null, r = s) {
|
|
707
|
-
let n = ue(s, e), i = n && me(r, e);
|
|
708
|
-
return i ? n.map(K).concat({ type: e, attrs: t }).concat(i.map(K)) : null;
|
|
709
|
-
}
|
|
710
|
-
function K(s) {
|
|
711
|
-
return { type: s, attrs: null };
|
|
712
|
-
}
|
|
713
|
-
function ue(s, e) {
|
|
714
|
-
let { parent: t, startIndex: r, endIndex: n } = s, i = t.contentMatchAt(r).findWrapping(e);
|
|
715
|
-
if (!i)
|
|
716
|
-
return null;
|
|
717
|
-
let o = i.length ? i[0] : e;
|
|
718
|
-
return t.canReplaceWith(r, n, o) ? i : null;
|
|
107
|
+
function W(t, e) {
|
|
108
|
+
let { $cursor: r } = t.selection;
|
|
109
|
+
return !r || (e ? !e.endOfTextblock("forward", t) : r.parentOffset < r.parent.content.size) ? null : r;
|
|
719
110
|
}
|
|
720
|
-
|
|
721
|
-
let
|
|
111
|
+
const K = (t, e, r) => {
|
|
112
|
+
let n = W(t, r);
|
|
113
|
+
if (!n)
|
|
114
|
+
return !1;
|
|
115
|
+
let o = R(n);
|
|
722
116
|
if (!o)
|
|
723
|
-
return
|
|
724
|
-
let
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
let l = t[o].type.contentMatch.matchFragment(r);
|
|
734
|
-
if (!l || !l.validEnd)
|
|
735
|
-
throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
|
|
736
|
-
}
|
|
737
|
-
r = w.from(t[o].type.create(t[o].attrs, r));
|
|
738
|
-
}
|
|
739
|
-
let n = e.start, i = e.end;
|
|
740
|
-
s.step(new M(n, i, n, i, new g(r, 0, 0), t.length, !0));
|
|
741
|
-
}
|
|
742
|
-
function we(s, e, t, r, n) {
|
|
743
|
-
if (!r.isTextblock)
|
|
744
|
-
throw new RangeError("Type given to setBlockType should be a textblock");
|
|
745
|
-
let i = s.steps.length;
|
|
746
|
-
s.doc.nodesBetween(e, t, (o, l) => {
|
|
747
|
-
let a = typeof n == "function" ? n(o) : n;
|
|
748
|
-
if (o.isTextblock && !o.hasMarkup(r, a) && ye(s.doc, s.mapping.slice(i).map(l), r)) {
|
|
749
|
-
let h = null;
|
|
750
|
-
if (r.schema.linebreakReplacement) {
|
|
751
|
-
let d = r.whitespace == "pre", u = !!r.contentMatch.matchType(r.schema.linebreakReplacement);
|
|
752
|
-
d && !u ? h = !1 : !d && u && (h = !0);
|
|
753
|
-
}
|
|
754
|
-
h === !1 && _(s, o, l, i), $(s, s.mapping.slice(i).map(l, 1), r, void 0, h === null);
|
|
755
|
-
let p = s.mapping.slice(i), c = p.map(l, 1), f = p.map(l + o.nodeSize, 1);
|
|
756
|
-
return s.step(new M(c, f, c + 1, f - 1, new g(w.from(r.create(a, null, o.marks)), 0, 0), 1, !0)), h === !0 && Z(s, o, l, i), !1;
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
function Z(s, e, t, r) {
|
|
761
|
-
e.forEach((n, i) => {
|
|
762
|
-
if (n.isText) {
|
|
763
|
-
let o, l = /\r?\n|\r/g;
|
|
764
|
-
for (; o = l.exec(n.text); ) {
|
|
765
|
-
let a = s.mapping.slice(r).map(t + 1 + i + o.index);
|
|
766
|
-
s.replaceWith(a, a + 1, e.type.schema.linebreakReplacement.create());
|
|
117
|
+
return !1;
|
|
118
|
+
let l = o.nodeAfter;
|
|
119
|
+
if (D(t, o, e, 1))
|
|
120
|
+
return !0;
|
|
121
|
+
if (n.parent.content.size == 0 && (x(l, "start") || d.isSelectable(l))) {
|
|
122
|
+
let i = B(t.doc, n.before(), n.after(), y.empty);
|
|
123
|
+
if (i && i.slice.size < i.to - i.from) {
|
|
124
|
+
if (e) {
|
|
125
|
+
let f = t.tr.step(i);
|
|
126
|
+
f.setSelection(x(l, "start") ? V.findFrom(f.doc.resolve(f.mapping.map(o.pos)), 1) : d.create(f.doc, f.mapping.map(o.pos))), e(f.scrollIntoView());
|
|
767
127
|
}
|
|
128
|
+
return !0;
|
|
768
129
|
}
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
function _(s, e, t, r) {
|
|
772
|
-
e.forEach((n, i) => {
|
|
773
|
-
if (n.type == n.type.schema.linebreakReplacement) {
|
|
774
|
-
let o = s.mapping.slice(r).map(t + 1 + i);
|
|
775
|
-
s.replaceWith(o, o + 1, e.type.schema.text(`
|
|
776
|
-
`));
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
function ye(s, e, t) {
|
|
781
|
-
let r = s.resolve(e), n = r.index();
|
|
782
|
-
return r.parent.canReplaceWith(n, n + 1, t);
|
|
783
|
-
}
|
|
784
|
-
function ke(s, e, t, r, n) {
|
|
785
|
-
let i = s.doc.nodeAt(e);
|
|
786
|
-
if (!i)
|
|
787
|
-
throw new RangeError("No node at given position");
|
|
788
|
-
t || (t = i.type);
|
|
789
|
-
let o = t.create(r, null, n || i.marks);
|
|
790
|
-
if (i.isLeaf)
|
|
791
|
-
return s.replaceWith(e, e + i.nodeSize, o);
|
|
792
|
-
if (!t.validContent(i.content))
|
|
793
|
-
throw new RangeError("Invalid content for node type " + t.name);
|
|
794
|
-
s.step(new M(e, e + i.nodeSize, e + 1, e + i.nodeSize - 1, new g(w.from(o), 0, 0), 1, !0));
|
|
795
|
-
}
|
|
796
|
-
function Je(s, e, t = 1, r) {
|
|
797
|
-
let n = s.resolve(e), i = n.depth - t, o = r && r[r.length - 1] || n.parent;
|
|
798
|
-
if (i < 0 || n.parent.type.spec.isolating || !n.parent.canReplace(n.index(), n.parent.childCount) || !o.type.validContent(n.parent.content.cutByIndex(n.index(), n.parent.childCount)))
|
|
799
|
-
return !1;
|
|
800
|
-
for (let h = n.depth - 1, p = t - 2; h > i; h--, p--) {
|
|
801
|
-
let c = n.node(h), f = n.index(h);
|
|
802
|
-
if (c.type.spec.isolating)
|
|
803
|
-
return !1;
|
|
804
|
-
let d = c.content.cutByIndex(f, c.childCount), u = r && r[p + 1];
|
|
805
|
-
u && (d = d.replaceChild(0, u.type.create(u.attrs)));
|
|
806
|
-
let m = r && r[p] || c;
|
|
807
|
-
if (!c.canReplace(f + 1, c.childCount) || !m.type.validContent(d))
|
|
808
|
-
return !1;
|
|
809
130
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
let p = r && r[h];
|
|
818
|
-
o = w.from(p ? p.type.create(p.attrs, o) : n.node(l).copy(o));
|
|
819
|
-
}
|
|
820
|
-
s.step(new v(e, e, new g(i.append(o), t, t), !0));
|
|
821
|
-
}
|
|
822
|
-
function Ae(s, e) {
|
|
823
|
-
let t = s.resolve(e), r = t.index();
|
|
824
|
-
return j(t.nodeBefore, t.nodeAfter) && t.parent.canReplace(r, r + 1);
|
|
825
|
-
}
|
|
826
|
-
function xe(s, e) {
|
|
827
|
-
e.content.size || s.type.compatibleContent(e.type);
|
|
828
|
-
let t = s.contentMatchAt(s.childCount), { linebreakReplacement: r } = s.type.schema;
|
|
829
|
-
for (let n = 0; n < e.childCount; n++) {
|
|
830
|
-
let i = e.child(n), o = i.type == r ? s.type.schema.nodes.text : i.type;
|
|
831
|
-
if (t = t.matchType(o), !t || !s.type.allowsMarks(i.marks))
|
|
131
|
+
return l.isAtom && o.depth == n.depth - 1 ? (e && e(t.tr.delete(o.pos, o.pos + l.nodeSize).scrollIntoView()), !0) : !1;
|
|
132
|
+
}, L = (t, e, r) => {
|
|
133
|
+
let { $head: n, empty: o } = t.selection, l = n;
|
|
134
|
+
if (!o)
|
|
135
|
+
return !1;
|
|
136
|
+
if (n.parent.isTextblock) {
|
|
137
|
+
if (r ? !r.endOfTextblock("forward", t) : n.parentOffset < n.parent.content.size)
|
|
832
138
|
return !1;
|
|
139
|
+
l = R(n);
|
|
833
140
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
if (n == 0)
|
|
846
|
-
break;
|
|
847
|
-
e = t < 0 ? r.before(n) : r.after(n);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
function Se(s, e, t) {
|
|
851
|
-
let r = null, { linebreakReplacement: n } = s.doc.type.schema, i = s.doc.resolve(e - t), o = i.node().type;
|
|
852
|
-
if (n && o.inlineContent) {
|
|
853
|
-
let p = o.whitespace == "pre", c = !!o.contentMatch.matchType(n);
|
|
854
|
-
p && !c ? r = !1 : !p && c && (r = !0);
|
|
855
|
-
}
|
|
856
|
-
let l = s.steps.length;
|
|
857
|
-
if (r === !1) {
|
|
858
|
-
let p = s.doc.resolve(e + t);
|
|
859
|
-
_(s, p.node(), p.before(), l);
|
|
860
|
-
}
|
|
861
|
-
o.inlineContent && $(s, e + t - 1, o, i.node().contentMatchAt(i.index()), r == null);
|
|
862
|
-
let a = s.mapping.slice(l), h = a.map(e - t);
|
|
863
|
-
if (s.step(new v(h, a.map(e + t, -1), g.empty, !0)), r === !0) {
|
|
864
|
-
let p = s.doc.resolve(h);
|
|
865
|
-
Z(s, p.node(), p.before(), s.steps.length);
|
|
866
|
-
}
|
|
867
|
-
return s;
|
|
868
|
-
}
|
|
869
|
-
function be(s, e, t) {
|
|
870
|
-
let r = s.resolve(e);
|
|
871
|
-
if (r.parent.canReplaceWith(r.index(), r.index(), t))
|
|
872
|
-
return e;
|
|
873
|
-
if (r.parentOffset == 0)
|
|
874
|
-
for (let n = r.depth - 1; n >= 0; n--) {
|
|
875
|
-
let i = r.index(n);
|
|
876
|
-
if (r.node(n).canReplaceWith(i, i, t))
|
|
877
|
-
return r.before(n + 1);
|
|
878
|
-
if (i > 0)
|
|
879
|
-
return null;
|
|
880
|
-
}
|
|
881
|
-
if (r.parentOffset == r.parent.content.size)
|
|
882
|
-
for (let n = r.depth - 1; n >= 0; n--) {
|
|
883
|
-
let i = r.indexAfter(n);
|
|
884
|
-
if (r.node(n).canReplaceWith(i, i, t))
|
|
885
|
-
return r.after(n + 1);
|
|
886
|
-
if (i < r.node(n).childCount)
|
|
887
|
-
return null;
|
|
141
|
+
let i = l && l.nodeAfter;
|
|
142
|
+
return !i || !d.isSelectable(i) ? !1 : (e && e(t.tr.setSelection(d.create(t.doc, l.pos)).scrollIntoView()), !0);
|
|
143
|
+
};
|
|
144
|
+
function R(t) {
|
|
145
|
+
if (!t.parent.type.spec.isolating)
|
|
146
|
+
for (let e = t.depth - 1; e >= 0; e--) {
|
|
147
|
+
let r = t.node(e);
|
|
148
|
+
if (t.index(e) + 1 < r.childCount)
|
|
149
|
+
return t.doc.resolve(t.after(e + 1));
|
|
150
|
+
if (r.type.spec.isolating)
|
|
151
|
+
break;
|
|
888
152
|
}
|
|
889
153
|
return null;
|
|
890
154
|
}
|
|
891
|
-
|
|
892
|
-
let r =
|
|
893
|
-
if (
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
155
|
+
const ie = (t, e) => {
|
|
156
|
+
let r = t.selection, n = r instanceof d, o;
|
|
157
|
+
if (n) {
|
|
158
|
+
if (r.node.isTextblock || !T(t.doc, r.from))
|
|
159
|
+
return !1;
|
|
160
|
+
o = r.from;
|
|
161
|
+
} else if (o = F(t.doc, r.from, -1), o == null)
|
|
162
|
+
return !1;
|
|
163
|
+
if (e) {
|
|
164
|
+
let l = t.tr.join(o);
|
|
165
|
+
n && l.setSelection(d.create(l.doc, o - t.doc.resolve(o).nodeBefore.nodeSize)), e(l.scrollIntoView());
|
|
166
|
+
}
|
|
167
|
+
return !0;
|
|
168
|
+
}, fe = (t, e) => {
|
|
169
|
+
let r = t.selection, n;
|
|
170
|
+
if (r instanceof d) {
|
|
171
|
+
if (r.node.isTextblock || !T(t.doc, r.to))
|
|
172
|
+
return !1;
|
|
173
|
+
n = r.to;
|
|
174
|
+
} else if (n = F(t.doc, r.to, 1), n == null)
|
|
175
|
+
return !1;
|
|
176
|
+
return e && e(t.tr.join(n).scrollIntoView()), !0;
|
|
177
|
+
}, ce = (t, e) => {
|
|
178
|
+
let { $from: r, $to: n } = t.selection, o = r.blockRange(n), l = o && A(o);
|
|
179
|
+
return l == null ? !1 : (e && e(t.tr.lift(o, l).scrollIntoView()), !0);
|
|
180
|
+
}, Q = (t, e) => {
|
|
181
|
+
let { $head: r, $anchor: n } = t.selection;
|
|
182
|
+
return !r.parent.type.spec.code || !r.sameParent(n) ? !1 : (e && e(t.tr.insertText(`
|
|
183
|
+
`).scrollIntoView()), !0);
|
|
184
|
+
};
|
|
185
|
+
function j(t) {
|
|
186
|
+
for (let e = 0; e < t.edgeCount; e++) {
|
|
187
|
+
let { type: r } = t.edge(e);
|
|
188
|
+
if (r.isTextblock && !r.hasRequiredAttrs())
|
|
189
|
+
return r;
|
|
190
|
+
}
|
|
910
191
|
return null;
|
|
911
192
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
return null;
|
|
945
|
-
let i = this.placed, o = r.depth, l = n.depth;
|
|
946
|
-
for (; o && l && i.childCount == 1; )
|
|
947
|
-
i = i.firstChild.content, o--, l--;
|
|
948
|
-
let a = new g(i, o, l);
|
|
949
|
-
return e > -1 ? new M(r.pos, e, this.$to.pos, this.$to.end(), a, t) : a.size || r.pos != this.$to.pos ? new v(r.pos, n.pos, a) : null;
|
|
193
|
+
const se = (t, e) => {
|
|
194
|
+
let { $head: r, $anchor: n } = t.selection;
|
|
195
|
+
if (!r.parent.type.spec.code || !r.sameParent(n))
|
|
196
|
+
return !1;
|
|
197
|
+
let o = r.node(-1), l = r.indexAfter(-1), i = j(o.contentMatchAt(l));
|
|
198
|
+
if (!i || !o.canReplaceWith(l, l, i))
|
|
199
|
+
return !1;
|
|
200
|
+
if (e) {
|
|
201
|
+
let f = r.after(), c = t.tr.replaceWith(f, f, i.createAndFill());
|
|
202
|
+
c.setSelection(V.near(c.doc.resolve(f), 1)), e(c.scrollIntoView());
|
|
203
|
+
}
|
|
204
|
+
return !0;
|
|
205
|
+
}, X = (t, e) => {
|
|
206
|
+
let r = t.selection, { $from: n, $to: o } = r;
|
|
207
|
+
if (r instanceof P || n.parent.inlineContent || o.parent.inlineContent)
|
|
208
|
+
return !1;
|
|
209
|
+
let l = j(o.parent.contentMatchAt(o.indexAfter()));
|
|
210
|
+
if (!l || !l.isTextblock)
|
|
211
|
+
return !1;
|
|
212
|
+
if (e) {
|
|
213
|
+
let i = (!n.parentOffset && o.index() < o.parent.childCount ? n : o).pos, f = t.tr.insert(i, l.createAndFill());
|
|
214
|
+
f.setSelection(I.create(f.doc, i + 1)), e(f.scrollIntoView());
|
|
215
|
+
}
|
|
216
|
+
return !0;
|
|
217
|
+
}, Y = (t, e) => {
|
|
218
|
+
let { $cursor: r } = t.selection;
|
|
219
|
+
if (!r || r.parent.content.size)
|
|
220
|
+
return !1;
|
|
221
|
+
if (r.depth > 1 && r.after() != r.end(-1)) {
|
|
222
|
+
let l = r.before();
|
|
223
|
+
if (h(t.doc, l))
|
|
224
|
+
return e && e(t.tr.split(l).scrollIntoView()), !0;
|
|
950
225
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
226
|
+
let n = r.blockRange(), o = n && A(n);
|
|
227
|
+
return o == null ? !1 : (e && e(t.tr.lift(n, o).scrollIntoView()), !0);
|
|
228
|
+
};
|
|
229
|
+
function Z(t) {
|
|
230
|
+
return (e, r) => {
|
|
231
|
+
let { $from: n, $to: o } = e.selection;
|
|
232
|
+
if (e.selection instanceof d && e.selection.node.isBlock)
|
|
233
|
+
return !n.parentOffset || !h(e.doc, n.pos) ? !1 : (r && r(e.tr.split(n.pos).scrollIntoView()), !0);
|
|
234
|
+
if (!n.depth)
|
|
235
|
+
return !1;
|
|
236
|
+
let l = [], i, f, c = !1, p = !1;
|
|
237
|
+
for (let u = n.depth; ; u--)
|
|
238
|
+
if (n.node(u).isBlock) {
|
|
239
|
+
c = n.end(u) == n.pos + (n.depth - u), p = n.start(u) == n.pos - (n.depth - u), f = j(n.node(u - 1).contentMatchAt(n.indexAfter(u - 1))), l.unshift(c && f ? { type: f } : null), i = u;
|
|
960
240
|
break;
|
|
241
|
+
} else {
|
|
242
|
+
if (u == 1)
|
|
243
|
+
return !1;
|
|
244
|
+
l.unshift(null);
|
|
961
245
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
let { type: a, match: h } = this.frontier[l], p, c = null;
|
|
971
|
-
if (t == 1 && (o ? h.matchType(o.type) || (c = h.fillBefore(w.from(o), !1)) : i && a.compatibleContent(i.type)))
|
|
972
|
-
return { sliceDepth: r, frontierDepth: l, parent: i, inject: c };
|
|
973
|
-
if (t == 2 && o && (p = h.findWrapping(o.type)))
|
|
974
|
-
return { sliceDepth: r, frontierDepth: l, parent: i, wrap: p };
|
|
975
|
-
if (i && h.matchType(i.type))
|
|
976
|
-
break;
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
openMore() {
|
|
981
|
-
let { content: e, openStart: t, openEnd: r } = this.unplaced, n = W(e, t);
|
|
982
|
-
return !n.childCount || n.firstChild.isLeaf ? !1 : (this.unplaced = new g(e, t + 1, Math.max(r, n.size + t >= e.size - r ? t + 1 : 0)), !0);
|
|
983
|
-
}
|
|
984
|
-
dropNode() {
|
|
985
|
-
let { content: e, openStart: t, openEnd: r } = this.unplaced, n = W(e, t);
|
|
986
|
-
if (n.childCount <= 1 && t > 0) {
|
|
987
|
-
let i = e.size - t <= t + n.size;
|
|
988
|
-
this.unplaced = new g(O(e, t - 1, 1), t - 1, i ? t - 1 : r);
|
|
989
|
-
} else
|
|
990
|
-
this.unplaced = new g(O(e, t, 1), t, r);
|
|
991
|
-
}
|
|
992
|
-
// Move content from the unplaced slice at `sliceDepth` to the
|
|
993
|
-
// frontier node at `frontierDepth`. Close that frontier node when
|
|
994
|
-
// applicable.
|
|
995
|
-
placeNodes({ sliceDepth: e, frontierDepth: t, parent: r, inject: n, wrap: i }) {
|
|
996
|
-
for (; this.depth > t; )
|
|
997
|
-
this.closeFrontierNode();
|
|
998
|
-
if (i)
|
|
999
|
-
for (let m = 0; m < i.length; m++)
|
|
1000
|
-
this.openFrontierNode(i[m]);
|
|
1001
|
-
let o = this.unplaced, l = r ? r.content : o.content, a = o.openStart - e, h = 0, p = [], { match: c, type: f } = this.frontier[t];
|
|
1002
|
-
if (n) {
|
|
1003
|
-
for (let m = 0; m < n.childCount; m++)
|
|
1004
|
-
p.push(n.child(m));
|
|
1005
|
-
c = c.matchFragment(n);
|
|
1006
|
-
}
|
|
1007
|
-
let d = l.size + e - (o.content.size - o.openEnd);
|
|
1008
|
-
for (; h < l.childCount; ) {
|
|
1009
|
-
let m = l.child(h), x = c.matchType(m.type);
|
|
1010
|
-
if (!x)
|
|
1011
|
-
break;
|
|
1012
|
-
h++, (h > 1 || a == 0 || m.content.size) && (c = x, p.push(te(m.mark(f.allowedMarks(m.marks)), h == 1 ? a : 0, h == l.childCount ? d : -1)));
|
|
246
|
+
let s = e.tr;
|
|
247
|
+
(e.selection instanceof I || e.selection instanceof P) && s.deleteSelection();
|
|
248
|
+
let m = s.mapping.map(n.pos), k = h(s.doc, m, l.length, l);
|
|
249
|
+
if (k || (l[0] = f ? { type: f } : null, k = h(s.doc, m, l.length, l)), !k)
|
|
250
|
+
return !1;
|
|
251
|
+
if (s.split(m, l.length, l), !c && p && n.node(i).type != f) {
|
|
252
|
+
let u = s.mapping.map(n.before(i)), a = s.doc.resolve(u);
|
|
253
|
+
f && n.node(i - 1).canReplaceWith(a.index(), a.index() + 1, f) && s.setNodeMarkup(s.mapping.map(n.before(i)), f);
|
|
1013
254
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
255
|
+
return r && r(s.scrollIntoView()), !0;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const _ = Z(), ue = (t, e) => {
|
|
259
|
+
let { $from: r, to: n } = t.selection, o, l = r.sharedDepth(n);
|
|
260
|
+
return l == 0 ? !1 : (o = r.before(l), e && e(t.tr.setSelection(d.create(t.doc, o))), !0);
|
|
261
|
+
};
|
|
262
|
+
function ee(t, e, r) {
|
|
263
|
+
let n = e.nodeBefore, o = e.nodeAfter, l = e.index();
|
|
264
|
+
return !n || !o || !n.type.compatibleContent(o.type) ? !1 : !n.content.size && e.parent.canReplace(l - 1, l) ? (r && r(t.tr.delete(e.pos - n.nodeSize, e.pos).scrollIntoView()), !0) : !e.parent.canReplace(l, l + 1) || !(o.isTextblock || T(t.doc, e.pos)) ? !1 : (r && r(t.tr.join(e.pos).scrollIntoView()), !0);
|
|
265
|
+
}
|
|
266
|
+
function D(t, e, r, n) {
|
|
267
|
+
let o = e.nodeBefore, l = e.nodeAfter, i, f, c = o.type.spec.isolating || l.type.spec.isolating;
|
|
268
|
+
if (!c && ee(t, e, r))
|
|
269
|
+
return !0;
|
|
270
|
+
let p = !c && e.parent.canReplace(e.index(), e.index() + 1);
|
|
271
|
+
if (p && (i = (f = o.contentMatchAt(o.childCount)).findWrapping(l.type)) && f.matchType(i[0] || l.type).validEnd) {
|
|
272
|
+
if (r) {
|
|
273
|
+
let u = e.pos + l.nodeSize, a = S.empty;
|
|
274
|
+
for (let w = i.length - 1; w >= 0; w--)
|
|
275
|
+
a = S.from(i[w].create(null, a));
|
|
276
|
+
a = S.from(o.copy(a));
|
|
277
|
+
let b = t.tr.step(new v(e.pos - 1, u, e.pos, u, new y(a, 1, 0), i.length, !0)), g = b.doc.resolve(u + 2 * i.length);
|
|
278
|
+
g.nodeAfter && g.nodeAfter.type == o.type && T(b.doc, g.pos) && b.join(g.pos), r(b.scrollIntoView());
|
|
1019
279
|
}
|
|
1020
|
-
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
if (!p || p.childCount)
|
|
1040
|
-
continue e;
|
|
1041
|
-
}
|
|
1042
|
-
return { depth: t, fit: o, move: i ? e.doc.resolve(e.after(t + 1)) : e };
|
|
280
|
+
return !0;
|
|
281
|
+
}
|
|
282
|
+
let s = l.type.spec.isolating || n > 0 && c ? null : V.findFrom(e, 1), m = s && s.$from.blockRange(s.$to), k = m && A(m);
|
|
283
|
+
if (k != null && k >= e.depth)
|
|
284
|
+
return r && r(t.tr.lift(m, k).scrollIntoView()), !0;
|
|
285
|
+
if (p && x(l, "start", !0) && x(o, "end")) {
|
|
286
|
+
let u = o, a = [];
|
|
287
|
+
for (; a.push(u), !u.isTextblock; )
|
|
288
|
+
u = u.lastChild;
|
|
289
|
+
let b = l, g = 1;
|
|
290
|
+
for (; !b.isTextblock; b = b.firstChild)
|
|
291
|
+
g++;
|
|
292
|
+
if (u.canReplace(u.childCount, u.childCount, b.content)) {
|
|
293
|
+
if (r) {
|
|
294
|
+
let w = S.empty;
|
|
295
|
+
for (let C = a.length - 1; C >= 0; C--)
|
|
296
|
+
w = S.from(a[C].copy(w));
|
|
297
|
+
let q = t.tr.step(new v(e.pos - a.length, e.pos + l.nodeSize, e.pos + g, e.pos + l.nodeSize - g, new y(w, a.length, 0), 0, !0));
|
|
298
|
+
r(q.scrollIntoView());
|
|
1043
299
|
}
|
|
300
|
+
return !0;
|
|
1044
301
|
}
|
|
1045
302
|
}
|
|
1046
|
-
close(e) {
|
|
1047
|
-
let t = this.findCloseLevel(e);
|
|
1048
|
-
if (!t)
|
|
1049
|
-
return null;
|
|
1050
|
-
for (; this.depth > t.depth; )
|
|
1051
|
-
this.closeFrontierNode();
|
|
1052
|
-
t.fit.childCount && (this.placed = F(this.placed, t.depth, t.fit)), e = t.move;
|
|
1053
|
-
for (let r = t.depth + 1; r <= e.depth; r++) {
|
|
1054
|
-
let n = e.node(r), i = n.type.contentMatch.fillBefore(n.content, !0, e.index(r));
|
|
1055
|
-
this.openFrontierNode(n.type, n.attrs, i);
|
|
1056
|
-
}
|
|
1057
|
-
return e;
|
|
1058
|
-
}
|
|
1059
|
-
openFrontierNode(e, t = null, r) {
|
|
1060
|
-
let n = this.frontier[this.depth];
|
|
1061
|
-
n.match = n.match.matchType(e), this.placed = F(this.placed, this.depth, w.from(e.create(t, r))), this.frontier.push({ type: e, match: e.contentMatch });
|
|
1062
|
-
}
|
|
1063
|
-
closeFrontierNode() {
|
|
1064
|
-
let t = this.frontier.pop().match.fillBefore(w.empty, !0);
|
|
1065
|
-
t.childCount && (this.placed = F(this.placed, this.frontier.length, t));
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
function O(s, e, t) {
|
|
1069
|
-
return e == 0 ? s.cutByIndex(t, s.childCount) : s.replaceChild(0, s.firstChild.copy(O(s.firstChild.content, e - 1, t)));
|
|
1070
|
-
}
|
|
1071
|
-
function F(s, e, t) {
|
|
1072
|
-
return e == 0 ? s.append(t) : s.replaceChild(s.childCount - 1, s.lastChild.copy(F(s.lastChild.content, e - 1, t)));
|
|
1073
|
-
}
|
|
1074
|
-
function W(s, e) {
|
|
1075
|
-
for (let t = 0; t < e; t++)
|
|
1076
|
-
s = s.firstChild.content;
|
|
1077
|
-
return s;
|
|
1078
|
-
}
|
|
1079
|
-
function te(s, e, t) {
|
|
1080
|
-
if (e <= 0)
|
|
1081
|
-
return s;
|
|
1082
|
-
let r = s.content;
|
|
1083
|
-
return e > 1 && (r = r.replaceChild(0, te(r.firstChild, e - 1, r.childCount == 1 ? t - 1 : 0))), e > 0 && (r = s.type.contentMatch.fillBefore(r).append(r), t <= 0 && (r = r.append(s.type.contentMatch.matchFragment(r).fillBefore(w.empty, !0)))), s.copy(r);
|
|
1084
|
-
}
|
|
1085
|
-
function D(s, e, t, r, n) {
|
|
1086
|
-
let i = s.node(e), o = n ? s.indexAfter(e) : s.index(e);
|
|
1087
|
-
if (o == i.childCount && !t.compatibleContent(i.type))
|
|
1088
|
-
return null;
|
|
1089
|
-
let l = r.fillBefore(i.content, !0, o);
|
|
1090
|
-
return l && !Ne(t, i.content, o) ? l : null;
|
|
1091
|
-
}
|
|
1092
|
-
function Ne(s, e, t) {
|
|
1093
|
-
for (let r = t; r < e.childCount; r++)
|
|
1094
|
-
if (!s.allowsMarks(e.child(r).marks))
|
|
1095
|
-
return !0;
|
|
1096
303
|
return !1;
|
|
1097
304
|
}
|
|
1098
|
-
function
|
|
1099
|
-
return
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
return
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
let
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
let
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
for (let f = r.openStart; f >= 0; f--) {
|
|
1132
|
-
let d = (f + p + 1) % (r.openStart + 1), u = h[d];
|
|
1133
|
-
if (u)
|
|
1134
|
-
for (let m = 0; m < o.length; m++) {
|
|
1135
|
-
let x = o[(m + a) % o.length], I = !0;
|
|
1136
|
-
x < 0 && (I = !1, x = -x);
|
|
1137
|
-
let ie = n.node(x - 1), G = n.index(x - 1);
|
|
1138
|
-
if (ie.canReplaceWith(G, G, u.type, u.marks))
|
|
1139
|
-
return s.replace(n.before(x), I ? i.after(x) : t, new g(re(r.content, 0, r.openStart, d), d, r.openEnd));
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
let c = s.steps.length;
|
|
1143
|
-
for (let f = o.length - 1; f >= 0 && (s.replace(e, t, r), !(s.steps.length > c)); f--) {
|
|
1144
|
-
let d = o[f];
|
|
1145
|
-
d < 0 || (e = n.before(d), t = i.after(d));
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
function re(s, e, t, r, n) {
|
|
1149
|
-
if (e < t) {
|
|
1150
|
-
let i = s.firstChild;
|
|
1151
|
-
s = s.replaceChild(0, i.copy(re(i.content, e + 1, t, r, i)));
|
|
1152
|
-
}
|
|
1153
|
-
if (e > r) {
|
|
1154
|
-
let i = n.contentMatchAt(0), o = i.fillBefore(s).append(s);
|
|
1155
|
-
s = o.append(i.matchFragment(o).fillBefore(w.empty, !0));
|
|
1156
|
-
}
|
|
1157
|
-
return s;
|
|
1158
|
-
}
|
|
1159
|
-
function Ee(s, e, t, r) {
|
|
1160
|
-
if (!r.isInline && e == t && s.doc.resolve(e).parent.content.size) {
|
|
1161
|
-
let n = be(s.doc, e, r.type);
|
|
1162
|
-
n != null && (e = t = n);
|
|
1163
|
-
}
|
|
1164
|
-
s.replaceRange(e, t, new g(w.from(r), 0, 0));
|
|
1165
|
-
}
|
|
1166
|
-
function Te(s, e, t) {
|
|
1167
|
-
let r = s.doc.resolve(e), n = s.doc.resolve(t), i = ne(r, n);
|
|
1168
|
-
for (let o = 0; o < i.length; o++) {
|
|
1169
|
-
let l = i[o], a = o == i.length - 1;
|
|
1170
|
-
if (a && l == 0 || r.node(l).type.contentMatch.validEnd)
|
|
1171
|
-
return s.delete(r.start(l), n.end(l));
|
|
1172
|
-
if (l > 0 && (a || r.node(l - 1).canReplace(r.index(l - 1), n.indexAfter(l - 1))))
|
|
1173
|
-
return s.delete(r.before(l), n.after(l));
|
|
1174
|
-
}
|
|
1175
|
-
for (let o = 1; o <= r.depth && o <= n.depth; o++)
|
|
1176
|
-
if (e - r.start(o) == r.depth - o && t > r.end(o) && n.end(o) - t != n.depth - o && r.start(o - 1) == n.start(o - 1) && r.node(o - 1).canReplace(r.index(o - 1), n.index(o - 1)))
|
|
1177
|
-
return s.delete(r.before(o), t);
|
|
1178
|
-
s.delete(e, t);
|
|
1179
|
-
}
|
|
1180
|
-
function ne(s, e) {
|
|
1181
|
-
let t = [], r = Math.min(s.depth, e.depth);
|
|
1182
|
-
for (let n = r; n >= 0; n--) {
|
|
1183
|
-
let i = s.start(n);
|
|
1184
|
-
if (i < s.pos - (s.depth - n) || e.end(n) > e.pos + (e.depth - n) || s.node(n).type.spec.isolating || e.node(n).type.spec.isolating)
|
|
1185
|
-
break;
|
|
1186
|
-
(i == e.start(n) || n == s.depth && n == e.depth && s.parent.inlineContent && e.parent.inlineContent && n && e.start(n - 1) == i - 1) && t.push(n);
|
|
1187
|
-
}
|
|
1188
|
-
return t;
|
|
1189
|
-
}
|
|
1190
|
-
class E extends k {
|
|
1191
|
-
/**
|
|
1192
|
-
Construct an attribute step.
|
|
1193
|
-
*/
|
|
1194
|
-
constructor(e, t, r) {
|
|
1195
|
-
super(), this.pos = e, this.attr = t, this.value = r;
|
|
1196
|
-
}
|
|
1197
|
-
apply(e) {
|
|
1198
|
-
let t = e.nodeAt(this.pos);
|
|
1199
|
-
if (!t)
|
|
1200
|
-
return y.fail("No node at attribute step's position");
|
|
1201
|
-
let r = /* @__PURE__ */ Object.create(null);
|
|
1202
|
-
for (let i in t.attrs)
|
|
1203
|
-
r[i] = t.attrs[i];
|
|
1204
|
-
r[this.attr] = this.value;
|
|
1205
|
-
let n = t.type.create(r, null, t.marks);
|
|
1206
|
-
return y.fromReplace(e, this.pos, this.pos + 1, new g(w.from(n), 0, t.isLeaf ? 0 : 1));
|
|
1207
|
-
}
|
|
1208
|
-
getMap() {
|
|
1209
|
-
return S.empty;
|
|
1210
|
-
}
|
|
1211
|
-
invert(e) {
|
|
1212
|
-
return new E(this.pos, this.attr, e.nodeAt(this.pos).attrs[this.attr]);
|
|
1213
|
-
}
|
|
1214
|
-
map(e) {
|
|
1215
|
-
let t = e.mapResult(this.pos, 1);
|
|
1216
|
-
return t.deletedAfter ? null : new E(t.pos, this.attr, this.value);
|
|
1217
|
-
}
|
|
1218
|
-
toJSON() {
|
|
1219
|
-
return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
|
|
1220
|
-
}
|
|
1221
|
-
static fromJSON(e, t) {
|
|
1222
|
-
if (typeof t.pos != "number" || typeof t.attr != "string")
|
|
1223
|
-
throw new RangeError("Invalid input for AttrStep.fromJSON");
|
|
1224
|
-
return new E(t.pos, t.attr, t.value);
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
k.jsonID("attr", E);
|
|
1228
|
-
class z extends k {
|
|
1229
|
-
/**
|
|
1230
|
-
Construct an attribute step.
|
|
1231
|
-
*/
|
|
1232
|
-
constructor(e, t) {
|
|
1233
|
-
super(), this.attr = e, this.value = t;
|
|
1234
|
-
}
|
|
1235
|
-
apply(e) {
|
|
1236
|
-
let t = /* @__PURE__ */ Object.create(null);
|
|
1237
|
-
for (let n in e.attrs)
|
|
1238
|
-
t[n] = e.attrs[n];
|
|
1239
|
-
t[this.attr] = this.value;
|
|
1240
|
-
let r = e.type.create(t, e.content, e.marks);
|
|
1241
|
-
return y.ok(r);
|
|
1242
|
-
}
|
|
1243
|
-
getMap() {
|
|
1244
|
-
return S.empty;
|
|
1245
|
-
}
|
|
1246
|
-
invert(e) {
|
|
1247
|
-
return new z(this.attr, e.attrs[this.attr]);
|
|
1248
|
-
}
|
|
1249
|
-
map(e) {
|
|
1250
|
-
return this;
|
|
1251
|
-
}
|
|
1252
|
-
toJSON() {
|
|
1253
|
-
return { stepType: "docAttr", attr: this.attr, value: this.value };
|
|
1254
|
-
}
|
|
1255
|
-
static fromJSON(e, t) {
|
|
1256
|
-
if (typeof t.attr != "string")
|
|
1257
|
-
throw new RangeError("Invalid input for DocAttrStep.fromJSON");
|
|
1258
|
-
return new z(t.attr, t.value);
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
k.jsonID("docAttr", z);
|
|
1262
|
-
let T = class extends Error {
|
|
1263
|
-
};
|
|
1264
|
-
T = function s(e) {
|
|
1265
|
-
let t = Error.call(this, e);
|
|
1266
|
-
return t.__proto__ = s.prototype, t;
|
|
1267
|
-
};
|
|
1268
|
-
T.prototype = Object.create(Error.prototype);
|
|
1269
|
-
T.prototype.constructor = T;
|
|
1270
|
-
T.prototype.name = "TransformError";
|
|
1271
|
-
class De {
|
|
1272
|
-
/**
|
|
1273
|
-
Create a transform that starts with the given document.
|
|
1274
|
-
*/
|
|
1275
|
-
constructor(e) {
|
|
1276
|
-
this.doc = e, this.steps = [], this.docs = [], this.mapping = new A();
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
The starting document.
|
|
1280
|
-
*/
|
|
1281
|
-
get before() {
|
|
1282
|
-
return this.docs.length ? this.docs[0] : this.doc;
|
|
1283
|
-
}
|
|
1284
|
-
/**
|
|
1285
|
-
Apply a new step in this transform, saving the result. Throws an
|
|
1286
|
-
error when the step fails.
|
|
1287
|
-
*/
|
|
1288
|
-
step(e) {
|
|
1289
|
-
let t = this.maybeStep(e);
|
|
1290
|
-
if (t.failed)
|
|
1291
|
-
throw new T(t.failed);
|
|
1292
|
-
return this;
|
|
1293
|
-
}
|
|
1294
|
-
/**
|
|
1295
|
-
Try to apply a step in this transformation, ignoring it if it
|
|
1296
|
-
fails. Returns the step result.
|
|
1297
|
-
*/
|
|
1298
|
-
maybeStep(e) {
|
|
1299
|
-
let t = e.apply(this.doc);
|
|
1300
|
-
return t.failed || this.addStep(e, t.doc), t;
|
|
1301
|
-
}
|
|
1302
|
-
/**
|
|
1303
|
-
True when the document has been changed (when there are any
|
|
1304
|
-
steps).
|
|
1305
|
-
*/
|
|
1306
|
-
get docChanged() {
|
|
1307
|
-
return this.steps.length > 0;
|
|
1308
|
-
}
|
|
1309
|
-
/**
|
|
1310
|
-
Return a single range, in post-transform document positions,
|
|
1311
|
-
that covers all content changed by this transform. Returns null
|
|
1312
|
-
if no replacements are made. Note that this will ignore changes
|
|
1313
|
-
that add/remove marks without replacing the underlying content.
|
|
1314
|
-
*/
|
|
1315
|
-
changedRange() {
|
|
1316
|
-
let e = 1e9, t = -1e9;
|
|
1317
|
-
for (let r = 0; r < this.mapping.maps.length; r++) {
|
|
1318
|
-
let n = this.mapping.maps[r];
|
|
1319
|
-
r && (e = n.map(e, 1), t = n.map(t, -1)), n.forEach((i, o, l, a) => {
|
|
1320
|
-
e = Math.min(e, l), t = Math.max(t, a);
|
|
305
|
+
function $(t) {
|
|
306
|
+
return function(e, r) {
|
|
307
|
+
let n = e.selection, o = t < 0 ? n.$from : n.$to, l = o.depth;
|
|
308
|
+
for (; o.node(l).isInline; ) {
|
|
309
|
+
if (!l)
|
|
310
|
+
return !1;
|
|
311
|
+
l--;
|
|
312
|
+
}
|
|
313
|
+
return o.node(l).isTextblock ? (r && r(e.tr.setSelection(I.create(e.doc, t < 0 ? o.start(l) : o.end(l)))), !0) : !1;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const ae = $(-1), pe = $(1);
|
|
317
|
+
function de(t, e = null) {
|
|
318
|
+
return function(r, n) {
|
|
319
|
+
let { $from: o, $to: l } = r.selection, i = o.blockRange(l), f = i && J(i, t, e);
|
|
320
|
+
return f ? (n && n(r.tr.wrap(i, f).scrollIntoView()), !0) : !1;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function me(t, e = null) {
|
|
324
|
+
return function(r, n) {
|
|
325
|
+
let o = !1;
|
|
326
|
+
for (let l = 0; l < r.selection.ranges.length && !o; l++) {
|
|
327
|
+
let { $from: { pos: i }, $to: { pos: f } } = r.selection.ranges[l];
|
|
328
|
+
r.doc.nodesBetween(i, f, (c, p) => {
|
|
329
|
+
if (o)
|
|
330
|
+
return !1;
|
|
331
|
+
if (!(!c.isTextblock || c.hasMarkup(t, e)))
|
|
332
|
+
if (c.type == t)
|
|
333
|
+
o = !0;
|
|
334
|
+
else {
|
|
335
|
+
let s = r.doc.resolve(p), m = s.index();
|
|
336
|
+
o = s.parent.canReplaceWith(m, m + 1, t);
|
|
337
|
+
}
|
|
1321
338
|
});
|
|
1322
339
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
Replace the part of the document between `from` and `to` with the
|
|
1333
|
-
given `slice`.
|
|
1334
|
-
*/
|
|
1335
|
-
replace(e, t = e, r = g.empty) {
|
|
1336
|
-
let n = Me(this.doc, e, t, r);
|
|
1337
|
-
return n && this.step(n), this;
|
|
1338
|
-
}
|
|
1339
|
-
/**
|
|
1340
|
-
Replace the given range with the given content, which may be a
|
|
1341
|
-
fragment, node, or array of nodes.
|
|
1342
|
-
*/
|
|
1343
|
-
replaceWith(e, t, r) {
|
|
1344
|
-
return this.replace(e, t, new g(w.from(r), 0, 0));
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
Delete the content between the given positions.
|
|
1348
|
-
*/
|
|
1349
|
-
delete(e, t) {
|
|
1350
|
-
return this.replace(e, t, g.empty);
|
|
1351
|
-
}
|
|
1352
|
-
/**
|
|
1353
|
-
Insert the given content at the given position.
|
|
1354
|
-
*/
|
|
1355
|
-
insert(e, t) {
|
|
1356
|
-
return this.replaceWith(e, e, t);
|
|
1357
|
-
}
|
|
1358
|
-
/**
|
|
1359
|
-
Replace a range of the document with a given slice, using
|
|
1360
|
-
`from`, `to`, and the slice's
|
|
1361
|
-
[`openStart`](https://prosemirror.net/docs/ref/#model.Slice.openStart) property as hints, rather
|
|
1362
|
-
than fixed start and end points. This method may grow the
|
|
1363
|
-
replaced area or close open nodes in the slice in order to get a
|
|
1364
|
-
fit that is more in line with WYSIWYG expectations, by dropping
|
|
1365
|
-
fully covered parent nodes of the replaced region when they are
|
|
1366
|
-
marked [non-defining as
|
|
1367
|
-
context](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext), or including an
|
|
1368
|
-
open parent node from the slice that _is_ marked as [defining
|
|
1369
|
-
its content](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
|
|
1370
|
-
|
|
1371
|
-
This is the method, for example, to handle paste. The similar
|
|
1372
|
-
[`replace`](https://prosemirror.net/docs/ref/#transform.Transform.replace) method is a more
|
|
1373
|
-
primitive tool which will _not_ move the start and end of its given
|
|
1374
|
-
range, and is useful in situations where you need more precise
|
|
1375
|
-
control over what happens.
|
|
1376
|
-
*/
|
|
1377
|
-
replaceRange(e, t, r) {
|
|
1378
|
-
return Re(this, e, t, r), this;
|
|
1379
|
-
}
|
|
1380
|
-
/**
|
|
1381
|
-
Replace the given range with a node, but use `from` and `to` as
|
|
1382
|
-
hints, rather than precise positions. When from and to are the same
|
|
1383
|
-
and are at the start or end of a parent node in which the given
|
|
1384
|
-
node doesn't fit, this method may _move_ them out towards a parent
|
|
1385
|
-
that does allow the given node to be placed. When the given range
|
|
1386
|
-
completely covers a parent node, this method may completely replace
|
|
1387
|
-
that parent node.
|
|
1388
|
-
*/
|
|
1389
|
-
replaceRangeWith(e, t, r) {
|
|
1390
|
-
return Ee(this, e, t, r), this;
|
|
1391
|
-
}
|
|
1392
|
-
/**
|
|
1393
|
-
Delete the given range, expanding it to cover fully covered
|
|
1394
|
-
parent nodes until a valid replace is found.
|
|
1395
|
-
*/
|
|
1396
|
-
deleteRange(e, t) {
|
|
1397
|
-
return Te(this, e, t), this;
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
Split the content in the given range off from its parent, if there
|
|
1401
|
-
is sibling content before or after it, and move it up the tree to
|
|
1402
|
-
the depth specified by `target`. You'll probably want to use
|
|
1403
|
-
[`liftTarget`](https://prosemirror.net/docs/ref/#transform.liftTarget) to compute `target`, to make
|
|
1404
|
-
sure the lift is valid.
|
|
1405
|
-
*/
|
|
1406
|
-
lift(e, t) {
|
|
1407
|
-
return de(this, e, t), this;
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
Join the blocks around the given position. If depth is 2, their
|
|
1411
|
-
last and first siblings are also joined, and so on.
|
|
1412
|
-
*/
|
|
1413
|
-
join(e, t = 1) {
|
|
1414
|
-
return Se(this, e, t), this;
|
|
1415
|
-
}
|
|
1416
|
-
/**
|
|
1417
|
-
Wrap the given [range](https://prosemirror.net/docs/ref/#model.NodeRange) in the given set of wrappers.
|
|
1418
|
-
The wrappers are assumed to be valid in this position, and should
|
|
1419
|
-
probably be computed with [`findWrapping`](https://prosemirror.net/docs/ref/#transform.findWrapping).
|
|
1420
|
-
*/
|
|
1421
|
-
wrap(e, t) {
|
|
1422
|
-
return ge(this, e, t), this;
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
Set the type of all textblocks (partly) between `from` and `to` to
|
|
1426
|
-
the given node type with the given attributes.
|
|
1427
|
-
*/
|
|
1428
|
-
setBlockType(e, t = e, r, n = null) {
|
|
1429
|
-
return we(this, e, t, r, n), this;
|
|
1430
|
-
}
|
|
1431
|
-
/**
|
|
1432
|
-
Change the type, attributes, and/or marks of the node at `pos`.
|
|
1433
|
-
When `type` isn't given, the existing node type is preserved,
|
|
1434
|
-
*/
|
|
1435
|
-
setNodeMarkup(e, t, r = null, n) {
|
|
1436
|
-
return ke(this, e, t, r, n), this;
|
|
1437
|
-
}
|
|
1438
|
-
/**
|
|
1439
|
-
Set a single attribute on a given node to a new value.
|
|
1440
|
-
The `pos` addresses the document content. Use `setDocAttribute`
|
|
1441
|
-
to set attributes on the document itself.
|
|
1442
|
-
*/
|
|
1443
|
-
setNodeAttribute(e, t, r) {
|
|
1444
|
-
return this.step(new E(e, t, r)), this;
|
|
1445
|
-
}
|
|
1446
|
-
/**
|
|
1447
|
-
Set a single attribute on the document to a new value.
|
|
1448
|
-
*/
|
|
1449
|
-
setDocAttribute(e, t) {
|
|
1450
|
-
return this.step(new z(e, t)), this;
|
|
1451
|
-
}
|
|
1452
|
-
/**
|
|
1453
|
-
Add a mark to the node at position `pos`.
|
|
1454
|
-
*/
|
|
1455
|
-
addNodeMark(e, t) {
|
|
1456
|
-
return this.step(new N(e, t)), this;
|
|
1457
|
-
}
|
|
1458
|
-
/**
|
|
1459
|
-
Remove a mark (or all marks of the given type) from the node at
|
|
1460
|
-
position `pos`.
|
|
1461
|
-
*/
|
|
1462
|
-
removeNodeMark(e, t) {
|
|
1463
|
-
let r = this.doc.nodeAt(e);
|
|
1464
|
-
if (!r)
|
|
1465
|
-
throw new RangeError("No node at position " + e);
|
|
1466
|
-
if (t instanceof se)
|
|
1467
|
-
t.isInSet(r.marks) && this.step(new R(e, t));
|
|
1468
|
-
else {
|
|
1469
|
-
let n = r.marks, i, o = [];
|
|
1470
|
-
for (; i = t.isInSet(n); )
|
|
1471
|
-
o.push(new R(e, i)), n = i.removeFromSet(n);
|
|
1472
|
-
for (let l = o.length - 1; l >= 0; l--)
|
|
1473
|
-
this.step(o[l]);
|
|
340
|
+
if (!o)
|
|
341
|
+
return !1;
|
|
342
|
+
if (n) {
|
|
343
|
+
let l = r.tr;
|
|
344
|
+
for (let i = 0; i < r.selection.ranges.length; i++) {
|
|
345
|
+
let { $from: { pos: f }, $to: { pos: c } } = r.selection.ranges[i];
|
|
346
|
+
l.setBlockType(f, c, t, e);
|
|
347
|
+
}
|
|
348
|
+
n(l.scrollIntoView());
|
|
1474
349
|
}
|
|
1475
|
-
return
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return ve(this, e, t, r), this;
|
|
1486
|
-
}
|
|
1487
|
-
/**
|
|
1488
|
-
Add the given mark to the inline content between `from` and `to`.
|
|
1489
|
-
*/
|
|
1490
|
-
addMark(e, t, r) {
|
|
1491
|
-
return pe(this, e, t, r), this;
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
Remove marks from inline nodes between `from` and `to`. When
|
|
1495
|
-
`mark` is a single mark, remove precisely that mark. When it is
|
|
1496
|
-
a mark type, remove all marks of that type. When it is null,
|
|
1497
|
-
remove all marks of any type.
|
|
1498
|
-
*/
|
|
1499
|
-
removeMark(e, t, r) {
|
|
1500
|
-
return fe(this, e, t, r), this;
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
Removes all marks and nodes from the content of the node at
|
|
1504
|
-
`pos` that don't match the given new parent node type. Accepts
|
|
1505
|
-
an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as
|
|
1506
|
-
third argument.
|
|
1507
|
-
*/
|
|
1508
|
-
clearIncompatible(e, t, r) {
|
|
1509
|
-
return $(this, e, t, r), this;
|
|
1510
|
-
}
|
|
350
|
+
return !0;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function O(...t) {
|
|
354
|
+
return function(e, r, n) {
|
|
355
|
+
for (let o = 0; o < t.length; o++)
|
|
356
|
+
if (t[o](e, r, n))
|
|
357
|
+
return !0;
|
|
358
|
+
return !1;
|
|
359
|
+
};
|
|
1511
360
|
}
|
|
361
|
+
O(M, G, H);
|
|
362
|
+
O(M, K, L);
|
|
363
|
+
O(Q, X, Y, _);
|
|
364
|
+
typeof navigator < "u" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os < "u" && os.platform && os.platform() == "darwin";
|
|
1512
365
|
export {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
Me as replaceStep
|
|
366
|
+
O as chainCommands,
|
|
367
|
+
X as createParagraphNear,
|
|
368
|
+
M as deleteSelection,
|
|
369
|
+
se as exitCode,
|
|
370
|
+
G as joinBackward,
|
|
371
|
+
fe as joinDown,
|
|
372
|
+
K as joinForward,
|
|
373
|
+
oe as joinTextblockBackward,
|
|
374
|
+
le as joinTextblockForward,
|
|
375
|
+
ie as joinUp,
|
|
376
|
+
ce as lift,
|
|
377
|
+
Y as liftEmptyBlock,
|
|
378
|
+
Q as newlineInCode,
|
|
379
|
+
H as selectNodeBackward,
|
|
380
|
+
L as selectNodeForward,
|
|
381
|
+
ue as selectParentNode,
|
|
382
|
+
pe as selectTextblockEnd,
|
|
383
|
+
ae as selectTextblockStart,
|
|
384
|
+
me as setBlockType,
|
|
385
|
+
_ as splitBlock,
|
|
386
|
+
Z as splitBlockAs,
|
|
387
|
+
de as wrapIn
|
|
1536
388
|
};
|