prosemirror-transform 1.3.4 → 1.4.2
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 +18 -0
- package/dist/index.es.js +18 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +18 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/map.js +2 -0
- package/src/replace.js +16 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 1.4.2 (2022-04-05)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Make replacements that span to the end of a textblock more consistent with those ending in the middle of the block.
|
|
6
|
+
|
|
7
|
+
## 1.4.1 (2022-03-31)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
`replaceRange` will now close multiple defining parent nodes when appropriate.
|
|
12
|
+
|
|
13
|
+
## 1.4.0 (2022-03-21)
|
|
14
|
+
|
|
15
|
+
### New features
|
|
16
|
+
|
|
17
|
+
Node specs can now use the `definingForContent` and `definingAsContext` properties to opt in to specific parts of the existing `defining` behavior.
|
|
18
|
+
|
|
1
19
|
## 1.3.4 (2022-02-04)
|
|
2
20
|
|
|
3
21
|
### Bug fixes
|
package/dist/index.es.js
CHANGED
|
@@ -142,6 +142,8 @@ StepMap.offset = function offset (n) {
|
|
|
142
142
|
return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n])
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
+
// :: StepMap
|
|
146
|
+
// A StepMap that contains no changed ranges.
|
|
145
147
|
StepMap.empty = new StepMap([]);
|
|
146
148
|
|
|
147
149
|
// :: class extends Mappable
|
|
@@ -1435,7 +1437,7 @@ Fitter.prototype.placeNodes = function placeNodes (ref) {
|
|
|
1435
1437
|
};
|
|
1436
1438
|
|
|
1437
1439
|
Fitter.prototype.mustMoveInline = function mustMoveInline () {
|
|
1438
|
-
if (!this.$to.parent.isTextblock
|
|
1440
|
+
if (!this.$to.parent.isTextblock) { return -1 }
|
|
1439
1441
|
var top = this.frontier[this.depth], level;
|
|
1440
1442
|
if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) ||
|
|
1441
1443
|
(this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth)) { return -1 }
|
|
@@ -1536,6 +1538,10 @@ function invalidMarks(type, fragment, start) {
|
|
|
1536
1538
|
return false
|
|
1537
1539
|
}
|
|
1538
1540
|
|
|
1541
|
+
function definesContent(type) {
|
|
1542
|
+
return type.spec.defining || type.spec.definingForContent
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1539
1545
|
// :: (number, number, Slice) → this
|
|
1540
1546
|
// Replace a range of the document with a given slice, using `from`,
|
|
1541
1547
|
// `to`, and the slice's [`openStart`](#model.Slice.openStart) property
|
|
@@ -1543,9 +1549,9 @@ function invalidMarks(type, fragment, start) {
|
|
|
1543
1549
|
// grow the replaced area or close open nodes in the slice in order to
|
|
1544
1550
|
// get a fit that is more in line with WYSIWYG expectations, by
|
|
1545
1551
|
// dropping fully covered parent nodes of the replaced region when
|
|
1546
|
-
// they are marked [non-defining](#model.NodeSpec.
|
|
1552
|
+
// they are marked [non-defining as context](#model.NodeSpec.definingAsContext), or
|
|
1547
1553
|
// including an open parent node from the slice that _is_ marked as
|
|
1548
|
-
// [defining](#model.NodeSpec.
|
|
1554
|
+
// [defining its content](#model.NodeSpec.definingForContent).
|
|
1549
1555
|
//
|
|
1550
1556
|
// This is the method, for example, to handle paste. The similar
|
|
1551
1557
|
// [`replace`](#transform.Transform.replace) method is a more
|
|
@@ -1572,7 +1578,7 @@ Transform.prototype.replaceRange = function(from, to, slice) {
|
|
|
1572
1578
|
// cross a defining node.
|
|
1573
1579
|
for (var d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {
|
|
1574
1580
|
var spec = $from.node(d).type.spec;
|
|
1575
|
-
if (spec.defining || spec.isolating) { break }
|
|
1581
|
+
if (spec.defining || spec.definingAsContext || spec.isolating) { break }
|
|
1576
1582
|
if (targetDepths.indexOf(d) > -1) { preferredTarget = d; }
|
|
1577
1583
|
else if ($from.before(d) == pos) { targetDepths.splice(1, 0, -d); }
|
|
1578
1584
|
}
|
|
@@ -1587,14 +1593,14 @@ Transform.prototype.replaceRange = function(from, to, slice) {
|
|
|
1587
1593
|
if (i == slice.openStart) { break }
|
|
1588
1594
|
content = node.content;
|
|
1589
1595
|
}
|
|
1590
|
-
|
|
1591
|
-
//
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1596
|
+
|
|
1597
|
+
// Back up preferredDepth to cover defining textblocks directly
|
|
1598
|
+
// above it, possibly skipping a non-defining textblock.
|
|
1599
|
+
for (var d$1 = preferredDepth - 1; d$1 >= 0; d$1--) {
|
|
1600
|
+
var type = leftNodes[d$1].type, def = definesContent(type);
|
|
1601
|
+
if (def && $from.node(preferredTargetIndex).type != type) { preferredDepth = d$1; }
|
|
1602
|
+
else if (def || !type.isTextblock) { break }
|
|
1603
|
+
}
|
|
1598
1604
|
|
|
1599
1605
|
for (var j = slice.openStart; j >= 0; j--) {
|
|
1600
1606
|
var openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);
|