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.
package/dist/index.js CHANGED
@@ -1324,7 +1324,7 @@ var Editable$1 = function Editable(props) {
1324
1324
 
1325
1325
 
1326
1326
  state.isUpdatingSelection = true;
1327
- var newDomRange = selection && hasDomSelectionInEditor && ReactEditor.toDOMRange(editor, selection);
1327
+ var newDomRange = selection && ReactEditor.toDOMRange(editor, selection);
1328
1328
 
1329
1329
  if (newDomRange) {
1330
1330
  if (slate.Range.isBackward(selection)) {
@@ -1959,8 +1959,6 @@ var Editable$1 = function Editable(props) {
1959
1959
  at: draggedRange
1960
1960
  });
1961
1961
  }
1962
-
1963
- state.isDraggingInternally = false;
1964
1962
  }
1965
1963
 
1966
1964
  ReactEditor.insertData(editor, data); // When dragging from another source into the editor, it's possible
@@ -1970,14 +1968,18 @@ var Editable$1 = function Editable(props) {
1970
1968
  ReactEditor.focus(editor);
1971
1969
  }
1972
1970
  }
1971
+
1972
+ state.isDraggingInternally = false;
1973
1973
  }, [readOnly, attributes.onDrop]),
1974
1974
  onDragEnd: React.useCallback(function (event) {
1975
- // When dropping on a different droppable element than the current editor,
1975
+ if (!readOnly && state.isDraggingInternally && attributes.onDragEnd && hasTarget(editor, event.target)) {
1976
+ attributes.onDragEnd(event);
1977
+ } // When dropping on a different droppable element than the current editor,
1976
1978
  // `onDrop` is not called. So we need to clean up in `onDragEnd` instead.
1977
1979
  // Note: `onDragEnd` is only called when `onDrop` is not called
1978
- if (!readOnly && state.isDraggingInternally && hasTarget(editor, event.target) && !isEventHandled(event, attributes.onDragEnd)) {
1979
- state.isDraggingInternally = false;
1980
- }
1980
+
1981
+
1982
+ state.isDraggingInternally = false;
1981
1983
  }, [readOnly, attributes.onDragEnd]),
1982
1984
  onFocus: React.useCallback(function (event) {
1983
1985
  if (!readOnly && !state.isUpdatingSelection && hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onFocus)) {
@@ -4161,6 +4163,8 @@ var Slate = function Slate(props) {
4161
4163
  value = props.value,
4162
4164
  rest = _objectWithoutProperties(props, _excluded);
4163
4165
 
4166
+ var unmountRef = React.useRef(false);
4167
+
4164
4168
  var _React$useState = React__default['default'].useState(function () {
4165
4169
  if (!slate.Node.isNodeList(value)) {
4166
4170
  throw new Error("[Slate] value is invalid! Expected a list of elements" + "but got: ".concat(JSON.stringify(value)));
@@ -4186,6 +4190,7 @@ var Slate = function Slate(props) {
4186
4190
  React.useEffect(function () {
4187
4191
  return function () {
4188
4192
  EDITOR_TO_ON_CHANGE.set(editor, function () {});
4193
+ unmountRef.current = true;
4189
4194
  };
4190
4195
  }, []);
4191
4196
 
@@ -4200,6 +4205,10 @@ var Slate = function Slate(props) {
4200
4205
  useIsomorphicLayoutEffect(function () {
4201
4206
  var fn = function fn() {
4202
4207
  setTimeout(function () {
4208
+ if (unmountRef.current) {
4209
+ return;
4210
+ }
4211
+
4203
4212
  setIsFocused(ReactEditor.isFocused(editor));
4204
4213
  }, 0);
4205
4214
  };