slate-react 0.83.0 → 0.83.1-20229315647

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
@@ -331,6 +331,7 @@ function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbo
331
331
  function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
332
332
 
333
333
  function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
334
+ var DOMText = globalThis.Text;
334
335
  /**
335
336
  * Returns the host window of a DOM node
336
337
  */
@@ -875,7 +876,13 @@ var ReactEditor = {
875
876
  if (point.offset === end && nextText !== null && nextText !== void 0 && nextText.hasAttribute('data-slate-mark-placeholder')) {
876
877
  var _nextText$textContent;
877
878
 
878
- domPoint = [nextText, (_nextText$textContent = nextText.textContent) !== null && _nextText$textContent !== void 0 && _nextText$textContent.startsWith("\uFEFF") ? 1 : 0];
879
+ var domText = nextText.childNodes[0];
880
+ domPoint = [// COMPAT: If we don't explicity set the dom point to be on the actual
881
+ // dom text element, chrome will put the selection behind the actual dom
882
+ // text element, causing domRange.getBoundingClientRect() calls on a collapsed
883
+ // selection to return incorrect zero values (https://bugs.chromium.org/p/chromium/issues/detail?id=435438)
884
+ // which will cause issues when scrolling to it.
885
+ domText instanceof DOMText ? domText : nextText, (_nextText$textContent = nextText.textContent) !== null && _nextText$textContent !== void 0 && _nextText$textContent.startsWith("\uFEFF") ? 1 : 0];
879
886
  break;
880
887
  }
881
888