prosemirror-transform 1.3.0 → 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 +26 -0
- package/dist/index.es.js +22 -7
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +22 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/map.js +1 -0
- package/src/replace.js +5 -2
- package/src/structure.js +15 -4
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ var MapResult = function MapResult(pos, deleted, recover) {
|
|
|
61
61
|
var StepMap = function StepMap(ranges, inverted) {
|
|
62
62
|
if ( inverted === void 0 ) inverted = false;
|
|
63
63
|
|
|
64
|
+
if (!ranges.length && StepMap.empty) { return StepMap.empty }
|
|
64
65
|
this.ranges = ranges;
|
|
65
66
|
this.inverted = inverted;
|
|
66
67
|
};
|
|
@@ -724,8 +725,14 @@ function findWrappingInside(range, type) {
|
|
|
724
725
|
// probably be computed with [`findWrapping`](#transform.findWrapping).
|
|
725
726
|
Transform.prototype.wrap = function(range, wrappers) {
|
|
726
727
|
var content = prosemirrorModel.Fragment.empty;
|
|
727
|
-
for (var i = wrappers.length - 1; i >= 0; i--)
|
|
728
|
-
|
|
728
|
+
for (var i = wrappers.length - 1; i >= 0; i--) {
|
|
729
|
+
if (content.size) {
|
|
730
|
+
var match = wrappers[i].type.contentMatch.matchFragment(content);
|
|
731
|
+
if (!match || !match.validEnd)
|
|
732
|
+
{ throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper") }
|
|
733
|
+
}
|
|
734
|
+
content = prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
735
|
+
}
|
|
729
736
|
|
|
730
737
|
var start = range.start, end = range.end;
|
|
731
738
|
return this.step(new ReplaceAroundStep(start, end, start, end, new prosemirrorModel.Slice(content, 0, 0), wrappers.length, true))
|
|
@@ -908,9 +915,14 @@ function dropPoint(doc, pos, slice) {
|
|
|
908
915
|
for (var d = $pos.depth; d >= 0; d--) {
|
|
909
916
|
var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
|
|
910
917
|
var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
918
|
+
var parent = $pos.node(d), fits = false;
|
|
919
|
+
if (pass == 1) {
|
|
920
|
+
fits = parent.canReplace(insertPos, insertPos, content);
|
|
921
|
+
} else {
|
|
922
|
+
var wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
|
|
923
|
+
fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
|
|
924
|
+
}
|
|
925
|
+
if (fits)
|
|
914
926
|
{ return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1) }
|
|
915
927
|
}
|
|
916
928
|
}
|
|
@@ -1610,7 +1622,7 @@ Transform.prototype.replaceRange = function(from, to, slice) {
|
|
|
1610
1622
|
this.replace(from, to, slice);
|
|
1611
1623
|
if (this.steps.length > startSteps) { break }
|
|
1612
1624
|
var depth = targetDepths[i$2];
|
|
1613
|
-
if (
|
|
1625
|
+
if (depth < 0) { continue }
|
|
1614
1626
|
from = $from.before(depth); to = $to.after(depth);
|
|
1615
1627
|
}
|
|
1616
1628
|
return this
|
|
@@ -1676,7 +1688,10 @@ function coveredDepths($from, $to) {
|
|
|
1676
1688
|
$to.end(d) > $to.pos + ($to.depth - d) ||
|
|
1677
1689
|
$from.node(d).type.spec.isolating ||
|
|
1678
1690
|
$to.node(d).type.spec.isolating) { break }
|
|
1679
|
-
if (start == $to.start(d)
|
|
1691
|
+
if (start == $to.start(d) ||
|
|
1692
|
+
(d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&
|
|
1693
|
+
d && $to.start(d - 1) == start - 1))
|
|
1694
|
+
{ result.push(d); }
|
|
1680
1695
|
}
|
|
1681
1696
|
return result
|
|
1682
1697
|
}
|