@cyberyozh/text-editor 0.5.0 → 0.5.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/editor.mjs CHANGED
@@ -6931,6 +6931,12 @@ function applyUploadResultsToNodes(imagesToNodes, results) {
6931
6931
  node.attrs.storageKey = result.storageKey;
6932
6932
  });
6933
6933
  }
6934
+ function shouldHandleInsertedFile(file, event) {
6935
+ if (!file) return false;
6936
+ event.preventDefault();
6937
+ event.stopPropagation();
6938
+ return file.type.startsWith("image/");
6939
+ }
6934
6940
 
6935
6941
  // src/editor/handlers/insertion-handlers.ts
6936
6942
  function useInsertionHandlers(imageHandlers) {
@@ -6942,9 +6948,7 @@ function useInsertionHandlers(imageHandlers) {
6942
6948
  }
6943
6949
  }, [insertedImage, activeDialog]);
6944
6950
  function genericInsertionHandler(file, event) {
6945
- event.preventDefault();
6946
- event.stopPropagation();
6947
- if (!file || !file.type.startsWith("image/")) return;
6951
+ if (!file || !shouldHandleInsertedFile(file, event)) return;
6948
6952
  if (!imageHandlers?.upload) return;
6949
6953
  setInsertedImage(file);
6950
6954
  openDialogCommand("image");
@@ -6980,7 +6984,9 @@ function useInsertionHandlers(imageHandlers) {
6980
6984
  setDisabled(false);
6981
6985
  });
6982
6986
  } else {
6983
- view.dispatch(view.state.tr.replaceSelection(removeImagesFromSlice(slice)));
6987
+ view.dispatch(
6988
+ view.state.tr.replaceSelection(removeImagesFromSlice(slice))
6989
+ );
6984
6990
  }
6985
6991
  return true;
6986
6992
  }