slate-react 0.91.11 → 0.92.0-202321717544

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.
@@ -2791,7 +2791,7 @@
2791
2791
  return function () {
2792
2792
  EDITOR_TO_PLACEHOLDER_ELEMENT["delete"](editor);
2793
2793
  };
2794
- }, [placeholderRef, leaf]);
2794
+ }, [placeholderRef, leaf, editor]);
2795
2795
  var children = /*#__PURE__*/React__default['default'].createElement(String$1, {
2796
2796
  isLast: isLast,
2797
2797
  leaf: leaf,
@@ -5044,7 +5044,7 @@
5044
5044
  return function () {
5045
5045
  return mutationObserver.disconnect();
5046
5046
  };
5047
- }, []);
5047
+ }, [mutationObserver, node, options]);
5048
5048
  }
5049
5049
 
5050
5050
  var _excluded$2 = ["node"];
@@ -5057,7 +5057,9 @@
5057
5057
  childList: true,
5058
5058
  characterData: true
5059
5059
  };
5060
- function useAndroidInputManager(_ref) {
5060
+ var useAndroidInputManager = !IS_ANDROID ? function () {
5061
+ return null;
5062
+ } : function (_ref) {
5061
5063
  var node = _ref.node,
5062
5064
  options = _objectWithoutProperties(_ref, _excluded$2);
5063
5065
 
@@ -5084,7 +5086,7 @@
5084
5086
  }
5085
5087
 
5086
5088
  return inputManager;
5087
- }
5089
+ };
5088
5090
 
5089
5091
  function useTrackUserInput() {
5090
5092
  var editor = useSlateStatic();
@@ -5101,7 +5103,7 @@
5101
5103
  animationFrameIdRef.current = window.requestAnimationFrame(function () {
5102
5104
  receivedUserInput.current = false;
5103
5105
  });
5104
- }, []);
5106
+ }, [editor]);
5105
5107
  React.useEffect(function () {
5106
5108
  return function () {
5107
5109
  return cancelAnimationFrame(animationFrameIdRef.current);
@@ -5200,65 +5202,79 @@
5200
5202
  if (ref.current && autoFocus) {
5201
5203
  ref.current.focus();
5202
5204
  }
5203
- }, [autoFocus]); // Listen on the native `selectionchange` event to be able to update any time
5205
+ }, [autoFocus]);
5206
+ /**
5207
+ * The AndroidInputManager object has a cyclical dependency on onDOMSelectionChange
5208
+ *
5209
+ * It is defined as a reference to simplify hook dependencies and clarify that
5210
+ * it needs to be initialized.
5211
+ */
5212
+
5213
+ var androidInputManagerRef = React.useRef(); // Listen on the native `selectionchange` event to be able to update any time
5204
5214
  // the selection changes. This is required because React's `onSelect` is leaky
5205
5215
  // and non-standard so it doesn't fire until after a selection has been
5206
5216
  // released. This causes issues in situations where another change happens
5207
5217
  // while a selection is being dragged.
5208
5218
 
