prosemirror-transform 1.2.12 → 1.3.3
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 +44 -5
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +44 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/mark_step.js +12 -0
- package/src/replace.js +5 -2
- package/src/replace_step.js +19 -0
- package/src/structure.js +8 -3
package/dist/index.js
CHANGED
|
@@ -443,8 +443,14 @@ StepResult.fromReplace = function fromReplace (doc, from, to, slice) {
|
|
|
443
443
|
var ReplaceStep = /*@__PURE__*/(function (Step) {
|
|
444
444
|
function ReplaceStep(from, to, slice, structure) {
|
|
445
445
|
Step.call(this);
|
|
446
|
+
// :: number
|
|
447
|
+
// The start position of the replaced range.
|
|
446
448
|
this.from = from;
|
|
449
|
+
// :: number
|
|
450
|
+
// The end position of the replaced range.
|
|
447
451
|
this.to = to;
|
|
452
|
+
// :: Slice
|
|
453
|
+
// The slice to insert.
|
|
448
454
|
this.slice = slice;
|
|
449
455
|
this.structure = !!structure;
|
|
450
456
|
}
|
|
@@ -513,11 +519,24 @@ Step.jsonID("replace", ReplaceStep);
|
|
|
513
519
|
var ReplaceAroundStep = /*@__PURE__*/(function (Step) {
|
|
514
520
|
function ReplaceAroundStep(from, to, gapFrom, gapTo, slice, insert, structure) {
|
|
515
521
|
Step.call(this);
|
|
522
|
+
// :: number
|
|
523
|
+
// The start position of the replaced range.
|
|
516
524
|
this.from = from;
|
|
525
|
+
// :: number
|
|
526
|
+
// The end position of the replaced range.
|
|
517
527
|
this.to = to;
|
|
528
|
+
// :: number
|
|
529
|
+
// The start of preserved range.
|
|
518
530
|
this.gapFrom = gapFrom;
|
|
531
|
+
// :: number
|
|
532
|
+
// The end of preserved range.
|
|
519
533
|
this.gapTo = gapTo;
|
|
534
|
+
// :: Slice
|
|
535
|
+
// The slice to insert.
|
|
520
536
|
this.slice = slice;
|
|
537
|
+
// :: number
|
|
538
|
+
// The position in the slice where the preserved range should be
|
|
539
|
+
// inserted.
|
|
521
540
|
this.insert = insert;
|
|
522
541
|
this.structure = !!structure;
|
|
523
542
|
}
|
|
@@ -889,9 +908,14 @@ function dropPoint(doc, pos, slice) {
|
|
|
889
908
|
for (var d = $pos.depth; d >= 0; d--) {
|
|
890
909
|
var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
|
|
891
910
|
var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
911
|
+
var parent = $pos.node(d), fits = false;
|
|
912
|
+
if (pass == 1) {
|
|
913
|
+
fits = parent.canReplace(insertPos, insertPos, content);
|
|
914
|
+
} else {
|
|
915
|
+
var wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
|
|
916
|
+
fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
|
|
917
|
+
}
|
|
918
|
+
if (fits)
|
|
895
919
|
{ return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1) }
|
|
896
920
|
}
|
|
897
921
|
}
|
|
@@ -913,8 +937,14 @@ function mapFragment(fragment, f, parent) {
|
|
|
913
937
|
var AddMarkStep = /*@__PURE__*/(function (Step) {
|
|
914
938
|
function AddMarkStep(from, to, mark) {
|
|
915
939
|
Step.call(this);
|
|
940
|
+
// :: number
|
|
941
|
+
// The start of the marked range.
|
|
916
942
|
this.from = from;
|
|
943
|
+
// :: number
|
|
944
|
+
// The end of the marked range.
|
|
917
945
|
this.to = to;
|
|
946
|
+
// :: Mark
|
|
947
|
+
// The mark to add.
|
|
918
948
|
this.mark = mark;
|
|
919
949
|
}
|
|
920
950
|
|
|
@@ -972,8 +1002,14 @@ Step.jsonID("addMark", AddMarkStep);
|
|
|
972
1002
|
var RemoveMarkStep = /*@__PURE__*/(function (Step) {
|
|
973
1003
|
function RemoveMarkStep(from, to, mark) {
|
|
974
1004
|
Step.call(this);
|
|
1005
|
+
// :: number
|
|
1006
|
+
// The start of the unmarked range.
|
|
975
1007
|
this.from = from;
|
|
1008
|
+
// :: number
|
|
1009
|
+
// The end of the unmarked range.
|
|
976
1010
|
this.to = to;
|
|
1011
|
+
// :: Mark
|
|
1012
|
+
// The mark to remove.
|
|
977
1013
|
this.mark = mark;
|
|
978
1014
|
}
|
|
979
1015
|
|
|
@@ -1579,7 +1615,7 @@ Transform.prototype.replaceRange = function(from, to, slice) {
|
|
|
1579
1615
|
this.replace(from, to, slice);
|
|
1580
1616
|
if (this.steps.length > startSteps) { break }
|
|
1581
1617
|
var depth = targetDepths[i$2];
|
|
1582
|
-
if (
|
|
1618
|
+
if (depth < 0) { continue }
|
|
1583
1619
|
from = $from.before(depth); to = $to.after(depth);
|
|
1584
1620
|
}
|
|
1585
1621
|
return this
|
|
@@ -1645,7 +1681,10 @@ function coveredDepths($from, $to) {
|
|
|
1645
1681
|
$to.end(d) > $to.pos + ($to.depth - d) ||
|
|
1646
1682
|
$from.node(d).type.spec.isolating ||
|
|
1647
1683
|
$to.node(d).type.spec.isolating) { break }
|
|
1648
|
-
if (start == $to.start(d)
|
|
1684
|
+
if (start == $to.start(d) ||
|
|
1685
|
+
(d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&
|
|
1686
|
+
d && $to.start(d - 1) == start - 1))
|
|
1687
|
+
{ result.push(d); }
|
|
1649
1688
|
}
|
|
1650
1689
|
return result
|
|
1651
1690
|
}
|