@vizel/core 0.0.1-alpha.5 → 0.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index10.js +1 -1
- package/dist/index11.js +2 -2
- package/dist/index14.js +1 -1
- package/dist/index20.js +2 -2
- package/dist/index21.js +2 -2
- package/dist/index22.js +3 -3
- package/dist/index26.js +1 -1
- package/dist/index3.js +1 -1
- package/dist/index31.js +2 -2
- package/dist/index34.js +16 -63
- package/dist/index35.js +58 -4
- package/dist/index36.js +15 -123
- package/dist/index37.js +42 -305
- package/dist/index38.js +4 -487
- package/dist/index39.js +112 -37
- package/dist/index4.js +1 -1
- package/dist/index40.js +301 -653
- package/dist/index41.js +487 -4
- package/dist/index42.js +48 -4
- package/dist/index43.js +647 -206
- package/dist/index44.js +4 -82
- package/dist/index45.js +4 -17
- package/dist/index46.js +237 -57
- package/dist/index47.js +82 -15
- package/dist/index48.js +5 -5
- package/dist/index49.js +1458 -158
- package/dist/index5.js +1 -1
- package/dist/index50.js +5 -1502
- package/dist/index51.js +202 -5
- package/dist/index54.js +21 -84
- package/dist/index55.js +10 -246
- package/dist/index56.js +7 -3
- package/dist/index57.js +7 -1231
- package/dist/index58.js +11 -731
- package/dist/index59.js +19 -21
- package/dist/index6.js +1 -1
- package/dist/index60.js +25 -10
- package/dist/index61.js +83 -6
- package/dist/index62.js +245 -7
- package/dist/index63.js +3 -14
- package/dist/index64.js +1230 -17
- package/dist/index65.js +733 -24
- package/dist/index66.js +1059 -53
- package/dist/index67.js +53 -1059
- package/dist/index68.js +3 -90
- package/dist/index70.js +90 -3
- package/dist/index8.js +1 -1
- package/dist/index9.js +1 -1
- package/package.json +1 -1
package/dist/index65.js
CHANGED
|
@@ -1,27 +1,736 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const d = e.indexOf(">", s), r = e.indexOf("</" + i);
|
|
6
|
-
if (d === -1 || r === -1) break;
|
|
7
|
-
const n = e.indexOf(">", r);
|
|
8
|
-
if (n === -1) break;
|
|
9
|
-
f += e.slice(d + 1, r).trim(), e = e.slice(0, s).trim() + e.slice(n + 1);
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
defs: f,
|
|
13
|
-
content: e
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function t(e, i) {
|
|
17
|
-
return e ? "<defs>" + e + "</defs>" + i : i;
|
|
18
|
-
}
|
|
19
|
-
function u(e, i, f) {
|
|
20
|
-
const s = l(e);
|
|
21
|
-
return t(s.defs, i + s.content + f);
|
|
1
|
+
import { Slice as c, ReplaceError as W, Fragment as E } from "./index64.js";
|
|
2
|
+
const A = 65535, L = Math.pow(2, 16);
|
|
3
|
+
function G(h, t) {
|
|
4
|
+
return h + t * L;
|
|
22
5
|
}
|
|
6
|
+
function z(h) {
|
|
7
|
+
return h & A;
|
|
8
|
+
}
|
|
9
|
+
function H(h) {
|
|
10
|
+
return (h - (h & A)) / L;
|
|
11
|
+
}
|
|
12
|
+
const C = 1, B = 2, I = 4, $ = 8;
|
|
13
|
+
class R {
|
|
14
|
+
/**
|
|
15
|
+
@internal
|
|
16
|
+
*/
|
|
17
|
+
constructor(t, e, r) {
|
|
18
|
+
this.pos = t, this.delInfo = e, 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 & $) > 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
Tells you whether the token before the mapped position was deleted.
|
|
30
|
+
*/
|
|
31
|
+
get deletedBefore() {
|
|
32
|
+
return (this.delInfo & (C | I)) > 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
True when the token after the mapped position was deleted.
|
|
36
|
+
*/
|
|
37
|
+
get deletedAfter() {
|
|
38
|
+
return (this.delInfo & (B | I)) > 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 & I) > 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class p {
|
|
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(t, e = !1) {
|
|
56
|
+
if (this.ranges = t, this.inverted = e, !t.length && p.empty)
|
|
57
|
+
return p.empty;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
@internal
|
|
61
|
+
*/
|
|
62
|
+
recover(t) {
|
|
63
|
+
let e = 0, r = z(t);
|
|
64
|
+
if (!this.inverted)
|
|
65
|
+
for (let s = 0; s < r; s++)
|
|
66
|
+
e += this.ranges[s * 3 + 2] - this.ranges[s * 3 + 1];
|
|
67
|
+
return this.ranges[r * 3] + e + H(t);
|
|
68
|
+
}
|
|
69
|
+
mapResult(t, e = 1) {
|
|
70
|
+
return this._map(t, e, !1);
|
|
71
|
+
}
|
|
72
|
+
map(t, e = 1) {
|
|
73
|
+
return this._map(t, e, !0);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
@internal
|
|
77
|
+
*/
|
|
78
|
+
_map(t, e, r) {
|
|
79
|
+
let s = 0, i = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
|
|
80
|
+
for (let o = 0; o < this.ranges.length; o += 3) {
|
|
81
|
+
let a = this.ranges[o] - (this.inverted ? s : 0);
|
|
82
|
+
if (a > t)
|
|
83
|
+
break;
|
|
84
|
+
let f = this.ranges[o + i], u = this.ranges[o + n], d = a + f;
|
|
85
|
+
if (t <= d) {
|
|
86
|
+
let q = f ? t == a ? -1 : t == d ? 1 : e : e, M = a + s + (q < 0 ? 0 : u);
|
|
87
|
+
if (r)
|
|
88
|
+
return M;
|
|
89
|
+
let P = t == (e < 0 ? a : d) ? null : G(o / 3, t - a), D = t == a ? B : t == d ? C : I;
|
|
90
|
+
return (e < 0 ? t != a : t != d) && (D |= $), new R(M, D, P);
|
|
91
|
+
}
|
|
92
|
+
s += u - f;
|
|
93
|
+
}
|
|
94
|
+
return r ? t + s : new R(t + s, 0, null);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
@internal
|
|
98
|
+
*/
|
|
99
|
+
touches(t, e) {
|
|
100
|
+
let r = 0, s = z(e), i = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
|
|
101
|
+
for (let o = 0; o < this.ranges.length; o += 3) {
|
|
102
|
+
let a = this.ranges[o] - (this.inverted ? r : 0);
|
|
103
|
+
if (a > t)
|
|
104
|
+
break;
|
|
105
|
+
let f = this.ranges[o + i], u = a + f;
|
|
106
|
+
if (t <= u && o == s * 3)
|
|
107
|
+
return !0;
|
|
108
|
+
r += this.ranges[o + n] - f;
|
|
109
|
+
}
|
|
110
|
+
return !1;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
Calls the given function on each of the changed ranges included in
|
|
114
|
+
this map.
|
|
115
|
+
*/
|
|
116
|
+
forEach(t) {
|
|
117
|
+
let e = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2;
|
|
118
|
+
for (let s = 0, i = 0; s < this.ranges.length; s += 3) {
|
|
119
|
+
let n = this.ranges[s], o = n - (this.inverted ? i : 0), a = n + (this.inverted ? 0 : i), f = this.ranges[s + e], u = this.ranges[s + r];
|
|
120
|
+
t(o, o + f, a, a + u), i += u - f;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
Create an inverted version of this map. The result can be used to
|
|
125
|
+
map positions in the post-step document to the pre-step document.
|
|
126
|
+
*/
|
|
127
|
+
invert() {
|
|
128
|
+
return new p(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(t) {
|
|
142
|
+
return t == 0 ? p.empty : new p(t < 0 ? [0, -t, 0] : [0, 0, t]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
p.empty = new p([]);
|
|
146
|
+
class x {
|
|
147
|
+
/**
|
|
148
|
+
Create a new mapping with the given position maps.
|
|
149
|
+
*/
|
|
150
|
+
constructor(t, e, r = 0, s = t ? t.length : 0) {
|
|
151
|
+
this.mirror = e, this.from = r, this.to = s, this._maps = t || [], this.ownData = !(t || e);
|
|
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(t = 0, e = this.maps.length) {
|
|
163
|
+
return new x(this._maps, this.mirror, t, e);
|
|
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(t, e) {
|
|
171
|
+
this.ownData || (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), this.ownData = !0), this.to = this._maps.push(t), e != null && this.setMirror(this._maps.length - 1, e);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
Add all the step maps in a given mapping to this one (preserving
|
|
175
|
+
mirroring information).
|
|
176
|
+
*/
|
|
177
|
+
appendMapping(t) {
|
|
178
|
+
for (let e = 0, r = this._maps.length; e < t._maps.length; e++) {
|
|
179
|
+
let s = t.getMirror(e);
|
|
180
|
+
this.appendMap(t._maps[e], s != null && s < e ? r + s : 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(t) {
|
|
189
|
+
if (this.mirror) {
|
|
190
|
+
for (let e = 0; e < this.mirror.length; e++)
|
|
191
|
+
if (this.mirror[e] == t)
|
|
192
|
+
return this.mirror[e + (e % 2 ? -1 : 1)];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
@internal
|
|
197
|
+
*/
|
|
198
|
+
setMirror(t, e) {
|
|
199
|
+
this.mirror || (this.mirror = []), this.mirror.push(t, e);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
Append the inverse of the given mapping to this one.
|
|
203
|
+
*/
|
|
204
|
+
appendMappingInverted(t) {
|
|
205
|
+
for (let e = t.maps.length - 1, r = this._maps.length + t._maps.length; e >= 0; e--) {
|
|
206
|
+
let s = t.getMirror(e);
|
|
207
|
+
this.appendMap(t._maps[e].invert(), s != null && s > e ? r - s - 1 : void 0);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
Create an inverted version of this mapping.
|
|
212
|
+
*/
|
|
213
|
+
invert() {
|
|
214
|
+
let t = new x();
|
|
215
|
+
return t.appendMappingInverted(this), t;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
Map a position through this mapping.
|
|
219
|
+
*/
|
|
220
|
+
map(t, e = 1) {
|
|
221
|
+
if (this.mirror)
|
|
222
|
+
return this._map(t, e, !0);
|
|
223
|
+
for (let r = this.from; r < this.to; r++)
|
|
224
|
+
t = this._maps[r].map(t, e);
|
|
225
|
+
return t;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
Map a position through this mapping, returning a mapping
|
|
229
|
+
result.
|
|
230
|
+
*/
|
|
231
|
+
mapResult(t, e = 1) {
|
|
232
|
+
return this._map(t, e, !1);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
@internal
|
|
236
|
+
*/
|
|
237
|
+
_map(t, e, r) {
|
|
238
|
+
let s = 0;
|
|
239
|
+
for (let i = this.from; i < this.to; i++) {
|
|
240
|
+
let n = this._maps[i], o = n.mapResult(t, e);
|
|
241
|
+
if (o.recover != null) {
|
|
242
|
+
let a = this.getMirror(i);
|
|
243
|
+
if (a != null && a > i && a < this.to) {
|
|
244
|
+
i = a, t = this._maps[a].recover(o.recover);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
s |= o.delInfo, t = o.pos;
|
|
249
|
+
}
|
|
250
|
+
return r ? t : new R(t, s, null);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const T = /* @__PURE__ */ Object.create(null);
|
|
254
|
+
class m {
|
|
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 p.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(t) {
|
|
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(t, e) {
|
|
276
|
+
if (!e || !e.stepType)
|
|
277
|
+
throw new RangeError("Invalid input for Step.fromJSON");
|
|
278
|
+
let r = T[e.stepType];
|
|
279
|
+
if (!r)
|
|
280
|
+
throw new RangeError(`No step type ${e.stepType} defined`);
|
|
281
|
+
return r.fromJSON(t, e);
|
|
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(t, e) {
|
|
290
|
+
if (t in T)
|
|
291
|
+
throw new RangeError("Duplicate use of step JSON ID " + t);
|
|
292
|
+
return T[t] = e, e.prototype.jsonID = t, e;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
class l {
|
|
296
|
+
/**
|
|
297
|
+
@internal
|
|
298
|
+
*/
|
|
299
|
+
constructor(t, e) {
|
|
300
|
+
this.doc = t, this.failed = e;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
Create a successful step result.
|
|
304
|
+
*/
|
|
305
|
+
static ok(t) {
|
|
306
|
+
return new l(t, null);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
Create a failed step result.
|
|
310
|
+
*/
|
|
311
|
+
static fail(t) {
|
|
312
|
+
return new l(null, t);
|
|
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(t, e, r, s) {
|
|
320
|
+
try {
|
|
321
|
+
return l.ok(t.replace(e, r, s));
|
|
322
|
+
} catch (i) {
|
|
323
|
+
if (i instanceof W)
|
|
324
|
+
return l.fail(i.message);
|
|
325
|
+
throw i;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function F(h, t, e) {
|
|
330
|
+
let r = [];
|
|
331
|
+
for (let s = 0; s < h.childCount; s++) {
|
|
332
|
+
let i = h.child(s);
|
|
333
|
+
i.content.size && (i = i.copy(F(i.content, t, i))), i.isInline && (i = t(i, e, s)), r.push(i);
|
|
334
|
+
}
|
|
335
|
+
return E.fromArray(r);
|
|
336
|
+
}
|
|
337
|
+
class w extends m {
|
|
338
|
+
/**
|
|
339
|
+
Create a mark step.
|
|
340
|
+
*/
|
|
341
|
+
constructor(t, e, r) {
|
|
342
|
+
super(), this.from = t, this.to = e, this.mark = r;
|
|
343
|
+
}
|
|
344
|
+
apply(t) {
|
|
345
|
+
let e = t.slice(this.from, this.to), r = t.resolve(this.from), s = r.node(r.sharedDepth(this.to)), i = new c(F(e.content, (n, o) => !n.isAtom || !o.type.allowsMarkType(this.mark.type) ? n : n.mark(this.mark.addToSet(n.marks)), s), e.openStart, e.openEnd);
|
|
346
|
+
return l.fromReplace(t, this.from, this.to, i);
|
|
347
|
+
}
|
|
348
|
+
invert() {
|
|
349
|
+
return new k(this.from, this.to, this.mark);
|
|
350
|
+
}
|
|
351
|
+
map(t) {
|
|
352
|
+
let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
|
|
353
|
+
return e.deleted && r.deleted || e.pos >= r.pos ? null : new w(e.pos, r.pos, this.mark);
|
|
354
|
+
}
|
|
355
|
+
merge(t) {
|
|
356
|
+
return t instanceof w && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new w(Math.min(this.from, t.from), Math.max(this.to, t.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(t, e) {
|
|
370
|
+
if (typeof e.from != "number" || typeof e.to != "number")
|
|
371
|
+
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
|
|
372
|
+
return new w(e.from, e.to, t.markFromJSON(e.mark));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
m.jsonID("addMark", w);
|
|
376
|
+
class k extends m {
|
|
377
|
+
/**
|
|
378
|
+
Create a mark-removing step.
|
|
379
|
+
*/
|
|
380
|
+
constructor(t, e, r) {
|
|
381
|
+
super(), this.from = t, this.to = e, this.mark = r;
|
|
382
|
+
}
|
|
383
|
+
apply(t) {
|
|
384
|
+
let e = t.slice(this.from, this.to), r = new c(F(e.content, (s) => s.mark(this.mark.removeFromSet(s.marks)), t), e.openStart, e.openEnd);
|
|
385
|
+
return l.fromReplace(t, this.from, this.to, r);
|
|
386
|
+
}
|
|
387
|
+
invert() {
|
|
388
|
+
return new w(this.from, this.to, this.mark);
|
|
389
|
+
}
|
|
390
|
+
map(t) {
|
|
391
|
+
let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
|
|
392
|
+
return e.deleted && r.deleted || e.pos >= r.pos ? null : new k(e.pos, r.pos, this.mark);
|
|
393
|
+
}
|
|
394
|
+
merge(t) {
|
|
395
|
+
return t instanceof k && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new k(Math.min(this.from, t.from), Math.max(this.to, t.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(t, e) {
|
|
409
|
+
if (typeof e.from != "number" || typeof e.to != "number")
|
|
410
|
+
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
411
|
+
return new k(e.from, e.to, t.markFromJSON(e.mark));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
m.jsonID("removeMark", k);
|
|
415
|
+
class y extends m {
|
|
416
|
+
/**
|
|
417
|
+
Create a node mark step.
|
|
418
|
+
*/
|
|
419
|
+
constructor(t, e) {
|
|
420
|
+
super(), this.pos = t, this.mark = e;
|
|
421
|
+
}
|
|
422
|
+
apply(t) {
|
|
423
|
+
let e = t.nodeAt(this.pos);
|
|
424
|
+
if (!e)
|
|
425
|
+
return l.fail("No node at mark step's position");
|
|
426
|
+
let r = e.type.create(e.attrs, null, this.mark.addToSet(e.marks));
|
|
427
|
+
return l.fromReplace(t, this.pos, this.pos + 1, new c(E.from(r), 0, e.isLeaf ? 0 : 1));
|
|
428
|
+
}
|
|
429
|
+
invert(t) {
|
|
430
|
+
let e = t.nodeAt(this.pos);
|
|
431
|
+
if (e) {
|
|
432
|
+
let r = this.mark.addToSet(e.marks);
|
|
433
|
+
if (r.length == e.marks.length) {
|
|
434
|
+
for (let s = 0; s < e.marks.length; s++)
|
|
435
|
+
if (!e.marks[s].isInSet(r))
|
|
436
|
+
return new y(this.pos, e.marks[s]);
|
|
437
|
+
return new y(this.pos, this.mark);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return new O(this.pos, this.mark);
|
|
441
|
+
}
|
|
442
|
+
map(t) {
|
|
443
|
+
let e = t.mapResult(this.pos, 1);
|
|
444
|
+
return e.deletedAfter ? null : new y(e.pos, this.mark);
|
|
445
|
+
}
|
|
446
|
+
toJSON() {
|
|
447
|
+
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
@internal
|
|
451
|
+
*/
|
|
452
|
+
static fromJSON(t, e) {
|
|
453
|
+
if (typeof e.pos != "number")
|
|
454
|
+
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
455
|
+
return new y(e.pos, t.markFromJSON(e.mark));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
m.jsonID("addNodeMark", y);
|
|
459
|
+
class O extends m {
|
|
460
|
+
/**
|
|
461
|
+
Create a mark-removing step.
|
|
462
|
+
*/
|
|
463
|
+
constructor(t, e) {
|
|
464
|
+
super(), this.pos = t, this.mark = e;
|
|
465
|
+
}
|
|
466
|
+
apply(t) {
|
|
467
|
+
let e = t.nodeAt(this.pos);
|
|
468
|
+
if (!e)
|
|
469
|
+
return l.fail("No node at mark step's position");
|
|
470
|
+
let r = e.type.create(e.attrs, null, this.mark.removeFromSet(e.marks));
|
|
471
|
+
return l.fromReplace(t, this.pos, this.pos + 1, new c(E.from(r), 0, e.isLeaf ? 0 : 1));
|
|
472
|
+
}
|
|
473
|
+
invert(t) {
|
|
474
|
+
let e = t.nodeAt(this.pos);
|
|
475
|
+
return !e || !this.mark.isInSet(e.marks) ? this : new y(this.pos, this.mark);
|
|
476
|
+
}
|
|
477
|
+
map(t) {
|
|
478
|
+
let e = t.mapResult(this.pos, 1);
|
|
479
|
+
return e.deletedAfter ? null : new O(e.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(t, e) {
|
|
488
|
+
if (typeof e.pos != "number")
|
|
489
|
+
throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
|
|
490
|
+
return new O(e.pos, t.markFromJSON(e.mark));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
m.jsonID("removeNodeMark", O);
|
|
494
|
+
class g extends m {
|
|
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(t, e, r, s = !1) {
|
|
505
|
+
super(), this.from = t, this.to = e, this.slice = r, this.structure = s;
|
|
506
|
+
}
|
|
507
|
+
apply(t) {
|
|
508
|
+
return this.structure && b(t, this.from, this.to) ? l.fail("Structure replace would overwrite content") : l.fromReplace(t, this.from, this.to, this.slice);
|
|
509
|
+
}
|
|
510
|
+
getMap() {
|
|
511
|
+
return new p([this.from, this.to - this.from, this.slice.size]);
|
|
512
|
+
}
|
|
513
|
+
invert(t) {
|
|
514
|
+
return new g(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
|
|
515
|
+
}
|
|
516
|
+
map(t) {
|
|
517
|
+
let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
|
|
518
|
+
return e.deletedAcross && r.deletedAcross ? null : new g(e.pos, Math.max(e.pos, r.pos), this.slice, this.structure);
|
|
519
|
+
}
|
|
520
|
+
merge(t) {
|
|
521
|
+
if (!(t instanceof g) || t.structure || this.structure)
|
|
522
|
+
return null;
|
|
523
|
+
if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
|
|
524
|
+
let e = this.slice.size + t.slice.size == 0 ? c.empty : new c(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
|
|
525
|
+
return new g(this.from, this.to + (t.to - t.from), e, this.structure);
|
|
526
|
+
} else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
|
|
527
|
+
let e = this.slice.size + t.slice.size == 0 ? c.empty : new c(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
|
|
528
|
+
return new g(t.from, this.to, e, this.structure);
|
|
529
|
+
} else
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
toJSON() {
|
|
533
|
+
let t = { stepType: "replace", from: this.from, to: this.to };
|
|
534
|
+
return this.slice.size && (t.slice = this.slice.toJSON()), this.structure && (t.structure = !0), t;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
@internal
|
|
538
|
+
*/
|
|
539
|
+
static fromJSON(t, e) {
|
|
540
|
+
if (typeof e.from != "number" || typeof e.to != "number")
|
|
541
|
+
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
|
|
542
|
+
return new g(e.from, e.to, c.fromJSON(t, e.slice), !!e.structure);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
m.jsonID("replace", g);
|
|
546
|
+
class v extends m {
|
|
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(t, e, r, s, i, n, o = !1) {
|
|
554
|
+
super(), this.from = t, this.to = e, this.gapFrom = r, this.gapTo = s, this.slice = i, this.insert = n, this.structure = o;
|
|
555
|
+
}
|
|
556
|
+
apply(t) {
|
|
557
|
+
if (this.structure && (b(t, this.from, this.gapFrom) || b(t, this.gapTo, this.to)))
|
|
558
|
+
return l.fail("Structure gap-replace would overwrite content");
|
|
559
|
+
let e = t.slice(this.gapFrom, this.gapTo);
|
|
560
|
+
if (e.openStart || e.openEnd)
|
|
561
|
+
return l.fail("Gap is not a flat range");
|
|
562
|
+
let r = this.slice.insertAt(this.insert, e.content);
|
|
563
|
+
return r ? l.fromReplace(t, this.from, this.to, r) : l.fail("Content does not fit in gap");
|
|
564
|
+
}
|
|
565
|
+
getMap() {
|
|
566
|
+
return new p([
|
|
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(t) {
|
|
576
|
+
let e = this.gapTo - this.gapFrom;
|
|
577
|
+
return new v(this.from, this.from + this.slice.size + e, this.from + this.insert, this.from + this.insert + e, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
578
|
+
}
|
|
579
|
+
map(t) {
|
|
580
|
+
let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), s = this.from == this.gapFrom ? e.pos : t.map(this.gapFrom, -1), i = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
|
|
581
|
+
return e.deletedAcross && r.deletedAcross || s < e.pos || i > r.pos ? null : new v(e.pos, r.pos, s, i, this.slice, this.insert, this.structure);
|
|
582
|
+
}
|
|
583
|
+
toJSON() {
|
|
584
|
+
let t = {
|
|
585
|
+
stepType: "replaceAround",
|
|
586
|
+
from: this.from,
|
|
587
|
+
to: this.to,
|
|
588
|
+
gapFrom: this.gapFrom,
|
|
589
|
+
gapTo: this.gapTo,
|
|
590
|
+
insert: this.insert
|
|
591
|
+
};
|
|
592
|
+
return this.slice.size && (t.slice = this.slice.toJSON()), this.structure && (t.structure = !0), t;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
@internal
|
|
596
|
+
*/
|
|
597
|
+
static fromJSON(t, e) {
|
|
598
|
+
if (typeof e.from != "number" || typeof e.to != "number" || typeof e.gapFrom != "number" || typeof e.gapTo != "number" || typeof e.insert != "number")
|
|
599
|
+
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
600
|
+
return new v(e.from, e.to, e.gapFrom, e.gapTo, c.fromJSON(t, e.slice), e.insert, !!e.structure);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
m.jsonID("replaceAround", v);
|
|
604
|
+
function b(h, t, e) {
|
|
605
|
+
let r = h.resolve(t), s = e - t, i = r.depth;
|
|
606
|
+
for (; s > 0 && i > 0 && r.indexAfter(i) == r.node(i).childCount; )
|
|
607
|
+
i--, s--;
|
|
608
|
+
if (s > 0) {
|
|
609
|
+
let n = r.node(i).maybeChild(r.indexAfter(i));
|
|
610
|
+
for (; s > 0; ) {
|
|
611
|
+
if (!n || n.isLeaf)
|
|
612
|
+
return !0;
|
|
613
|
+
n = n.firstChild, s--;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return !1;
|
|
617
|
+
}
|
|
618
|
+
function Q(h, t, e) {
|
|
619
|
+
let r = h.resolve(t);
|
|
620
|
+
if (!e.content.size)
|
|
621
|
+
return t;
|
|
622
|
+
let s = e.content;
|
|
623
|
+
for (let i = 0; i < e.openStart; i++)
|
|
624
|
+
s = s.firstChild.content;
|
|
625
|
+
for (let i = 1; i <= (e.openStart == 0 && e.size ? 2 : 1); i++)
|
|
626
|
+
for (let n = r.depth; n >= 0; n--) {
|
|
627
|
+
let o = n == r.depth ? 0 : r.pos <= (r.start(n + 1) + r.end(n + 1)) / 2 ? -1 : 1, a = r.index(n) + (o > 0 ? 1 : 0), f = r.node(n), u = !1;
|
|
628
|
+
if (i == 1)
|
|
629
|
+
u = f.canReplace(a, a, s);
|
|
630
|
+
else {
|
|
631
|
+
let d = f.contentMatchAt(a).findWrapping(s.firstChild.type);
|
|
632
|
+
u = d && f.canReplaceWith(a, a, d[0]);
|
|
633
|
+
}
|
|
634
|
+
if (u)
|
|
635
|
+
return o == 0 ? r.pos : o < 0 ? r.before(n + 1) : r.after(n + 1);
|
|
636
|
+
}
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
class S extends m {
|
|
640
|
+
/**
|
|
641
|
+
Construct an attribute step.
|
|
642
|
+
*/
|
|
643
|
+
constructor(t, e, r) {
|
|
644
|
+
super(), this.pos = t, this.attr = e, this.value = r;
|
|
645
|
+
}
|
|
646
|
+
apply(t) {
|
|
647
|
+
let e = t.nodeAt(this.pos);
|
|
648
|
+
if (!e)
|
|
649
|
+
return l.fail("No node at attribute step's position");
|
|
650
|
+
let r = /* @__PURE__ */ Object.create(null);
|
|
651
|
+
for (let i in e.attrs)
|
|
652
|
+
r[i] = e.attrs[i];
|
|
653
|
+
r[this.attr] = this.value;
|
|
654
|
+
let s = e.type.create(r, null, e.marks);
|
|
655
|
+
return l.fromReplace(t, this.pos, this.pos + 1, new c(E.from(s), 0, e.isLeaf ? 0 : 1));
|
|
656
|
+
}
|
|
657
|
+
getMap() {
|
|
658
|
+
return p.empty;
|
|
659
|
+
}
|
|
660
|
+
invert(t) {
|
|
661
|
+
return new S(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
|
|
662
|
+
}
|
|
663
|
+
map(t) {
|
|
664
|
+
let e = t.mapResult(this.pos, 1);
|
|
665
|
+
return e.deletedAfter ? null : new S(e.pos, this.attr, this.value);
|
|
666
|
+
}
|
|
667
|
+
toJSON() {
|
|
668
|
+
return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
|
|
669
|
+
}
|
|
670
|
+
static fromJSON(t, e) {
|
|
671
|
+
if (typeof e.pos != "number" || typeof e.attr != "string")
|
|
672
|
+
throw new RangeError("Invalid input for AttrStep.fromJSON");
|
|
673
|
+
return new S(e.pos, e.attr, e.value);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
m.jsonID("attr", S);
|
|
677
|
+
class J extends m {
|
|
678
|
+
/**
|
|
679
|
+
Construct an attribute step.
|
|
680
|
+
*/
|
|
681
|
+
constructor(t, e) {
|
|
682
|
+
super(), this.attr = t, this.value = e;
|
|
683
|
+
}
|
|
684
|
+
apply(t) {
|
|
685
|
+
let e = /* @__PURE__ */ Object.create(null);
|
|
686
|
+
for (let s in t.attrs)
|
|
687
|
+
e[s] = t.attrs[s];
|
|
688
|
+
e[this.attr] = this.value;
|
|
689
|
+
let r = t.type.create(e, t.content, t.marks);
|
|
690
|
+
return l.ok(r);
|
|
691
|
+
}
|
|
692
|
+
getMap() {
|
|
693
|
+
return p.empty;
|
|
694
|
+
}
|
|
695
|
+
invert(t) {
|
|
696
|
+
return new J(this.attr, t.attrs[this.attr]);
|
|
697
|
+
}
|
|
698
|
+
map(t) {
|
|
699
|
+
return this;
|
|
700
|
+
}
|
|
701
|
+
toJSON() {
|
|
702
|
+
return { stepType: "docAttr", attr: this.attr, value: this.value };
|
|
703
|
+
}
|
|
704
|
+
static fromJSON(t, e) {
|
|
705
|
+
if (typeof e.attr != "string")
|
|
706
|
+
throw new RangeError("Invalid input for DocAttrStep.fromJSON");
|
|
707
|
+
return new J(e.attr, e.value);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
m.jsonID("docAttr", J);
|
|
711
|
+
let N = class extends Error {
|
|
712
|
+
};
|
|
713
|
+
N = function h(t) {
|
|
714
|
+
let e = Error.call(this, t);
|
|
715
|
+
return e.__proto__ = h.prototype, e;
|
|
716
|
+
};
|
|
717
|
+
N.prototype = Object.create(Error.prototype);
|
|
718
|
+
N.prototype.constructor = N;
|
|
719
|
+
N.prototype.name = "TransformError";
|
|
23
720
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
721
|
+
w as AddMarkStep,
|
|
722
|
+
y as AddNodeMarkStep,
|
|
723
|
+
S as AttrStep,
|
|
724
|
+
J as DocAttrStep,
|
|
725
|
+
R as MapResult,
|
|
726
|
+
x as Mapping,
|
|
727
|
+
k as RemoveMarkStep,
|
|
728
|
+
O as RemoveNodeMarkStep,
|
|
729
|
+
v as ReplaceAroundStep,
|
|
730
|
+
g as ReplaceStep,
|
|
731
|
+
m as Step,
|
|
732
|
+
p as StepMap,
|
|
733
|
+
l as StepResult,
|
|
734
|
+
N as TransformError,
|
|
735
|
+
Q as dropPoint
|
|
27
736
|
};
|