slate-react 0.72.7 → 0.72.9-20221114642

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.
@@ -2234,7 +2234,7 @@
2234
2234
 
2235
2235
 
2236
2236
  state.isUpdatingSelection = true;
2237
- var newDomRange = selection && hasDomSelectionInEditor && ReactEditor.toDOMRange(editor, selection);
2237
+ var newDomRange = selection && ReactEditor.toDOMRange(editor, selection);
2238
2238
 
2239
2239
  if (newDomRange) {
2240
2240
  if (slate.Range.isBackward(selection)) {
@@ -2869,8 +2869,6 @@
2869
2869
  at: draggedRange
2870
2870
  });
2871
2871
  }
2872
-
2873
- state.isDraggingInternally = false;
2874
2872
  }
2875
2873
 
2876
2874
  ReactEditor.insertData(editor, data); // When dragging from another source into the editor, it's possible
@@ -2880,14 +2878,18 @@
2880
2878
  ReactEditor.focus(editor);
2881
2879
  }
2882
2880
  }
2881
+
2882
+ state.isDraggingInternally = false;
2883
2883
  }, [readOnly, attributes.onDrop]),
2884
2884
  onDragEnd: React.useCallback(function (event) {
2885
- // When dropping on a different droppable element than the current editor,
2885
+ if (!readOnly && state.isDraggingInternally && attributes.onDragEnd && hasTarget(editor, event.target)) {
2886
+ attributes.onDragEnd(event);
2887
+ } // When dropping on a different droppable element than the current editor,
2886
2888
  // `onDrop` is not called. So we need to clean up in `onDragEnd` instead.
2887
2889
  // Note: `onDragEnd` is only called when `onDrop` is not called
2888
- if (!readOnly && state.isDraggingInternally && hasTarget(editor, event.target) && !isEventHandled(event, attributes.onDragEnd)) {
2889
- state.isDraggingInternally = false;
2890
- }
2890
+
2891
+
2892
+ state.isDraggingInternally = false;
2891
2893
  }, [readOnly, attributes.onDragEnd]),
2892
2894
  onFocus: React.useCallback(function (event) {
2893
2895
  if (!readOnly && !state.isUpdatingSelection && hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onFocus)) {
@@ -5071,6 +5073,8 @@
5071
5073
  value = props.value,
5072
5074
  rest = _objectWithoutProperties(props, _excluded);
5073
5075
 
5076
+ var unmountRef = React.useRef(false);
5077
+
5074
5078
  var _React$useState = React__default['default'].useState(function () {
5075
5079
  if (!slate.Node.isNodeList(value)) {
5076
5080
  throw new Error("[Slate] value is invalid! Expected a list of elements" + "but got: ".concat(JSON.stringify(value)));
@@ -5096,6 +5100,7 @@
5096
5100
  React.useEffect(function () {
5097
5101
  return function () {
5098
5102
  EDITOR_TO_ON_CHANGE.set(editor, function () {});
5103
+ unmountRef.current = true;
5099
5104
  };
5100
5105
  }, []);
5101
5106
 
@@ -5110,6 +5115,10 @@
5110
5115
  useIsomorphicLayoutEffect(function () {
5111
5116
  var fn = function fn() {
5112
5117
  setTimeout(function () {
5118
+ if (unmountRef.current) {
5119
+ return;
5120
+ }
5121
+
5113
5122
  setIsFocused(ReactEditor.isFocused(editor));
5114
5123
  }, 0);
5115
5124
  };