slate-react 0.97.0 → 0.97.1

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
@@ -221,7 +221,7 @@ var useSlateStatic = function useSlateStatic() {
221
221
  return editor;
222
222
  };
223
223
 
224
- var IS_REACT_VERSION_17_OR_ABOVE = parseInt(React__default['default'].version.split('.')[0], 10) >= 17;
224
+ var REACT_MAJOR_VERSION = parseInt(React__default['default'].version.split('.')[0], 10);
225
225
  var IS_IOS = typeof navigator !== 'undefined' && typeof window !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
226
226
  var IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
227
227
  var IS_ANDROID = typeof navigator !== 'undefined' && /Android/.test(navigator.userAgent);
@@ -5304,7 +5304,7 @@ var Slate = function Slate(props) {
5304
5304
  return setIsFocused(ReactEditor.isFocused(editor));
5305
5305
  };
5306
5306
 
5307
- if (IS_REACT_VERSION_17_OR_ABOVE) {
5307
+ if (REACT_MAJOR_VERSION >= 17) {
5308
5308
  // In React >= 17 onFocus and onBlur listen to the focusin and focusout events during the bubbling phase.
5309
5309
  // Therefore in order for <Editable />'s handlers to run first, which is necessary for ReactEditor.isFocused(editor)
5310
5310
  // to return the correct value, we have to listen to the focusin and focusout events without useCapture here.
@@ -5740,11 +5740,15 @@ var withReact = function withReact(editor) {
5740
5740
  };
5741
5741
 
5742
5742
  e.onChange = function (options) {
5743
- // COMPAT: React doesn't batch `setState` hook calls, which means that the
5744
- // children and selection can get out of sync for one render pass. So we
5745
- // have to use this unstable API to ensure it batches them. (2019/12/03)
5743
+ // COMPAT: React < 18 doesn't batch `setState` hook calls, which means
5744
+ // that the children and selection can get out of sync for one render
5745
+ // pass. So we have to use this unstable API to ensure it batches them.
5746
+ // (2019/12/03)
5746
5747
  // https://github.com/facebook/react/issues/14259#issuecomment-439702367
5747
- ReactDOM__default['default'].unstable_batchedUpdates(function () {
5748
+ var maybeBatchUpdates = REACT_MAJOR_VERSION < 18 ? ReactDOM__default['default'].unstable_batchedUpdates : function (callback) {
5749
+ return callback();
5750
+ };
5751
+ maybeBatchUpdates(function () {
5748
5752
  var onContextChange = EDITOR_TO_ON_CHANGE.get(e);
5749
5753
 
5750
5754
  if (onContextChange) {