Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: prevent default for dropped files in editor

thecodrre08a32f79559
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index 9a303ac29..a49180967 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -387,7 +387,9 @@ function DropZone(props: DropZoneProps) {
display: "none",
}}
onDrop={async (e) => {
- if (!editor) return;
+ if (!editor || !e.dataTransfer.files?.length) return;
+ e.preventDefault();
+
for (let file of e.dataTransfer.files) {
const result = await attachFile(file);
if (!result) continue;
@@ -423,14 +425,6 @@ function useDragOverlay() {
if (!dropElement || !overlay) return;
- function isFile(e: DragEvent) {
- return (
- e.dataTransfer &&
- (e.dataTransfer.files?.length > 0 ||
- e.dataTransfer.types?.some((a) => a === "Files"))
- );
- }
-
function showOverlay(e: DragEvent) {
if (!overlay || !isFile(e)) return;
@@ -465,3 +459,11 @@ function useDragOverlay() {
return [dropElementRef, overlayRef] as const;
}
+
+function isFile(e: DragEvent) {
+ return (
+ e.dataTransfer &&
+ (e.dataTransfer.files?.length > 0 ||
+ e.dataTransfer.types?.some((a) => a === "Files"))
+ );
+}