slate-react 0.77.1 → 0.77.2-20223192094

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.js CHANGED
@@ -1454,6 +1454,8 @@ var Editable$1 = function Editable(props) {
1454
1454
  // When there is an inline element, e.g. a link, and you select
1455
1455
  // right after it (the start of the next node).
1456
1456
  selection.anchor.offset !== 0) {
1457
+ var _node$parentElement;
1458
+
1457
1459
  _native = true; // Skip native if there are marks, as
1458
1460
  // `insertText` will insert a node, not just text.
1459
1461
 
@@ -1465,23 +1467,24 @@ var Editable$1 = function Editable(props) {
1465
1467
 
1466
1468
  var anchor = selection.anchor;
1467
1469
 
1468
- if (slate.Editor.isEnd(editor, anchor, anchor.path)) {
1469
- var _node$parentElement;
1470
+ var _ReactEditor$toDOMPoi = ReactEditor.toDOMPoint(editor, anchor),
1471
+ _ReactEditor$toDOMPoi2 = _slicedToArray(_ReactEditor$toDOMPoi, 2),
1472
+ node = _ReactEditor$toDOMPoi2[0],
1473
+ offset = _ReactEditor$toDOMPoi2[1];
1470
1474
 
1471
- var _ReactEditor$toDOMPoi = ReactEditor.toDOMPoint(editor, selection.anchor),
1472
- _ReactEditor$toDOMPoi2 = _slicedToArray(_ReactEditor$toDOMPoi, 1),
1473
- node = _ReactEditor$toDOMPoi2[0];
1475
+ var anchorNode = (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 ? void 0 : _node$parentElement.closest('a');
1474
1476
 
1475
- var anchorNode = (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 ? void 0 : _node$parentElement.closest('a');
1477
+ if (anchorNode && ReactEditor.hasDOMNode(editor, anchorNode)) {
1478
+ var _lastText$textContent;
1476
1479
 
1477
- if (anchorNode && ReactEditor.hasDOMNode(editor, anchorNode)) {
1478
- var _node = ReactEditor.toSlateNode(editor, anchorNode);
1480
+ var _ReactEditor$getWindo = ReactEditor.getWindow(editor),
1481
+ document = _ReactEditor$getWindo.document; // Find the last text node inside the anchor.
1479
1482
 
1480
- var path = ReactEditor.findPath(editor, _node);
1481
1483
 
1482
- if (slate.Editor.isEnd(editor, anchor, path)) {
1483
- _native = false;
1484
- }
1484
+ var lastText = document.createTreeWalker(anchorNode, NodeFilter.SHOW_TEXT).lastChild();
1485
+
1486
+ if (lastText === node && ((_lastText$textContent = lastText.textContent) === null || _lastText$textContent === void 0 ? void 0 : _lastText$textContent.length) === offset) {
1487
+ _native = false;
1485
1488
  }
1486
1489
  }
1487
1490
  }