5209
- var onDOMSelectionChange = React.useCallback(throttle_1(function () {
5210
- if ((IS_ANDROID || !ReactEditor.isComposing(editor)) && (!state.isUpdatingSelection || androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.isFlushing()) && !state.isDraggingInternally) {
5211
- var root = ReactEditor.findDocumentOrShadowRoot(editor);
5212
- var activeElement = root.activeElement;
5213
- var el = ReactEditor.toDOMNode(editor, editor);
5214
- var domSelection = root.getSelection();
5219
+ var onDOMSelectionChange = React.useMemo(function () {
5220
+ return throttle_1(function () {
5221
+ var androidInputManager = androidInputManagerRef.current;
5215
5222
 
5216
- if (activeElement === el) {
5217
- state.latestElement = activeElement;
5218
- IS_FOCUSED.set(editor, true);
5219
- } else {
5220
- IS_FOCUSED["delete"](editor);
5221
- }
5223
+ if ((IS_ANDROID || !ReactEditor.isComposing(editor)) && (!state.isUpdatingSelection || androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.isFlushing()) && !state.isDraggingInternally) {
5224
+ var root = ReactEditor.findDocumentOrShadowRoot(editor);
5225
+ var activeElement = root.activeElement;
5226
+ var el = ReactEditor.toDOMNode(editor, editor);
5227
+ var domSelection = root.getSelection();
5222
5228
 
5223
- if (!domSelection) {
5224
- return slate.Transforms.deselect(editor);
5225
- }
5229
+ if (activeElement === el) {
5230
+ state.latestElement = activeElement;
5231
+ IS_FOCUSED.set(editor, true);
5232
+ } else {
5233
+ IS_FOCUSED["delete"](editor);
5234
+ }
5226
5235
 
5227
- var anchorNode = domSelection.anchorNode,
5228
- focusNode = domSelection.focusNode;
5229
- var anchorNodeSelectable = ReactEditor.hasEditableTarget(editor, anchorNode) || ReactEditor.isTargetInsideNonReadonlyVoid(editor, anchorNode);
5230
- var focusNodeSelectable = ReactEditor.hasEditableTarget(editor, focusNode) || ReactEditor.isTargetInsideNonReadonlyVoid(editor, focusNode);
5236
+ if (!domSelection) {
5237
+ return slate.Transforms.deselect(editor);
5238
+ }
5231
5239
 
5232
- if (anchorNodeSelectable && focusNodeSelectable) {
5233
- var range = ReactEditor.toSlateRange(editor, domSelection, {
5234
- exactMatch: false,
5235
- suppressThrow: true
5236
- });
5240
+ var anchorNode = domSelection.anchorNode,
5241
+ focusNode = domSelection.focusNode;
5242
+ var anchorNodeSelectable = ReactEditor.hasEditableTarget(editor, anchorNode) || ReactEditor.isTargetInsideNonReadonlyVoid(editor, anchorNode);
5243
+ var focusNodeSelectable = ReactEditor.hasEditableTarget(editor, focusNode) || ReactEditor.isTargetInsideNonReadonlyVoid(editor, focusNode);
5237
5244
 
5238
- if (range) {
5239
- if (!ReactEditor.isComposing(editor) && !(androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.hasPendingChanges()) && !(androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.isFlushing())) {
5240
- slate.Transforms.select(editor, range);
5241
- } else {
5242
- androidInputManager === null || androidInputManager === void 0 ? void 0 : androidInputManager.handleUserSelect(range);
5245
+ if (anchorNodeSelectable && focusNodeSelectable) {
5246
+ var range = ReactEditor.toSlateRange(editor, domSelection, {
5247
+ exactMatch: false,
5248
+ suppressThrow: true
5249
+ });
5250
+
5251
+ if (range) {
5252
+ if (!ReactEditor.isComposing(editor) && !(androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.hasPendingChanges()) && !(androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.isFlushing())) {
5253
+ slate.Transforms.select(editor, range);
5254
+ } else {
5255
+ androidInputManager === null || androidInputManager === void 0 ? void 0 : androidInputManager.handleUserSelect(range);
5256
+ }
5243
5257
  }
5244
- }
5245
- } // Deselect the editor if the dom selection is not selectable in readonly mode
5258
+ } // Deselect the editor if the dom selection is not selectable in readonly mode
5246
5259
 
5247
5260
 
5248
- if (readOnly && (!anchorNodeSelectable || !focusNodeSelectable)) {
5249
- slate.Transforms.deselect(editor);
5261
+ if (readOnly && (!anchorNodeSelectable || !focusNodeSelectable)) {
5262
+ slate.Transforms.deselect(editor);
5263
+ }
5250
5264
  }
5251
- }
5252
- }, 100), [readOnly]);
5265
+ }, 100);
5266
+ }, [editor, readOnly, state]);
5253
5267
  var scheduleOnDOMSelectionChange = React.useMemo(function () {
5254
5268
  return debounce_1(onDOMSelectionChange, 0);
5255
5269
  }, [onDOMSelectionChange]);
5256
- var androidInputManager = useAndroidInputManager({
5270
+ androidInputManagerRef.current = useAndroidInputManager({
5257
5271
  node: ref,
5258
5272
  onDOMSelectionChange: onDOMSelectionChange,
5259
5273
  scheduleOnDOMSelectionChange: scheduleOnDOMSelectionChange
5260
5274
  });
5261
5275
  useIsomorphicLayoutEffect(function () {
5276
+ var _androidInputManagerR, _androidInputManagerR2;
5277
+
5262
5278
  // Update element-related weak maps with the DOM element ref.
5263
5279
  var window;
5264
5280
 
@@ -5276,7 +5292,7 @@
5276
5292
  var root = ReactEditor.findDocumentOrShadowRoot(editor);
5277
5293
  var domSelection = root.getSelection();
5278
5294
 
5279
- if (!domSelection || !ReactEditor.isFocused(editor) || androidInputManager !== null && androidInputManager !== void 0 && androidInputManager.hasPendingAction()) {
5295
+ if (!domSelection || !ReactEditor.isFocused(editor) || (_androidInputManagerR = androidInputManagerRef.current) !== null && _androidInputManagerR !== void 0 && _androidInputManagerR.hasPendingAction()) {
5280
5296
  return;
5281
5297
  }
5282
5298
 
@@ -5352,7 +5368,7 @@
5352
5368
  };
5353
5369
 
5354
5370
  var newDomRange = setDomSelection();
5355
- var ensureSelection = (androidInputManager === null || androidInputManager === void 0 ? void 0 : androidInputManager.isFlushing()) === 'action';
5371
+ var ensureSelection = ((_androidInputManagerR2 = androidInputManagerRef.current) === null || _androidInputManagerR2 === void 0 ? void 0 : _androidInputManagerR2.isFlushing()) === 'action';
5356
5372
 
5357
5373
  if (!IS_ANDROID || !ensureSelection) {
5358
5374
  setTimeout(function () {
@@ -5413,8 +5429,8 @@
5413
5429
  var _EDITOR_TO_USER_SELEC;
5414
5430
 
5415
5431
  // COMPAT: BeforeInput events aren't cancelable on android, so we have to handle them differently using the android input manager.
5416
- if (androidInputManager) {
5417
- return androidInputManager.handleDOMBeforeInput(event);
5432
+ if (androidInputManagerRef.current) {
5433
+ return androidInputManagerRef.current.handleDOMBeforeInput(event);
5418
5434
  } // Some IMEs/Chrome extensions like e.g. Grammarly set the selection immediately before
5419
5435
  // triggering a `beforeinput` expecting the change to be applied to the immediately before
5420
5436
  // set selection.
@@ -5674,7 +5690,7 @@
5674
5690
  slate.Transforms.select(editor, toRestore);
5675
5691
  }
5676
5692
  }
5677
- }, [readOnly, propsOnDOMBeforeInput]);
5693
+ }, [editor, onDOMSelectionChange, onUserInput, propsOnDOMBeforeInput, readOnly, scheduleOnDOMSelectionChange]);
5678
5694
  var callbackRef = React.useCallback(function (node) {
5679
5695
  if (node == null) {
5680
5696
  onDOMSelectionChange.cancel();
@@ -5698,7 +5714,7 @@
5698
5714
  }
5699
5715
 
5700
5716
  ref.current = node;
5701
- }, [ref, onDOMBeforeInput, onDOMSelectionChange, scheduleOnDOMSelectionChange]); // Attach a native DOM event handler for `selectionchange`, because React's
5717
+ }, [onDOMSelectionChange, scheduleOnDOMSelectionChange, editor, onDOMBeforeInput]); // Attach a native DOM event handler for `selectionchange`, because React's
5702
5718
  // built-in `onSelect` handler doesn't fire for all selection changes. It's a
5703
5719
  // leaky polyfill that only fires on keypresses or clicks. Instead, we want to
5704
5720
  // fire for any change to the selection inside the editor. (2019/11/04)
@@ -5824,14 +5840,14 @@
5824
5840
  slate.Editor.insertText(editor, _text2);
5825
5841
  }
5826
5842
  }
