prosemirror-transform 1.10.3 → 1.10.4
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/CHANGELOG.md +8 -0
- package/dist/index.cjs +14 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -10
- package/package.json +1 -1
- package/src/replace_step.ts +1 -1
- package/src/transform.ts +12 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 1.10.4 (2025-04-22)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug that caused mapping `ReplaceStep`s to reset their `structure` flag.
|
|
6
|
+
|
|
7
|
+
Align `removeNodeMark`'s behavior to that of `removeMark`. When passing in a node type, it now removes all occurrences of that type.
|
|
8
|
+
|
|
1
9
|
## 1.10.3 (2025-03-04)
|
|
2
10
|
|
|
3
11
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -613,7 +613,7 @@ var ReplaceStep = function (_Step5) {
|
|
|
613
613
|
var from = mapping.mapResult(this.from, 1),
|
|
614
614
|
to = mapping.mapResult(this.to, -1);
|
|
615
615
|
if (from.deletedAcross && to.deletedAcross) return null;
|
|
616
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
616
|
+
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
|
|
617
617
|
}
|
|
618
618
|
}, {
|
|
619
619
|
key: "merge",
|
|
@@ -1796,13 +1796,20 @@ var Transform = function () {
|
|
|
1796
1796
|
}, {
|
|
1797
1797
|
key: "removeNodeMark",
|
|
1798
1798
|
value: function removeNodeMark(pos, mark) {
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1799
|
+
var node = this.doc.nodeAt(pos);
|
|
1800
|
+
if (!node) throw new RangeError("No node at position " + pos);
|
|
1801
|
+
if (mark instanceof prosemirrorModel.Mark) {
|
|
1802
|
+
if (mark.isInSet(node.marks)) this.step(new RemoveNodeMarkStep(pos, mark));
|
|
1803
|
+
} else {
|
|
1804
|
+
var set = node.marks,
|
|
1805
|
+
found,
|
|
1806
|
+
steps = [];
|
|
1807
|
+
while (found = mark.isInSet(set)) {
|
|
1808
|
+
steps.push(new RemoveNodeMarkStep(pos, found));
|
|
1809
|
+
set = found.removeFromSet(set);
|
|
1810
|
+
}
|
|
1811
|
+
for (var i = steps.length - 1; i >= 0; i--) this.step(steps[i]);
|
|
1804
1812
|
}
|
|
1805
|
-
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
1806
1813
|
return this;
|
|
1807
1814
|
}
|
|
1808
1815
|
}, {
|
package/dist/index.d.cts
CHANGED
|
@@ -425,7 +425,7 @@ declare class Transform {
|
|
|
425
425
|
*/
|
|
426
426
|
addNodeMark(pos: number, mark: Mark): this;
|
|
427
427
|
/**
|
|
428
|
-
Remove a mark (or
|
|
428
|
+
Remove a mark (or all marks of the given type) from the node at
|
|
429
429
|
position `pos`.
|
|
430
430
|
*/
|
|
431
431
|
removeNodeMark(pos: number, mark: Mark | MarkType): this;
|
package/dist/index.d.ts
CHANGED
|
@@ -425,7 +425,7 @@ declare class Transform {
|
|
|
425
425
|
*/
|
|
426
426
|
addNodeMark(pos: number, mark: Mark): this;
|
|
427
427
|
/**
|
|
428
|
-
Remove a mark (or
|
|
428
|
+
Remove a mark (or all marks of the given type) from the node at
|
|
429
429
|
position `pos`.
|
|
430
430
|
*/
|
|
431
431
|
removeNodeMark(pos: number, mark: Mark | MarkType): this;
|
package/dist/index.js
CHANGED
|
@@ -714,7 +714,7 @@ class ReplaceStep extends Step {
|
|
|
714
714
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
715
715
|
if (from.deletedAcross && to.deletedAcross)
|
|
716
716
|
return null;
|
|
717
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
717
|
+
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
|
|
718
718
|
}
|
|
719
719
|
merge(other) {
|
|
720
720
|
if (!(other instanceof ReplaceStep) || other.structure || this.structure)
|
|
@@ -2091,19 +2091,26 @@ class Transform {
|
|
|
2091
2091
|
return this;
|
|
2092
2092
|
}
|
|
2093
2093
|
/**
|
|
2094
|
-
Remove a mark (or
|
|
2094
|
+
Remove a mark (or all marks of the given type) from the node at
|
|
2095
2095
|
position `pos`.
|
|
2096
2096
|
*/
|
|
2097
2097
|
removeNodeMark(pos, mark) {
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2098
|
+
let node = this.doc.nodeAt(pos);
|
|
2099
|
+
if (!node)
|
|
2100
|
+
throw new RangeError("No node at position " + pos);
|
|
2101
|
+
if (mark instanceof Mark) {
|
|
2102
|
+
if (mark.isInSet(node.marks))
|
|
2103
|
+
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
2104
|
+
}
|
|
2105
|
+
else {
|
|
2106
|
+
let set = node.marks, found, steps = [];
|
|
2107
|
+
while (found = mark.isInSet(set)) {
|
|
2108
|
+
steps.push(new RemoveNodeMarkStep(pos, found));
|
|
2109
|
+
set = found.removeFromSet(set);
|
|
2110
|
+
}
|
|
2111
|
+
for (let i = steps.length - 1; i >= 0; i--)
|
|
2112
|
+
this.step(steps[i]);
|
|
2105
2113
|
}
|
|
2106
|
-
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
2107
2114
|
return this;
|
|
2108
2115
|
}
|
|
2109
2116
|
/**
|
package/package.json
CHANGED
package/src/replace_step.ts
CHANGED
|
@@ -42,7 +42,7 @@ export class ReplaceStep extends Step {
|
|
|
42
42
|
map(mapping: Mappable) {
|
|
43
43
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1)
|
|
44
44
|
if (from.deletedAcross && to.deletedAcross) return null
|
|
45
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice)
|
|
45
|
+
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
merge(other: Step) {
|
package/src/transform.ts
CHANGED
|
@@ -198,16 +198,21 @@ export class Transform {
|
|
|
198
198
|
return this
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
/// Remove a mark (or
|
|
201
|
+
/// Remove a mark (or all marks of the given type) from the node at
|
|
202
202
|
/// position `pos`.
|
|
203
203
|
removeNodeMark(pos: number, mark: Mark | MarkType): this {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
let node = this.doc.nodeAt(pos)
|
|
205
|
+
if (!node) throw new RangeError("No node at position " + pos)
|
|
206
|
+
if (mark instanceof Mark) {
|
|
207
|
+
if (mark.isInSet(node.marks)) this.step(new RemoveNodeMarkStep(pos, mark))
|
|
208
|
+
} else {
|
|
209
|
+
let set = node.marks, found, steps: Step[] = []
|
|
210
|
+
while (found = mark.isInSet(set)) {
|
|
211
|
+
steps.push(new RemoveNodeMarkStep(pos, found))
|
|
212
|
+
set = found.removeFromSet(set)
|
|
213
|
+
}
|
|
214
|
+
for (let i = steps.length - 1; i >= 0; i--) this.step(steps[i])
|
|
209
215
|
}
|
|
210
|
-
this.step(new RemoveNodeMarkStep(pos, mark))
|
|
211
216
|
return this
|
|
212
217
|
}
|
|
213
218
|
|