slate-react 0.100.1 → 0.100.2-20231109130745

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 CHANGED
@@ -815,6 +815,7 @@ var ReactEditor = {
815
815
  };
816
816
  },
817
817
  toSlateRange: (editor, domRange, options) => {
818
+ var _focusNode$textConten;
818
819
  var {
819
820
  exactMatch,
820
821
  suppressThrow
@@ -907,6 +908,12 @@ var ReactEditor = {
907
908
  if (anchorNode == null || focusNode == null || anchorOffset == null || focusOffset == null) {
908
909
  throw new Error("Cannot resolve a Slate range from DOM range: ".concat(domRange));
909
910
  }
911
+ // COMPAT: Firefox sometimes includes an extra \n (rendered by TextString
912
+ // when isTrailing is true) in the focusOffset, resulting in an invalid
913
+ // Slate point. (2023/11/01)
914
+ if (IS_FIREFOX && (_focusNode$textConten = focusNode.textContent) !== null && _focusNode$textConten !== void 0 && _focusNode$textConten.endsWith('\n\n') && focusOffset === focusNode.textContent.length) {
915
+ focusOffset--;
916
+ }
910
917
  // COMPAT: Triple-clicking a word in chrome will sometimes place the focus
911
918
  // inside a `contenteditable="false"` DOM node following the word, which
912
919
  // will cause `toSlatePoint` to throw an error. (2023/03/07)