5827
- }, [readOnly]),
5843
+ }, [attributes.onBeforeInput, editor, readOnly]),
5828
5844
  onInput: React.useCallback(function (event) {
5829
5845
  if (isEventHandled(event, attributes.onInput)) {
5830
5846
  return;
5831
5847
  }
5832
5848
 
5833
- if (androidInputManager) {
5834
- androidInputManager.handleInput();
5849
+ if (androidInputManagerRef.current) {
5850
+ androidInputManagerRef.current.handleInput();
5835
5851
  return;
5836
5852
  } // Flush native operations, as native events will have propogated
5837
5853
  // and we can correctly compare DOM text values in components
@@ -5854,7 +5870,7 @@
5854
5870
  }
5855
5871
 
5856
5872
  deferredOperations.current = [];
5857
- }, []),
5873
+ }, [attributes.onInput]),
5858
5874
  onBlur: React.useCallback(function (event) {
5859
5875
  if (readOnly || state.isUpdatingSelection || !ReactEditor.hasSelectableTarget(editor, event.target) || isEventHandled(event, attributes.onBlur)) {
5860
5876
  return;
@@ -5905,7 +5921,7 @@
5905
5921
  }
5906
5922
 
5907
5923
  IS_FOCUSED["delete"](editor);
5908
- }, [readOnly, attributes.onBlur]),
5924
+ }, [readOnly, state.isUpdatingSelection, state.latestElement, editor, attributes.onBlur]),
5909
5925
  onClick: React.useCallback(function (event) {
5910
5926
  if (ReactEditor.hasTarget(editor, event.target) && !isEventHandled(event, attributes.onClick) && isDOMNode(event.target)) {
5911
5927
  var node = ReactEditor.toSlateNode(editor, event.target);
@@ -5958,15 +5974,17 @@
5958
5974
  slate.Transforms.select(editor, _range);
5959
5975
  }
5960
5976
  }
5961
- }, [readOnly, attributes.onClick]),
5977
+ }, [editor, attributes.onClick, readOnly]),
5962
5978
  onCompositionEnd: React.useCallback(function (event) {
5963
5979
  if (ReactEditor.hasSelectableTarget(editor, event.target)) {
5980
+ var _androidInputManagerR3;
5981
+
5964
5982
  if (ReactEditor.isComposing(editor)) {
5965
5983
  setIsComposing(false);
5966
5984
  IS_COMPOSING.set(editor, false);
5967
5985
  }
5968
5986
 
5969
- androidInputManager === null || androidInputManager === void 0 ? void 0 : androidInputManager.handleCompositionEnd(event);
5987
+ (_androidInputManagerR3 = androidInputManagerRef.current) === null || _androidInputManagerR3 === void 0 ? void 0 : _androidInputManagerR3.handleCompositionEnd(event);
5970
5988
 
5971
5989
  if (isEventHandled(event, attributes.onCompositionEnd) || IS_ANDROID) {
5972
5990
  return;
@@ -5994,7 +6012,7 @@
5994
6012
  }
5995
6013
  }
5996
6014
  }
5997
- }, [attributes.onCompositionEnd]),
6015
+ }, [attributes.onCompositionEnd, editor]),
5998
6016
  onCompositionUpdate: React.useCallback(function (event) {
5999
6017
  if (ReactEditor.hasSelectableTarget(editor, event.target) && !isEventHandled(event, attributes.onCompositionUpdate)) {
6000
6018
  if (!ReactEditor.isComposing(editor)) {
@@ -6002,10 +6020,12 @@
6002
6020
  IS_COMPOSING.set(editor, true);
6003
6021
  }
6004
6022
  }
6005
- }, [attributes.onCompositionUpdate]),
6023
+ }, [attributes.onCompositionUpdate, editor]),
6006
6024
  onCompositionStart: React.useCallback(function (event) {
6007
6025
  if (ReactEditor.hasSelectableTarget(editor, event.target)) {
6008
- androidInputManager === null || androidInputManager === void 0 ? void 0 : androidInputManager.handleCompositionStart(event);
6026
+ var _androidInputManagerR4;
6027
+
6028
+ (_androidInputManagerR4 = androidInputManagerRef.current) === null || _androidInputManagerR4 === void 0 ? void 0 : _androidInputManagerR4.handleCompositionStart(event);
6009
6029
 
6010
6030
  if (isEventHandled(event, attributes.onCompositionStart) || IS_ANDROID) {
6011
6031
  return;
@@ -6041,15 +6061,15 @@
6041
6061
  }
6042
6062
  }
6043
6063
  }
6044
- }, [attributes.onCompositionStart]),
6064
+ }, [attributes.onCompositionStart, editor]),
6045
6065
  onCopy: React.useCallback(function (event) {
6046
- if (ReactEditor.hasSelectableTarget(editor, event.target) && !isEventHandled(event, attributes.onCopy)) {
6066
+ if (ReactEditor.hasSelectableTarget(editor, event.target) && !isEventHandled(event, attributes.onCopy) && !isDOMEventTargetInput(event)) {
6047
6067
  event.preventDefault();
6048
6068
  ReactEditor.setFragmentData(editor, event.clipboardData, 'copy');
6049
6069
  }
6050
- }, [attributes.onCopy]),
6070
+ }, [attributes.onCopy, editor]),
6051
6071
  onCut: React.useCallback(function (event) {
6052
- if (!readOnly && ReactEditor.hasSelectableTarget(editor, event.target) && !isEventHandled(event, attributes.onCut)) {
6072
+ if (!readOnly && ReactEditor.hasSelectableTarget(editor, event.target) && !isEventHandled(event, attributes.onCut) && !isDOMEventTargetInput(event)) {
6053
6073
  event.preventDefault();
6054
6074
  ReactEditor.setFragmentData(editor, event.clipboardData, 'cut');
6055
6075
  var selection = editor.selection;
@@ -6066,7 +6086,7 @@
6066
6086
  }
6067
6087
  }
6068
6088
  }
6069
- }, [readOnly, attributes.onCut]),
6089
+ }, [readOnly, editor, attributes.onCut]),
6070
6090
  onDragOver: React.useCallback(function (event) {
6071
6091
  if (ReactEditor.hasTarget(editor, event.target) && !isEventHandled(event, attributes.onDragOver)) {
6072
6092
  // Only when the target is void, call `preventDefault` to signal
@@ -6078,7 +6098,7 @@
6078
6098
  event.preventDefault();
6079
6099
  }
6080
6100
  }
6081
- }, [attributes.onDragOver]),
6101
+ }, [attributes.onDragOver, editor]),
6082
6102
  onDragStart: React.useCallback(function (event) {
6083
6103
  if (!readOnly && ReactEditor.hasTarget(editor, event.target) && !isEventHandled(event, attributes.onDragStart)) {
6084
6104
  var node = ReactEditor.toSlateNode(editor, event.target);
@@ -6097,7 +6117,7 @@
6097
6117
  state.isDraggingInternally = true;
6098
6118
  ReactEditor.setFragmentData(editor, event.dataTransfer, 'drag');
6099
6119
  }
6100
- }, [readOnly, attributes.onDragStart]),
6120
+ }, [readOnly, editor, attributes.onDragStart, state]),
6101
6121
  onDrop: React.useCallback(function (event) {
6102
6122
  if (!readOnly && ReactEditor.hasTarget(editor, event.target) && !isEventHandled(event, attributes.onDrop)) {
6103
6123
  event.preventDefault(); // Keep a reference to the dragged range before updating selection
@@ -6128,7 +6148,7 @@
6128
6148
  }
6129
6149
 
6130
6150
  state.isDraggingInternally = false;
6131
- }, [readOnly, attributes.onDrop]),
6151
+ }, [readOnly, editor, attributes.onDrop, state]),
6132
6152
  onDragEnd: React.useCallback(function (event) {
6133
6153
  if (!readOnly && state.isDraggingInternally && attributes.onDragEnd && ReactEditor.hasTarget(editor, event.target)) {
6134
6154
  attributes.onDragEnd(event);
@@ -6138,7 +6158,7 @@
6138
6158
 
6139
6159
 
6140
6160
  state.isDraggingInternally = false;
6141
- }, [readOnly, attributes.onDragEnd]),
6161
+ }, [readOnly, state, attributes, editor]),
6142
6162
  onFocus: React.useCallback(function (event) {
6143
6163
  if (!readOnly && !state.isUpdatingSelection && ReactEditor.hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onFocus)) {
6144
6164
  var el = ReactEditor.toDOMNode(editor, editor);
@@ -6154,10 +6174,12 @@
6154
6174
 
6155
6175
  IS_FOCUSED.set(editor, true);
6156
6176
  }
6157
- }, [readOnly, attributes.onFocus]),
6177
+ }, [readOnly, state, editor, attributes.onFocus]),
6158
6178
  onKeyDown: React.useCallback(function (event) {
6159
6179
  if (!readOnly && ReactEditor.hasEditableTarget(editor, event.target)) {
6160
- androidInputManager === null || androidInputManager === void 0 ? void 0 : androidInputManager.handleKeyDown(event);
6180
+ var _androidInputManagerR5;
6181
+
6182
+ (_androidInputManagerR5 = androidInputManagerRef.current) === null || _androidInputManagerR5 === void 0 ? void 0 : _androidInputManagerR5.handleKeyDown(event);
6161
6183
  var nativeEvent = event.nativeEvent; // COMPAT: The composition end event isn't fired reliably in all browsers,
6162
6184
  // so we sometimes might end up stuck in a composition state even though we
6163
6185
  // aren't composing any more.
@@ -6441,7 +6463,7 @@
6441
6463
  }
6442
6464
  }
6443
6465
  }
