slate-react 0.72.4 → 0.72.6

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.
@@ -855,6 +855,40 @@
855
855
  return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);
856
856
  }
857
857
 
858
+ var IS_IOS = typeof navigator !== 'undefined' && typeof window !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
859
+ var IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
860
+ var IS_ANDROID = typeof navigator !== 'undefined' && /Android/.test(navigator.userAgent);
861
+ var IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
862
+ var IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent); // "modern" Edge was released at 79.x
863
+
864
+ var IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
865
+ var IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent); // Native `beforeInput` events don't work well with react on Chrome 75
866
+ // and older, Chrome 76+ can use `beforeInput` though.
867
+
868
+ var IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent); // Firefox did not support `beforeInput` until `v87`.
869
+
870
+ var IS_FIREFOX_LEGACY = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])).*/i.test(navigator.userAgent); // qq browser
871
+
872
+ var IS_QQBROWSER = typeof navigator !== 'undefined' && /.*QQBrowser/.test(navigator.userAgent); // UC mobile browser
873
+
874
+ var IS_UC_MOBILE = typeof navigator !== 'undefined' && /.*UCBrowser/.test(navigator.userAgent); // Wechat browser
875
+
876
+ var IS_WECHATBROWSER = typeof navigator !== 'undefined' && /.*Wechat/.test(navigator.userAgent); // Check if DOM is available as React does internally.
877
+ // https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
878
+
879
+ var CAN_USE_DOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); // COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
880
+ // Chrome Legacy doesn't support `beforeinput` correctly
881
+
882
+ var HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
883
+ typeof globalThis !== 'undefined' && globalThis.InputEvent && // @ts-ignore The `getTargetRanges` property isn't recognized.
884
+ typeof globalThis.InputEvent.prototype.getTargetRanges === 'function';
885
+
886
+ /**
887
+ * Prevent warning on SSR by falling back to useEffect when DOM isn't available
888
+ */
889
+
890
+ var useIsomorphicLayoutEffect = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
891
+
858
892
  /**
859
893
  * Leaf content strings.
860
894
  */
@@ -922,7 +956,7 @@
922
956
  // eg makes native spellcheck opt out from checking the text node.
923
957
  // useLayoutEffect: updating our span before browser paint
924
958
 
925
- React.useLayoutEffect(function () {
959
+ useIsomorphicLayoutEffect(function () {
926
960
  // null coalescing text to make sure we're not outputing "null" as a string in the extreme case it is nullish at runtime
927
961
  var textWithTrailing = "".concat(text !== null && text !== void 0 ? text : '').concat(isTrailing ? '\n' : '');
928
962
 
@@ -1076,40 +1110,6 @@
1076
1110
  return /*#__PURE__*/React__default['default'].createElement("span", Object.assign({}, attributes), children);
1077
1111
  };
1078
1112
 
1079
- var IS_IOS = typeof navigator !== 'undefined' && typeof window !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
1080
- var IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
1081
- var IS_ANDROID = typeof navigator !== 'undefined' && /Android/.test(navigator.userAgent);
1082
- var IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
1083
- var IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent); // "modern" Edge was released at 79.x
1084
-
1085
- var IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
1086
- var IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent); // Native `beforeInput` events don't work well with react on Chrome 75
1087
- // and older, Chrome 76+ can use `beforeInput` though.
1088
-
1089
- var IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent); // Firefox did not support `beforeInput` until `v87`.
1090
-
1091
- var IS_FIREFOX_LEGACY = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])).*/i.test(navigator.userAgent); // qq browser
1092
-
1093
- var IS_QQBROWSER = typeof navigator !== 'undefined' && /.*QQBrowser/.test(navigator.userAgent); // UC mobile browser
1094
-
1095
- var IS_UC_MOBILE = typeof navigator !== 'undefined' && /.*UCBrowser/.test(navigator.userAgent); // Wechat browser
1096
-
1097
- var IS_WECHATBROWSER = typeof navigator !== 'undefined' && /.*Wechat/.test(navigator.userAgent); // Check if DOM is available as React does internally.
1098
- // https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
1099
-
1100
- var CAN_USE_DOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); // COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
1101
- // Chrome Legacy doesn't support `beforeinput` correctly
1102
-
1103
- var HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
1104
- typeof globalThis !== 'undefined' && globalThis.InputEvent && // @ts-ignore The `getTargetRanges` property isn't recognized.
1105
- typeof globalThis.InputEvent.prototype.getTargetRanges === 'function';
1106
-
1107
- /**
1108
- * Prevent warning on SSR by falling back to useEffect when DOM isn't available
1109
- */
1110
-
1111
- var useIsomorphicLayoutEffect = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
1112
-
1113
1113
  var _excluded$3 = ["anchor", "focus"],
1114
1114
  _excluded2 = ["anchor", "focus"];
1115
1115
  var shallowCompare = function shallowCompare(obj1, obj2) {
@@ -2220,7 +2220,7 @@
2220
2220
 
2221
2221
 
2222
2222
  state.isUpdatingSelection = true;
2223
- var newDomRange = selection && ReactEditor.toDOMRange(editor, selection);
2223
+ var newDomRange = selection && hasDomSelectionInEditor && ReactEditor.toDOMRange(editor, selection);
2224
2224
 
2225
2225
  if (newDomRange) {
2226
2226
  if (slate.Range.isBackward(selection)) {
@@ -5097,20 +5097,10 @@
5097
5097
  };
5098
5098
 
5099
5099
  document.addEventListener('focus', fn, true);
5100
- return function () {
5101
- return document.removeEventListener('focus', fn, true);
5102
- };
5103
- }, []);
5104
- useIsomorphicLayoutEffect(function () {
5105
- var fn = function fn() {
5106
- setTimeout(function () {
5107
- setIsFocused(ReactEditor.isFocused(editor));
5108
- }, 0);
5109
- };
5110
-
5111
5100
  document.addEventListener('blur', fn, true);
5112
5101
  return function () {
5113
- return document.removeEventListener('blur', fn, true);
5102
+ document.removeEventListener('focus', fn, true);
5103
+ document.removeEventListener('blur', fn, true);
5114
5104
  };
5115
5105
  }, []);
5116
5106
  return /*#__PURE__*/React__default['default'].createElement(SlateContext.Provider, {