diff --git a/src/components/VideoEditor.tsx b/src/components/VideoEditor.tsx index d43f5d18..c30d9f4b 100644 --- a/src/components/VideoEditor.tsx +++ b/src/components/VideoEditor.tsx @@ -62,6 +62,7 @@ export default function VideoEditor() { recommendedPreset, } = useVideoEditor(); const [copied, setCopied] = useState(false); + const [isDraggingGlobally, setIsDraggingGlobally] = useState(false); const downloadRef = useRef(null); useEffect(() => { @@ -88,7 +89,39 @@ export default function VideoEditor() { }, [videoSrc]); return ( -
+
{ + if (e.dataTransfer?.types.includes("Files")) { + e.preventDefault(); + setIsDraggingGlobally(true); + } + }} + > + {isDraggingGlobally && ( +
e.preventDefault()} + onDragLeave={(e) => { + e.preventDefault(); + setIsDraggingGlobally(false); + }} + onDrop={(e) => { + e.preventDefault(); + setIsDraggingGlobally(false); + const droppedFile = e.dataTransfer.files?.[0]; + if (droppedFile) { + handleFileSelect(droppedFile); + } + }} + > +
+ +

Drop video here to begin

+
+
+ )} diff --git a/src/hooks/useVideoEditor.ts b/src/hooks/useVideoEditor.ts index a2283128..7ddbd9e8 100644 --- a/src/hooks/useVideoEditor.ts +++ b/src/hooks/useVideoEditor.ts @@ -348,13 +348,13 @@ export function useVideoEditor() { useEffect(() => { const shouldWarn = status === "exporting" || - status === "loading-engine" || - status === "done"; + status === "loading-engine"; if (!shouldWarn) return; const handler = (e: BeforeUnloadEvent) => { e.preventDefault(); + e.returnValue = ""; }; window.addEventListener("beforeunload", handler);