6444
- }, [readOnly, attributes.onKeyDown]),
6466
+ }, [readOnly, editor, attributes.onKeyDown]),
6445
6467
  onPaste: React.useCallback(function (event) {
6446
6468
  if (!readOnly && ReactEditor.hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onPaste)) {
6447
6469
  // COMPAT: Certain browsers don't support the `beforeinput` event, so we
@@ -6456,7 +6478,7 @@
6456
6478
  ReactEditor.insertData(editor, event.clipboardData);
6457
6479
  }
6458
6480
  }
6459
- }, [readOnly, attributes.onPaste])
6481
+ }, [readOnly, editor, attributes.onPaste])
6460
6482
  }), /*#__PURE__*/React__default['default'].createElement(Children, {
6461
6483
  decorations: decorations,
6462
6484
  node: editor,
@@ -6524,6 +6546,13 @@
6524
6546
 
6525
6547
  return event.isDefaultPrevented() || event.isPropagationStopped();
6526
6548
  };
6549
+ /**
6550
+ * Check if the event's target is an input element
6551
+ */
6552
+
6553
+ var isDOMEventTargetInput = function isDOMEventTargetInput(event) {
6554
+ return isDOMNode(event.target) && (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement);
6555
+ };
6527
6556
  /**
6528
6557
  * Check if a DOM event is overrided by a handler.
6529
6558
  */
@@ -6658,7 +6687,7 @@
6658
6687
  * Create selector context with editor updating on every editor change
6659
6688
  */
6660
6689
 
6661
- function getSelectorContext(editor) {
6690
+ function useSelectorContext(editor) {
6662
6691
  var eventListeners = React.useRef([]).current;
6663
6692
  var slateRef = React.useRef({
6664
6693
  editor: editor
@@ -6668,7 +6697,7 @@
6668
6697
  eventListeners.forEach(function (listener) {
6669
6698
  return listener(editor);
6670
6699
  });
6671
- }, []);
6700
+ }, [eventListeners, slateRef]);
6672
6701
  var selectorContext = React.useMemo(function () {
6673
6702
  return {
6674
6703
  getSlate: function getSlate() {
@@ -6723,9 +6752,9 @@
6723
6752
  context = _React$useState2[0],
6724
6753
  setContext = _React$useState2[1];
6725
6754
 
6726
- var _getSelectorContext = getSelectorContext(editor),
6727
- selectorContext = _getSelectorContext.selectorContext,
6728
- handleSelectorChange = _getSelectorContext.onChange;
6755
+ var _useSelectorContext = useSelectorContext(editor),
6756
+ selectorContext = _useSelectorContext.selectorContext,
6757
+ handleSelectorChange = _useSelectorContext.onChange;
6729
6758
 
6730
6759
  var onContextChange = React.useCallback(function () {
6731
6760
  if (onChange) {
@@ -6739,14 +6768,14 @@
6739
6768
  };
6740
6769
  });
6741
6770
  handleSelectorChange(editor);
6742
- }, [onChange]);
6771
+ }, [editor, handleSelectorChange, onChange]);
6743
6772
  React.useEffect(function () {
6744
6773
  EDITOR_TO_ON_CHANGE.set(editor, onContextChange);
6745
6774
  return function () {
6746
6775
  EDITOR_TO_ON_CHANGE.set(editor, function () {});
6747
6776
  unmountRef.current = true;
6748
6777
  };
6749
- }, [onContextChange]);
6778
+ }, [editor, onContextChange]);
6750
6779
 
6751
6780
  var _useState = React.useState(ReactEditor.isFocused(editor)),
6752
6781
  _useState2 = _slicedToArray(_useState, 2),
@@ -6755,7 +6784,7 @@
6755
6784
 
6756
6785
  React.useEffect(function () {
6757
6786
  setIsFocused(ReactEditor.isFocused(editor));
6758
- });
6787
+ }, [editor]);
6759
6788
  useIsomorphicLayoutEffect(function () {
6760
6789
  var fn = function fn() {
6761
6790
  return setIsFocused(ReactEditor.isFocused(editor));