prosemirror-transform 1.3.3 → 1.3.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 +6 -0
- package/dist/index.es.js +9 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/map.js +1 -0
- package/src/structure.js +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-transform",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "ProseMirror document transformations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"prosemirror-model": "^1.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"mocha": "^
|
|
23
|
+
"mocha": "^9.1.2",
|
|
24
24
|
"ist": "^1.0.0",
|
|
25
25
|
"prosemirror-test-builder": "^1.0.0",
|
|
26
26
|
"rollup": "^2.26.3",
|
package/src/map.js
CHANGED
|
@@ -57,6 +57,7 @@ export class StepMap {
|
|
|
57
57
|
// represented as an array of numbers, in which each group of three
|
|
58
58
|
// represents a modified chunk as `[start, oldSize, newSize]`.
|
|
59
59
|
constructor(ranges, inverted = false) {
|
|
60
|
+
if (!ranges.length && StepMap.empty) return StepMap.empty
|
|
60
61
|
this.ranges = ranges
|
|
61
62
|
this.inverted = inverted
|
|
62
63
|
}
|
package/src/structure.js
CHANGED
|
@@ -103,8 +103,14 @@ function findWrappingInside(range, type) {
|
|
|
103
103
|
// probably be computed with [`findWrapping`](#transform.findWrapping).
|
|
104
104
|
Transform.prototype.wrap = function(range, wrappers) {
|
|
105
105
|
let content = Fragment.empty
|
|
106
|
-
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
106
|
+
for (let i = wrappers.length - 1; i >= 0; i--) {
|
|
107
|
+
if (content.size) {
|
|
108
|
+
let match = wrappers[i].type.contentMatch.matchFragment(content)
|
|
109
|
+
if (!match || !match.validEnd)
|
|
110
|
+
throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")
|
|
111
|
+
}
|
|
107
112
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content))
|
|
113
|
+
}
|
|
108
114
|
|
|
109
115
|
let start = range.start, end = range.end
|
|
110
116
|
return this.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true))
|