slate 0.82.1 → 0.84.0
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/dist/index.es.js +106 -110
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +104 -103
- package/dist/index.js.map +1 -1
- package/dist/interfaces/path.d.ts.map +1 -1
- package/dist/slate.js +104 -103
- package/dist/slate.min.js +1 -1
- package/dist/transforms/text.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3370,6 +3370,7 @@ var Operation = {
|
|
|
3370
3370
|
}
|
|
3371
3371
|
};
|
|
3372
3372
|
|
|
3373
|
+
// eslint-disable-next-line no-redeclare
|
|
3373
3374
|
var Path = {
|
|
3374
3375
|
/**
|
|
3375
3376
|
* Get a list of ancestor paths for a given path.
|
|
@@ -3653,120 +3654,120 @@ var Path = {
|
|
|
3653
3654
|
*/
|
|
3654
3655
|
transform: function transform(path, operation) {
|
|
3655
3656
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
3656
|
-
|
|
3657
|
-
var _options$affinity = options.affinity,
|
|
3658
|
-
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity; // PERF: Exit early if the operation is guaranteed not to have an effect.
|
|
3657
|
+
if (!path) return null; // PERF: use destructing instead of immer
|
|
3659
3658
|
|
|
3660
|
-
|
|
3661
|
-
return;
|
|
3662
|
-
}
|
|
3659
|
+
var p = _toConsumableArray(path);
|
|
3663
3660
|
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
}
|
|
3661
|
+
var _options$affinity = options.affinity,
|
|
3662
|
+
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity; // PERF: Exit early if the operation is guaranteed not to have an effect.
|
|
3667
3663
|
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
var op = operation.path;
|
|
3664
|
+
if (path.length === 0) {
|
|
3665
|
+
return p;
|
|
3666
|
+
}
|
|
3672
3667
|
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3668
|
+
switch (operation.type) {
|
|
3669
|
+
case 'insert_node':
|
|
3670
|
+
{
|
|
3671
|
+
var op = operation.path;
|
|
3676
3672
|
|
|
3677
|
-
|
|
3673
|
+
if (Path.equals(op, p) || Path.endsBefore(op, p) || Path.isAncestor(op, p)) {
|
|
3674
|
+
p[op.length - 1] += 1;
|
|
3678
3675
|
}
|
|
3679
3676
|
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
var _op = operation.path;
|
|
3677
|
+
break;
|
|
3678
|
+
}
|
|
3683
3679
|
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
p[_op.length - 1] -= 1;
|
|
3688
|
-
}
|
|
3680
|
+
case 'remove_node':
|
|
3681
|
+
{
|
|
3682
|
+
var _op = operation.path;
|
|
3689
3683
|
|
|
3690
|
-
|
|
3684
|
+
if (Path.equals(_op, p) || Path.isAncestor(_op, p)) {
|
|
3685
|
+
return null;
|
|
3686
|
+
} else if (Path.endsBefore(_op, p)) {
|
|
3687
|
+
p[_op.length - 1] -= 1;
|
|
3691
3688
|
}
|
|
3692
3689
|
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
var _op2 = operation.path,
|
|
3696
|
-
position = operation.position;
|
|
3697
|
-
|
|
3698
|
-
if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
|
|
3699
|
-
p[_op2.length - 1] -= 1;
|
|
3700
|
-
} else if (Path.isAncestor(_op2, p)) {
|
|
3701
|
-
p[_op2.length - 1] -= 1;
|
|
3702
|
-
p[_op2.length] += position;
|
|
3703
|
-
}
|
|
3690
|
+
break;
|
|
3691
|
+
}
|
|
3704
3692
|
|
|
3705
|
-
|
|
3693
|
+
case 'merge_node':
|
|
3694
|
+
{
|
|
3695
|
+
var _op2 = operation.path,
|
|
3696
|
+
position = operation.position;
|
|
3697
|
+
|
|
3698
|
+
if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
|
|
3699
|
+
p[_op2.length - 1] -= 1;
|
|
3700
|
+
} else if (Path.isAncestor(_op2, p)) {
|
|
3701
|
+
p[_op2.length - 1] -= 1;
|
|
3702
|
+
p[_op2.length] += position;
|
|
3706
3703
|
}
|
|
3707
3704
|
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
var _op3 = operation.path,
|
|
3711
|
-
_position = operation.position;
|
|
3705
|
+
break;
|
|
3706
|
+
}
|
|
3712
3707
|
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
return null;
|
|
3718
|
-
}
|
|
3719
|
-
} else if (Path.endsBefore(_op3, p)) {
|
|
3720
|
-
p[_op3.length - 1] += 1;
|
|
3721
|
-
} else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
|
|
3722
|
-
p[_op3.length - 1] += 1;
|
|
3723
|
-
p[_op3.length] -= _position;
|
|
3724
|
-
}
|
|
3708
|
+
case 'split_node':
|
|
3709
|
+
{
|
|
3710
|
+
var _op3 = operation.path,
|
|
3711
|
+
_position = operation.position;
|
|
3725
3712
|
|
|
3726
|
-
|
|
3713
|
+
if (Path.equals(_op3, p)) {
|
|
3714
|
+
if (affinity === 'forward') {
|
|
3715
|
+
p[p.length - 1] += 1;
|
|
3716
|
+
} else if (affinity === 'backward') ; else {
|
|
3717
|
+
return null;
|
|
3718
|
+
}
|
|
3719
|
+
} else if (Path.endsBefore(_op3, p)) {
|
|
3720
|
+
p[_op3.length - 1] += 1;
|
|
3721
|
+
} else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
|
|
3722
|
+
p[_op3.length - 1] += 1;
|
|
3723
|
+
p[_op3.length] -= _position;
|
|
3727
3724
|
}
|
|
3728
3725
|
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
var _op4 = operation.path,
|
|
3732
|
-
onp = operation.newPath; // If the old and new path are the same, it's a no-op.
|
|
3733
|
-
|
|
3734
|
-
if (Path.equals(_op4, onp)) {
|
|
3735
|
-
return;
|
|
3736
|
-
}
|
|
3726
|
+
break;
|
|
3727
|
+
}
|
|
3737
3728
|
|
|
3738
|
-
|
|
3739
|
-
|
|
3729
|
+
case 'move_node':
|
|
3730
|
+
{
|
|
3731
|
+
var _op4 = operation.path,
|
|
3732
|
+
onp = operation.newPath; // If the old and new path are the same, it's a no-op.
|
|
3740
3733
|
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3734
|
+
if (Path.equals(_op4, onp)) {
|
|
3735
|
+
return p;
|
|
3736
|
+
}
|
|
3744
3737
|
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
if (Path.endsBefore(_op4, p)) {
|
|
3748
|
-
p[_op4.length - 1] -= 1;
|
|
3749
|
-
} else {
|
|
3750
|
-
p[_op4.length - 1] += 1;
|
|
3751
|
-
}
|
|
3752
|
-
} else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
|
|
3753
|
-
if (Path.endsBefore(_op4, p)) {
|
|
3754
|
-
p[_op4.length - 1] -= 1;
|
|
3755
|
-
}
|
|
3738
|
+
if (Path.isAncestor(_op4, p) || Path.equals(_op4, p)) {
|
|
3739
|
+
var copy = onp.slice();
|
|
3756
3740
|
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
p[onp.length - 1] += 1;
|
|
3761
|
-
}
|
|
3741
|
+
if (Path.endsBefore(_op4, onp) && _op4.length < onp.length) {
|
|
3742
|
+
copy[_op4.length - 1] -= 1;
|
|
3743
|
+
}
|
|
3762
3744
|
|
|
3745
|
+
return copy.concat(p.slice(_op4.length));
|
|
3746
|
+
} else if (Path.isSibling(_op4, onp) && (Path.isAncestor(onp, p) || Path.equals(onp, p))) {
|
|
3747
|
+
if (Path.endsBefore(_op4, p)) {
|
|
3748
|
+
p[_op4.length - 1] -= 1;
|
|
3749
|
+
} else {
|
|
3750
|
+
p[_op4.length - 1] += 1;
|
|
3751
|
+
}
|
|
3752
|
+
} else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
|
|
3753
|
+
if (Path.endsBefore(_op4, p)) {
|
|
3763
3754
|
p[_op4.length - 1] -= 1;
|
|
3764
3755
|
}
|
|
3765
3756
|
|
|
3766
|
-
|
|
3757
|
+
p[onp.length - 1] += 1;
|
|
3758
|
+
} else if (Path.endsBefore(_op4, p)) {
|
|
3759
|
+
if (Path.equals(onp, p)) {
|
|
3760
|
+
p[onp.length - 1] += 1;
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
p[_op4.length - 1] -= 1;
|
|
3767
3764
|
}
|
|
3768
|
-
|
|
3769
|
-
|
|
3765
|
+
|
|
3766
|
+
break;
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
return p;
|
|
3770
3771
|
}
|
|
3771
3772
|
};
|
|
3772
3773
|
|
|
@@ -6439,15 +6440,15 @@ var TextTransforms = {
|
|
|
6439
6440
|
|
|
6440
6441
|
var _entry = _slicedToArray(entry, 2),
|
|
6441
6442
|
_node2 = _entry[0],
|
|
6442
|
-
|
|
6443
|
+
_path2 = _entry[1];
|
|
6443
6444
|
|
|
6444
|
-
if (lastPath && Path.compare(
|
|
6445
|
+
if (lastPath && Path.compare(_path2, lastPath) === 0) {
|
|
6445
6446
|
continue;
|
|
6446
6447
|
}
|
|
6447
6448
|
|
|
6448
|
-
if (!voids && Editor.isVoid(editor, _node2) || !Path.isCommon(
|
|
6449
|
+
if (!voids && Editor.isVoid(editor, _node2) || !Path.isCommon(_path2, start.path) && !Path.isCommon(_path2, end.path)) {
|
|
6449
6450
|
matches.push(entry);
|
|
6450
|
-
lastPath =
|
|
6451
|
+
lastPath = _path2;
|
|
6451
6452
|
}
|
|
6452
6453
|
}
|
|
6453
6454
|
} catch (err) {
|
|
@@ -6489,16 +6490,16 @@ var TextTransforms = {
|
|
|
6489
6490
|
}
|
|
6490
6491
|
}
|
|
6491
6492
|
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
Transforms.removeNodes(editor, {
|
|
6498
|
-
at:
|
|
6493
|
+
pathRefs.reverse().map(function (r) {
|
|
6494
|
+
return r.unref();
|
|
6495
|
+
}).filter(function (r) {
|
|
6496
|
+
return r !== null;
|
|
6497
|
+
}).forEach(function (p) {
|
|
6498
|
+
return Transforms.removeNodes(editor, {
|
|
6499
|
+
at: p,
|
|
6499
6500
|
voids: voids
|
|
6500
6501
|
});
|
|
6501
|
-
}
|
|
6502
|
+
});
|
|
6502
6503
|
|
|
6503
6504
|
if (!endVoid) {
|
|
6504
6505
|
var _point2 = endRef.current;
|
|
@@ -6507,7 +6508,7 @@ var TextTransforms = {
|
|
|
6507
6508
|
_Editor$leaf4 = _slicedToArray(_Editor$leaf3, 1),
|
|
6508
6509
|
_node = _Editor$leaf4[0];
|
|
6509
6510
|
|
|
6510
|
-
var
|
|
6511
|
+
var _path = _point2.path;
|
|
6511
6512
|
|
|
6512
6513
|
var _offset = isSingleText ? start.offset : 0;
|
|
6513
6514
|
|
|
@@ -6516,7 +6517,7 @@ var TextTransforms = {
|
|
|
6516
6517
|
if (_text.length > 0) {
|
|
6517
6518
|
editor.apply({
|
|
6518
6519
|
type: 'remove_text',
|
|
6519
|
-
path:
|
|
6520
|
+
path: _path,
|
|
6520
6521
|
offset: _offset,
|
|
6521
6522
|
text: _text
|
|
6522
6523
|
});
|
|
@@ -6710,8 +6711,8 @@ var TextTransforms = {
|
|
|
6710
6711
|
var starting = true;
|
|
6711
6712
|
var hasBlocks = false;
|
|
6712
6713
|
|
|
6713
|
-
for (var
|
|
6714
|
-
var _matches$_i = _slicedToArray(_matches[
|
|
6714
|
+
for (var _i = 0, _matches = matches; _i < _matches.length; _i++) {
|
|
6715
|
+
var _matches$_i = _slicedToArray(_matches[_i], 1),
|
|
6715
6716
|
node = _matches$_i[0];
|
|
6716
6717
|
|
|
6717
6718
|
if (Element.isElement(node) && !editor.isInline(node)) {
|