@quoreadmin/ui 1.10.12 → 1.10.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index157.js +172 -163
- package/dist/index186.js +4 -4
- package/dist/index193.js +8 -8
- package/dist/index194.js +14 -3
- package/dist/index195.js +8 -8
- package/dist/index201.js +26 -26
- package/dist/index202.js +1 -1
- package/dist/index203.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/index216.js +2 -2
- package/dist/index217.js +1 -1
- package/dist/index219.js +4 -4
- package/dist/index221.js +1 -1
- package/dist/index222.js +1 -1
- package/dist/index223.js +1 -1
- package/dist/index224.js +4 -4
- package/dist/index226.js +1 -1
- package/dist/index230.js +159 -159
- package/dist/index231.js +228 -20
- package/dist/index232.js +36 -19
- package/dist/index233.js +10 -22
- package/dist/index234.js +129 -167
- package/dist/index235.js +19 -69
- package/dist/index236.js +20 -34
- package/dist/index237.js +21 -39
- package/dist/index238.js +185 -113
- package/dist/index239.js +57 -25
- package/dist/index240.js +31 -77
- package/dist/index241.js +39 -19
- package/dist/index242.js +126 -19
- package/dist/index243.js +34 -16
- package/dist/index244.js +80 -20
- package/dist/index245.js +19 -160
- package/dist/index246.js +20 -228
- package/dist/index247.js +19 -36
- package/dist/index248.js +20 -10
- package/dist/index249.js +22 -3636
- package/dist/index250.js +22 -55
- package/dist/index251.js +20 -77
- package/dist/index252.js +823 -39
- package/dist/index253.js +685 -198
- package/dist/index254.js +175 -9
- package/dist/index255.js +22 -57
- package/dist/index256.js +20 -61
- package/dist/index257.js +20 -54
- package/dist/index258.js +3 -75
- package/dist/index259.js +170 -709
- package/dist/index260.js +128 -37
- package/dist/index261.js +1214 -55
- package/dist/index262.js +20 -11
- package/dist/index263.js +22 -705
- package/dist/index264.js +22 -820
- package/dist/index265.js +22 -15
- package/dist/index266.js +13 -15
- package/dist/index267.js +12 -12
- package/dist/index268.js +2 -836
- package/dist/index269.js +2 -702
- package/dist/index270.js +3630 -170
- package/dist/index271.js +55 -22
- package/dist/index272.js +77 -20
- package/dist/index273.js +52 -20
- package/dist/index274.js +215 -3
- package/dist/index275.js +10 -187
- package/dist/index276.js +52 -128
- package/dist/index277.js +52 -1214
- package/dist/index278.js +54 -20
- package/dist/index279.js +75 -22
- package/dist/index280.js +725 -21
- package/dist/index281.js +42 -29
- package/dist/index282.js +64 -20
- package/dist/index283.js +11 -20
- package/dist/index284.js +705 -2
- package/dist/index285.js +820 -2
- package/dist/index290.js +3 -54
- package/dist/index291.js +25 -77
- package/dist/index292.js +53 -25
- package/dist/index293.js +78 -21
- package/dist/index294.js +17 -13
- package/dist/index295.js +22 -16
- package/dist/index296.js +22 -17
- package/dist/index297.js +15 -22
- package/dist/index298.js +17 -2
- package/dist/index299.js +23 -1534
- package/dist/index3.js +2 -2
- package/dist/index300.js +2 -386
- package/dist/index301.js +1288 -2485
- package/dist/index302.js +370 -70
- package/dist/index303.js +2403 -3464
- package/dist/index304.js +77 -51
- package/dist/index305.js +3790 -13
- package/dist/index306.js +55 -79
- package/dist/index307.js +73 -196
- package/dist/index308.js +22 -246
- package/dist/index309.js +935 -3
- package/dist/index310.js +21 -26
- package/dist/index311.js +19 -78
- package/dist/index312.js +13 -15
- package/dist/index313.js +64 -930
- package/dist/index314.js +18 -21
- package/dist/index315.js +19 -20
- package/dist/index316.js +13 -11
- package/dist/index317.js +21 -68
- package/dist/index318.js +60 -16
- package/dist/index319.js +84 -19
- package/dist/index320.js +202 -22
- package/dist/index321.js +246 -22
- package/dist/index322.js +15 -63
- 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 +1 -1
- package/dist/index381.js +17 -91
- package/dist/index382.js +91 -98
- package/dist/index383.js +97 -16
- package/dist/index45.js +1 -1
- package/dist/index50.js +1 -1
- package/dist/index66.js +17 -17
- package/dist/src/components/room-details-popover/room-details-popover.d.ts +1 -1
- package/package.json +1 -1
package/dist/index301.js
CHANGED
|
@@ -1,2733 +1,1536 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return l.childCount == t.childCount ? null : e;
|
|
6
|
-
let i = l.child(n), r = t.child(n);
|
|
7
|
-
if (i == r) {
|
|
8
|
-
e += i.nodeSize;
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
if (!i.sameMarkup(r))
|
|
12
|
-
return e;
|
|
13
|
-
if (i.isText && i.text != r.text) {
|
|
14
|
-
for (let s = 0; i.text[s] == r.text[s]; s++)
|
|
15
|
-
e++;
|
|
16
|
-
return e;
|
|
17
|
-
}
|
|
18
|
-
if (i.content.size || r.content.size) {
|
|
19
|
-
let s = Y(i.content, r.content, e + 1);
|
|
20
|
-
if (s != null)
|
|
21
|
-
return s;
|
|
22
|
-
}
|
|
23
|
-
e += i.nodeSize;
|
|
24
|
-
}
|
|
1
|
+
import { Slice as g, Fragment as w, Mark as se, MarkType as oe, ReplaceError as le } from "./index303.js";
|
|
2
|
+
const Q = 65535, U = Math.pow(2, 16);
|
|
3
|
+
function ae(s, e) {
|
|
4
|
+
return s + e * U;
|
|
25
5
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
if (i == 0 || r == 0)
|
|
29
|
-
return i == r ? null : { a: e, b: n };
|
|
30
|
-
let s = l.child(--i), o = t.child(--r), h = s.nodeSize;
|
|
31
|
-
if (s == o) {
|
|
32
|
-
e -= h, n -= h;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (!s.sameMarkup(o))
|
|
36
|
-
return { a: e, b: n };
|
|
37
|
-
if (s.isText && s.text != o.text) {
|
|
38
|
-
let a = 0, f = Math.min(s.text.length, o.text.length);
|
|
39
|
-
for (; a < f && s.text[s.text.length - a - 1] == o.text[o.text.length - a - 1]; )
|
|
40
|
-
a++, e--, n--;
|
|
41
|
-
return { a: e, b: n };
|
|
42
|
-
}
|
|
43
|
-
if (s.content.size || o.content.size) {
|
|
44
|
-
let a = Z(s.content, o.content, e - 1, n - 1);
|
|
45
|
-
if (a)
|
|
46
|
-
return a;
|
|
47
|
-
}
|
|
48
|
-
e -= h, n -= h;
|
|
49
|
-
}
|
|
6
|
+
function H(s) {
|
|
7
|
+
return s & Q;
|
|
50
8
|
}
|
|
51
|
-
|
|
9
|
+
function he(s) {
|
|
10
|
+
return (s - (s & Q)) / U;
|
|
11
|
+
}
|
|
12
|
+
const V = 1, X = 2, J = 4, Y = 8;
|
|
13
|
+
class L {
|
|
52
14
|
/**
|
|
53
15
|
@internal
|
|
54
16
|
*/
|
|
55
|
-
constructor(t,
|
|
56
|
-
|
|
57
|
-
for (let n = 0; n < t.length; n++)
|
|
58
|
-
this.size += t[n].nodeSize;
|
|
17
|
+
constructor(e, t, r) {
|
|
18
|
+
this.pos = e, this.delInfo = t, this.recover = r;
|
|
59
19
|
}
|
|
60
20
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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.
|
|
64
24
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let h = this.content[s], a = o + h.nodeSize;
|
|
68
|
-
if (a > t && n(h, i + o, r || null, s) !== !1 && h.content.size) {
|
|
69
|
-
let f = o + 1;
|
|
70
|
-
h.nodesBetween(Math.max(0, t - f), Math.min(h.content.size, e - f), n, i + f);
|
|
71
|
-
}
|
|
72
|
-
o = a;
|
|
73
|
-
}
|
|
25
|
+
get deleted() {
|
|
26
|
+
return (this.delInfo & Y) > 0;
|
|
74
27
|
}
|
|
75
28
|
/**
|
|
76
|
-
|
|
77
|
-
relative to the start of the fragment. The callback may return
|
|
78
|
-
`false` to prevent traversal of a given node's children.
|
|
29
|
+
Tells you whether the token before the mapped position was deleted.
|
|
79
30
|
*/
|
|
80
|
-
|
|
81
|
-
this.
|
|
31
|
+
get deletedBefore() {
|
|
32
|
+
return (this.delInfo & (V | J)) > 0;
|
|
82
33
|
}
|
|
83
34
|
/**
|
|
84
|
-
|
|
85
|
-
[`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
|
|
35
|
+
True when the token after the mapped position was deleted.
|
|
86
36
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return this.nodesBetween(t, e, (o, h) => {
|
|
90
|
-
let a = o.isText ? o.text.slice(Math.max(t, h) - h, e - h) : o.isLeaf ? i ? typeof i == "function" ? i(o) : i : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
|
|
91
|
-
o.isBlock && (o.isLeaf && a || o.isTextblock) && n && (s ? s = !1 : r += n), r += a;
|
|
92
|
-
}, 0), r;
|
|
37
|
+
get deletedAfter() {
|
|
38
|
+
return (this.delInfo & (X | J)) > 0;
|
|
93
39
|
}
|
|
94
40
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
41
|
+
Tells whether any of the steps mapped through deletes across the
|
|
42
|
+
position (including both the token before and after the
|
|
43
|
+
position).
|
|
97
44
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return this;
|
|
101
|
-
if (!this.size)
|
|
102
|
-
return t;
|
|
103
|
-
let e = this.lastChild, n = t.firstChild, i = this.content.slice(), r = 0;
|
|
104
|
-
for (e.isText && e.sameMarkup(n) && (i[i.length - 1] = e.withText(e.text + n.text), r = 1); r < t.content.length; r++)
|
|
105
|
-
i.push(t.content[r]);
|
|
106
|
-
return new c(i, this.size + t.size);
|
|
45
|
+
get deletedAcross() {
|
|
46
|
+
return (this.delInfo & J) > 0;
|
|
107
47
|
}
|
|
48
|
+
}
|
|
49
|
+
class S {
|
|
108
50
|
/**
|
|
109
|
-
|
|
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]`.
|
|
110
54
|
*/
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
return
|
|
114
|
-
let n = [], i = 0;
|
|
115
|
-
if (e > t)
|
|
116
|
-
for (let r = 0, s = 0; s < e; r++) {
|
|
117
|
-
let o = this.content[r], h = s + o.nodeSize;
|
|
118
|
-
h > t && ((s < t || h > e) && (o.isText ? o = o.cut(Math.max(0, t - s), Math.min(o.text.length, e - s)) : o = o.cut(Math.max(0, t - s - 1), Math.min(o.content.size, e - s - 1))), n.push(o), i += o.nodeSize), s = h;
|
|
119
|
-
}
|
|
120
|
-
return new c(n, i);
|
|
55
|
+
constructor(e, t = !1) {
|
|
56
|
+
if (this.ranges = e, this.inverted = t, !e.length && S.empty)
|
|
57
|
+
return S.empty;
|
|
121
58
|
}
|
|
122
59
|
/**
|
|
123
60
|
@internal
|
|
124
61
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
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);
|
|
127
68
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
replaced by the given node.
|
|
131
|
-
*/
|
|
132
|
-
replaceChild(t, e) {
|
|
133
|
-
let n = this.content[t];
|
|
134
|
-
if (n == e)
|
|
135
|
-
return this;
|
|
136
|
-
let i = this.content.slice(), r = this.size + e.nodeSize - n.nodeSize;
|
|
137
|
-
return i[t] = e, new c(i, r);
|
|
69
|
+
mapResult(e, t = 1) {
|
|
70
|
+
return this._map(e, t, !1);
|
|
138
71
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
fragment.
|
|
142
|
-
*/
|
|
143
|
-
addToStart(t) {
|
|
144
|
-
return new c([t].concat(this.content), this.size + t.nodeSize);
|
|
72
|
+
map(e, t = 1) {
|
|
73
|
+
return this._map(e, t, !0);
|
|
145
74
|
}
|
|
146
75
|
/**
|
|
147
|
-
|
|
148
|
-
fragment.
|
|
76
|
+
@internal
|
|
149
77
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
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);
|
|
152
95
|
}
|
|
153
96
|
/**
|
|
154
|
-
|
|
97
|
+
@internal
|
|
155
98
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
}
|
|
110
|
+
return !1;
|
|
163
111
|
}
|
|
164
112
|
/**
|
|
165
|
-
|
|
113
|
+
Calls the given function on each of the changed ranges included in
|
|
114
|
+
this map.
|
|
166
115
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
116
|
+
forEach(e) {
|
|
117
|
+
let t = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2;
|
|
118
|
+
for (let n = 0, i = 0; n < this.ranges.length; n += 3) {
|
|
119
|
+
let o = this.ranges[n], l = o - (this.inverted ? i : 0), a = o + (this.inverted ? 0 : i), h = this.ranges[n + t], p = this.ranges[n + r];
|
|
120
|
+
e(l, l + h, a, a + p), i += p - h;
|
|
121
|
+
}
|
|
169
122
|
}
|
|
170
123
|
/**
|
|
171
|
-
|
|
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.
|
|
172
126
|
*/
|
|
173
|
-
|
|
174
|
-
return this.
|
|
127
|
+
invert() {
|
|
128
|
+
return new S(this.ranges, !this.inverted);
|
|
175
129
|
}
|
|
176
130
|
/**
|
|
177
|
-
|
|
131
|
+
@internal
|
|
178
132
|
*/
|
|
179
|
-
|
|
180
|
-
return this.
|
|
133
|
+
toString() {
|
|
134
|
+
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
|
|
181
135
|
}
|
|
182
136
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
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.
|
|
185
140
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (!e)
|
|
189
|
-
throw new RangeError("Index " + t + " out of range for " + this);
|
|
190
|
-
return e;
|
|
141
|
+
static offset(e) {
|
|
142
|
+
return e == 0 ? S.empty : new S(e < 0 ? [0, -e, 0] : [0, 0, e]);
|
|
191
143
|
}
|
|
144
|
+
}
|
|
145
|
+
S.empty = new S([]);
|
|
146
|
+
class A {
|
|
192
147
|
/**
|
|
193
|
-
|
|
148
|
+
Create a new mapping with the given position maps.
|
|
194
149
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
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);
|
|
197
152
|
}
|
|
198
153
|
/**
|
|
199
|
-
|
|
200
|
-
into this parent node, and its index.
|
|
154
|
+
The step maps in this mapping.
|
|
201
155
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
let i = this.content[e];
|
|
205
|
-
t(i, n, e), n += i.nodeSize;
|
|
206
|
-
}
|
|
156
|
+
get maps() {
|
|
157
|
+
return this._maps;
|
|
207
158
|
}
|
|
208
159
|
/**
|
|
209
|
-
|
|
210
|
-
fragment differ, or `null` if they are the same.
|
|
160
|
+
Create a mapping that maps only through a part of this one.
|
|
211
161
|
*/
|
|
212
|
-
|
|
213
|
-
return
|
|
162
|
+
slice(e = 0, t = this.maps.length) {
|
|
163
|
+
return new A(this._maps, this.mirror, e, t);
|
|
214
164
|
}
|
|
215
165
|
/**
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
nodes, an object with two separate positions is returned.
|
|
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.
|
|
220
169
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
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);
|
|
223
172
|
}
|
|
224
173
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
(overwritten) the next time the function is called. @internal
|
|
174
|
+
Add all the step maps in a given mapping to this one (preserving
|
|
175
|
+
mirroring information).
|
|
228
176
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return O(this.content.length, t);
|
|
234
|
-
if (t > this.size || t < 0)
|
|
235
|
-
throw new RangeError(`Position ${t} outside of fragment (${this})`);
|
|
236
|
-
for (let e = 0, n = 0; ; e++) {
|
|
237
|
-
let i = this.child(e), r = n + i.nodeSize;
|
|
238
|
-
if (r >= t)
|
|
239
|
-
return r == t ? O(e + 1, r) : O(e, n);
|
|
240
|
-
n = r;
|
|
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);
|
|
241
181
|
}
|
|
242
182
|
}
|
|
243
183
|
/**
|
|
244
|
-
|
|
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`).
|
|
245
187
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
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
|
+
}
|
|
248
194
|
}
|
|
249
195
|
/**
|
|
250
196
|
@internal
|
|
251
197
|
*/
|
|
252
|
-
|
|
253
|
-
|
|
198
|
+
setMirror(e, t) {
|
|
199
|
+
this.mirror || (this.mirror = []), this.mirror.push(e, t);
|
|
254
200
|
}
|
|
255
201
|
/**
|
|
256
|
-
|
|
202
|
+
Append the inverse of the given mapping to this one.
|
|
257
203
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
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
|
+
}
|
|
260
209
|
}
|
|
261
210
|
/**
|
|
262
|
-
|
|
211
|
+
Create an inverted version of this mapping.
|
|
263
212
|
*/
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (!Array.isArray(e))
|
|
268
|
-
throw new RangeError("Invalid input for Fragment.fromJSON");
|
|
269
|
-
return new c(e.map(t.nodeFromJSON));
|
|
213
|
+
invert() {
|
|
214
|
+
let e = new A();
|
|
215
|
+
return e.appendMappingInverted(this), e;
|
|
270
216
|
}
|
|
271
217
|
/**
|
|
272
|
-
|
|
273
|
-
text nodes with the same marks are joined together.
|
|
218
|
+
Map a position through this mapping.
|
|
274
219
|
*/
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
return
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
n += r.nodeSize, i && r.isText && t[i - 1].sameMarkup(r) ? (e || (e = t.slice(0, i)), e[e.length - 1] = r.withText(e[e.length - 1].text + r.text)) : e && e.push(r);
|
|
282
|
-
}
|
|
283
|
-
return new c(e || t, n);
|
|
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;
|
|
284
226
|
}
|
|
285
227
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
fragment, the fragment itself. For a node or array of nodes, a
|
|
289
|
-
fragment containing those nodes.
|
|
228
|
+
Map a position through this mapping, returning a mapping
|
|
229
|
+
result.
|
|
290
230
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return c.empty;
|
|
294
|
-
if (t instanceof c)
|
|
295
|
-
return t;
|
|
296
|
-
if (Array.isArray(t))
|
|
297
|
-
return this.fromArray(t);
|
|
298
|
-
if (t.attrs)
|
|
299
|
-
return new c([t], t.nodeSize);
|
|
300
|
-
throw new RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
|
|
231
|
+
mapResult(e, t = 1) {
|
|
232
|
+
return this._map(e, t, !1);
|
|
301
233
|
}
|
|
302
|
-
}
|
|
303
|
-
c.empty = new c([], 0);
|
|
304
|
-
const N = { index: 0, offset: 0 };
|
|
305
|
-
function O(l, t) {
|
|
306
|
-
return N.index = l, N.offset = t, N;
|
|
307
|
-
}
|
|
308
|
-
function M(l, t) {
|
|
309
|
-
if (l === t)
|
|
310
|
-
return !0;
|
|
311
|
-
if (!(l && typeof l == "object") || !(t && typeof t == "object"))
|
|
312
|
-
return !1;
|
|
313
|
-
let e = Array.isArray(l);
|
|
314
|
-
if (Array.isArray(t) != e)
|
|
315
|
-
return !1;
|
|
316
|
-
if (e) {
|
|
317
|
-
if (l.length != t.length)
|
|
318
|
-
return !1;
|
|
319
|
-
for (let n = 0; n < l.length; n++)
|
|
320
|
-
if (!M(l[n], t[n]))
|
|
321
|
-
return !1;
|
|
322
|
-
} else {
|
|
323
|
-
for (let n in l)
|
|
324
|
-
if (!(n in t) || !M(l[n], t[n]))
|
|
325
|
-
return !1;
|
|
326
|
-
for (let n in t)
|
|
327
|
-
if (!(n in l))
|
|
328
|
-
return !1;
|
|
329
|
-
}
|
|
330
|
-
return !0;
|
|
331
|
-
}
|
|
332
|
-
class u {
|
|
333
234
|
/**
|
|
334
235
|
@internal
|
|
335
236
|
*/
|
|
336
|
-
|
|
337
|
-
|
|
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;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
n |= l.delInfo, e = l.pos;
|
|
249
|
+
}
|
|
250
|
+
return r ? e : new L(e, n, null);
|
|
338
251
|
}
|
|
252
|
+
}
|
|
253
|
+
const B = /* @__PURE__ */ Object.create(null);
|
|
254
|
+
class k {
|
|
339
255
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
the
|
|
343
|
-
[exclusive](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) with this mark are present,
|
|
344
|
-
those are replaced by this one.
|
|
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.
|
|
345
259
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
for (let i = 0; i < t.length; i++) {
|
|
349
|
-
let r = t[i];
|
|
350
|
-
if (this.eq(r))
|
|
351
|
-
return t;
|
|
352
|
-
if (this.type.excludes(r.type))
|
|
353
|
-
e || (e = t.slice(0, i));
|
|
354
|
-
else {
|
|
355
|
-
if (r.type.excludes(this.type))
|
|
356
|
-
return t;
|
|
357
|
-
!n && r.type.rank > this.type.rank && (e || (e = t.slice(0, i)), e.push(this), n = !0), e && e.push(r);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
return e || (e = t.slice()), n || e.push(this), e;
|
|
260
|
+
getMap() {
|
|
261
|
+
return S.empty;
|
|
361
262
|
}
|
|
362
263
|
/**
|
|
363
|
-
|
|
364
|
-
|
|
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.
|
|
365
267
|
*/
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (this.eq(t[e]))
|
|
369
|
-
return t.slice(0, e).concat(t.slice(e + 1));
|
|
370
|
-
return t;
|
|
268
|
+
merge(e) {
|
|
269
|
+
return null;
|
|
371
270
|
}
|
|
372
271
|
/**
|
|
373
|
-
|
|
272
|
+
Deserialize a step from its JSON representation. Will call
|
|
273
|
+
through to the step class' own implementation of this method.
|
|
374
274
|
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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);
|
|
380
282
|
}
|
|
381
283
|
/**
|
|
382
|
-
|
|
383
|
-
|
|
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.
|
|
384
288
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
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;
|
|
387
293
|
}
|
|
294
|
+
}
|
|
295
|
+
class y {
|
|
388
296
|
/**
|
|
389
|
-
|
|
297
|
+
@internal
|
|
390
298
|
*/
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
for (let e in this.attrs) {
|
|
394
|
-
t.attrs = this.attrs;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
return t;
|
|
299
|
+
constructor(e, t) {
|
|
300
|
+
this.doc = e, this.failed = t;
|
|
398
301
|
}
|
|
399
302
|
/**
|
|
400
|
-
|
|
303
|
+
Create a successful step result.
|
|
401
304
|
*/
|
|
402
|
-
static
|
|
403
|
-
|
|
404
|
-
throw new RangeError("Invalid input for Mark.fromJSON");
|
|
405
|
-
let n = t.marks[e.type];
|
|
406
|
-
if (!n)
|
|
407
|
-
throw new RangeError(`There is no mark type ${e.type} in this schema`);
|
|
408
|
-
let i = n.create(e.attrs);
|
|
409
|
-
return n.checkAttrs(i.attrs), i;
|
|
305
|
+
static ok(e) {
|
|
306
|
+
return new y(e, null);
|
|
410
307
|
}
|
|
411
308
|
/**
|
|
412
|
-
|
|
309
|
+
Create a failed step result.
|
|
413
310
|
*/
|
|
414
|
-
static
|
|
415
|
-
|
|
416
|
-
return !0;
|
|
417
|
-
if (t.length != e.length)
|
|
418
|
-
return !1;
|
|
419
|
-
for (let n = 0; n < t.length; n++)
|
|
420
|
-
if (!t[n].eq(e[n]))
|
|
421
|
-
return !1;
|
|
422
|
-
return !0;
|
|
311
|
+
static fail(e) {
|
|
312
|
+
return new y(null, e);
|
|
423
313
|
}
|
|
424
314
|
/**
|
|
425
|
-
|
|
426
|
-
|
|
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`.
|
|
427
318
|
*/
|
|
428
|
-
static
|
|
429
|
-
|
|
430
|
-
return
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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
|
+
}
|
|
435
327
|
}
|
|
436
328
|
}
|
|
437
|
-
|
|
438
|
-
|
|
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);
|
|
439
336
|
}
|
|
440
|
-
class
|
|
337
|
+
class C extends k {
|
|
441
338
|
/**
|
|
442
|
-
Create a
|
|
443
|
-
make sure that there are nodes of at least that depth at the
|
|
444
|
-
appropriate side of the fragment—i.e. if the fragment is an
|
|
445
|
-
empty paragraph node, `openStart` and `openEnd` can't be greater
|
|
446
|
-
than 1.
|
|
447
|
-
|
|
448
|
-
It is not necessary for the content of open nodes to conform to
|
|
449
|
-
the schema's content constraints, though it should be a valid
|
|
450
|
-
start/end/middle for such a node, depending on which sides are
|
|
451
|
-
open.
|
|
339
|
+
Create a mark step.
|
|
452
340
|
*/
|
|
453
|
-
constructor(
|
|
454
|
-
this.
|
|
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
|
+
};
|
|
455
365
|
}
|
|
456
366
|
/**
|
|
457
|
-
|
|
367
|
+
@internal
|
|
458
368
|
*/
|
|
459
|
-
|
|
460
|
-
|
|
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));
|
|
461
373
|
}
|
|
374
|
+
}
|
|
375
|
+
k.jsonID("addMark", C);
|
|
376
|
+
class b extends k {
|
|
462
377
|
/**
|
|
463
|
-
|
|
378
|
+
Create a mark-removing step.
|
|
464
379
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
+
};
|
|
468
404
|
}
|
|
469
405
|
/**
|
|
470
406
|
@internal
|
|
471
407
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
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));
|
|
474
412
|
}
|
|
413
|
+
}
|
|
414
|
+
k.jsonID("removeMark", b);
|
|
415
|
+
class N extends k {
|
|
475
416
|
/**
|
|
476
|
-
|
|
417
|
+
Create a node mark step.
|
|
477
418
|
*/
|
|
478
|
-
|
|
479
|
-
|
|
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
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return new R(this.pos, this.mark);
|
|
441
|
+
}
|
|
442
|
+
map(e) {
|
|
443
|
+
let t = e.mapResult(this.pos, 1);
|
|
444
|
+
return t.deletedAfter ? null : new N(t.pos, this.mark);
|
|
445
|
+
}
|
|
446
|
+
toJSON() {
|
|
447
|
+
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
480
448
|
}
|
|
481
449
|
/**
|
|
482
450
|
@internal
|
|
483
451
|
*/
|
|
484
|
-
|
|
485
|
-
|
|
452
|
+
static fromJSON(e, t) {
|
|
453
|
+
if (typeof t.pos != "number")
|
|
454
|
+
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
455
|
+
return new N(t.pos, e.markFromJSON(t.mark));
|
|
486
456
|
}
|
|
457
|
+
}
|
|
458
|
+
k.jsonID("addNodeMark", N);
|
|
459
|
+
class R extends k {
|
|
487
460
|
/**
|
|
488
|
-
|
|
461
|
+
Create a mark-removing step.
|
|
489
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
|
+
}
|
|
490
481
|
toJSON() {
|
|
491
|
-
|
|
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
|
|
492
530
|
return null;
|
|
493
|
-
|
|
494
|
-
|
|
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;
|
|
495
535
|
}
|
|
496
536
|
/**
|
|
497
|
-
|
|
537
|
+
@internal
|
|
498
538
|
*/
|
|
499
|
-
static fromJSON(
|
|
500
|
-
if (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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);
|
|
582
|
+
}
|
|
583
|
+
toJSON() {
|
|
584
|
+
let e = {
|
|
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 && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
|
|
506
593
|
}
|
|
507
594
|
/**
|
|
508
|
-
|
|
509
|
-
open value on both side of the fragment.
|
|
595
|
+
@internal
|
|
510
596
|
*/
|
|
511
|
-
static
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
597
|
+
static fromJSON(e, t) {
|
|
598
|
+
if (typeof t.from != "number" || typeof t.to != "number" || typeof t.gapFrom != "number" || typeof t.gapTo != "number" || typeof t.insert != "number")
|
|
599
|
+
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
600
|
+
return new M(t.from, t.to, t.gapFrom, t.gapTo, g.fromJSON(e, t.slice), t.insert, !!t.structure);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
k.jsonID("replaceAround", M);
|
|
604
|
+
function q(s, e, t) {
|
|
605
|
+
let r = s.resolve(e), n = t - e, i = r.depth;
|
|
606
|
+
for (; n > 0 && i > 0 && r.indexAfter(i) == r.node(i).childCount; )
|
|
607
|
+
i--, n--;
|
|
608
|
+
if (n > 0) {
|
|
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
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return !1;
|
|
617
|
+
}
|
|
618
|
+
function pe(s, e, t, r) {
|
|
619
|
+
let n = [], i = [], o, l;
|
|
620
|
+
s.doc.nodesBetween(e, t, (a, h, p) => {
|
|
621
|
+
if (!a.isInline)
|
|
622
|
+
return;
|
|
623
|
+
let c = a.marks;
|
|
624
|
+
if (!r.isInSet(c) && p.type.allowsMarkType(r.type)) {
|
|
625
|
+
let f = Math.max(h, e), d = Math.min(h + a.nodeSize, t), u = r.addToSet(c);
|
|
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);
|
|
518
694
|
}
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
function de(s, e, t) {
|
|
698
|
+
let { $from: r, $to: n, depth: i } = e, o = r.before(i + 1), l = n.after(i + 1), a = o, h = l, p = w.empty, c = 0;
|
|
699
|
+
for (let u = i, m = !1; u > t; u--)
|
|
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));
|
|
519
705
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
if (i == t || r.isText) {
|
|
524
|
-
if (o != e && !l.child(s).isText)
|
|
525
|
-
throw new RangeError("Removing non-flat range");
|
|
526
|
-
return l.cut(0, t).append(l.cut(e));
|
|
527
|
-
}
|
|
528
|
-
if (n != s)
|
|
529
|
-
throw new RangeError("Removing non-flat range");
|
|
530
|
-
return l.replaceChild(n, r.copy(_(r.content, t - i - 1, e - i - 1)));
|
|
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;
|
|
531
709
|
}
|
|
532
|
-
function
|
|
533
|
-
|
|
534
|
-
if (r == t || s.isText)
|
|
535
|
-
return n && !n.canReplace(i, i, e) ? null : l.cut(0, t).append(e).append(l.cut(t));
|
|
536
|
-
let o = $(s.content, t - r - 1, e, s);
|
|
537
|
-
return o && l.replaceChild(i, s.copy(o));
|
|
710
|
+
function K(s) {
|
|
711
|
+
return { type: s, attrs: null };
|
|
538
712
|
}
|
|
539
|
-
function
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return
|
|
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;
|
|
545
719
|
}
|
|
546
|
-
function
|
|
547
|
-
let i =
|
|
548
|
-
if (
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
720
|
+
function me(s, e) {
|
|
721
|
+
let { parent: t, startIndex: r, endIndex: n } = s, i = t.child(r), o = e.contentMatch.findWrapping(i.type);
|
|
722
|
+
if (!o)
|
|
723
|
+
return null;
|
|
724
|
+
let a = (o.length ? o[o.length - 1] : e).contentMatch;
|
|
725
|
+
for (let h = r; a && h < n; h++)
|
|
726
|
+
a = a.matchType(t.child(h).type);
|
|
727
|
+
return !a || !a.validEnd ? null : o;
|
|
728
|
+
}
|
|
729
|
+
function ge(s, e, t) {
|
|
730
|
+
let r = w.empty;
|
|
731
|
+
for (let o = t.length - 1; o >= 0; o--) {
|
|
732
|
+
if (r.size) {
|
|
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;
|
|
558
757
|
}
|
|
559
|
-
|
|
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());
|
|
767
|
+
}
|
|
768
|
+
}
|
|
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
|
+
}
|
|
810
|
+
let l = n.indexAfter(i), a = r && r[0];
|
|
811
|
+
return n.node(i).canReplaceWith(l, l, a ? a.type : n.node(i + 1).type);
|
|
812
|
+
}
|
|
813
|
+
function ve(s, e, t = 1, r) {
|
|
814
|
+
let n = s.doc.resolve(e), i = w.empty, o = w.empty;
|
|
815
|
+
for (let l = n.depth, a = n.depth - t, h = t - 1; l > a; l--, h--) {
|
|
816
|
+
i = w.from(n.node(l).copy(i));
|
|
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);
|
|
560
825
|
}
|
|
561
|
-
function
|
|
562
|
-
|
|
563
|
-
|
|
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))
|
|
832
|
+
return !1;
|
|
833
|
+
}
|
|
834
|
+
return t.validEnd;
|
|
564
835
|
}
|
|
565
|
-
function
|
|
566
|
-
|
|
567
|
-
return et(n, t.node(e)), n;
|
|
836
|
+
function j(s, e) {
|
|
837
|
+
return !!(s && e && !s.isLeaf && xe(s, e));
|
|
568
838
|
}
|
|
569
|
-
function
|
|
570
|
-
let
|
|
571
|
-
|
|
839
|
+
function Be(s, e, t = -1) {
|
|
840
|
+
let r = s.resolve(e);
|
|
841
|
+
for (let n = r.depth; ; n--) {
|
|
842
|
+
let i, o, l = r.index(n);
|
|
843
|
+
if (n == r.depth ? (i = r.nodeBefore, o = r.nodeAfter) : t > 0 ? (i = r.node(n + 1), l++, o = r.node(n).maybeChild(l)) : (i = r.node(n).maybeChild(l - 1), o = r.node(n + 1)), i && !i.isTextblock && j(i, o) && r.node(n).canReplace(l, l + 1))
|
|
844
|
+
return e;
|
|
845
|
+
if (n == 0)
|
|
846
|
+
break;
|
|
847
|
+
e = t < 0 ? r.before(n) : r.after(n);
|
|
848
|
+
}
|
|
572
849
|
}
|
|
573
|
-
function
|
|
574
|
-
let
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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;
|
|
579
868
|
}
|
|
580
|
-
function
|
|
581
|
-
|
|
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;
|
|
888
|
+
}
|
|
889
|
+
return null;
|
|
582
890
|
}
|
|
583
|
-
function
|
|
584
|
-
let r =
|
|
585
|
-
|
|
891
|
+
function We(s, e, t) {
|
|
892
|
+
let r = s.resolve(e);
|
|
893
|
+
if (!t.content.size)
|
|
894
|
+
return e;
|
|
895
|
+
let n = t.content;
|
|
896
|
+
for (let i = 0; i < t.openStart; i++)
|
|
897
|
+
n = n.firstChild.content;
|
|
898
|
+
for (let i = 1; i <= (t.openStart == 0 && t.size ? 2 : 1); i++)
|
|
899
|
+
for (let o = r.depth; o >= 0; o--) {
|
|
900
|
+
let l = o == r.depth ? 0 : r.pos <= (r.start(o + 1) + r.end(o + 1)) / 2 ? -1 : 1, a = r.index(o) + (l > 0 ? 1 : 0), h = r.node(o), p = !1;
|
|
901
|
+
if (i == 1)
|
|
902
|
+
p = h.canReplace(a, a, n);
|
|
903
|
+
else {
|
|
904
|
+
let c = h.contentMatchAt(a).findWrapping(n.firstChild.type);
|
|
905
|
+
p = c && h.canReplaceWith(a, a, c[0]);
|
|
906
|
+
}
|
|
907
|
+
if (p)
|
|
908
|
+
return l == 0 ? r.pos : l < 0 ? r.before(o + 1) : r.after(o + 1);
|
|
909
|
+
}
|
|
910
|
+
return null;
|
|
586
911
|
}
|
|
587
|
-
function
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
912
|
+
function Me(s, e, t = e, r = g.empty) {
|
|
913
|
+
if (e == t && !r.size)
|
|
914
|
+
return null;
|
|
915
|
+
let n = s.resolve(e), i = s.resolve(t);
|
|
916
|
+
return ee(n, i, r) ? new v(e, t, r) : new Ce(n, i, r).fit();
|
|
917
|
+
}
|
|
918
|
+
function ee(s, e, t) {
|
|
919
|
+
return !t.openStart && !t.openEnd && s.start() == e.start() && s.parent.canReplace(s.index(), e.index(), t.content);
|
|
920
|
+
}
|
|
921
|
+
class Ce {
|
|
922
|
+
constructor(e, t, r) {
|
|
923
|
+
this.$from = e, this.$to = t, this.unplaced = r, this.frontier = [], this.placed = w.empty;
|
|
924
|
+
for (let n = 0; n <= e.depth; n++) {
|
|
925
|
+
let i = e.node(n);
|
|
926
|
+
this.frontier.push({
|
|
927
|
+
type: i.type,
|
|
928
|
+
match: i.contentMatchAt(e.indexAfter(n))
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
for (let n = e.depth; n > 0; n--)
|
|
932
|
+
this.placed = w.from(e.node(n).copy(this.placed));
|
|
933
|
+
}
|
|
934
|
+
get depth() {
|
|
935
|
+
return this.frontier.length - 1;
|
|
936
|
+
}
|
|
937
|
+
fit() {
|
|
938
|
+
for (; this.unplaced.size; ) {
|
|
939
|
+
let h = this.findFittable();
|
|
940
|
+
h ? this.placeNodes(h) : this.openMore() || this.dropNode();
|
|
941
|
+
}
|
|
942
|
+
let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, r = this.$from, n = this.close(e < 0 ? this.$to : r.doc.resolve(e));
|
|
943
|
+
if (!n)
|
|
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;
|
|
950
|
+
}
|
|
951
|
+
// Find a position on the start spine of `this.unplaced` that has
|
|
952
|
+
// content that can be moved somewhere on the frontier. Returns two
|
|
953
|
+
// depths, one for the slice and one for the frontier.
|
|
954
|
+
findFittable() {
|
|
955
|
+
let e = this.unplaced.openStart;
|
|
956
|
+
for (let t = this.unplaced.content, r = 0, n = this.unplaced.openEnd; r < e; r++) {
|
|
957
|
+
let i = t.firstChild;
|
|
958
|
+
if (t.childCount > 1 && (n = 0), i.type.spec.isolating && n <= r) {
|
|
959
|
+
e = r;
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
t = i.content;
|
|
963
|
+
}
|
|
964
|
+
for (let t = 1; t <= 2; t++)
|
|
965
|
+
for (let r = t == 1 ? e : this.unplaced.openStart; r >= 0; r--) {
|
|
966
|
+
let n, i = null;
|
|
967
|
+
r ? (i = W(this.unplaced.content, r - 1).firstChild, n = i.content) : n = this.unplaced.content;
|
|
968
|
+
let o = n.firstChild;
|
|
969
|
+
for (let l = this.depth; l >= 0; l--) {
|
|
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)));
|
|
1013
|
+
}
|
|
1014
|
+
let u = h == l.childCount;
|
|
1015
|
+
u || (d = -1), this.placed = F(this.placed, t, w.from(p)), this.frontier[t].match = c, u && d < 0 && r && r.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
|
|
1016
|
+
for (let m = 0, x = l; m < d; m++) {
|
|
1017
|
+
let I = x.lastChild;
|
|
1018
|
+
this.frontier.push({ type: I.type, match: I.contentMatchAt(I.childCount) }), x = I.content;
|
|
1019
|
+
}
|
|
1020
|
+
this.unplaced = u ? e == 0 ? g.empty : new g(O(o.content, e - 1, 1), e - 1, d < 0 ? o.openEnd : e - 1) : new g(O(o.content, e, h), o.openStart, o.openEnd);
|
|
1021
|
+
}
|
|
1022
|
+
mustMoveInline() {
|
|
1023
|
+
if (!this.$to.parent.isTextblock)
|
|
1024
|
+
return -1;
|
|
1025
|
+
let e = this.frontier[this.depth], t;
|
|
1026
|
+
if (!e.type.isTextblock || !D(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth)
|
|
1027
|
+
return -1;
|
|
1028
|
+
let { depth: r } = this.$to, n = this.$to.after(r);
|
|
1029
|
+
for (; r > 1 && n == this.$to.end(--r); )
|
|
1030
|
+
++n;
|
|
1031
|
+
return n;
|
|
1032
|
+
}
|
|
1033
|
+
findCloseLevel(e) {
|
|
1034
|
+
e: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) {
|
|
1035
|
+
let { match: r, type: n } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), o = D(e, t, n, r, i);
|
|
1036
|
+
if (o) {
|
|
1037
|
+
for (let l = t - 1; l >= 0; l--) {
|
|
1038
|
+
let { match: a, type: h } = this.frontier[l], p = D(e, l, h, a, !0);
|
|
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 };
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
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));
|
|
592
1066
|
}
|
|
593
|
-
return k(t, null, e, n), new c(n);
|
|
594
1067
|
}
|
|
595
|
-
function
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
+
return !1;
|
|
1097
|
+
}
|
|
1098
|
+
function Ie(s) {
|
|
1099
|
+
return s.spec.defining || s.spec.definingForContent;
|
|
1100
|
+
}
|
|
1101
|
+
function Re(s, e, t, r) {
|
|
1102
|
+
if (!r.size)
|
|
1103
|
+
return s.deleteRange(e, t);
|
|
1104
|
+
let n = s.doc.resolve(e), i = s.doc.resolve(t);
|
|
1105
|
+
if (ee(n, i, r))
|
|
1106
|
+
return s.step(new v(e, t, r));
|
|
1107
|
+
let o = ne(n, i);
|
|
1108
|
+
o[o.length - 1] == 0 && o.pop();
|
|
1109
|
+
let l = -(n.depth + 1);
|
|
1110
|
+
o.unshift(l);
|
|
1111
|
+
for (let f = n.depth, d = n.pos - 1; f > 0; f--, d--) {
|
|
1112
|
+
let u = n.node(f).type.spec;
|
|
1113
|
+
if (u.defining || u.definingAsContext || u.isolating)
|
|
1114
|
+
break;
|
|
1115
|
+
o.indexOf(f) > -1 ? l = f : n.before(f) == d && o.splice(1, 0, -f);
|
|
1116
|
+
}
|
|
1117
|
+
let a = o.indexOf(l), h = [], p = r.openStart;
|
|
1118
|
+
for (let f = r.content, d = 0; ; d++) {
|
|
1119
|
+
let u = f.firstChild;
|
|
1120
|
+
if (h.push(u), d == r.openStart)
|
|
1121
|
+
break;
|
|
1122
|
+
f = u.content;
|
|
1123
|
+
}
|
|
1124
|
+
for (let f = p - 1; f >= 0; f--) {
|
|
1125
|
+
let d = h[f], u = Ie(d.type);
|
|
1126
|
+
if (u && !d.sameMarkup(n.node(Math.abs(l) - 1)))
|
|
1127
|
+
p = f;
|
|
1128
|
+
else if (u || !d.type.isTextblock)
|
|
1129
|
+
break;
|
|
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;
|
|
603
1189
|
}
|
|
604
|
-
class E {
|
|
1190
|
+
class E extends k {
|
|
605
1191
|
/**
|
|
606
|
-
|
|
1192
|
+
Construct an attribute step.
|
|
607
1193
|
*/
|
|
608
|
-
constructor(
|
|
609
|
-
|
|
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);
|
|
610
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 {
|
|
611
1229
|
/**
|
|
612
|
-
|
|
1230
|
+
Construct an attribute step.
|
|
613
1231
|
*/
|
|
614
|
-
|
|
615
|
-
|
|
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);
|
|
616
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 {
|
|
617
1272
|
/**
|
|
618
|
-
|
|
619
|
-
a position points into a text node, that node is not considered
|
|
620
|
-
the parent—text nodes are ‘flat’ in this model, and have no content.
|
|
1273
|
+
Create a transform that starts with the given document.
|
|
621
1274
|
*/
|
|
622
|
-
|
|
623
|
-
|
|
1275
|
+
constructor(e) {
|
|
1276
|
+
this.doc = e, this.steps = [], this.docs = [], this.mapping = new A();
|
|
624
1277
|
}
|
|
625
1278
|
/**
|
|
626
|
-
The
|
|
1279
|
+
The starting document.
|
|
627
1280
|
*/
|
|
628
|
-
get
|
|
629
|
-
return this.
|
|
1281
|
+
get before() {
|
|
1282
|
+
return this.docs.length ? this.docs[0] : this.doc;
|
|
630
1283
|
}
|
|
631
1284
|
/**
|
|
632
|
-
|
|
633
|
-
|
|
1285
|
+
Apply a new step in this transform, saving the result. Throws an
|
|
1286
|
+
error when the step fails.
|
|
634
1287
|
*/
|
|
635
|
-
|
|
636
|
-
|
|
1288
|
+
step(e) {
|
|
1289
|
+
let t = this.maybeStep(e);
|
|
1290
|
+
if (t.failed)
|
|
1291
|
+
throw new T(t.failed);
|
|
1292
|
+
return this;
|
|
637
1293
|
}
|
|
638
1294
|
/**
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
example, `p.index(0)` is 1 and `p.index(1)` is 2.
|
|
1295
|
+
Try to apply a step in this transformation, ignoring it if it
|
|
1296
|
+
fails. Returns the step result.
|
|
642
1297
|
*/
|
|
643
|
-
|
|
644
|
-
|
|
1298
|
+
maybeStep(e) {
|
|
1299
|
+
let t = e.apply(this.doc);
|
|
1300
|
+
return t.failed || this.addStep(e, t.doc), t;
|
|
645
1301
|
}
|
|
646
1302
|
/**
|
|
647
|
-
|
|
648
|
-
|
|
1303
|
+
True when the document has been changed (when there are any
|
|
1304
|
+
steps).
|
|
649
1305
|
*/
|
|
650
|
-
|
|
651
|
-
return
|
|
1306
|
+
get docChanged() {
|
|
1307
|
+
return this.steps.length > 0;
|
|
652
1308
|
}
|
|
653
1309
|
/**
|
|
654
|
-
|
|
655
|
-
|
|
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.
|
|
656
1314
|
*/
|
|
657
|
-
|
|
658
|
-
|
|
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);
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
return e == 1e9 ? null : { from: e, to: t };
|
|
659
1324
|
}
|
|
660
1325
|
/**
|
|
661
|
-
|
|
662
|
-
level.
|
|
1326
|
+
@internal
|
|
663
1327
|
*/
|
|
664
|
-
|
|
665
|
-
|
|
1328
|
+
addStep(e, t) {
|
|
1329
|
+
this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t;
|
|
666
1330
|
}
|
|
667
1331
|
/**
|
|
668
|
-
|
|
669
|
-
given
|
|
670
|
-
position.
|
|
1332
|
+
Replace the part of the document between `from` and `to` with the
|
|
1333
|
+
given `slice`.
|
|
671
1334
|
*/
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
return t == this.depth + 1 ? this.pos : this.path[t * 3 - 1];
|
|
1335
|
+
replace(e, t = e, r = g.empty) {
|
|
1336
|
+
let n = Me(this.doc, e, t, r);
|
|
1337
|
+
return n && this.step(n), this;
|
|
676
1338
|
}
|
|
677
1339
|
/**
|
|
678
|
-
|
|
679
|
-
|
|
1340
|
+
Replace the given range with the given content, which may be a
|
|
1341
|
+
fragment, node, or array of nodes.
|
|
680
1342
|
*/
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
throw new RangeError("There is no position after the top-level node");
|
|
684
|
-
return t == this.depth + 1 ? this.pos : this.path[t * 3 - 1] + this.path[t * 3].nodeSize;
|
|
1343
|
+
replaceWith(e, t, r) {
|
|
1344
|
+
return this.replace(e, t, new g(w.from(r), 0, 0));
|
|
685
1345
|
}
|
|
686
1346
|
/**
|
|
687
|
-
|
|
688
|
-
distance between the position and the start of the text node.
|
|
689
|
-
Will be zero for positions that point between nodes.
|
|
1347
|
+
Delete the content between the given positions.
|
|
690
1348
|
*/
|
|
691
|
-
|
|
692
|
-
return this.
|
|
1349
|
+
delete(e, t) {
|
|
1350
|
+
return this.replace(e, t, g.empty);
|
|
693
1351
|
}
|
|
694
1352
|
/**
|
|
695
|
-
|
|
696
|
-
points into a text node, only the part of that node after the
|
|
697
|
-
position is returned.
|
|
1353
|
+
Insert the given content at the given position.
|
|
698
1354
|
*/
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
if (e == t.childCount)
|
|
702
|
-
return null;
|
|
703
|
-
let n = this.pos - this.path[this.path.length - 1], i = t.child(e);
|
|
704
|
-
return n ? t.child(e).cut(n) : i;
|
|
1355
|
+
insert(e, t) {
|
|
1356
|
+
return this.replaceWith(e, e, t);
|
|
705
1357
|
}
|
|
706
1358
|
/**
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
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.
|
|
710
1376
|
*/
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
return e ? this.parent.child(t).cut(0, e) : t == 0 ? null : this.parent.child(t - 1);
|
|
1377
|
+
replaceRange(e, t, r) {
|
|
1378
|
+
return Re(this, e, t, r), this;
|
|
714
1379
|
}
|
|
715
1380
|
/**
|
|
716
|
-
|
|
717
|
-
|
|
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.
|
|
718
1388
|
*/
|
|
719
|
-
|
|
720
|
-
e
|
|
721
|
-
let n = this.path[e * 3], i = e == 0 ? 0 : this.path[e * 3 - 1] + 1;
|
|
722
|
-
for (let r = 0; r < t; r++)
|
|
723
|
-
i += n.child(r).nodeSize;
|
|
724
|
-
return i;
|
|
1389
|
+
replaceRangeWith(e, t, r) {
|
|
1390
|
+
return Ee(this, e, t, r), this;
|
|
725
1391
|
}
|
|
726
1392
|
/**
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
position is at the start of a non-empty node, the marks of the
|
|
730
|
-
node after it (if any) are returned.
|
|
1393
|
+
Delete the given range, expanding it to cover fully covered
|
|
1394
|
+
parent nodes until a valid replace is found.
|
|
731
1395
|
*/
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
if (t.content.size == 0)
|
|
735
|
-
return u.none;
|
|
736
|
-
if (this.textOffset)
|
|
737
|
-
return t.child(e).marks;
|
|
738
|
-
let n = t.maybeChild(e - 1), i = t.maybeChild(e);
|
|
739
|
-
if (!n) {
|
|
740
|
-
let o = n;
|
|
741
|
-
n = i, i = o;
|
|
742
|
-
}
|
|
743
|
-
let r = n.marks;
|
|
744
|
-
for (var s = 0; s < r.length; s++)
|
|
745
|
-
r[s].type.spec.inclusive === !1 && (!i || !r[s].isInSet(i.marks)) && (r = r[s--].removeFromSet(r));
|
|
746
|
-
return r;
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
Get the marks after the current position, if any, except those
|
|
750
|
-
that are non-inclusive and not present at position `$end`. This
|
|
751
|
-
is mostly useful for getting the set of marks to preserve after a
|
|
752
|
-
deletion. Will return `null` if this position is at the end of
|
|
753
|
-
its parent node or its parent node isn't a textblock (in which
|
|
754
|
-
case no marks should be preserved).
|
|
755
|
-
*/
|
|
756
|
-
marksAcross(t) {
|
|
757
|
-
let e = this.parent.maybeChild(this.index());
|
|
758
|
-
if (!e || !e.isInline)
|
|
759
|
-
return null;
|
|
760
|
-
let n = e.marks, i = t.parent.maybeChild(t.index());
|
|
761
|
-
for (var r = 0; r < n.length; r++)
|
|
762
|
-
n[r].type.spec.inclusive === !1 && (!i || !n[r].isInSet(i.marks)) && (n = n[r--].removeFromSet(n));
|
|
763
|
-
return n;
|
|
1396
|
+
deleteRange(e, t) {
|
|
1397
|
+
return Te(this, e, t), this;
|
|
764
1398
|
}
|
|
765
1399
|
/**
|
|
766
|
-
|
|
767
|
-
|
|
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.
|
|
768
1405
|
*/
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
if (this.start(e) <= t && this.end(e) >= t)
|
|
772
|
-
return e;
|
|
773
|
-
return 0;
|
|
1406
|
+
lift(e, t) {
|
|
1407
|
+
return de(this, e, t), this;
|
|
774
1408
|
}
|
|
775
1409
|
/**
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
the same textblock, for example, a range around that textblock
|
|
779
|
-
will be returned. If they point into different blocks, the range
|
|
780
|
-
around those blocks in their shared ancestor is returned. You can
|
|
781
|
-
pass in an optional predicate that will be called with a parent
|
|
782
|
-
node to see if a range into that parent is acceptable.
|
|
1410
|
+
Join the blocks around the given position. If depth is 2, their
|
|
1411
|
+
last and first siblings are also joined, and so on.
|
|
783
1412
|
*/
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
return t.blockRange(this);
|
|
787
|
-
for (let n = this.depth - (this.parent.inlineContent || this.pos == t.pos ? 1 : 0); n >= 0; n--)
|
|
788
|
-
if (t.pos <= this.end(n) && (!e || e(this.node(n))))
|
|
789
|
-
return new mt(this, t, n);
|
|
790
|
-
return null;
|
|
1413
|
+
join(e, t = 1) {
|
|
1414
|
+
return Se(this, e, t), this;
|
|
791
1415
|
}
|
|
792
1416
|
/**
|
|
793
|
-
|
|
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).
|
|
794
1420
|
*/
|
|
795
|
-
|
|
796
|
-
return this
|
|
1421
|
+
wrap(e, t) {
|
|
1422
|
+
return ge(this, e, t), this;
|
|
797
1423
|
}
|
|
798
1424
|
/**
|
|
799
|
-
|
|
1425
|
+
Set the type of all textblocks (partly) between `from` and `to` to
|
|
1426
|
+
the given node type with the given attributes.
|
|
800
1427
|
*/
|
|
801
|
-
|
|
802
|
-
return
|
|
1428
|
+
setBlockType(e, t = e, r, n = null) {
|
|
1429
|
+
return we(this, e, t, r, n), this;
|
|
803
1430
|
}
|
|
804
1431
|
/**
|
|
805
|
-
|
|
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,
|
|
806
1434
|
*/
|
|
807
|
-
|
|
808
|
-
return
|
|
1435
|
+
setNodeMarkup(e, t, r = null, n) {
|
|
1436
|
+
return ke(this, e, t, r, n), this;
|
|
809
1437
|
}
|
|
810
1438
|
/**
|
|
811
|
-
|
|
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.
|
|
812
1442
|
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
for (let e = 1; e <= this.depth; e++)
|
|
816
|
-
t += (t ? "/" : "") + this.node(e).type.name + "_" + this.index(e - 1);
|
|
817
|
-
return t + ":" + this.parentOffset;
|
|
1443
|
+
setNodeAttribute(e, t, r) {
|
|
1444
|
+
return this.step(new E(e, t, r)), this;
|
|
818
1445
|
}
|
|
819
1446
|
/**
|
|
820
|
-
|
|
1447
|
+
Set a single attribute on the document to a new value.
|
|
821
1448
|
*/
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
throw new RangeError("Position " + e + " out of range");
|
|
825
|
-
let n = [], i = 0, r = e;
|
|
826
|
-
for (let s = t; ; ) {
|
|
827
|
-
let { index: o, offset: h } = s.content.findIndex(r), a = r - h;
|
|
828
|
-
if (n.push(s, o, i + h), !a || (s = s.child(o), s.isText))
|
|
829
|
-
break;
|
|
830
|
-
r = a - 1, i += h + 1;
|
|
831
|
-
}
|
|
832
|
-
return new E(e, n, r);
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
@internal
|
|
836
|
-
*/
|
|
837
|
-
static resolveCached(t, e) {
|
|
838
|
-
let n = L.get(t);
|
|
839
|
-
if (n)
|
|
840
|
-
for (let r = 0; r < n.elts.length; r++) {
|
|
841
|
-
let s = n.elts[r];
|
|
842
|
-
if (s.pos == e)
|
|
843
|
-
return s;
|
|
844
|
-
}
|
|
845
|
-
else
|
|
846
|
-
L.set(t, n = new gt());
|
|
847
|
-
let i = n.elts[n.i] = E.resolve(t, e);
|
|
848
|
-
return n.i = (n.i + 1) % xt, i;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
class gt {
|
|
852
|
-
constructor() {
|
|
853
|
-
this.elts = [], this.i = 0;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
const xt = 12, L = /* @__PURE__ */ new WeakMap();
|
|
857
|
-
class mt {
|
|
858
|
-
/**
|
|
859
|
-
Construct a node range. `$from` and `$to` should point into the
|
|
860
|
-
same node until at least the given `depth`, since a node range
|
|
861
|
-
denotes an adjacent set of nodes in a single parent node.
|
|
862
|
-
*/
|
|
863
|
-
constructor(t, e, n) {
|
|
864
|
-
this.$from = t, this.$to = e, this.depth = n;
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
The position at the start of the range.
|
|
868
|
-
*/
|
|
869
|
-
get start() {
|
|
870
|
-
return this.$from.before(this.depth + 1);
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
The position at the end of the range.
|
|
874
|
-
*/
|
|
875
|
-
get end() {
|
|
876
|
-
return this.$to.after(this.depth + 1);
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
The parent node that the range points into.
|
|
880
|
-
*/
|
|
881
|
-
get parent() {
|
|
882
|
-
return this.$from.node(this.depth);
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
The start index of the range in the parent node.
|
|
886
|
-
*/
|
|
887
|
-
get startIndex() {
|
|
888
|
-
return this.$from.index(this.depth);
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
The end index of the range in the parent node.
|
|
892
|
-
*/
|
|
893
|
-
get endIndex() {
|
|
894
|
-
return this.$to.indexAfter(this.depth);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
const wt = /* @__PURE__ */ Object.create(null);
|
|
898
|
-
class g {
|
|
899
|
-
/**
|
|
900
|
-
@internal
|
|
901
|
-
*/
|
|
902
|
-
constructor(t, e, n, i = u.none) {
|
|
903
|
-
this.type = t, this.attrs = e, this.marks = i, this.content = n || c.empty;
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
The array of this node's child nodes.
|
|
907
|
-
*/
|
|
908
|
-
get children() {
|
|
909
|
-
return this.content.content;
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
The size of this node, as defined by the integer-based [indexing
|
|
913
|
-
scheme](https://prosemirror.net/docs/guide/#doc.indexing). For text nodes, this is the
|
|
914
|
-
amount of characters. For other leaf nodes, it is one. For
|
|
915
|
-
non-leaf nodes, it is the size of the content plus two (the
|
|
916
|
-
start and end token).
|
|
917
|
-
*/
|
|
918
|
-
get nodeSize() {
|
|
919
|
-
return this.isLeaf ? 1 : 2 + this.content.size;
|
|
920
|
-
}
|
|
921
|
-
/**
|
|
922
|
-
The number of children that the node has.
|
|
923
|
-
*/
|
|
924
|
-
get childCount() {
|
|
925
|
-
return this.content.childCount;
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
Get the child node at the given index. Raises an error when the
|
|
929
|
-
index is out of range.
|
|
930
|
-
*/
|
|
931
|
-
child(t) {
|
|
932
|
-
return this.content.child(t);
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
Get the child node at the given index, if it exists.
|
|
936
|
-
*/
|
|
937
|
-
maybeChild(t) {
|
|
938
|
-
return this.content.maybeChild(t);
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
Call `f` for every child node, passing the node, its offset
|
|
942
|
-
into this parent node, and its index.
|
|
943
|
-
*/
|
|
944
|
-
forEach(t) {
|
|
945
|
-
this.content.forEach(t);
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
Invoke a callback for all descendant nodes recursively between
|
|
949
|
-
the given two positions that are relative to start of this
|
|
950
|
-
node's content. The callback is invoked with the node, its
|
|
951
|
-
position relative to the original node (method receiver),
|
|
952
|
-
its parent node, and its child index. When the callback returns
|
|
953
|
-
false for a given node, that node's children will not be
|
|
954
|
-
recursed over. The last parameter can be used to specify a
|
|
955
|
-
starting position to count from.
|
|
956
|
-
*/
|
|
957
|
-
nodesBetween(t, e, n, i = 0) {
|
|
958
|
-
this.content.nodesBetween(t, e, n, i, this);
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
Call the given callback for every descendant node. Doesn't
|
|
962
|
-
descend into a node when the callback returns `false`.
|
|
963
|
-
*/
|
|
964
|
-
descendants(t) {
|
|
965
|
-
this.nodesBetween(0, this.content.size, t);
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
Concatenates all the text nodes found in this fragment and its
|
|
969
|
-
children.
|
|
970
|
-
*/
|
|
971
|
-
get textContent() {
|
|
972
|
-
return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
Get all text between positions `from` and `to`. When
|
|
976
|
-
`blockSeparator` is given, it will be inserted to separate text
|
|
977
|
-
from different block nodes. If `leafText` is given, it'll be
|
|
978
|
-
inserted for every non-text leaf node encountered, otherwise
|
|
979
|
-
[`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec.leafText) will be used.
|
|
980
|
-
*/
|
|
981
|
-
textBetween(t, e, n, i) {
|
|
982
|
-
return this.content.textBetween(t, e, n, i);
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
Returns this node's first child, or `null` if there are no
|
|
986
|
-
children.
|
|
987
|
-
*/
|
|
988
|
-
get firstChild() {
|
|
989
|
-
return this.content.firstChild;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
Returns this node's last child, or `null` if there are no
|
|
993
|
-
children.
|
|
994
|
-
*/
|
|
995
|
-
get lastChild() {
|
|
996
|
-
return this.content.lastChild;
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
Test whether two nodes represent the same piece of document.
|
|
1000
|
-
*/
|
|
1001
|
-
eq(t) {
|
|
1002
|
-
return this == t || this.sameMarkup(t) && this.content.eq(t.content);
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
Compare the markup (type, attributes, and marks) of this node to
|
|
1006
|
-
those of another. Returns `true` if both have the same markup.
|
|
1007
|
-
*/
|
|
1008
|
-
sameMarkup(t) {
|
|
1009
|
-
return this.hasMarkup(t.type, t.attrs, t.marks);
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
Check whether this node's markup correspond to the given type,
|
|
1013
|
-
attributes, and marks.
|
|
1014
|
-
*/
|
|
1015
|
-
hasMarkup(t, e, n) {
|
|
1016
|
-
return this.type == t && M(this.attrs, e || t.defaultAttrs || wt) && u.sameSet(this.marks, n || u.none);
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
Create a new node with the same markup as this node, containing
|
|
1020
|
-
the given content (or empty, if no content is given).
|
|
1021
|
-
*/
|
|
1022
|
-
copy(t = null) {
|
|
1023
|
-
return t == this.content ? this : new g(this.type, this.attrs, t, this.marks);
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
Create a copy of this node, with the given set of marks instead
|
|
1027
|
-
of the node's own marks.
|
|
1028
|
-
*/
|
|
1029
|
-
mark(t) {
|
|
1030
|
-
return t == this.marks ? this : new g(this.type, this.attrs, this.content, t);
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
Create a copy of this node with only the content between the
|
|
1034
|
-
given positions. If `to` is not given, it defaults to the end of
|
|
1035
|
-
the node.
|
|
1036
|
-
*/
|
|
1037
|
-
cut(t, e = this.content.size) {
|
|
1038
|
-
return t == 0 && e == this.content.size ? this : this.copy(this.content.cut(t, e));
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
Cut out the part of the document between the given positions, and
|
|
1042
|
-
return it as a `Slice` object.
|
|
1043
|
-
*/
|
|
1044
|
-
slice(t, e = this.content.size, n = !1) {
|
|
1045
|
-
if (t == e)
|
|
1046
|
-
return d.empty;
|
|
1047
|
-
let i = this.resolve(t), r = this.resolve(e), s = n ? 0 : i.sharedDepth(e), o = i.start(s), a = i.node(s).content.cut(i.pos - o, r.pos - o);
|
|
1048
|
-
return new d(a, i.depth - s, r.depth - s);
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
Replace the part of the document between the given positions with
|
|
1052
|
-
the given slice. The slice must 'fit', meaning its open sides
|
|
1053
|
-
must be able to connect to the surrounding content, and its
|
|
1054
|
-
content nodes must be valid children for the node they are placed
|
|
1055
|
-
into. If any of this is violated, an error of type
|
|
1056
|
-
[`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown.
|
|
1057
|
-
*/
|
|
1058
|
-
replace(t, e, n) {
|
|
1059
|
-
return dt(this.resolve(t), this.resolve(e), n);
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
Find the node directly after the given position.
|
|
1063
|
-
*/
|
|
1064
|
-
nodeAt(t) {
|
|
1065
|
-
for (let e = this; ; ) {
|
|
1066
|
-
let { index: n, offset: i } = e.content.findIndex(t);
|
|
1067
|
-
if (e = e.maybeChild(n), !e)
|
|
1068
|
-
return null;
|
|
1069
|
-
if (i == t || e.isText)
|
|
1070
|
-
return e;
|
|
1071
|
-
t -= i + 1;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
/**
|
|
1075
|
-
Find the (direct) child node after the given offset, if any,
|
|
1076
|
-
and return it along with its index and offset relative to this
|
|
1077
|
-
node.
|
|
1078
|
-
*/
|
|
1079
|
-
childAfter(t) {
|
|
1080
|
-
let { index: e, offset: n } = this.content.findIndex(t);
|
|
1081
|
-
return { node: this.content.maybeChild(e), index: e, offset: n };
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
Find the (direct) child node before the given offset, if any,
|
|
1085
|
-
and return it along with its index and offset relative to this
|
|
1086
|
-
node.
|
|
1087
|
-
*/
|
|
1088
|
-
childBefore(t) {
|
|
1089
|
-
if (t == 0)
|
|
1090
|
-
return { node: null, index: 0, offset: 0 };
|
|
1091
|
-
let { index: e, offset: n } = this.content.findIndex(t);
|
|
1092
|
-
if (n < t)
|
|
1093
|
-
return { node: this.content.child(e), index: e, offset: n };
|
|
1094
|
-
let i = this.content.child(e - 1);
|
|
1095
|
-
return { node: i, index: e - 1, offset: n - i.nodeSize };
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
Resolve the given position in the document, returning an
|
|
1099
|
-
[object](https://prosemirror.net/docs/ref/#model.ResolvedPos) with information about its context.
|
|
1100
|
-
*/
|
|
1101
|
-
resolve(t) {
|
|
1102
|
-
return E.resolveCached(this, t);
|
|
1103
|
-
}
|
|
1104
|
-
/**
|
|
1105
|
-
@internal
|
|
1106
|
-
*/
|
|
1107
|
-
resolveNoCache(t) {
|
|
1108
|
-
return E.resolve(this, t);
|
|
1109
|
-
}
|
|
1110
|
-
/**
|
|
1111
|
-
Test whether a given mark or mark type occurs in this document
|
|
1112
|
-
between the two given positions.
|
|
1113
|
-
*/
|
|
1114
|
-
rangeHasMark(t, e, n) {
|
|
1115
|
-
let i = !1;
|
|
1116
|
-
return e > t && this.nodesBetween(t, e, (r) => (n.isInSet(r.marks) && (i = !0), !i)), i;
|
|
1117
|
-
}
|
|
1118
|
-
/**
|
|
1119
|
-
True when this is a block (non-inline node)
|
|
1120
|
-
*/
|
|
1121
|
-
get isBlock() {
|
|
1122
|
-
return this.type.isBlock;
|
|
1123
|
-
}
|
|
1124
|
-
/**
|
|
1125
|
-
True when this is a textblock node, a block node with inline
|
|
1126
|
-
content.
|
|
1127
|
-
*/
|
|
1128
|
-
get isTextblock() {
|
|
1129
|
-
return this.type.isTextblock;
|
|
1130
|
-
}
|
|
1131
|
-
/**
|
|
1132
|
-
True when this node allows inline content.
|
|
1133
|
-
*/
|
|
1134
|
-
get inlineContent() {
|
|
1135
|
-
return this.type.inlineContent;
|
|
1136
|
-
}
|
|
1137
|
-
/**
|
|
1138
|
-
True when this is an inline node (a text node or a node that can
|
|
1139
|
-
appear among text).
|
|
1140
|
-
*/
|
|
1141
|
-
get isInline() {
|
|
1142
|
-
return this.type.isInline;
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
True when this is a text node.
|
|
1146
|
-
*/
|
|
1147
|
-
get isText() {
|
|
1148
|
-
return this.type.isText;
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
True when this is a leaf node.
|
|
1152
|
-
*/
|
|
1153
|
-
get isLeaf() {
|
|
1154
|
-
return this.type.isLeaf;
|
|
1155
|
-
}
|
|
1156
|
-
/**
|
|
1157
|
-
True when this is an atom, i.e. when it does not have directly
|
|
1158
|
-
editable content. This is usually the same as `isLeaf`, but can
|
|
1159
|
-
be configured with the [`atom` property](https://prosemirror.net/docs/ref/#model.NodeSpec.atom)
|
|
1160
|
-
on a node's spec (typically used when the node is displayed as
|
|
1161
|
-
an uneditable [node view](https://prosemirror.net/docs/ref/#view.NodeView)).
|
|
1162
|
-
*/
|
|
1163
|
-
get isAtom() {
|
|
1164
|
-
return this.type.isAtom;
|
|
1165
|
-
}
|
|
1166
|
-
/**
|
|
1167
|
-
Return a string representation of this node for debugging
|
|
1168
|
-
purposes.
|
|
1169
|
-
*/
|
|
1170
|
-
toString() {
|
|
1171
|
-
if (this.type.spec.toDebugString)
|
|
1172
|
-
return this.type.spec.toDebugString(this);
|
|
1173
|
-
let t = this.type.name;
|
|
1174
|
-
return this.content.size && (t += "(" + this.content.toStringInner() + ")"), it(this.marks, t);
|
|
1175
|
-
}
|
|
1176
|
-
/**
|
|
1177
|
-
Get the content match in this node at the given index.
|
|
1178
|
-
*/
|
|
1179
|
-
contentMatchAt(t) {
|
|
1180
|
-
let e = this.type.contentMatch.matchFragment(this.content, 0, t);
|
|
1181
|
-
if (!e)
|
|
1182
|
-
throw new Error("Called contentMatchAt on a node with invalid content");
|
|
1183
|
-
return e;
|
|
1184
|
-
}
|
|
1185
|
-
/**
|
|
1186
|
-
Test whether replacing the range between `from` and `to` (by
|
|
1187
|
-
child index) with the given replacement fragment (which defaults
|
|
1188
|
-
to the empty fragment) would leave the node's content valid. You
|
|
1189
|
-
can optionally pass `start` and `end` indices into the
|
|
1190
|
-
replacement fragment.
|
|
1191
|
-
*/
|
|
1192
|
-
canReplace(t, e, n = c.empty, i = 0, r = n.childCount) {
|
|
1193
|
-
let s = this.contentMatchAt(t).matchFragment(n, i, r), o = s && s.matchFragment(this.content, e);
|
|
1194
|
-
if (!o || !o.validEnd)
|
|
1195
|
-
return !1;
|
|
1196
|
-
for (let h = i; h < r; h++)
|
|
1197
|
-
if (!this.type.allowsMarks(n.child(h).marks))
|
|
1198
|
-
return !1;
|
|
1199
|
-
return !0;
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
Test whether replacing the range `from` to `to` (by index) with
|
|
1203
|
-
a node of the given type would leave the node's content valid.
|
|
1204
|
-
*/
|
|
1205
|
-
canReplaceWith(t, e, n, i) {
|
|
1206
|
-
if (i && !this.type.allowsMarks(i))
|
|
1207
|
-
return !1;
|
|
1208
|
-
let r = this.contentMatchAt(t).matchType(n), s = r && r.matchFragment(this.content, e);
|
|
1209
|
-
return s ? s.validEnd : !1;
|
|
1210
|
-
}
|
|
1211
|
-
/**
|
|
1212
|
-
Test whether the given node's content could be appended to this
|
|
1213
|
-
node. If that node is empty, this will only return true if there
|
|
1214
|
-
is at least one node type that can appear in both nodes (to avoid
|
|
1215
|
-
merging completely incompatible nodes).
|
|
1216
|
-
*/
|
|
1217
|
-
canAppend(t) {
|
|
1218
|
-
return t.content.size ? this.canReplace(this.childCount, this.childCount, t.content) : this.type.compatibleContent(t.type);
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
Check whether this node and its descendants conform to the
|
|
1222
|
-
schema, and raise an exception when they do not.
|
|
1223
|
-
*/
|
|
1224
|
-
check() {
|
|
1225
|
-
this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
|
|
1226
|
-
let t = u.none;
|
|
1227
|
-
for (let e = 0; e < this.marks.length; e++) {
|
|
1228
|
-
let n = this.marks[e];
|
|
1229
|
-
n.type.checkAttrs(n.attrs), t = n.addToSet(t);
|
|
1230
|
-
}
|
|
1231
|
-
if (!u.sameSet(t, this.marks))
|
|
1232
|
-
throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
|
|
1233
|
-
this.content.forEach((e) => e.check());
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
Return a JSON-serializeable representation of this node.
|
|
1237
|
-
*/
|
|
1238
|
-
toJSON() {
|
|
1239
|
-
let t = { type: this.type.name };
|
|
1240
|
-
for (let e in this.attrs) {
|
|
1241
|
-
t.attrs = this.attrs;
|
|
1242
|
-
break;
|
|
1243
|
-
}
|
|
1244
|
-
return this.content.size && (t.content = this.content.toJSON()), this.marks.length && (t.marks = this.marks.map((e) => e.toJSON())), t;
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
Deserialize a node from its JSON representation.
|
|
1248
|
-
*/
|
|
1249
|
-
static fromJSON(t, e) {
|
|
1250
|
-
if (!e)
|
|
1251
|
-
throw new RangeError("Invalid input for Node.fromJSON");
|
|
1252
|
-
let n;
|
|
1253
|
-
if (e.marks) {
|
|
1254
|
-
if (!Array.isArray(e.marks))
|
|
1255
|
-
throw new RangeError("Invalid mark data for Node.fromJSON");
|
|
1256
|
-
n = e.marks.map(t.markFromJSON);
|
|
1257
|
-
}
|
|
1258
|
-
if (e.type == "text") {
|
|
1259
|
-
if (typeof e.text != "string")
|
|
1260
|
-
throw new RangeError("Invalid text node in JSON");
|
|
1261
|
-
return t.text(e.text, n);
|
|
1262
|
-
}
|
|
1263
|
-
let i = c.fromJSON(t, e.content), r = t.nodeType(e.type).create(e.attrs, i, n);
|
|
1264
|
-
return r.type.checkAttrs(r.attrs), r;
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
g.prototype.text = void 0;
|
|
1268
|
-
class z extends g {
|
|
1269
|
-
/**
|
|
1270
|
-
@internal
|
|
1271
|
-
*/
|
|
1272
|
-
constructor(t, e, n, i) {
|
|
1273
|
-
if (super(t, e, null, i), !n)
|
|
1274
|
-
throw new RangeError("Empty text nodes are not allowed");
|
|
1275
|
-
this.text = n;
|
|
1276
|
-
}
|
|
1277
|
-
toString() {
|
|
1278
|
-
return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : it(this.marks, JSON.stringify(this.text));
|
|
1279
|
-
}
|
|
1280
|
-
get textContent() {
|
|
1281
|
-
return this.text;
|
|
1282
|
-
}
|
|
1283
|
-
textBetween(t, e) {
|
|
1284
|
-
return this.text.slice(t, e);
|
|
1285
|
-
}
|
|
1286
|
-
get nodeSize() {
|
|
1287
|
-
return this.text.length;
|
|
1288
|
-
}
|
|
1289
|
-
mark(t) {
|
|
1290
|
-
return t == this.marks ? this : new z(this.type, this.attrs, this.text, t);
|
|
1291
|
-
}
|
|
1292
|
-
withText(t) {
|
|
1293
|
-
return t == this.text ? this : new z(this.type, this.attrs, t, this.marks);
|
|
1294
|
-
}
|
|
1295
|
-
cut(t = 0, e = this.text.length) {
|
|
1296
|
-
return t == 0 && e == this.text.length ? this : this.withText(this.text.slice(t, e));
|
|
1297
|
-
}
|
|
1298
|
-
eq(t) {
|
|
1299
|
-
return this.sameMarkup(t) && this.text == t.text;
|
|
1300
|
-
}
|
|
1301
|
-
toJSON() {
|
|
1302
|
-
let t = super.toJSON();
|
|
1303
|
-
return t.text = this.text, t;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
function it(l, t) {
|
|
1307
|
-
for (let e = l.length - 1; e >= 0; e--)
|
|
1308
|
-
t = l[e].type.name + "(" + t + ")";
|
|
1309
|
-
return t;
|
|
1310
|
-
}
|
|
1311
|
-
class w {
|
|
1312
|
-
/**
|
|
1313
|
-
@internal
|
|
1314
|
-
*/
|
|
1315
|
-
constructor(t) {
|
|
1316
|
-
this.validEnd = t, this.next = [], this.wrapCache = [];
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
@internal
|
|
1320
|
-
*/
|
|
1321
|
-
static parse(t, e) {
|
|
1322
|
-
let n = new kt(t, e);
|
|
1323
|
-
if (n.next == null)
|
|
1324
|
-
return w.empty;
|
|
1325
|
-
let i = rt(n);
|
|
1326
|
-
n.next && n.err("Unexpected trailing text");
|
|
1327
|
-
let r = Mt(bt(i));
|
|
1328
|
-
return At(r, n), r;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
Match a node type, returning a match after that node if
|
|
1332
|
-
successful.
|
|
1333
|
-
*/
|
|
1334
|
-
matchType(t) {
|
|
1335
|
-
for (let e = 0; e < this.next.length; e++)
|
|
1336
|
-
if (this.next[e].type == t)
|
|
1337
|
-
return this.next[e].next;
|
|
1338
|
-
return null;
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
Try to match a fragment. Returns the resulting match when
|
|
1342
|
-
successful.
|
|
1343
|
-
*/
|
|
1344
|
-
matchFragment(t, e = 0, n = t.childCount) {
|
|
1345
|
-
let i = this;
|
|
1346
|
-
for (let r = e; i && r < n; r++)
|
|
1347
|
-
i = i.matchType(t.child(r).type);
|
|
1348
|
-
return i;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
@internal
|
|
1352
|
-
*/
|
|
1353
|
-
get inlineContent() {
|
|
1354
|
-
return this.next.length != 0 && this.next[0].type.isInline;
|
|
1355
|
-
}
|
|
1356
|
-
/**
|
|
1357
|
-
Get the first matching node type at this match position that can
|
|
1358
|
-
be generated.
|
|
1359
|
-
*/
|
|
1360
|
-
get defaultType() {
|
|
1361
|
-
for (let t = 0; t < this.next.length; t++) {
|
|
1362
|
-
let { type: e } = this.next[t];
|
|
1363
|
-
if (!(e.isText || e.hasRequiredAttrs()))
|
|
1364
|
-
return e;
|
|
1365
|
-
}
|
|
1366
|
-
return null;
|
|
1367
|
-
}
|
|
1368
|
-
/**
|
|
1369
|
-
@internal
|
|
1370
|
-
*/
|
|
1371
|
-
compatible(t) {
|
|
1372
|
-
for (let e = 0; e < this.next.length; e++)
|
|
1373
|
-
for (let n = 0; n < t.next.length; n++)
|
|
1374
|
-
if (this.next[e].type == t.next[n].type)
|
|
1375
|
-
return !0;
|
|
1376
|
-
return !1;
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
Try to match the given fragment, and if that fails, see if it can
|
|
1380
|
-
be made to match by inserting nodes in front of it. When
|
|
1381
|
-
successful, return a fragment of inserted nodes (which may be
|
|
1382
|
-
empty if nothing had to be inserted). When `toEnd` is true, only
|
|
1383
|
-
return a fragment if the resulting match goes to the end of the
|
|
1384
|
-
content expression.
|
|
1385
|
-
*/
|
|
1386
|
-
fillBefore(t, e = !1, n = 0) {
|
|
1387
|
-
let i = [this];
|
|
1388
|
-
function r(s, o) {
|
|
1389
|
-
let h = s.matchFragment(t, n);
|
|
1390
|
-
if (h && (!e || h.validEnd))
|
|
1391
|
-
return c.from(o.map((a) => a.createAndFill()));
|
|
1392
|
-
for (let a = 0; a < s.next.length; a++) {
|
|
1393
|
-
let { type: f, next: p } = s.next[a];
|
|
1394
|
-
if (!(f.isText || f.hasRequiredAttrs()) && i.indexOf(p) == -1) {
|
|
1395
|
-
i.push(p);
|
|
1396
|
-
let y = r(p, o.concat(f));
|
|
1397
|
-
if (y)
|
|
1398
|
-
return y;
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
return null;
|
|
1402
|
-
}
|
|
1403
|
-
return r(this, []);
|
|
1404
|
-
}
|
|
1405
|
-
/**
|
|
1406
|
-
Find a set of wrapping node types that would allow a node of the
|
|
1407
|
-
given type to appear at this position. The result may be empty
|
|
1408
|
-
(when it fits directly) and will be null when no such wrapping
|
|
1409
|
-
exists.
|
|
1410
|
-
*/
|
|
1411
|
-
findWrapping(t) {
|
|
1412
|
-
for (let n = 0; n < this.wrapCache.length; n += 2)
|
|
1413
|
-
if (this.wrapCache[n] == t)
|
|
1414
|
-
return this.wrapCache[n + 1];
|
|
1415
|
-
let e = this.computeWrapping(t);
|
|
1416
|
-
return this.wrapCache.push(t, e), e;
|
|
1417
|
-
}
|
|
1418
|
-
/**
|
|
1419
|
-
@internal
|
|
1420
|
-
*/
|
|
1421
|
-
computeWrapping(t) {
|
|
1422
|
-
let e = /* @__PURE__ */ Object.create(null), n = [{ match: this, type: null, via: null }];
|
|
1423
|
-
for (; n.length; ) {
|
|
1424
|
-
let i = n.shift(), r = i.match;
|
|
1425
|
-
if (r.matchType(t)) {
|
|
1426
|
-
let s = [];
|
|
1427
|
-
for (let o = i; o.type; o = o.via)
|
|
1428
|
-
s.push(o.type);
|
|
1429
|
-
return s.reverse();
|
|
1430
|
-
}
|
|
1431
|
-
for (let s = 0; s < r.next.length; s++) {
|
|
1432
|
-
let { type: o, next: h } = r.next[s];
|
|
1433
|
-
!o.isLeaf && !o.hasRequiredAttrs() && !(o.name in e) && (!i.type || h.validEnd) && (n.push({ match: o.contentMatch, type: o, via: i }), e[o.name] = !0);
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
return null;
|
|
1437
|
-
}
|
|
1438
|
-
/**
|
|
1439
|
-
The number of outgoing edges this node has in the finite
|
|
1440
|
-
automaton that describes the content expression.
|
|
1441
|
-
*/
|
|
1442
|
-
get edgeCount() {
|
|
1443
|
-
return this.next.length;
|
|
1444
|
-
}
|
|
1445
|
-
/**
|
|
1446
|
-
Get the _n_th outgoing edge from this node in the finite
|
|
1447
|
-
automaton that describes the content expression.
|
|
1448
|
-
*/
|
|
1449
|
-
edge(t) {
|
|
1450
|
-
if (t >= this.next.length)
|
|
1451
|
-
throw new RangeError(`There's no ${t}th edge in this content match`);
|
|
1452
|
-
return this.next[t];
|
|
1453
|
-
}
|
|
1454
|
-
/**
|
|
1455
|
-
@internal
|
|
1456
|
-
*/
|
|
1457
|
-
toString() {
|
|
1458
|
-
let t = [];
|
|
1459
|
-
function e(n) {
|
|
1460
|
-
t.push(n);
|
|
1461
|
-
for (let i = 0; i < n.next.length; i++)
|
|
1462
|
-
t.indexOf(n.next[i].next) == -1 && e(n.next[i].next);
|
|
1463
|
-
}
|
|
1464
|
-
return e(this), t.map((n, i) => {
|
|
1465
|
-
let r = i + (n.validEnd ? "*" : " ") + " ";
|
|
1466
|
-
for (let s = 0; s < n.next.length; s++)
|
|
1467
|
-
r += (s ? ", " : "") + n.next[s].type.name + "->" + t.indexOf(n.next[s].next);
|
|
1468
|
-
return r;
|
|
1469
|
-
}).join(`
|
|
1470
|
-
`);
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
w.empty = new w(!0);
|
|
1474
|
-
class kt {
|
|
1475
|
-
constructor(t, e) {
|
|
1476
|
-
this.string = t, this.nodeTypes = e, this.inline = null, this.pos = 0, this.tokens = t.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
|
|
1477
|
-
}
|
|
1478
|
-
get next() {
|
|
1479
|
-
return this.tokens[this.pos];
|
|
1480
|
-
}
|
|
1481
|
-
eat(t) {
|
|
1482
|
-
return this.next == t && (this.pos++ || !0);
|
|
1483
|
-
}
|
|
1484
|
-
err(t) {
|
|
1485
|
-
throw new SyntaxError(t + " (in content expression '" + this.string + "')");
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
function rt(l) {
|
|
1489
|
-
let t = [];
|
|
1490
|
-
do
|
|
1491
|
-
t.push(St(l));
|
|
1492
|
-
while (l.eat("|"));
|
|
1493
|
-
return t.length == 1 ? t[0] : { type: "choice", exprs: t };
|
|
1494
|
-
}
|
|
1495
|
-
function St(l) {
|
|
1496
|
-
let t = [];
|
|
1497
|
-
do
|
|
1498
|
-
t.push(Et(l));
|
|
1499
|
-
while (l.next && l.next != ")" && l.next != "|");
|
|
1500
|
-
return t.length == 1 ? t[0] : { type: "seq", exprs: t };
|
|
1501
|
-
}
|
|
1502
|
-
function Et(l) {
|
|
1503
|
-
let t = Tt(l);
|
|
1504
|
-
for (; ; )
|
|
1505
|
-
if (l.eat("+"))
|
|
1506
|
-
t = { type: "plus", expr: t };
|
|
1507
|
-
else if (l.eat("*"))
|
|
1508
|
-
t = { type: "star", expr: t };
|
|
1509
|
-
else if (l.eat("?"))
|
|
1510
|
-
t = { type: "opt", expr: t };
|
|
1511
|
-
else if (l.eat("{"))
|
|
1512
|
-
t = Ct(l, t);
|
|
1513
|
-
else
|
|
1514
|
-
break;
|
|
1515
|
-
return t;
|
|
1516
|
-
}
|
|
1517
|
-
function W(l) {
|
|
1518
|
-
/\D/.test(l.next) && l.err("Expected number, got '" + l.next + "'");
|
|
1519
|
-
let t = Number(l.next);
|
|
1520
|
-
return l.pos++, t;
|
|
1521
|
-
}
|
|
1522
|
-
function Ct(l, t) {
|
|
1523
|
-
let e = W(l), n = e;
|
|
1524
|
-
return l.eat(",") && (l.next != "}" ? n = W(l) : n = -1), l.eat("}") || l.err("Unclosed braced range"), { type: "range", min: e, max: n, expr: t };
|
|
1525
|
-
}
|
|
1526
|
-
function Ot(l, t) {
|
|
1527
|
-
let e = l.nodeTypes, n = e[t];
|
|
1528
|
-
if (n)
|
|
1529
|
-
return [n];
|
|
1530
|
-
let i = [];
|
|
1531
|
-
for (let r in e) {
|
|
1532
|
-
let s = e[r];
|
|
1533
|
-
s.isInGroup(t) && i.push(s);
|
|
1534
|
-
}
|
|
1535
|
-
return i.length == 0 && l.err("No node type or group '" + t + "' found"), i;
|
|
1536
|
-
}
|
|
1537
|
-
function Tt(l) {
|
|
1538
|
-
if (l.eat("(")) {
|
|
1539
|
-
let t = rt(l);
|
|
1540
|
-
return l.eat(")") || l.err("Missing closing paren"), t;
|
|
1541
|
-
} else if (/\W/.test(l.next))
|
|
1542
|
-
l.err("Unexpected token '" + l.next + "'");
|
|
1543
|
-
else {
|
|
1544
|
-
let t = Ot(l, l.next).map((e) => (l.inline == null ? l.inline = e.isInline : l.inline != e.isInline && l.err("Mixing inline and block content"), { type: "name", value: e }));
|
|
1545
|
-
return l.pos++, t.length == 1 ? t[0] : { type: "choice", exprs: t };
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
function bt(l) {
|
|
1549
|
-
let t = [[]];
|
|
1550
|
-
return i(r(l, 0), e()), t;
|
|
1551
|
-
function e() {
|
|
1552
|
-
return t.push([]) - 1;
|
|
1553
|
-
}
|
|
1554
|
-
function n(s, o, h) {
|
|
1555
|
-
let a = { term: h, to: o };
|
|
1556
|
-
return t[s].push(a), a;
|
|
1557
|
-
}
|
|
1558
|
-
function i(s, o) {
|
|
1559
|
-
s.forEach((h) => h.to = o);
|
|
1560
|
-
}
|
|
1561
|
-
function r(s, o) {
|
|
1562
|
-
if (s.type == "choice")
|
|
1563
|
-
return s.exprs.reduce((h, a) => h.concat(r(a, o)), []);
|
|
1564
|
-
if (s.type == "seq")
|
|
1565
|
-
for (let h = 0; ; h++) {
|
|
1566
|
-
let a = r(s.exprs[h], o);
|
|
1567
|
-
if (h == s.exprs.length - 1)
|
|
1568
|
-
return a;
|
|
1569
|
-
i(a, o = e());
|
|
1570
|
-
}
|
|
1571
|
-
else if (s.type == "star") {
|
|
1572
|
-
let h = e();
|
|
1573
|
-
return n(o, h), i(r(s.expr, h), h), [n(h)];
|
|
1574
|
-
} else if (s.type == "plus") {
|
|
1575
|
-
let h = e();
|
|
1576
|
-
return i(r(s.expr, o), h), i(r(s.expr, h), h), [n(h)];
|
|
1577
|
-
} else {
|
|
1578
|
-
if (s.type == "opt")
|
|
1579
|
-
return [n(o)].concat(r(s.expr, o));
|
|
1580
|
-
if (s.type == "range") {
|
|
1581
|
-
let h = o;
|
|
1582
|
-
for (let a = 0; a < s.min; a++) {
|
|
1583
|
-
let f = e();
|
|
1584
|
-
i(r(s.expr, h), f), h = f;
|
|
1585
|
-
}
|
|
1586
|
-
if (s.max == -1)
|
|
1587
|
-
i(r(s.expr, h), h);
|
|
1588
|
-
else
|
|
1589
|
-
for (let a = s.min; a < s.max; a++) {
|
|
1590
|
-
let f = e();
|
|
1591
|
-
n(h, f), i(r(s.expr, h), f), h = f;
|
|
1592
|
-
}
|
|
1593
|
-
return [n(h)];
|
|
1594
|
-
} else {
|
|
1595
|
-
if (s.type == "name")
|
|
1596
|
-
return [n(o, void 0, s.value)];
|
|
1597
|
-
throw new Error("Unknown expr type");
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
function st(l, t) {
|
|
1603
|
-
return t - l;
|
|
1604
|
-
}
|
|
1605
|
-
function j(l, t) {
|
|
1606
|
-
let e = [];
|
|
1607
|
-
return n(t), e.sort(st);
|
|
1608
|
-
function n(i) {
|
|
1609
|
-
let r = l[i];
|
|
1610
|
-
if (r.length == 1 && !r[0].term)
|
|
1611
|
-
return n(r[0].to);
|
|
1612
|
-
e.push(i);
|
|
1613
|
-
for (let s = 0; s < r.length; s++) {
|
|
1614
|
-
let { term: o, to: h } = r[s];
|
|
1615
|
-
!o && e.indexOf(h) == -1 && n(h);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
function Mt(l) {
|
|
1620
|
-
let t = /* @__PURE__ */ Object.create(null);
|
|
1621
|
-
return e(j(l, 0));
|
|
1622
|
-
function e(n) {
|
|
1623
|
-
let i = [];
|
|
1624
|
-
n.forEach((s) => {
|
|
1625
|
-
l[s].forEach(({ term: o, to: h }) => {
|
|
1626
|
-
if (!o)
|
|
1627
|
-
return;
|
|
1628
|
-
let a;
|
|
1629
|
-
for (let f = 0; f < i.length; f++)
|
|
1630
|
-
i[f][0] == o && (a = i[f][1]);
|
|
1631
|
-
j(l, h).forEach((f) => {
|
|
1632
|
-
a || i.push([o, a = []]), a.indexOf(f) == -1 && a.push(f);
|
|
1633
|
-
});
|
|
1634
|
-
});
|
|
1635
|
-
});
|
|
1636
|
-
let r = t[n.join(",")] = new w(n.indexOf(l.length - 1) > -1);
|
|
1637
|
-
for (let s = 0; s < i.length; s++) {
|
|
1638
|
-
let o = i[s][1].sort(st);
|
|
1639
|
-
r.next.push({ type: i[s][0], next: t[o.join(",")] || e(o) });
|
|
1640
|
-
}
|
|
1641
|
-
return r;
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
function At(l, t) {
|
|
1645
|
-
for (let e = 0, n = [l]; e < n.length; e++) {
|
|
1646
|
-
let i = n[e], r = !i.validEnd, s = [];
|
|
1647
|
-
for (let o = 0; o < i.next.length; o++) {
|
|
1648
|
-
let { type: h, next: a } = i.next[o];
|
|
1649
|
-
s.push(h.name), r && !(h.isText || h.hasRequiredAttrs()) && (r = !1), n.indexOf(a) == -1 && n.push(a);
|
|
1650
|
-
}
|
|
1651
|
-
r && t.err("Only non-generatable nodes (" + s.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
function lt(l) {
|
|
1655
|
-
let t = /* @__PURE__ */ Object.create(null);
|
|
1656
|
-
for (let e in l) {
|
|
1657
|
-
let n = l[e];
|
|
1658
|
-
if (!n.hasDefault)
|
|
1659
|
-
return null;
|
|
1660
|
-
t[e] = n.default;
|
|
1661
|
-
}
|
|
1662
|
-
return t;
|
|
1663
|
-
}
|
|
1664
|
-
function ot(l, t) {
|
|
1665
|
-
let e = /* @__PURE__ */ Object.create(null);
|
|
1666
|
-
for (let n in l) {
|
|
1667
|
-
let i = t && t[n];
|
|
1668
|
-
if (i === void 0) {
|
|
1669
|
-
let r = l[n];
|
|
1670
|
-
if (r.hasDefault)
|
|
1671
|
-
i = r.default;
|
|
1672
|
-
else
|
|
1673
|
-
throw new RangeError("No value supplied for attribute " + n);
|
|
1674
|
-
}
|
|
1675
|
-
e[n] = i;
|
|
1676
|
-
}
|
|
1677
|
-
return e;
|
|
1678
|
-
}
|
|
1679
|
-
function ht(l, t, e, n) {
|
|
1680
|
-
for (let i in t)
|
|
1681
|
-
if (!(i in l))
|
|
1682
|
-
throw new RangeError(`Unsupported attribute ${i} for ${e} of type ${i}`);
|
|
1683
|
-
for (let i in l) {
|
|
1684
|
-
let r = l[i];
|
|
1685
|
-
r.validate && r.validate(t[i]);
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
function at(l, t) {
|
|
1689
|
-
let e = /* @__PURE__ */ Object.create(null);
|
|
1690
|
-
if (t)
|
|
1691
|
-
for (let n in t)
|
|
1692
|
-
e[n] = new vt(l, n, t[n]);
|
|
1693
|
-
return e;
|
|
1694
|
-
}
|
|
1695
|
-
class v {
|
|
1696
|
-
/**
|
|
1697
|
-
@internal
|
|
1698
|
-
*/
|
|
1699
|
-
constructor(t, e, n) {
|
|
1700
|
-
this.name = t, this.schema = e, this.spec = n, this.markSet = null, this.groups = n.group ? n.group.split(" ") : [], this.attrs = at(t, n.attrs), this.defaultAttrs = lt(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(n.inline || t == "text"), this.isText = t == "text";
|
|
1701
|
-
}
|
|
1702
|
-
/**
|
|
1703
|
-
True if this is an inline type.
|
|
1704
|
-
*/
|
|
1705
|
-
get isInline() {
|
|
1706
|
-
return !this.isBlock;
|
|
1707
|
-
}
|
|
1708
|
-
/**
|
|
1709
|
-
True if this is a textblock type, a block that contains inline
|
|
1710
|
-
content.
|
|
1711
|
-
*/
|
|
1712
|
-
get isTextblock() {
|
|
1713
|
-
return this.isBlock && this.inlineContent;
|
|
1714
|
-
}
|
|
1715
|
-
/**
|
|
1716
|
-
True for node types that allow no content.
|
|
1717
|
-
*/
|
|
1718
|
-
get isLeaf() {
|
|
1719
|
-
return this.contentMatch == w.empty;
|
|
1720
|
-
}
|
|
1721
|
-
/**
|
|
1722
|
-
True when this node is an atom, i.e. when it does not have
|
|
1723
|
-
directly editable content.
|
|
1724
|
-
*/
|
|
1725
|
-
get isAtom() {
|
|
1726
|
-
return this.isLeaf || !!this.spec.atom;
|
|
1727
|
-
}
|
|
1728
|
-
/**
|
|
1729
|
-
Return true when this node type is part of the given
|
|
1730
|
-
[group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
|
|
1731
|
-
*/
|
|
1732
|
-
isInGroup(t) {
|
|
1733
|
-
return this.groups.indexOf(t) > -1;
|
|
1734
|
-
}
|
|
1735
|
-
/**
|
|
1736
|
-
The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
|
|
1737
|
-
*/
|
|
1738
|
-
get whitespace() {
|
|
1739
|
-
return this.spec.whitespace || (this.spec.code ? "pre" : "normal");
|
|
1740
|
-
}
|
|
1741
|
-
/**
|
|
1742
|
-
Tells you whether this node type has any required attributes.
|
|
1743
|
-
*/
|
|
1744
|
-
hasRequiredAttrs() {
|
|
1745
|
-
for (let t in this.attrs)
|
|
1746
|
-
if (this.attrs[t].isRequired)
|
|
1747
|
-
return !0;
|
|
1748
|
-
return !1;
|
|
1749
|
-
}
|
|
1750
|
-
/**
|
|
1751
|
-
Indicates whether this node allows some of the same content as
|
|
1752
|
-
the given node type.
|
|
1753
|
-
*/
|
|
1754
|
-
compatibleContent(t) {
|
|
1755
|
-
return this == t || this.contentMatch.compatible(t.contentMatch);
|
|
1756
|
-
}
|
|
1757
|
-
/**
|
|
1758
|
-
@internal
|
|
1759
|
-
*/
|
|
1760
|
-
computeAttrs(t) {
|
|
1761
|
-
return !t && this.defaultAttrs ? this.defaultAttrs : ot(this.attrs, t);
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
Create a `Node` of this type. The given attributes are
|
|
1765
|
-
checked and defaulted (you can pass `null` to use the type's
|
|
1766
|
-
defaults entirely, if no required attributes exist). `content`
|
|
1767
|
-
may be a `Fragment`, a node, an array of nodes, or
|
|
1768
|
-
`null`. Similarly `marks` may be `null` to default to the empty
|
|
1769
|
-
set of marks.
|
|
1770
|
-
*/
|
|
1771
|
-
create(t = null, e, n) {
|
|
1772
|
-
if (this.isText)
|
|
1773
|
-
throw new Error("NodeType.create can't construct text nodes");
|
|
1774
|
-
return new g(this, this.computeAttrs(t), c.from(e), u.setFrom(n));
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
1778
|
-
against the node type's content restrictions, and throw an error
|
|
1779
|
-
if it doesn't match.
|
|
1780
|
-
*/
|
|
1781
|
-
createChecked(t = null, e, n) {
|
|
1782
|
-
return e = c.from(e), this.checkContent(e), new g(this, this.computeAttrs(t), e, u.setFrom(n));
|
|
1783
|
-
}
|
|
1784
|
-
/**
|
|
1785
|
-
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
1786
|
-
necessary to add nodes to the start or end of the given fragment
|
|
1787
|
-
to make it fit the node. If no fitting wrapping can be found,
|
|
1788
|
-
return null. Note that, due to the fact that required nodes can
|
|
1789
|
-
always be created, this will always succeed if you pass null or
|
|
1790
|
-
`Fragment.empty` as content.
|
|
1791
|
-
*/
|
|
1792
|
-
createAndFill(t = null, e, n) {
|
|
1793
|
-
if (t = this.computeAttrs(t), e = c.from(e), e.size) {
|
|
1794
|
-
let s = this.contentMatch.fillBefore(e);
|
|
1795
|
-
if (!s)
|
|
1796
|
-
return null;
|
|
1797
|
-
e = s.append(e);
|
|
1798
|
-
}
|
|
1799
|
-
let i = this.contentMatch.matchFragment(e), r = i && i.fillBefore(c.empty, !0);
|
|
1800
|
-
return r ? new g(this, t, e.append(r), u.setFrom(n)) : null;
|
|
1801
|
-
}
|
|
1802
|
-
/**
|
|
1803
|
-
Returns true if the given fragment is valid content for this node
|
|
1804
|
-
type.
|
|
1805
|
-
*/
|
|
1806
|
-
validContent(t) {
|
|
1807
|
-
let e = this.contentMatch.matchFragment(t);
|
|
1808
|
-
if (!e || !e.validEnd)
|
|
1809
|
-
return !1;
|
|
1810
|
-
for (let n = 0; n < t.childCount; n++)
|
|
1811
|
-
if (!this.allowsMarks(t.child(n).marks))
|
|
1812
|
-
return !1;
|
|
1813
|
-
return !0;
|
|
1814
|
-
}
|
|
1815
|
-
/**
|
|
1816
|
-
Throws a RangeError if the given fragment is not valid content for this
|
|
1817
|
-
node type.
|
|
1818
|
-
@internal
|
|
1819
|
-
*/
|
|
1820
|
-
checkContent(t) {
|
|
1821
|
-
if (!this.validContent(t))
|
|
1822
|
-
throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0, 50)}`);
|
|
1823
|
-
}
|
|
1824
|
-
/**
|
|
1825
|
-
@internal
|
|
1826
|
-
*/
|
|
1827
|
-
checkAttrs(t) {
|
|
1828
|
-
ht(this.attrs, t, "node", this.name);
|
|
1829
|
-
}
|
|
1830
|
-
/**
|
|
1831
|
-
Check whether the given mark type is allowed in this node.
|
|
1832
|
-
*/
|
|
1833
|
-
allowsMarkType(t) {
|
|
1834
|
-
return this.markSet == null || this.markSet.indexOf(t) > -1;
|
|
1835
|
-
}
|
|
1836
|
-
/**
|
|
1837
|
-
Test whether the given set of marks are allowed in this node.
|
|
1838
|
-
*/
|
|
1839
|
-
allowsMarks(t) {
|
|
1840
|
-
if (this.markSet == null)
|
|
1841
|
-
return !0;
|
|
1842
|
-
for (let e = 0; e < t.length; e++)
|
|
1843
|
-
if (!this.allowsMarkType(t[e].type))
|
|
1844
|
-
return !1;
|
|
1845
|
-
return !0;
|
|
1846
|
-
}
|
|
1847
|
-
/**
|
|
1848
|
-
Removes the marks that are not allowed in this node from the given set.
|
|
1849
|
-
*/
|
|
1850
|
-
allowedMarks(t) {
|
|
1851
|
-
if (this.markSet == null)
|
|
1852
|
-
return t;
|
|
1853
|
-
let e;
|
|
1854
|
-
for (let n = 0; n < t.length; n++)
|
|
1855
|
-
this.allowsMarkType(t[n].type) ? e && e.push(t[n]) : e || (e = t.slice(0, n));
|
|
1856
|
-
return e ? e.length ? e : u.none : t;
|
|
1857
|
-
}
|
|
1858
|
-
/**
|
|
1859
|
-
@internal
|
|
1860
|
-
*/
|
|
1861
|
-
static compile(t, e) {
|
|
1862
|
-
let n = /* @__PURE__ */ Object.create(null);
|
|
1863
|
-
t.forEach((r, s) => n[r] = new v(r, e, s));
|
|
1864
|
-
let i = e.spec.topNode || "doc";
|
|
1865
|
-
if (!n[i])
|
|
1866
|
-
throw new RangeError("Schema is missing its top node type ('" + i + "')");
|
|
1867
|
-
if (!n.text)
|
|
1868
|
-
throw new RangeError("Every schema needs a 'text' type");
|
|
1869
|
-
for (let r in n.text.attrs)
|
|
1870
|
-
throw new RangeError("The text node type should not have attributes");
|
|
1871
|
-
return n;
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
function zt(l, t, e) {
|
|
1875
|
-
let n = e.split("|");
|
|
1876
|
-
return (i) => {
|
|
1877
|
-
let r = i === null ? "null" : typeof i;
|
|
1878
|
-
if (n.indexOf(r) < 0)
|
|
1879
|
-
throw new RangeError(`Expected value of type ${n} for attribute ${t} on type ${l}, got ${r}`);
|
|
1880
|
-
};
|
|
1881
|
-
}
|
|
1882
|
-
class vt {
|
|
1883
|
-
constructor(t, e, n) {
|
|
1884
|
-
this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default"), this.default = n.default, this.validate = typeof n.validate == "string" ? zt(t, e, n.validate) : n.validate;
|
|
1885
|
-
}
|
|
1886
|
-
get isRequired() {
|
|
1887
|
-
return !this.hasDefault;
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
class F {
|
|
1891
|
-
/**
|
|
1892
|
-
@internal
|
|
1893
|
-
*/
|
|
1894
|
-
constructor(t, e, n, i) {
|
|
1895
|
-
this.name = t, this.rank = e, this.schema = n, this.spec = i, this.attrs = at(t, i.attrs), this.excluded = null;
|
|
1896
|
-
let r = lt(this.attrs);
|
|
1897
|
-
this.instance = r ? new u(this, r) : null;
|
|
1898
|
-
}
|
|
1899
|
-
/**
|
|
1900
|
-
Create a mark of this type. `attrs` may be `null` or an object
|
|
1901
|
-
containing only some of the mark's attributes. The others, if
|
|
1902
|
-
they have defaults, will be added.
|
|
1903
|
-
*/
|
|
1904
|
-
create(t = null) {
|
|
1905
|
-
return !t && this.instance ? this.instance : new u(this, ot(this.attrs, t));
|
|
1906
|
-
}
|
|
1907
|
-
/**
|
|
1908
|
-
@internal
|
|
1909
|
-
*/
|
|
1910
|
-
static compile(t, e) {
|
|
1911
|
-
let n = /* @__PURE__ */ Object.create(null), i = 0;
|
|
1912
|
-
return t.forEach((r, s) => n[r] = new F(r, i++, e, s)), n;
|
|
1913
|
-
}
|
|
1914
|
-
/**
|
|
1915
|
-
When there is a mark of this type in the given set, a new set
|
|
1916
|
-
without it is returned. Otherwise, the input set is returned.
|
|
1917
|
-
*/
|
|
1918
|
-
removeFromSet(t) {
|
|
1919
|
-
for (var e = 0; e < t.length; e++)
|
|
1920
|
-
t[e].type == this && (t = t.slice(0, e).concat(t.slice(e + 1)), e--);
|
|
1921
|
-
return t;
|
|
1922
|
-
}
|
|
1923
|
-
/**
|
|
1924
|
-
Tests whether there is a mark of this type in the given set.
|
|
1925
|
-
*/
|
|
1926
|
-
isInSet(t) {
|
|
1927
|
-
for (let e = 0; e < t.length; e++)
|
|
1928
|
-
if (t[e].type == this)
|
|
1929
|
-
return t[e];
|
|
1930
|
-
}
|
|
1931
|
-
/**
|
|
1932
|
-
@internal
|
|
1933
|
-
*/
|
|
1934
|
-
checkAttrs(t) {
|
|
1935
|
-
ht(this.attrs, t, "mark", this.name);
|
|
1936
|
-
}
|
|
1937
|
-
/**
|
|
1938
|
-
Queries whether a given mark type is
|
|
1939
|
-
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
|
|
1940
|
-
*/
|
|
1941
|
-
excludes(t) {
|
|
1942
|
-
return this.excluded.indexOf(t) > -1;
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
class qt {
|
|
1946
|
-
/**
|
|
1947
|
-
Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
|
|
1948
|
-
*/
|
|
1949
|
-
constructor(t) {
|
|
1950
|
-
this.linebreakReplacement = null, this.cached = /* @__PURE__ */ Object.create(null);
|
|
1951
|
-
let e = this.spec = {};
|
|
1952
|
-
for (let i in t)
|
|
1953
|
-
e[i] = t[i];
|
|
1954
|
-
e.nodes = q.from(t.nodes), e.marks = q.from(t.marks || {}), this.nodes = v.compile(this.spec.nodes, this), this.marks = F.compile(this.spec.marks, this);
|
|
1955
|
-
let n = /* @__PURE__ */ Object.create(null);
|
|
1956
|
-
for (let i in this.nodes) {
|
|
1957
|
-
if (i in this.marks)
|
|
1958
|
-
throw new RangeError(i + " can not be both a node and a mark");
|
|
1959
|
-
let r = this.nodes[i], s = r.spec.content || "", o = r.spec.marks;
|
|
1960
|
-
if (r.contentMatch = n[s] || (n[s] = w.parse(s, this.nodes)), r.inlineContent = r.contentMatch.inlineContent, r.spec.linebreakReplacement) {
|
|
1961
|
-
if (this.linebreakReplacement)
|
|
1962
|
-
throw new RangeError("Multiple linebreak nodes defined");
|
|
1963
|
-
if (!r.isInline || !r.isLeaf)
|
|
1964
|
-
throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
|
|
1965
|
-
this.linebreakReplacement = r;
|
|
1966
|
-
}
|
|
1967
|
-
r.markSet = o == "_" ? null : o ? U(this, o.split(" ")) : o == "" || !r.inlineContent ? [] : null;
|
|
1968
|
-
}
|
|
1969
|
-
for (let i in this.marks) {
|
|
1970
|
-
let r = this.marks[i], s = r.spec.excludes;
|
|
1971
|
-
r.excluded = s == null ? [r] : s == "" ? [] : U(this, s.split(" "));
|
|
1972
|
-
}
|
|
1973
|
-
this.nodeFromJSON = (i) => g.fromJSON(this, i), this.markFromJSON = (i) => u.fromJSON(this, i), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = /* @__PURE__ */ Object.create(null);
|
|
1974
|
-
}
|
|
1975
|
-
/**
|
|
1976
|
-
Create a node in this schema. The `type` may be a string or a
|
|
1977
|
-
`NodeType` instance. Attributes will be extended with defaults,
|
|
1978
|
-
`content` may be a `Fragment`, `null`, a `Node`, or an array of
|
|
1979
|
-
nodes.
|
|
1980
|
-
*/
|
|
1981
|
-
node(t, e = null, n, i) {
|
|
1982
|
-
if (typeof t == "string")
|
|
1983
|
-
t = this.nodeType(t);
|
|
1984
|
-
else if (t instanceof v) {
|
|
1985
|
-
if (t.schema != this)
|
|
1986
|
-
throw new RangeError("Node type from different schema used (" + t.name + ")");
|
|
1987
|
-
} else throw new RangeError("Invalid node type: " + t);
|
|
1988
|
-
return t.createChecked(e, n, i);
|
|
1989
|
-
}
|
|
1990
|
-
/**
|
|
1991
|
-
Create a text node in the schema. Empty text nodes are not
|
|
1992
|
-
allowed.
|
|
1993
|
-
*/
|
|
1994
|
-
text(t, e) {
|
|
1995
|
-
let n = this.nodes.text;
|
|
1996
|
-
return new z(n, n.defaultAttrs, t, u.setFrom(e));
|
|
1997
|
-
}
|
|
1998
|
-
/**
|
|
1999
|
-
Create a mark with the given type and attributes.
|
|
2000
|
-
*/
|
|
2001
|
-
mark(t, e) {
|
|
2002
|
-
return typeof t == "string" && (t = this.marks[t]), t.create(e);
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
@internal
|
|
2006
|
-
*/
|
|
2007
|
-
nodeType(t) {
|
|
2008
|
-
let e = this.nodes[t];
|
|
2009
|
-
if (!e)
|
|
2010
|
-
throw new RangeError("Unknown node type: " + t);
|
|
2011
|
-
return e;
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
function U(l, t) {
|
|
2015
|
-
let e = [];
|
|
2016
|
-
for (let n = 0; n < t.length; n++) {
|
|
2017
|
-
let i = t[n], r = l.marks[i], s = r;
|
|
2018
|
-
if (r)
|
|
2019
|
-
e.push(r);
|
|
2020
|
-
else
|
|
2021
|
-
for (let o in l.marks) {
|
|
2022
|
-
let h = l.marks[o];
|
|
2023
|
-
(i == "_" || h.spec.group && h.spec.group.split(" ").indexOf(i) > -1) && e.push(s = h);
|
|
2024
|
-
}
|
|
2025
|
-
if (!s)
|
|
2026
|
-
throw new SyntaxError("Unknown mark type: '" + t[n] + "'");
|
|
2027
|
-
}
|
|
2028
|
-
return e;
|
|
2029
|
-
}
|
|
2030
|
-
function Nt(l) {
|
|
2031
|
-
return l.tag != null;
|
|
2032
|
-
}
|
|
2033
|
-
function Rt(l) {
|
|
2034
|
-
return l.style != null;
|
|
2035
|
-
}
|
|
2036
|
-
class P {
|
|
2037
|
-
/**
|
|
2038
|
-
Create a parser that targets the given schema, using the given
|
|
2039
|
-
parsing rules.
|
|
2040
|
-
*/
|
|
2041
|
-
constructor(t, e) {
|
|
2042
|
-
this.schema = t, this.rules = e, this.tags = [], this.styles = [];
|
|
2043
|
-
let n = this.matchedStyles = [];
|
|
2044
|
-
e.forEach((i) => {
|
|
2045
|
-
if (Nt(i))
|
|
2046
|
-
this.tags.push(i);
|
|
2047
|
-
else if (Rt(i)) {
|
|
2048
|
-
let r = /[^=]*/.exec(i.style)[0];
|
|
2049
|
-
n.indexOf(r) < 0 && n.push(r), this.styles.push(i);
|
|
2050
|
-
}
|
|
2051
|
-
}), this.normalizeLists = !this.tags.some((i) => {
|
|
2052
|
-
if (!/^(ul|ol)\b/.test(i.tag) || !i.node)
|
|
2053
|
-
return !1;
|
|
2054
|
-
let r = t.nodes[i.node];
|
|
2055
|
-
return r.contentMatch.matchType(r);
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
/**
|
|
2059
|
-
Parse a document from the content of a DOM node.
|
|
2060
|
-
*/
|
|
2061
|
-
parse(t, e = {}) {
|
|
2062
|
-
let n = new G(this, e, !1);
|
|
2063
|
-
return n.addAll(t, u.none, e.from, e.to), n.finish();
|
|
2064
|
-
}
|
|
2065
|
-
/**
|
|
2066
|
-
Parses the content of the given DOM node, like
|
|
2067
|
-
[`parse`](https://prosemirror.net/docs/ref/#model.DOMParser.parse), and takes the same set of
|
|
2068
|
-
options. But unlike that method, which produces a whole node,
|
|
2069
|
-
this one returns a slice that is open at the sides, meaning that
|
|
2070
|
-
the schema constraints aren't applied to the start of nodes to
|
|
2071
|
-
the left of the input and the end of nodes at the end.
|
|
2072
|
-
*/
|
|
2073
|
-
parseSlice(t, e = {}) {
|
|
2074
|
-
let n = new G(this, e, !0);
|
|
2075
|
-
return n.addAll(t, u.none, e.from, e.to), d.maxOpen(n.finish());
|
|
2076
|
-
}
|
|
2077
|
-
/**
|
|
2078
|
-
@internal
|
|
2079
|
-
*/
|
|
2080
|
-
matchTag(t, e, n) {
|
|
2081
|
-
for (let i = n ? this.tags.indexOf(n) + 1 : 0; i < this.tags.length; i++) {
|
|
2082
|
-
let r = this.tags[i];
|
|
2083
|
-
if (Pt(t, r.tag) && (r.namespace === void 0 || t.namespaceURI == r.namespace) && (!r.context || e.matchesContext(r.context))) {
|
|
2084
|
-
if (r.getAttrs) {
|
|
2085
|
-
let s = r.getAttrs(t);
|
|
2086
|
-
if (s === !1)
|
|
2087
|
-
continue;
|
|
2088
|
-
r.attrs = s || void 0;
|
|
2089
|
-
}
|
|
2090
|
-
return r;
|
|
2091
|
-
}
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
@internal
|
|
2096
|
-
*/
|
|
2097
|
-
matchStyle(t, e, n, i) {
|
|
2098
|
-
for (let r = i ? this.styles.indexOf(i) + 1 : 0; r < this.styles.length; r++) {
|
|
2099
|
-
let s = this.styles[r], o = s.style;
|
|
2100
|
-
if (!(o.indexOf(t) != 0 || s.context && !n.matchesContext(s.context) || // Test that the style string either precisely matches the prop,
|
|
2101
|
-
// or has an '=' sign after the prop, followed by the given
|
|
2102
|
-
// value.
|
|
2103
|
-
o.length > t.length && (o.charCodeAt(t.length) != 61 || o.slice(t.length + 1) != e))) {
|
|
2104
|
-
if (s.getAttrs) {
|
|
2105
|
-
let h = s.getAttrs(e);
|
|
2106
|
-
if (h === !1)
|
|
2107
|
-
continue;
|
|
2108
|
-
s.attrs = h || void 0;
|
|
2109
|
-
}
|
|
2110
|
-
return s;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
1449
|
+
setDocAttribute(e, t) {
|
|
1450
|
+
return this.step(new z(e, t)), this;
|
|
2113
1451
|
}
|
|
2114
1452
|
/**
|
|
2115
|
-
|
|
1453
|
+
Add a mark to the node at position `pos`.
|
|
2116
1454
|
*/
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
function n(i) {
|
|
2120
|
-
let r = i.priority == null ? 50 : i.priority, s = 0;
|
|
2121
|
-
for (; s < e.length; s++) {
|
|
2122
|
-
let o = e[s];
|
|
2123
|
-
if ((o.priority == null ? 50 : o.priority) < r)
|
|
2124
|
-
break;
|
|
2125
|
-
}
|
|
2126
|
-
e.splice(s, 0, i);
|
|
2127
|
-
}
|
|
2128
|
-
for (let i in t.marks) {
|
|
2129
|
-
let r = t.marks[i].spec.parseDOM;
|
|
2130
|
-
r && r.forEach((s) => {
|
|
2131
|
-
n(s = H(s)), s.mark || s.ignore || s.clearMark || (s.mark = i);
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
for (let i in t.nodes) {
|
|
2135
|
-
let r = t.nodes[i].spec.parseDOM;
|
|
2136
|
-
r && r.forEach((s) => {
|
|
2137
|
-
n(s = H(s)), s.node || s.ignore || s.mark || (s.node = i);
|
|
2138
|
-
});
|
|
2139
|
-
}
|
|
2140
|
-
return e;
|
|
1455
|
+
addNodeMark(e, t) {
|
|
1456
|
+
return this.step(new N(e, t)), this;
|
|
2141
1457
|
}
|
|
2142
1458
|
/**
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
[priority](https://prosemirror.net/docs/ref/#model.GenericParseRule.priority).
|
|
1459
|
+
Remove a mark (or all marks of the given type) from the node at
|
|
1460
|
+
position `pos`.
|
|
2146
1461
|
*/
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
article: !0,
|
|
2154
|
-
aside: !0,
|
|
2155
|
-
blockquote: !0,
|
|
2156
|
-
canvas: !0,
|
|
2157
|
-
dd: !0,
|
|
2158
|
-
div: !0,
|
|
2159
|
-
dl: !0,
|
|
2160
|
-
fieldset: !0,
|
|
2161
|
-
figcaption: !0,
|
|
2162
|
-
figure: !0,
|
|
2163
|
-
footer: !0,
|
|
2164
|
-
form: !0,
|
|
2165
|
-
h1: !0,
|
|
2166
|
-
h2: !0,
|
|
2167
|
-
h3: !0,
|
|
2168
|
-
h4: !0,
|
|
2169
|
-
h5: !0,
|
|
2170
|
-
h6: !0,
|
|
2171
|
-
header: !0,
|
|
2172
|
-
hgroup: !0,
|
|
2173
|
-
hr: !0,
|
|
2174
|
-
li: !0,
|
|
2175
|
-
noscript: !0,
|
|
2176
|
-
ol: !0,
|
|
2177
|
-
output: !0,
|
|
2178
|
-
p: !0,
|
|
2179
|
-
pre: !0,
|
|
2180
|
-
section: !0,
|
|
2181
|
-
table: !0,
|
|
2182
|
-
tfoot: !0,
|
|
2183
|
-
ul: !0
|
|
2184
|
-
}, It = {
|
|
2185
|
-
head: !0,
|
|
2186
|
-
noscript: !0,
|
|
2187
|
-
object: !0,
|
|
2188
|
-
script: !0,
|
|
2189
|
-
style: !0,
|
|
2190
|
-
title: !0
|
|
2191
|
-
}, ct = { ol: !0, ul: !0 }, C = 1, B = 2, S = 4;
|
|
2192
|
-
function V(l, t, e) {
|
|
2193
|
-
return t != null ? (t ? C : 0) | (t === "full" ? B : 0) : l && l.whitespace == "pre" ? C | B : e & ~S;
|
|
2194
|
-
}
|
|
2195
|
-
class T {
|
|
2196
|
-
constructor(t, e, n, i, r, s) {
|
|
2197
|
-
this.type = t, this.attrs = e, this.marks = n, this.solid = i, this.options = s, this.content = [], this.activeMarks = u.none, this.match = r || (s & S ? null : t.contentMatch);
|
|
2198
|
-
}
|
|
2199
|
-
findWrapping(t) {
|
|
2200
|
-
if (!this.match) {
|
|
2201
|
-
if (!this.type)
|
|
2202
|
-
return [];
|
|
2203
|
-
let e = this.type.contentMatch.fillBefore(c.from(t));
|
|
2204
|
-
if (e)
|
|
2205
|
-
this.match = this.type.contentMatch.matchFragment(e);
|
|
2206
|
-
else {
|
|
2207
|
-
let n = this.type.contentMatch, i;
|
|
2208
|
-
return (i = n.findWrapping(t.type)) ? (this.match = n, i) : null;
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
return this.match.findWrapping(t.type);
|
|
2212
|
-
}
|
|
2213
|
-
finish(t) {
|
|
2214
|
-
if (!(this.options & C)) {
|
|
2215
|
-
let n = this.content[this.content.length - 1], i;
|
|
2216
|
-
if (n && n.isText && (i = /[ \t\r\n\u000c]+$/.exec(n.text))) {
|
|
2217
|
-
let r = n;
|
|
2218
|
-
n.text.length == i[0].length ? this.content.pop() : this.content[this.content.length - 1] = r.withText(r.text.slice(0, r.text.length - i[0].length));
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
let e = c.from(this.content);
|
|
2222
|
-
return !t && this.match && (e = e.append(this.match.fillBefore(c.empty, !0))), this.type ? this.type.create(this.attrs, e, this.marks) : e;
|
|
2223
|
-
}
|
|
2224
|
-
inlineContext(t) {
|
|
2225
|
-
return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : t.parentNode && !ft.hasOwnProperty(t.parentNode.nodeName.toLowerCase());
|
|
2226
|
-
}
|
|
2227
|
-
}
|
|
2228
|
-
class G {
|
|
2229
|
-
constructor(t, e, n) {
|
|
2230
|
-
this.parser = t, this.options = e, this.isOpen = n, this.open = 0, this.localPreserveWS = !1;
|
|
2231
|
-
let i = e.topNode, r, s = V(null, e.preserveWhitespace, 0) | (n ? S : 0);
|
|
2232
|
-
i ? r = new T(i.type, i.attrs, u.none, !0, e.topMatch || i.type.contentMatch, s) : n ? r = new T(null, null, u.none, !0, null, s) : r = new T(t.schema.topNodeType, null, u.none, !0, null, s), this.nodes = [r], this.find = e.findPositions, this.needsBlock = !1;
|
|
2233
|
-
}
|
|
2234
|
-
get top() {
|
|
2235
|
-
return this.nodes[this.open];
|
|
2236
|
-
}
|
|
2237
|
-
// Add a DOM node to the content. Text is inserted as text node,
|
|
2238
|
-
// otherwise, the node is passed to `addElement` or, if it has a
|
|
2239
|
-
// `style` attribute, `addElementWithStyles`.
|
|
2240
|
-
addDOM(t, e) {
|
|
2241
|
-
t.nodeType == 3 ? this.addTextNode(t, e) : t.nodeType == 1 && this.addElement(t, e);
|
|
2242
|
-
}
|
|
2243
|
-
addTextNode(t, e) {
|
|
2244
|
-
let n = t.nodeValue, i = this.top, r = i.options & B ? "full" : this.localPreserveWS || (i.options & C) > 0, { schema: s } = this.parser;
|
|
2245
|
-
if (r === "full" || i.inlineContext(t) || /[^ \t\r\n\u000c]/.test(n)) {
|
|
2246
|
-
if (r)
|
|
2247
|
-
if (r === "full")
|
|
2248
|
-
n = n.replace(/\r\n?/g, `
|
|
2249
|
-
`);
|
|
2250
|
-
else if (s.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(s.linebreakReplacement.create())) {
|
|
2251
|
-
let o = n.split(/\r?\n|\r/);
|
|
2252
|
-
for (let h = 0; h < o.length; h++)
|
|
2253
|
-
h && this.insertNode(s.linebreakReplacement.create(), e, !0), o[h] && this.insertNode(s.text(o[h]), e, !/\S/.test(o[h]));
|
|
2254
|
-
n = "";
|
|
2255
|
-
} else
|
|
2256
|
-
n = n.replace(/\r?\n|\r/g, " ");
|
|
2257
|
-
else if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
|
|
2258
|
-
let o = i.content[i.content.length - 1], h = t.previousSibling;
|
|
2259
|
-
(!o || h && h.nodeName == "BR" || o.isText && /[ \t\r\n\u000c]$/.test(o.text)) && (n = n.slice(1));
|
|
2260
|
-
}
|
|
2261
|
-
n && this.insertNode(s.text(n), e, !/\S/.test(n)), this.findInText(t);
|
|
2262
|
-
} else
|
|
2263
|
-
this.findInside(t);
|
|
2264
|
-
}
|
|
2265
|
-
// Try to find a handler for the given tag and use that to parse. If
|
|
2266
|
-
// none is found, the element's content nodes are added directly.
|
|
2267
|
-
addElement(t, e, n) {
|
|
2268
|
-
let i = this.localPreserveWS, r = this.top;
|
|
2269
|
-
(t.tagName == "PRE" || /pre/.test(t.style && t.style.whiteSpace)) && (this.localPreserveWS = !0);
|
|
2270
|
-
let s = t.nodeName.toLowerCase(), o;
|
|
2271
|
-
ct.hasOwnProperty(s) && this.parser.normalizeLists && Dt(t);
|
|
2272
|
-
let h = this.options.ruleFromNode && this.options.ruleFromNode(t) || (o = this.parser.matchTag(t, this, n));
|
|
2273
|
-
t: if (h ? h.ignore : It.hasOwnProperty(s))
|
|
2274
|
-
this.findInside(t), this.ignoreFallback(t, e);
|
|
2275
|
-
else if (!h || h.skip || h.closeParent) {
|
|
2276
|
-
h && h.closeParent ? this.open = Math.max(0, this.open - 1) : h && h.skip.nodeType && (t = h.skip);
|
|
2277
|
-
let a, f = this.needsBlock;
|
|
2278
|
-
if (ft.hasOwnProperty(s))
|
|
2279
|
-
r.content.length && r.content[0].isInline && this.open && (this.open--, r = this.top), a = !0, r.type || (this.needsBlock = !0);
|
|
2280
|
-
else if (!t.firstChild) {
|
|
2281
|
-
this.leafFallback(t, e);
|
|
2282
|
-
break t;
|
|
2283
|
-
}
|
|
2284
|
-
let p = h && h.skip ? e : this.readStyles(t, e);
|
|
2285
|
-
p && this.addAll(t, p), a && this.sync(r), this.needsBlock = f;
|
|
2286
|
-
} else {
|
|
2287
|
-
let a = this.readStyles(t, e);
|
|
2288
|
-
a && this.addElementByRule(t, h, a, h.consuming === !1 ? o : void 0);
|
|
2289
|
-
}
|
|
2290
|
-
this.localPreserveWS = i;
|
|
2291
|
-
}
|
|
2292
|
-
// Called for leaf DOM nodes that would otherwise be ignored
|
|
2293
|
-
leafFallback(t, e) {
|
|
2294
|
-
t.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(t.ownerDocument.createTextNode(`
|
|
2295
|
-
`), e);
|
|
2296
|
-
}
|
|
2297
|
-
// Called for ignored nodes
|
|
2298
|
-
ignoreFallback(t, e) {
|
|
2299
|
-
t.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), e, !0);
|
|
2300
|
-
}
|
|
2301
|
-
// Run any style parser associated with the node's styles. Either
|
|
2302
|
-
// return an updated array of marks, or null to indicate some of the
|
|
2303
|
-
// styles had a rule with `ignore` set.
|
|
2304
|
-
readStyles(t, e) {
|
|
2305
|
-
let n = t.style;
|
|
2306
|
-
if (n && n.length)
|
|
2307
|
-
for (let i = 0; i < this.parser.matchedStyles.length; i++) {
|
|
2308
|
-
let r = this.parser.matchedStyles[i], s = n.getPropertyValue(r);
|
|
2309
|
-
if (s)
|
|
2310
|
-
for (let o = void 0; ; ) {
|
|
2311
|
-
let h = this.parser.matchStyle(r, s, this, o);
|
|
2312
|
-
if (!h)
|
|
2313
|
-
break;
|
|
2314
|
-
if (h.ignore)
|
|
2315
|
-
return null;
|
|
2316
|
-
if (h.clearMark ? e = e.filter((a) => !h.clearMark(a)) : e = e.concat(this.parser.schema.marks[h.mark].create(h.attrs)), h.consuming === !1)
|
|
2317
|
-
o = h;
|
|
2318
|
-
else
|
|
2319
|
-
break;
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
return e;
|
|
2323
|
-
}
|
|
2324
|
-
// Look up a handler for the given node. If none are found, return
|
|
2325
|
-
// false. Otherwise, apply it, use its return value to drive the way
|
|
2326
|
-
// the node's content is wrapped, and return true.
|
|
2327
|
-
addElementByRule(t, e, n, i) {
|
|
2328
|
-
let r, s;
|
|
2329
|
-
if (e.node)
|
|
2330
|
-
if (s = this.parser.schema.nodes[e.node], s.isLeaf)
|
|
2331
|
-
this.insertNode(s.create(e.attrs), n, t.nodeName == "BR") || this.leafFallback(t, n);
|
|
2332
|
-
else {
|
|
2333
|
-
let h = this.enter(s, e.attrs || null, n, e.preserveWhitespace);
|
|
2334
|
-
h && (r = !0, n = h);
|
|
2335
|
-
}
|
|
2336
|
-
else {
|
|
2337
|
-
let h = this.parser.schema.marks[e.mark];
|
|
2338
|
-
n = n.concat(h.create(e.attrs));
|
|
2339
|
-
}
|
|
2340
|
-
let o = this.top;
|
|
2341
|
-
if (s && s.isLeaf)
|
|
2342
|
-
this.findInside(t);
|
|
2343
|
-
else if (i)
|
|
2344
|
-
this.addElement(t, n, i);
|
|
2345
|
-
else if (e.getContent)
|
|
2346
|
-
this.findInside(t), e.getContent(t, this.parser.schema).forEach((h) => this.insertNode(h, n, !1));
|
|
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));
|
|
2347
1468
|
else {
|
|
2348
|
-
let
|
|
2349
|
-
|
|
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]);
|
|
2350
1474
|
}
|
|
2351
|
-
|
|
2352
|
-
}
|
|
2353
|
-
// Add all child nodes between `startIndex` and `endIndex` (or the
|
|
2354
|
-
// whole node, if not given). If `sync` is passed, use it to
|
|
2355
|
-
// synchronize after every block element.
|
|
2356
|
-
addAll(t, e, n, i) {
|
|
2357
|
-
let r = n || 0;
|
|
2358
|
-
for (let s = n ? t.childNodes[n] : t.firstChild, o = i == null ? null : t.childNodes[i]; s != o; s = s.nextSibling, ++r)
|
|
2359
|
-
this.findAtPoint(t, r), this.addDOM(s, e);
|
|
2360
|
-
this.findAtPoint(t, r);
|
|
2361
|
-
}
|
|
2362
|
-
// Try to find a way to fit the given node type into the current
|
|
2363
|
-
// context. May add intermediate wrappers and/or leave non-solid
|
|
2364
|
-
// nodes that we're in.
|
|
2365
|
-
findPlace(t, e, n) {
|
|
2366
|
-
let i, r;
|
|
2367
|
-
for (let s = this.open, o = 0; s >= 0; s--) {
|
|
2368
|
-
let h = this.nodes[s], a = h.findWrapping(t);
|
|
2369
|
-
if (a && (!i || i.length > a.length + o) && (i = a, r = h, !a.length))
|
|
2370
|
-
break;
|
|
2371
|
-
if (h.solid) {
|
|
2372
|
-
if (n)
|
|
2373
|
-
break;
|
|
2374
|
-
o += 2;
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
if (!i)
|
|
2378
|
-
return null;
|
|
2379
|
-
this.sync(r);
|
|
2380
|
-
for (let s = 0; s < i.length; s++)
|
|
2381
|
-
e = this.enterInner(i[s], null, e, !1);
|
|
2382
|
-
return e;
|
|
2383
|
-
}
|
|
2384
|
-
// Try to insert the given node, adjusting the context when needed.
|
|
2385
|
-
insertNode(t, e, n) {
|
|
2386
|
-
if (t.isInline && this.needsBlock && !this.top.type) {
|
|
2387
|
-
let r = this.textblockFromContext();
|
|
2388
|
-
r && (e = this.enterInner(r, null, e));
|
|
2389
|
-
}
|
|
2390
|
-
let i = this.findPlace(t, e, n);
|
|
2391
|
-
if (i) {
|
|
2392
|
-
this.closeExtra();
|
|
2393
|
-
let r = this.top;
|
|
2394
|
-
r.match && (r.match = r.match.matchType(t.type));
|
|
2395
|
-
let s = u.none;
|
|
2396
|
-
for (let o of i.concat(t.marks))
|
|
2397
|
-
(r.type ? r.type.allowsMarkType(o.type) : K(o.type, t.type)) && (s = o.addToSet(s));
|
|
2398
|
-
return r.content.push(t.mark(s)), !0;
|
|
2399
|
-
}
|
|
2400
|
-
return !1;
|
|
2401
|
-
}
|
|
2402
|
-
// Try to start a node of the given type, adjusting the context when
|
|
2403
|
-
// necessary.
|
|
2404
|
-
enter(t, e, n, i) {
|
|
2405
|
-
let r = this.findPlace(t.create(e), n, !1);
|
|
2406
|
-
return r && (r = this.enterInner(t, e, n, !0, i)), r;
|
|
2407
|
-
}
|
|
2408
|
-
// Open a node of the given type
|
|
2409
|
-
enterInner(t, e, n, i = !1, r) {
|
|
2410
|
-
this.closeExtra();
|
|
2411
|
-
let s = this.top;
|
|
2412
|
-
s.match = s.match && s.match.matchType(t);
|
|
2413
|
-
let o = V(t, r, s.options);
|
|
2414
|
-
s.options & S && s.content.length == 0 && (o |= S);
|
|
2415
|
-
let h = u.none;
|
|
2416
|
-
return n = n.filter((a) => (s.type ? s.type.allowsMarkType(a.type) : K(a.type, t)) ? (h = a.addToSet(h), !1) : !0), this.nodes.push(new T(t, e, h, i, null, o)), this.open++, n;
|
|
2417
|
-
}
|
|
2418
|
-
// Make sure all nodes above this.open are finished and added to
|
|
2419
|
-
// their parents
|
|
2420
|
-
closeExtra(t = !1) {
|
|
2421
|
-
let e = this.nodes.length - 1;
|
|
2422
|
-
if (e > this.open) {
|
|
2423
|
-
for (; e > this.open; e--)
|
|
2424
|
-
this.nodes[e - 1].content.push(this.nodes[e].finish(t));
|
|
2425
|
-
this.nodes.length = this.open + 1;
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
finish() {
|
|
2429
|
-
return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
|
|
2430
|
-
}
|
|
2431
|
-
sync(t) {
|
|
2432
|
-
for (let e = this.open; e >= 0; e--) {
|
|
2433
|
-
if (this.nodes[e] == t)
|
|
2434
|
-
return this.open = e, !0;
|
|
2435
|
-
this.localPreserveWS && (this.nodes[e].options |= C);
|
|
2436
|
-
}
|
|
2437
|
-
return !1;
|
|
2438
|
-
}
|
|
2439
|
-
get currentPos() {
|
|
2440
|
-
this.closeExtra();
|
|
2441
|
-
let t = 0;
|
|
2442
|
-
for (let e = this.open; e >= 0; e--) {
|
|
2443
|
-
let n = this.nodes[e].content;
|
|
2444
|
-
for (let i = n.length - 1; i >= 0; i--)
|
|
2445
|
-
t += n[i].nodeSize;
|
|
2446
|
-
e && t++;
|
|
2447
|
-
}
|
|
2448
|
-
return t;
|
|
2449
|
-
}
|
|
2450
|
-
findAtPoint(t, e) {
|
|
2451
|
-
if (this.find)
|
|
2452
|
-
for (let n = 0; n < this.find.length; n++)
|
|
2453
|
-
this.find[n].node == t && this.find[n].offset == e && (this.find[n].pos = this.currentPos);
|
|
2454
|
-
}
|
|
2455
|
-
findInside(t) {
|
|
2456
|
-
if (this.find)
|
|
2457
|
-
for (let e = 0; e < this.find.length; e++)
|
|
2458
|
-
this.find[e].pos == null && t.nodeType == 1 && t.contains(this.find[e].node) && (this.find[e].pos = this.currentPos);
|
|
2459
|
-
}
|
|
2460
|
-
findAround(t, e, n) {
|
|
2461
|
-
if (t != e && this.find)
|
|
2462
|
-
for (let i = 0; i < this.find.length; i++)
|
|
2463
|
-
this.find[i].pos == null && t.nodeType == 1 && t.contains(this.find[i].node) && e.compareDocumentPosition(this.find[i].node) & (n ? 2 : 4) && (this.find[i].pos = this.currentPos);
|
|
2464
|
-
}
|
|
2465
|
-
findInText(t) {
|
|
2466
|
-
if (this.find)
|
|
2467
|
-
for (let e = 0; e < this.find.length; e++)
|
|
2468
|
-
this.find[e].node == t && (this.find[e].pos = this.currentPos - (t.nodeValue.length - this.find[e].offset));
|
|
2469
|
-
}
|
|
2470
|
-
// Determines whether the given context string matches this context.
|
|
2471
|
-
matchesContext(t) {
|
|
2472
|
-
if (t.indexOf("|") > -1)
|
|
2473
|
-
return t.split(/\s*\|\s*/).some(this.matchesContext, this);
|
|
2474
|
-
let e = t.split("/"), n = this.options.context, i = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), r = -(n ? n.depth + 1 : 0) + (i ? 0 : 1), s = (o, h) => {
|
|
2475
|
-
for (; o >= 0; o--) {
|
|
2476
|
-
let a = e[o];
|
|
2477
|
-
if (a == "") {
|
|
2478
|
-
if (o == e.length - 1 || o == 0)
|
|
2479
|
-
continue;
|
|
2480
|
-
for (; h >= r; h--)
|
|
2481
|
-
if (s(o - 1, h))
|
|
2482
|
-
return !0;
|
|
2483
|
-
return !1;
|
|
2484
|
-
} else {
|
|
2485
|
-
let f = h > 0 || h == 0 && i ? this.nodes[h].type : n && h >= r ? n.node(h - r).type : null;
|
|
2486
|
-
if (!f || f.name != a && !f.isInGroup(a))
|
|
2487
|
-
return !1;
|
|
2488
|
-
h--;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
return !0;
|
|
2492
|
-
};
|
|
2493
|
-
return s(e.length - 1, this.open);
|
|
2494
|
-
}
|
|
2495
|
-
textblockFromContext() {
|
|
2496
|
-
let t = this.options.context;
|
|
2497
|
-
if (t)
|
|
2498
|
-
for (let e = t.depth; e >= 0; e--) {
|
|
2499
|
-
let n = t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;
|
|
2500
|
-
if (n && n.isTextblock && n.defaultAttrs)
|
|
2501
|
-
return n;
|
|
2502
|
-
}
|
|
2503
|
-
for (let e in this.parser.schema.nodes) {
|
|
2504
|
-
let n = this.parser.schema.nodes[e];
|
|
2505
|
-
if (n.isTextblock && n.defaultAttrs)
|
|
2506
|
-
return n;
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
function Dt(l) {
|
|
2511
|
-
for (let t = l.firstChild, e = null; t; t = t.nextSibling) {
|
|
2512
|
-
let n = t.nodeType == 1 ? t.nodeName.toLowerCase() : null;
|
|
2513
|
-
n && ct.hasOwnProperty(n) && e ? (e.appendChild(t), t = e) : n == "li" ? e = t : n && (e = null);
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
function Pt(l, t) {
|
|
2517
|
-
return (l.matches || l.msMatchesSelector || l.webkitMatchesSelector || l.mozMatchesSelector).call(l, t);
|
|
2518
|
-
}
|
|
2519
|
-
function H(l) {
|
|
2520
|
-
let t = {};
|
|
2521
|
-
for (let e in l)
|
|
2522
|
-
t[e] = l[e];
|
|
2523
|
-
return t;
|
|
2524
|
-
}
|
|
2525
|
-
function K(l, t) {
|
|
2526
|
-
let e = t.schema.nodes;
|
|
2527
|
-
for (let n in e) {
|
|
2528
|
-
let i = e[n];
|
|
2529
|
-
if (!i.allowsMarkType(l))
|
|
2530
|
-
continue;
|
|
2531
|
-
let r = [], s = (o) => {
|
|
2532
|
-
r.push(o);
|
|
2533
|
-
for (let h = 0; h < o.edgeCount; h++) {
|
|
2534
|
-
let { type: a, next: f } = o.edge(h);
|
|
2535
|
-
if (a == t || r.indexOf(f) < 0 && s(f))
|
|
2536
|
-
return !0;
|
|
2537
|
-
}
|
|
2538
|
-
};
|
|
2539
|
-
if (s(i.contentMatch))
|
|
2540
|
-
return !0;
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
class ut {
|
|
2544
|
-
/**
|
|
2545
|
-
Create a serializer. `nodes` should map node names to functions
|
|
2546
|
-
that take a node and return a description of the corresponding
|
|
2547
|
-
DOM. `marks` does the same for mark names, but also gets an
|
|
2548
|
-
argument that tells it whether the mark's content is block or
|
|
2549
|
-
inline content (for typical use, it'll always be inline). A mark
|
|
2550
|
-
serializer may be `null` to indicate that marks of that type
|
|
2551
|
-
should not be serialized.
|
|
2552
|
-
*/
|
|
2553
|
-
constructor(t, e) {
|
|
2554
|
-
this.nodes = t, this.marks = e;
|
|
2555
|
-
}
|
|
2556
|
-
/**
|
|
2557
|
-
Serialize the content of this fragment to a DOM fragment. When
|
|
2558
|
-
not in the browser, the `document` option, containing a DOM
|
|
2559
|
-
document, should be passed so that the serializer can create
|
|
2560
|
-
nodes.
|
|
2561
|
-
*/
|
|
2562
|
-
serializeFragment(t, e = {}, n) {
|
|
2563
|
-
n || (n = R(e).createDocumentFragment());
|
|
2564
|
-
let i = n, r = [];
|
|
2565
|
-
return t.forEach((s) => {
|
|
2566
|
-
if (r.length || s.marks.length) {
|
|
2567
|
-
let o = 0, h = 0;
|
|
2568
|
-
for (; o < r.length && h < s.marks.length; ) {
|
|
2569
|
-
let a = s.marks[h];
|
|
2570
|
-
if (!this.marks[a.type.name]) {
|
|
2571
|
-
h++;
|
|
2572
|
-
continue;
|
|
2573
|
-
}
|
|
2574
|
-
if (!a.eq(r[o][0]) || a.type.spec.spanning === !1)
|
|
2575
|
-
break;
|
|
2576
|
-
o++, h++;
|
|
2577
|
-
}
|
|
2578
|
-
for (; o < r.length; )
|
|
2579
|
-
i = r.pop()[1];
|
|
2580
|
-
for (; h < s.marks.length; ) {
|
|
2581
|
-
let a = s.marks[h++], f = this.serializeMark(a, s.isInline, e);
|
|
2582
|
-
f && (r.push([a, i]), i.appendChild(f.dom), i = f.contentDOM || f.dom);
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
i.appendChild(this.serializeNodeInner(s, e));
|
|
2586
|
-
}), n;
|
|
2587
|
-
}
|
|
2588
|
-
/**
|
|
2589
|
-
@internal
|
|
2590
|
-
*/
|
|
2591
|
-
serializeNodeInner(t, e) {
|
|
2592
|
-
let { dom: n, contentDOM: i } = b(R(e), this.nodes[t.type.name](t), null, t.attrs);
|
|
2593
|
-
if (i) {
|
|
2594
|
-
if (t.isLeaf)
|
|
2595
|
-
throw new RangeError("Content hole not allowed in a leaf node spec");
|
|
2596
|
-
this.serializeFragment(t.content, e, i);
|
|
2597
|
-
}
|
|
2598
|
-
return n;
|
|
2599
|
-
}
|
|
2600
|
-
/**
|
|
2601
|
-
Serialize this node to a DOM node. This can be useful when you
|
|
2602
|
-
need to serialize a part of a document, as opposed to the whole
|
|
2603
|
-
document. To serialize a whole document, use
|
|
2604
|
-
[`serializeFragment`](https://prosemirror.net/docs/ref/#model.DOMSerializer.serializeFragment) on
|
|
2605
|
-
its [content](https://prosemirror.net/docs/ref/#model.Node.content).
|
|
2606
|
-
*/
|
|
2607
|
-
serializeNode(t, e = {}) {
|
|
2608
|
-
let n = this.serializeNodeInner(t, e);
|
|
2609
|
-
for (let i = t.marks.length - 1; i >= 0; i--) {
|
|
2610
|
-
let r = this.serializeMark(t.marks[i], t.isInline, e);
|
|
2611
|
-
r && ((r.contentDOM || r.dom).appendChild(n), n = r.dom);
|
|
2612
|
-
}
|
|
2613
|
-
return n;
|
|
1475
|
+
return this;
|
|
2614
1476
|
}
|
|
2615
1477
|
/**
|
|
2616
|
-
|
|
1478
|
+
Split the node at the given position, and optionally, if `depth` is
|
|
1479
|
+
greater than one, any number of nodes above that. By default, the
|
|
1480
|
+
parts split off will inherit the node type of the original node.
|
|
1481
|
+
This can be changed by passing an array of types and attributes to
|
|
1482
|
+
use after the split (with the outermost nodes coming first).
|
|
2617
1483
|
*/
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
return i && b(R(n), i(t, e), null, t.attrs);
|
|
2621
|
-
}
|
|
2622
|
-
static renderSpec(t, e, n = null, i) {
|
|
2623
|
-
return b(t, e, n, i);
|
|
1484
|
+
split(e, t = 1, r) {
|
|
1485
|
+
return ve(this, e, t, r), this;
|
|
2624
1486
|
}
|
|
2625
1487
|
/**
|
|
2626
|
-
|
|
2627
|
-
properties in a schema's node and mark specs.
|
|
1488
|
+
Add the given mark to the inline content between `from` and `to`.
|
|
2628
1489
|
*/
|
|
2629
|
-
|
|
2630
|
-
return
|
|
1490
|
+
addMark(e, t, r) {
|
|
1491
|
+
return pe(this, e, t, r), this;
|
|
2631
1492
|
}
|
|
2632
1493
|
/**
|
|
2633
|
-
|
|
2634
|
-
|
|
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.
|
|
2635
1498
|
*/
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
return e.text || (e.text = (n) => n.text), e;
|
|
1499
|
+
removeMark(e, t, r) {
|
|
1500
|
+
return fe(this, e, t, r), this;
|
|
2639
1501
|
}
|
|
2640
1502
|
/**
|
|
2641
|
-
|
|
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.
|
|
2642
1507
|
*/
|
|
2643
|
-
|
|
2644
|
-
return
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
function Q(l) {
|
|
2648
|
-
let t = {};
|
|
2649
|
-
for (let e in l) {
|
|
2650
|
-
let n = l[e].spec.toDOM;
|
|
2651
|
-
n && (t[e] = n);
|
|
2652
|
-
}
|
|
2653
|
-
return t;
|
|
2654
|
-
}
|
|
2655
|
-
function R(l) {
|
|
2656
|
-
return l.document || window.document;
|
|
2657
|
-
}
|
|
2658
|
-
const X = /* @__PURE__ */ new WeakMap();
|
|
2659
|
-
function Bt(l) {
|
|
2660
|
-
let t = X.get(l);
|
|
2661
|
-
return t === void 0 && X.set(l, t = Ft(l)), t;
|
|
2662
|
-
}
|
|
2663
|
-
function Ft(l) {
|
|
2664
|
-
let t = null;
|
|
2665
|
-
function e(n) {
|
|
2666
|
-
if (n && typeof n == "object")
|
|
2667
|
-
if (Array.isArray(n))
|
|
2668
|
-
if (typeof n[0] == "string")
|
|
2669
|
-
t || (t = []), t.push(n);
|
|
2670
|
-
else
|
|
2671
|
-
for (let i = 0; i < n.length; i++)
|
|
2672
|
-
e(n[i]);
|
|
2673
|
-
else
|
|
2674
|
-
for (let i in n)
|
|
2675
|
-
e(n[i]);
|
|
2676
|
-
}
|
|
2677
|
-
return e(l), t;
|
|
2678
|
-
}
|
|
2679
|
-
function b(l, t, e, n) {
|
|
2680
|
-
if (typeof t == "string")
|
|
2681
|
-
return { dom: l.createTextNode(t) };
|
|
2682
|
-
if (t.nodeType != null)
|
|
2683
|
-
return { dom: t };
|
|
2684
|
-
if (t.dom && t.dom.nodeType != null)
|
|
2685
|
-
return t;
|
|
2686
|
-
let i = t[0], r;
|
|
2687
|
-
if (typeof i != "string")
|
|
2688
|
-
throw new RangeError("Invalid array passed to renderSpec");
|
|
2689
|
-
if (n && (r = Bt(n)) && r.indexOf(t) > -1)
|
|
2690
|
-
throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
|
|
2691
|
-
let s = i.indexOf(" ");
|
|
2692
|
-
s > 0 && (e = i.slice(0, s), i = i.slice(s + 1));
|
|
2693
|
-
let o, h = e ? l.createElementNS(e, i) : l.createElement(i), a = t[1], f = 1;
|
|
2694
|
-
if (a && typeof a == "object" && a.nodeType == null && !Array.isArray(a)) {
|
|
2695
|
-
f = 2;
|
|
2696
|
-
for (let p in a)
|
|
2697
|
-
if (a[p] != null) {
|
|
2698
|
-
let y = p.indexOf(" ");
|
|
2699
|
-
y > 0 ? h.setAttributeNS(p.slice(0, y), p.slice(y + 1), a[p]) : p == "style" && h.style ? h.style.cssText = a[p] : h.setAttribute(p, a[p]);
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
for (let p = f; p < t.length; p++) {
|
|
2703
|
-
let y = t[p];
|
|
2704
|
-
if (y === 0) {
|
|
2705
|
-
if (p < t.length - 1 || p > f)
|
|
2706
|
-
throw new RangeError("Content hole must be the only child of its parent node");
|
|
2707
|
-
return { dom: h, contentDOM: h };
|
|
2708
|
-
} else {
|
|
2709
|
-
let { dom: pt, contentDOM: J } = b(l, y, e, n);
|
|
2710
|
-
if (h.appendChild(pt), J) {
|
|
2711
|
-
if (o)
|
|
2712
|
-
throw new RangeError("Multiple content holes");
|
|
2713
|
-
o = J;
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
1508
|
+
clearIncompatible(e, t, r) {
|
|
1509
|
+
return $(this, e, t, r), this;
|
|
2716
1510
|
}
|
|
2717
|
-
return { dom: h, contentDOM: o };
|
|
2718
1511
|
}
|
|
2719
1512
|
export {
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
1513
|
+
C as AddMarkStep,
|
|
1514
|
+
N as AddNodeMarkStep,
|
|
1515
|
+
E as AttrStep,
|
|
1516
|
+
z as DocAttrStep,
|
|
1517
|
+
L as MapResult,
|
|
1518
|
+
A as Mapping,
|
|
1519
|
+
b as RemoveMarkStep,
|
|
1520
|
+
R as RemoveNodeMarkStep,
|
|
1521
|
+
M as ReplaceAroundStep,
|
|
1522
|
+
v as ReplaceStep,
|
|
1523
|
+
k as Step,
|
|
1524
|
+
S as StepMap,
|
|
1525
|
+
y as StepResult,
|
|
1526
|
+
De as Transform,
|
|
1527
|
+
T as TransformError,
|
|
1528
|
+
Ae as canJoin,
|
|
1529
|
+
Je as canSplit,
|
|
1530
|
+
We as dropPoint,
|
|
1531
|
+
ze as findWrapping,
|
|
1532
|
+
be as insertPoint,
|
|
1533
|
+
Be as joinPoint,
|
|
1534
|
+
Fe as liftTarget,
|
|
1535
|
+
Me as replaceStep
|
|
2733
1536
|
};
|