prosemirror-transform 1.7.0 → 1.7.1
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/README.md +1 -1
- package/dist/index.cjs +16 -2
- package/dist/index.js +13 -2
- package/package.json +1 -1
- package/src/replace.ts +12 -1
- package/src/structure.ts +1 -1
- package/src/transform.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 1.7.1 (2023-01-20)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Keep content in isolating nodes inside their parent when fitting a replace step.
|
|
6
|
+
|
|
7
|
+
`Transform.setNodeMarkup` will no longer clear the node's marks when it isn't given an array of marks.
|
|
8
|
+
|
|
1
9
|
## 1.7.0 (2022-08-16)
|
|
2
10
|
|
|
3
11
|
### New features
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# prosemirror-transform
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**
|
|
3
|
+
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-transform/blob/master/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This is a [core module](https://prosemirror.net/docs/ref/#transform) of [ProseMirror](https://prosemirror.net).
|
|
6
6
|
ProseMirror is a well-behaved rich semantic content editor based on
|
package/dist/index.cjs
CHANGED
|
@@ -1341,8 +1341,22 @@ var Fitter = function () {
|
|
|
1341
1341
|
}, {
|
|
1342
1342
|
key: "findFittable",
|
|
1343
1343
|
value: function findFittable() {
|
|
1344
|
+
var startDepth = this.unplaced.openStart;
|
|
1345
|
+
|
|
1346
|
+
for (var cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {
|
|
1347
|
+
var node = cur.firstChild;
|
|
1348
|
+
if (cur.childCount > 1) openEnd = 0;
|
|
1349
|
+
|
|
1350
|
+
if (node.type.spec.isolating && openEnd <= d) {
|
|
1351
|
+
startDepth = d;
|
|
1352
|
+
break;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
cur = node.content;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1344
1358
|
for (var pass = 1; pass <= 2; pass++) {
|
|
1345
|
-
for (var sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
1359
|
+
for (var sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
1346
1360
|
var fragment = void 0,
|
|
1347
1361
|
parent = null;
|
|
1348
1362
|
|
|
@@ -1950,7 +1964,7 @@ var Transform = function () {
|
|
|
1950
1964
|
key: "setNodeMarkup",
|
|
1951
1965
|
value: function setNodeMarkup(pos, type) {
|
|
1952
1966
|
var attrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1953
|
-
var marks = arguments.length > 3
|
|
1967
|
+
var marks = arguments.length > 3 ? arguments[3] : undefined;
|
|
1954
1968
|
|
|
1955
1969
|
_setNodeMarkup(this, pos, type, attrs, marks);
|
|
1956
1970
|
|
package/dist/index.js
CHANGED
|
@@ -1332,10 +1332,21 @@ class Fitter {
|
|
|
1332
1332
|
// content that can be moved somewhere on the frontier. Returns two
|
|
1333
1333
|
// depths, one for the slice and one for the frontier.
|
|
1334
1334
|
findFittable() {
|
|
1335
|
+
let startDepth = this.unplaced.openStart;
|
|
1336
|
+
for (let cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {
|
|
1337
|
+
let node = cur.firstChild;
|
|
1338
|
+
if (cur.childCount > 1)
|
|
1339
|
+
openEnd = 0;
|
|
1340
|
+
if (node.type.spec.isolating && openEnd <= d) {
|
|
1341
|
+
startDepth = d;
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
cur = node.content;
|
|
1345
|
+
}
|
|
1335
1346
|
// Only try wrapping nodes (pass 2) after finding a place without
|
|
1336
1347
|
// wrapping failed.
|
|
1337
1348
|
for (let pass = 1; pass <= 2; pass++) {
|
|
1338
|
-
for (let sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
1349
|
+
for (let sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
1339
1350
|
let fragment, parent = null;
|
|
1340
1351
|
if (sliceDepth) {
|
|
1341
1352
|
parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;
|
|
@@ -1924,7 +1935,7 @@ class Transform {
|
|
|
1924
1935
|
Change the type, attributes, and/or marks of the node at `pos`.
|
|
1925
1936
|
When `type` isn't given, the existing node type is preserved,
|
|
1926
1937
|
*/
|
|
1927
|
-
setNodeMarkup(pos, type, attrs = null, marks
|
|
1938
|
+
setNodeMarkup(pos, type, attrs = null, marks) {
|
|
1928
1939
|
setNodeMarkup(this, pos, type, attrs, marks);
|
|
1929
1940
|
return this;
|
|
1930
1941
|
}
|
package/package.json
CHANGED
package/src/replace.ts
CHANGED
|
@@ -110,10 +110,21 @@ class Fitter {
|
|
|
110
110
|
// content that can be moved somewhere on the frontier. Returns two
|
|
111
111
|
// depths, one for the slice and one for the frontier.
|
|
112
112
|
findFittable(): Fittable | undefined {
|
|
113
|
+
let startDepth = this.unplaced.openStart
|
|
114
|
+
for (let cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {
|
|
115
|
+
let node = cur.firstChild!
|
|
116
|
+
if (cur.childCount > 1) openEnd = 0
|
|
117
|
+
if (node.type.spec.isolating && openEnd <= d) {
|
|
118
|
+
startDepth = d
|
|
119
|
+
break
|
|
120
|
+
}
|
|
121
|
+
cur = node.content
|
|
122
|
+
}
|
|
123
|
+
|
|
113
124
|
// Only try wrapping nodes (pass 2) after finding a place without
|
|
114
125
|
// wrapping failed.
|
|
115
126
|
for (let pass = 1; pass <= 2; pass++) {
|
|
116
|
-
for (let sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
127
|
+
for (let sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
117
128
|
let fragment, parent = null
|
|
118
129
|
if (sliceDepth) {
|
|
119
130
|
parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild
|
package/src/structure.ts
CHANGED
|
@@ -135,7 +135,7 @@ function canChangeType(doc: Node, pos: number, type: NodeType) {
|
|
|
135
135
|
/// Change the type, attributes, and/or marks of the node at `pos`.
|
|
136
136
|
/// When `type` isn't given, the existing node type is preserved,
|
|
137
137
|
export function setNodeMarkup(tr: Transform, pos: number, type: NodeType | undefined | null,
|
|
138
|
-
attrs: Attrs | null, marks: readonly Mark[]) {
|
|
138
|
+
attrs: Attrs | null, marks: readonly Mark[] | undefined) {
|
|
139
139
|
let node = tr.doc.nodeAt(pos)
|
|
140
140
|
if (!node) throw new RangeError("No node at given position")
|
|
141
141
|
if (!type) type = node.type
|
package/src/transform.ts
CHANGED
|
@@ -173,7 +173,7 @@ export class Transform {
|
|
|
173
173
|
|
|
174
174
|
/// Change the type, attributes, and/or marks of the node at `pos`.
|
|
175
175
|
/// When `type` isn't given, the existing node type is preserved,
|
|
176
|
-
setNodeMarkup(pos: number, type?: NodeType | null, attrs: Attrs | null = null, marks
|
|
176
|
+
setNodeMarkup(pos: number, type?: NodeType | null, attrs: Attrs | null = null, marks?: readonly Mark[]): this {
|
|
177
177
|
setNodeMarkup(this, pos, type, attrs, marks)
|
|
178
178
|
return this
|
|
179
179
|
}
|