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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 1.3.3 (2021-09-29)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an inconsistency in `deleteRange` where it would delete the parent node for ranges covering all textblocks in a given parent.
|
|
6
|
+
|
|
7
|
+
## 1.3.2 (2021-04-06)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix a regression in `dropPoint` that caused it to dereference undefined in some circumstances.
|
|
12
|
+
|
|
13
|
+
## 1.3.1 (2021-04-01)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Fix a crash in `Transform.replaceRange` when called with under specific circumstances.
|
|
18
|
+
|
|
19
|
+
Fix an issue where `dropPoint` could return an invalid drop point.
|
|
20
|
+
|
|
21
|
+
## 1.3.0 (2021-03-31)
|
|
22
|
+
|
|
23
|
+
### New features
|
|
24
|
+
|
|
25
|
+
The various properties of subclasses of `Step` (`ReplaceStep`, `ReplaceAroundStep`, `AddMarkStep`, and `RemoveMarkStep`) are now part of the public interface.
|
|
26
|
+
|
|
1
27
|
## 1.2.12 (2021-02-20)
|
|
2
28
|
|
|
3
29
|
### Bug fixes
|
package/dist/index.es.js
CHANGED
|
@@ -439,8 +439,14 @@ StepResult.fromReplace = function fromReplace (doc, from, to, slice) {
|
|
|
439
439
|
var ReplaceStep = /*@__PURE__*/(function (Step) {
|
|
440
440
|
function ReplaceStep(from, to, slice, structure) {
|
|
441
441
|
Step.call(this);
|
|
442
|
+
// :: number
|
|
443
|
+
// The start position of the replaced range.
|
|
442
444
|
this.from = from;
|
|
445
|
+
// :: number
|
|
446
|
+
// The end position of the replaced range.
|
|
443
447
|
this.to = to;
|
|
448
|
+
// :: Slice
|
|
449
|
+
// The slice to insert.
|
|
444
450
|
this.slice = slice;
|
|
445
451
|
this.structure = !!structure;
|
|
446
452
|
}
|
|
@@ -509,11 +515,24 @@ Step.jsonID("replace", ReplaceStep);
|
|
|
509
515
|
var ReplaceAroundStep = /*@__PURE__*/(function (Step) {
|
|
510
516
|
function ReplaceAroundStep(from, to, gapFrom, gapTo, slice, insert, structure) {
|
|
511
517
|
Step.call(this);
|
|
518
|
+
// :: number
|
|
519
|
+
// The start position of the replaced range.
|
|
512
520
|
this.from = from;
|
|
521
|
+
// :: number
|
|
522
|
+
// The end position of the replaced range.
|
|
513
523
|
this.to = to;
|
|
524
|
+
// :: number
|
|
525
|
+
// The start of preserved range.
|
|
514
526
|
this.gapFrom = gapFrom;
|
|
527
|
+
// :: number
|
|
528
|
+
// The end of preserved range.
|
|
515
529
|
this.gapTo = gapTo;
|
|
530
|
+
// :: Slice
|
|
531
|
+
// The slice to insert.
|
|
516
532
|
this.slice = slice;
|
|
533
|
+
// :: number
|
|
534
|
+
// The position in the slice where the preserved range should be
|
|
535
|
+
// inserted.
|
|
517
536
|
this.insert = insert;
|
|
518
537
|
this.structure = !!structure;
|
|
519
538
|
}
|
|
@@ -885,9 +904,14 @@ function dropPoint(doc, pos, slice) {
|
|
|
885
904
|
for (var d = $pos.depth; d >= 0; d--) {
|
|
886
905
|
var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
|
|
887
906
|
var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
907
|
+
var parent = $pos.node(d), fits = false;
|
|
908
|
+
if (pass == 1) {
|
|
909
|
+
fits = parent.canReplace(insertPos, insertPos, content);
|
|
910
|
+
} else {
|
|
911
|
+
var wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
|
|
912
|
+
fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
|
|
913
|
+
}
|
|
914
|
+
if (fits)
|
|
891
915
|
{ return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1) }
|
|
892
916
|
}
|
|
893
917
|
}
|
|
@@ -909,8 +933,14 @@ function mapFragment(fragment, f, parent) {
|
|
|
909
933
|
var AddMarkStep = /*@__PURE__*/(function (Step) {
|
|
910
934
|
function AddMarkStep(from, to, mark) {
|
|
911
935
|
Step.call(this);
|
|
936
|
+
// :: number
|
|
937
|
+
// The start of the marked range.
|
|
912
938
|
this.from = from;
|
|
939
|
+
// :: number
|
|
940
|
+
// The end of the marked range.
|
|
913
941
|
this.to = to;
|
|
942
|
+
// :: Mark
|
|
943
|
+
// The mark to add.
|
|
914
944
|
this.mark = mark;
|
|
915
945
|
}
|
|
916
946
|
|
|
@@ -968,8 +998,14 @@ Step.jsonID("addMark", AddMarkStep);
|
|
|
968
998
|
var RemoveMarkStep = /*@__PURE__*/(function (Step) {
|
|
969
999
|
function RemoveMarkStep(from, to, mark) {
|
|
970
1000
|
Step.call(this);
|
|
1001
|
+
// :: number
|
|
1002
|
+
// The start of the unmarked range.
|
|
971
1003
|
this.from = from;
|
|
1004
|
+
// :: number
|
|
1005
|
+
// The end of the unmarked range.
|
|
972
1006
|
this.to = to;
|
|
1007
|
+
// :: Mark
|
|
1008
|
+
// The mark to remove.
|
|
973
1009
|
this.mark = mark;
|
|
974
1010
|
}
|
|
975
1011
|
|
|
@@ -1575,7 +1611,7 @@ Transform.prototype.replaceRange = function(from, to, slice) {
|
|
|
1575
1611
|
this.replace(from, to, slice);
|
|
1576
1612
|
if (this.steps.length > startSteps) { break }
|
|
1577
1613
|
var depth = targetDepths[i$2];
|
|
1578
|
-
if (
|
|
1614
|
+
if (depth < 0) { continue }
|
|
1579
1615
|
from = $from.before(depth); to = $to.after(depth);
|
|
1580
1616
|
}
|
|
1581
1617
|
return this
|
|
@@ -1641,7 +1677,10 @@ function coveredDepths($from, $to) {
|
|
|
1641
1677
|
$to.end(d) > $to.pos + ($to.depth - d) ||
|
|
1642
1678
|
$from.node(d).type.spec.isolating ||
|
|
1643
1679
|
$to.node(d).type.spec.isolating) { break }
|
|
1644
|
-
if (start == $to.start(d)
|
|
1680
|
+
if (start == $to.start(d) ||
|
|
1681
|
+
(d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&
|
|
1682
|
+
d && $to.start(d - 1) == start - 1))
|
|
1683
|
+
{ result.push(d); }
|
|
1645
1684
|
}
|
|
1646
1685
|
return result
|
|
1647
1686
|
}
|