Skip to content

Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.

Add drag-and-drop upload support across studio tools

Anil-matcha5482a777047c
diff --git a/packages/Open-Poe-AI b/packages/Open-Poe-AI
index 0e9f0c23..3e21ebc9 160000
--- a/packages/Open-Poe-AI
+++ b/packages/Open-Poe-AI
@@ -1 +1 @@
-Subproject commit 0e9f0c23f39cf9e4e955c047356ac5e7b99c5233
+Subproject commit 3e21ebc92d93bd699ffc6000bbcf980eaa8830cb
diff --git a/packages/studio/src/components/AudioStudio.jsx b/packages/studio/src/components/AudioStudio.jsx
index 40a53aad..14d22309 100644
--- a/packages/studio/src/components/AudioStudio.jsx
+++ b/packages/studio/src/components/AudioStudio.jsx
@@ -71,7 +71,9 @@ function AudioFileUploader({ label, value, onChange, apiKey }) {
const [uploadState, setUploadState] = useState(value ? UPLOAD_STATE.READY : UPLOAD_STATE.IDLE);
const [progress, setProgress] = useState(0);
const [fileName, setFileName] = useState(value ? value.split('/').pop().slice(-30) : "");
+ const [isDragging, setIsDragging] = useState(false);
const fileInputRef = useRef(null);
+ const dragCounterRef = useRef(0);
useEffect(() => {
if (!value) {
@@ -84,8 +86,8 @@ function AudioFileUploader({ label, value, onChange, apiKey }) {
}
}, [value]);
- const handleUpload = async (e) => {
- const file = e.target.files?.[0];
+ const handleUpload = async (files) => {
+ const file = files?.[0];
if (!file) return;
if (file.size > 20 * 1024 * 1024) {
@@ -111,11 +113,53 @@ function AudioFileUploader({ label, value, onChange, apiKey }) {
}
};
+ const handleInputChange = (e) => {
+ handleUpload(Array.from(e.target.files || []));
+ };
+
const clearFile = (e) => {
e.stopPropagation();
onChange(null);
};
+ const handleDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (uploadState !== UPLOAD_STATE.IDLE) return;
+ dragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsDragging(true);
+ }
+ };
+
+ const handleDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (uploadState !== UPLOAD_STATE.IDLE) return;
+ dragCounterRef.current -= 1;
+ if (dragCounterRef.current <= 0) {
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ }
+ };
+
+ const handleDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ if (uploadState !== UPLOAD_STATE.IDLE) return;
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ handleUpload(Array.from(files));
+ }
+ };
+
return (
<div className="space-y-2">
<div className="flex items-center justify-between">
@@ -133,20 +177,26 @@ function AudioFileUploader({ label, value, onChange, apiKey }) {
)}
</div>
- <div
+ <div
onClick={() => uploadState === UPLOAD_STATE.IDLE && fileInputRef.current?.click()}
+ onDragEnter={handleDragEnter}
+ onDragLeave={handleDragLeave}
+ onDragOver={handleDragOver}
+ onDrop={handleDrop}
className={`relative border rounded p-4 transition-all duration-300 flex items-center gap-3.5 cursor-pointer ${
- uploadState === UPLOAD_STATE.READY
- ? "border-primary/60 bg-primary/10 shadow-[0_0_15px_rgba(34,211,238,0.05)]"
+ isDragging
+ ? "border-primary bg-primary/15 shadow-[0_0_15px_rgba(34,211,238,0.15)]"
+ : uploadState === UPLOAD_STATE.READY
+ ? "border-primary/60 bg-primary/10 shadow-[0_0_15px_rgba(34,211,238,0.05)]"
: "border-zinc-700 bg-zinc-900 hover:bg-zinc-850 hover:border-primary/50"
}`}
>
- <input
- ref={fileInputRef}
- type="file"
- accept="audio/*"
- className="hidden"
- onChange={handleUpload}
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept="audio/*"
+ className="hidden"
+ onChange={handleInputChange}
/>
{uploadState === UPLOAD_STATE.IDLE && (
diff --git a/packages/studio/src/components/CinemaStudio.jsx b/packages/studio/src/components/CinemaStudio.jsx
index c5e8aa6e..b73c724e 100644
--- a/packages/studio/src/components/CinemaStudio.jsx
+++ b/packages/studio/src/components/CinemaStudio.jsx
@@ -576,8 +576,8 @@ export default function CinemaStudio({
const textareaRef = useRef(null);
const resultImgRef = useRef(null);
- const handleImageUpload = async (e) => {
- const file = e.target.files?.[0];
+ const handleImageFiles = async (files) => {
+ const file = files?.[0];
if (!file) return;
setIsUploadingImage(true);
@@ -597,10 +597,54 @@ export default function CinemaStudio({
}
};
+ const handleImageUpload = async (e) => {
+ await handleImageFiles(Array.from(e.target.files || []));
+ };
+
const removeImage = () => {
setUploadedImage(null);
};
+ // ── Image drag-and-drop ─────────────────────────────────────────────────
+ const [isImageDragging, setIsImageDragging] = useState(false);
+ const imageDragCounterRef = useRef(0);
+
+ const handleImageDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ imageDragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsImageDragging(true);
+ }
+ };
+
+ const handleImageDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ imageDragCounterRef.current -= 1;
+ if (imageDragCounterRef.current <= 0) {
+ imageDragCounterRef.current = 0;
+ setIsImageDragging(false);
+ }
+ };
+
+ const handleImageDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleImageDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ imageDragCounterRef.current = 0;
+ setIsImageDragging(false);
+ if (isUploadingImage) return;
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ handleImageFiles(Array.from(files));
+ }
+ };
+
// ── Persistence: Load ────────────────────────────────────────────────────
useEffect(() => {
try {
@@ -1047,7 +1091,13 @@ export default function CinemaStudio({
{/* Upper Row: Image Upload & Textarea */}
<div className="flex items-start gap-4 w-full px-1">
{/* Image Upload Button */}
- <div className="relative pt-0.5">
+ <div
+ className="relative pt-0.5"
+ onDragEnter={handleImageDragEnter}
+ onDragLeave={handleImageDragLeave}
+ onDragOver={handleImageDragOver}
+ onDrop={handleImageDrop}
+ >
<input
type="file"
ref={imageInputRef}
@@ -1055,7 +1105,7 @@ export default function CinemaStudio({
accept="image/*"
onChange={handleImageUpload}
/>
-
+
<button
onClick={() =>
uploadedImage
@@ -1064,8 +1114,8 @@ export default function CinemaStudio({
}
disabled={isUploadingImage}
className={promptMediaButtonClassName({
- active: Boolean(uploadedImage),
- })}
+ active: Boolean(uploadedImage) || isImageDragging,
+ }) + (isImageDragging ? " ring-2 ring-[#22d3ee] ring-offset-1 ring-offset-black scale-105" : "")}
>
{isUploadingImage ? (
<div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">
diff --git a/packages/studio/src/components/ClippingStudio.jsx b/packages/studio/src/components/ClippingStudio.jsx
index 00d0e6f8..7c54ad3f 100644
--- a/packages/studio/src/components/ClippingStudio.jsx
+++ b/packages/studio/src/components/ClippingStudio.jsx
@@ -238,6 +238,8 @@ export default function ClippingStudio({
const [videoUploading, setVideoUploading] = useState(false);
const [videoProgress, setVideoProgress] = useState(0);
const videoFileInputRef = useRef(null);
+ const [isVideoDragging, setIsVideoDragging] = useState(false);
+ const videoDragCounterRef = useRef(0);
// ── Generation State ─────────────────────────────────────────────────────
const [isGenerating, setIsGenerating] = useState(false);
@@ -412,8 +414,8 @@ export default function ClippingStudio({
};
// ── Video File Handlers ──
- const handleVideoFileChange = async (e) => {
- const file = e.target.files[0];
+ const processVideoFiles = async (files) => {
+ const file = files && files[0];
if (!file) return;
if (file.size > MAX_VIDEO_SIZE_BYTES) {
showVideoSizeLimitToast();
@@ -437,6 +439,48 @@ export default function ClippingStudio({
}
};
+ const handleVideoFileChange = async (e) => {
+ const files = Array.from(e.target.files || []);
+ await processVideoFiles(files);
+ };
+
+ const handleVideoDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ videoDragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsVideoDragging(true);
+ }
+ };
+
+ const handleVideoDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ videoDragCounterRef.current -= 1;
+ if (videoDragCounterRef.current <= 0) {
+ videoDragCounterRef.current = 0;
+ setIsVideoDragging(false);
+ }
+ };
+
+ const handleVideoDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleVideoDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ videoDragCounterRef.current = 0;
+ setIsVideoDragging(false);
+ const files = Array.from(e.dataTransfer?.files || []).filter((f) =>
+ f.type.startsWith("video/"),
+ );
+ if (files.length > 0) {
+ processVideoFiles(files);
+ }
+ };
+
const clearVideoUpload = () => {
setVideoUrl("");
};
@@ -932,9 +976,13 @@ export default function ClippingStudio({
type="button"
title="Upload source video"
onClick={() => videoFileInputRef.current?.click()}
- className={promptMediaButtonClassName({
+ onDragEnter={handleVideoDragEnter}
+ onDragLeave={handleVideoDragLeave}
+ onDragOver={handleVideoDragOver}
+ onDrop={handleVideoDrop}
+ className={`${promptMediaButtonClassName({
active: Boolean(videoUrl),
- })}
+ })}${isVideoDragging ? " ring-2 ring-primary border-primary bg-primary/10" : ""}`}
>
{videoUploading ? (
<div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/85 z-20 backdrop-blur-[1px]">
diff --git a/packages/studio/src/components/DrawModal.jsx b/packages/studio/src/components/DrawModal.jsx
index 5b0f8d44..6ed514cd 100644
--- a/packages/studio/src/components/DrawModal.jsx
+++ b/packages/studio/src/components/DrawModal.jsx
@@ -55,6 +55,10 @@ export default function DrawModal({
const fileInputRef = useRef(null);
const insertImageInputRef = useRef(null);
+ const [isBgDragging, setIsBgDragging] = useState(false);
+ const bgDragCounterRef = useRef(0);
+ const [isOverlayDragging, setIsOverlayDragging] = useState(false);
+ const overlayDragCounterRef = useRef(0);
const modelDropdownRef = useRef(null);
const arDropdownRef = useRef(null);
@@ -780,8 +784,11 @@ export default function DrawModal({
}, [brushSize]);
// Upload background file
- const handleUploadBg = (e) => {
- const file = e.target.files?.[0];
+ const handleUploadBg = (filesOrEvent) => {
+ const files = Array.isArray(filesOrEvent)
+ ? filesOrEvent
+ : Array.from(filesOrEvent?.target?.files || []);
+ const file = files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
@@ -792,13 +799,52 @@ export default function DrawModal({
reader.readAsDataURL(file);
};
+ // Drag-and-drop handlers for the background upload dropzone
+ const handleBgDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ bgDragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsBgDragging(true);
+ }
+ };
+
+ const handleBgDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ bgDragCounterRef.current -= 1;
+ if (bgDragCounterRef.current <= 0) {
+ bgDragCounterRef.current = 0;
+ setIsBgDragging(false);
+ }
+ };
+
+ const handleBgDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleBgDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ bgDragCounterRef.current = 0;
+ setIsBgDragging(false);
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ handleUploadBg(Array.from(files));
+ }
+ };
+
// Insert Overlay image
const handleInsertImageClick = () => {
insertImageInputRef.current?.click();
};
- const handleInsertImage = (e) => {
- const file = e.target.files?.[0];
+ const handleInsertImage = (filesOrEvent) => {
+ const files = Array.isArray(filesOrEvent)
+ ? filesOrEvent
+ : Array.from(filesOrEvent?.target?.files || []);
+ const file = files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
@@ -835,6 +881,42 @@ export default function DrawModal({
reader.readAsDataURL(file);
};
+ // Drag-and-drop handlers for the insert-overlay-image tool
+ const handleOverlayDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ overlayDragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsOverlayDragging(true);
+ }
+ };
+
+ const handleOverlayDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ overlayDragCounterRef.current -= 1;
+ if (overlayDragCounterRef.current <= 0) {
+ overlayDragCounterRef.current = 0;
+ setIsOverlayDragging(false);
+ }
+ };
+
+ const handleOverlayDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleOverlayDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ overlayDragCounterRef.current = 0;
+ setIsOverlayDragging(false);
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ handleInsertImage(Array.from(files));
+ }
+ };
+
// Clear Canvas (Remove image, drawings, text overlays and reset to setup screen)
const handleClearCanvas = () => {
if (
@@ -1042,7 +1124,17 @@ export default function DrawModal({
<div className="flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto custom-scrollbar relative bg-[#070708]/30">
{viewState === "setup" ? (
/* Setup Card */
- <div className="border-2 border-dashed border-white/10 rounded-2xl p-8 max-w-md w-full text-center flex flex-col items-center gap-6 bg-[#070708]/50">
+ <div
+ onDragEnter={handleBgDragEnter}
+ onDragLeave={handleBgDragLeave}
+ onDragOver={handleBgDragOver}
+ onDrop={handleBgDrop}
+ className={`border-2 border-dashed rounded-2xl p-8 max-w-md w-full text-center flex flex-col items-center gap-6 bg-[#070708]/50 transition-colors ${
+ isBgDragging
+ ? "border-[#b5f500] bg-[#b5f500]/5"
+ : "border-white/10"
+ }`}
+ >
<div className="w-56 h-36 rounded-xl border border-white/5 overflow-hidden shadow-lg select-none relative bg-black/40">
<img
src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"
@@ -1469,9 +1561,15 @@ export default function DrawModal({
{/* Insert Overlay Image Tool */}
<button
onClick={handleInsertImageClick}
- title="Insert overlay image"
+ onDragEnter={handleOverlayDragEnter}
+ onDragLeave={handleOverlayDragLeave}
+ onDragOver={handleOverlayDragOver}
+ onDrop={handleOverlayDrop}
+ title="Insert overlay image (or drop an image here)"
className={`p-1.5 rounded-lg transition-all ${
- activeTool === "image"
+ isOverlayDragging
+ ? "bg-[#b5f500] text-black ring-2 ring-[#b5f500]"
+ : activeTool === "image"
? "bg-white text-black"
: "text-white/60 hover:text-white"
}`}
diff --git a/packages/studio/src/components/ImageStudio.jsx b/packages/studio/src/components/ImageStudio.jsx
index 0c8eeeaa..b02d2aaf 100644
--- a/packages/studio/src/components/ImageStudio.jsx
+++ b/packages/studio/src/components/ImageStudio.jsx
@@ -107,6 +107,8 @@ function UploadButton({ apiKey, maxImages, onSelect, onClear, initialUrls = [],
}, [persistedHistory]);
const [lastUploadProgress, setLastUploadProgress] = useState(0);
+ const [isDragging, setIsDragging] = useState(false);
+ const dragCounterRef = useRef(0);
const fileInputRef = useRef(null);
const panelRef = useRef(null);
const triggerRef = useRef(null);
@@ -178,8 +180,12 @@ function UploadButton({ apiKey, maxImages, onSelect, onClear, initialUrls = [],
const handleFileChange = async (e) => {
const files = Array.from(e.target.files);
- if (!files.length) return;
e.target.value = "";
+ await processFiles(files);
+ };
+
+ const processFiles = async (files) => {
+ if (!files.length) return;
const MAX_IMAGE_SIZE = 10 * 1024 * 1024; // 10MB
const tooLarge = files.filter((f) => f.size > MAX_IMAGE_SIZE);
@@ -248,6 +254,43 @@ function UploadButton({ apiKey, maxImages, onSelect, onClear, initialUrls = [],
}
};
+ const handleTriggerDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsDragging(true);
+ }
+ };
+
+ const handleTriggerDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current -= 1;
+ if (dragCounterRef.current <= 0) {
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ }
+ };
+
+ const handleTriggerDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleTriggerDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ const files = Array.from(e.dataTransfer?.files || []).filter((f) =>
+ f.type.startsWith("image/"),
+ );
+ if (files.length > 0) {
+ processFiles(files);
+ }
+ };
+
const handleCellClick = (entry) => {
const selIdx = selectedEntries.findIndex((e) => e.url === entry.url);
const isSelected = selIdx !== -1;
@@ -385,9 +428,13 @@ function UploadButton({ apiKey, maxImages, onSelect, onClear, initialUrls = [],
e.stopPropagation();
setPanelOpen((o) => !o);
}}
- className={promptMediaButtonClassName({
+ onDragEnter={handleTriggerDragEnter}
+ onDragLeave={handleTriggerDragLeave}
+ onDragOver={handleTriggerDragOver}
+ onDrop={handleTriggerDrop}
+ className={`${promptMediaButtonClassName({
active: hasSelection,
- })}
+ })}${isDragging ? " ring-2 ring-primary border-primary bg-primary/10" : ""}`}
>
{triggerContent}
</button>
diff --git a/packages/studio/src/components/LayersStudio.jsx b/packages/studio/src/components/LayersStudio.jsx
index 8a0f5998..ea73f96b 100644
--- a/packages/studio/src/components/LayersStudio.jsx
+++ b/packages/studio/src/components/LayersStudio.jsx
@@ -183,6 +183,10 @@ export default function LayersStudio({
const imageWrapperRef = useRef(null);
const canvasContainerRef = useRef(null);
+ // Drag & Drop Upload State
+ const [isDropzoneDragging, setIsDropzoneDragging] = useState(false);
+ const dropzoneDragCounterRef = useRef(0);
+
// Drawing History Stack
const [historyStack, setHistoryStack] = useState([]);
const [historyIndex, setHistoryIndex] = useState(-1);
@@ -292,9 +296,64 @@ export default function LayersStudio({
}
};
+ // Shared entry point for both click-to-browse and drag-and-drop uploads
+ const handleFiles = (files) => {
+ const fileList = Array.from(files || []);
+ if (fileList.length === 0) return;
+
+ const MAX_IMAGE_SIZE = 20 * 1024 * 1024; // 20MB
+ const file = fileList.find((f) => f.type.startsWith("image/")) || fileList[0];
+ if (!file) return;
+
+ if (!file.type.startsWith("image/")) {
+ toast.error("Please upload an image file.");
+ return;
+ }
+ if (file.size > MAX_IMAGE_SIZE) {
+ toast.error(`File too large (max 20MB): ${file.name}`);
+ return;
+ }
+
+ handleUploadFile(file);
+ };
+
const handleFileInputChange = (e) => {
- if (e.target.files && e.target.files[0]) {
- handleUploadFile(e.target.files[0]);
+ handleFiles(e.target.files);
+ e.target.value = "";
+ };
+
+ const handleDropzoneDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dropzoneDragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsDropzoneDragging(true);
+ }
+ };
+
+ const handleDropzoneDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dropzoneDragCounterRef.current -= 1;
+ if (dropzoneDragCounterRef.current <= 0) {
+ dropzoneDragCounterRef.current = 0;
+ setIsDropzoneDragging(false);
+ }
+ };
+
+ const handleDropzoneDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleDropzoneDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dropzoneDragCounterRef.current = 0;
+ setIsDropzoneDragging(false);
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ handleFiles(files);
}
};
@@ -1547,7 +1606,15 @@ export default function LayersStudio({
) : (
<div
onClick={() => fileInputRef.current?.click()}
- className="flex flex-col items-center justify-center p-16 border-2 border-dashed border-white/20 hover:border-[#84cc16]/60 rounded-3xl cursor-pointer transition-all duration-200 bg-[#16181f]/50 hover:bg-[#16181f]/80"
+ onDragEnter={handleDropzoneDragEnter}
+ onDragLeave={handleDropzoneDragLeave}
+ onDragOver={handleDropzoneDragOver}
+ onDrop={handleDropzoneDrop}
+ className={`flex flex-col items-center justify-center p-16 border-2 border-dashed rounded-3xl cursor-pointer transition-all duration-200 ${
+ isDropzoneDragging
+ ? "border-[#84cc16] bg-[#84cc16]/10 scale-[1.02]"
+ : "border-white/20 hover:border-[#84cc16]/60 bg-[#16181f]/50 hover:bg-[#16181f]/80"
+ }`}
>
<div className="w-16 h-16 rounded-2xl bg-[#84cc16]/10 text-[#84cc16] flex items-center justify-center mb-4">
<svg
diff --git a/packages/studio/src/components/LipSyncStudio.jsx b/packages/studio/src/components/LipSyncStudio.jsx
index e213a6d1..cc65cdd0 100644
--- a/packages/studio/src/components/LipSyncStudio.jsx
+++ b/packages/studio/src/components/LipSyncStudio.jsx
@@ -57,6 +57,9 @@ function MediaPickerButton({
apiKey,
}) {
const inputRef = useRef(null);
+ const [isDragging, setIsDragging] = useState(false);
+ const dragCounterRef = useRef(0);
+ const acceptPrefix = accept?.split("/")[0];
const handleClick = (e) => {
e.stopPropagation();
@@ -68,10 +71,49 @@ function MediaPickerButton({
};
const handleChange = async (e) => {
- const file = e.target.files?.[0];
- if (!file) return;
+ const files = e.target.files;
+ if (!files || files.length === 0) return;
e.target.value = "";
- await onUpload(file);
+ await onUpload(Array.from(files));
+ };
+
+ const handleDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsDragging(true);
+ }
+ };
+
+ const handleDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current -= 1;
+ if (dragCounterRef.current <= 0) {
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ }
+ };
+
+ const handleDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleDrop = async (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ if (uploadState === UPLOAD_STATE.UPLOADING) return;
+ const files = e.dataTransfer?.files;
+ if (!files || files.length === 0) return;
+ const matched = acceptPrefix
+ ? Array.from(files).filter((f) => f.type.startsWith(`${acceptPrefix}/`))
+ : Array.from(files);
+ if (matched.length === 0) return;
+ await onUpload(matched);
};
return (
@@ -83,8 +125,15 @@ function MediaPickerButton({
: `Upload ${label.toLowerCase()} file`
}
onClick={handleClick}
+ onDragEnter={handleDragEnter}
+ onDragLeave={handleDragLeave}
+ onDragOver={handleDragOver}
+ onDrop={handleDrop}
className={promptMediaButtonClassName({
active: uploadState === UPLOAD_STATE.READY,
+ className: isDragging
+ ? "ring-2 ring-[#22d3ee] ring-offset-1 ring-offset-black scale-105"
+ : "",
})}
>
<input
@@ -479,7 +528,9 @@ export default function LipSyncStudio({
// ── Upload handlers ─────────────────────────────────────────────────────
const handleImageUpload = useCallback(
- async (file) => {
+ async (files) => {
+ const file = Array.isArray(files) ? files[0] : files;
+ if (!file) return;
if (file.size > 10 * 1024 * 1024) {
alert("Image exceeds 10MB limit.");
return;
@@ -504,7 +555,9 @@ export default function LipSyncStudio({
);
const handleVideoPick = useCallback(
- async (file) => {
+ async (files) => {
+ const file = Array.isArray(files) ? files[0] : files;
+ if (!file) return;
if (file.size > 50 * 1024 * 1024) {
alert("Video exceeds 50MB limit.");
return;
@@ -533,7 +586,9 @@ export default function LipSyncStudio({
};
const handleAudioPick = useCallback(
- async (file) => {
+ async (files) => {
+ const file = Array.isArray(files) ? files[0] : files;
+ if (!file) return;
if (file.size > 10 * 1024 * 1024) {
alert("Audio file exceeds 10MB limit.");
return;
diff --git a/packages/studio/src/components/MarketingStudio.jsx b/packages/studio/src/components/MarketingStudio.jsx
index 8143127e..67ed9eb2 100644
--- a/packages/studio/src/components/MarketingStudio.jsx
+++ b/packages/studio/src/components/MarketingStudio.jsx
@@ -119,26 +119,67 @@ const OPTIONS = {
function UploadSlot({ icon, url, progress, label, onUpload, onClear, multiple = false, images = [] }) {
const inputRef = useRef(null);
-
+ const [isDraggingSlot, setIsDraggingSlot] = useState(false);
+ const dragCounterRef = useRef(0);
+
+ const handleSlotDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsDraggingSlot(true);
+ }
+ };
+
+ const handleSlotDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current -= 1;
+ if (dragCounterRef.current <= 0) {
+ dragCounterRef.current = 0;
+ setIsDraggingSlot(false);
+ }
+ };
+
+ const handleSlotDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleSlotDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current = 0;
+ setIsDraggingSlot(false);
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ onUpload(Array.from(files));
+ }
+ };
+
return (
<div className="relative group/slot flex items-center">
- <div
+ <div
onClick={() => inputRef.current?.click()}
+ onDragEnter={handleSlotDragEnter}
+ onDragLeave={handleSlotDragLeave}
+ onDragOver={handleSlotDragOver}
+ onDrop={handleSlotDrop}
title={`Upload ${label}`}
className={promptMediaButtonClassName({
- active: Boolean(url),
- className: "cursor-pointer",
+ active: Boolean(url) || isDraggingSlot,
+ className: `cursor-pointer${isDraggingSlot ? " ring-2 ring-primary ring-offset-1 ring-offset-black/40" : ""}`,
})}
>
- <input
- ref={inputRef}
- type="file"
+ <input
+ ref={inputRef}
+ type="file"
accept="image/*"
- className="hidden"
+ className="hidden"
multiple={multiple}
- onChange={(e) => onUpload(e)}
+ onChange={(e) => onUpload(Array.from(e.target.files))}
/>
-
+
{progress > 0 && progress < 100 ? (
<div className="absolute inset-0 bg-black/60 rounded-full flex items-center justify-center z-10">
<span className="text-[8px] font-black text-primary">{progress}%</span>
@@ -356,9 +397,8 @@ export default function MarketingStudio({
}
};
- const handleUpload = async (e, target) => {
- const files = Array.from(e.target.files);
- if (!files.length) return;
+ const handleUpload = async (files, target) => {
+ if (!files || !files.length) return;
if (target === 'additional') {
const remaining = 6 - additionalImages.length;
@@ -601,25 +641,25 @@ export default function MarketingStudio({
icon={<ProductIcon />}
url={productImage}
progress={uploadProgress.product}
- onUpload={(e) => handleUpload(e, 'product')}
- onClear={() => setProductImage(null)}
+ onUpload={(files) => handleUpload(files, 'product')}
+ onClear={() => setProductImage(null)}
/>
- <UploadSlot
- label="Avatar"
- icon={<AvatarIcon />}
- url={avatarImage}
- progress={uploadProgress.avatar}
- onUpload={(e) => handleUpload(e, 'avatar')}
- onClear={() => setAvatarImage(null)}
+ <UploadSlot
+ label="Avatar"
+ icon={<AvatarIcon />}
+ url={avatarImage}
+ progress={uploadProgress.avatar}
+ onUpload={(files) => handleUpload(files, 'avatar')}
+ onClear={() => setAvatarImage(null)}
/>
- <UploadSlot
- label="References"
- icon={<RefIcon />}
- url={additionalImages[0]}
- progress={uploadProgress.additional}
- multiple
+ <UploadSlot
+ label="References"
+ icon={<RefIcon />}
+ url={additionalImages[0]}
+ progress={uploadProgress.additional}
+ multiple
images={additionalImages}
- onUpload={(e) => handleUpload(e, 'additional')}
+ onUpload={(files) => handleUpload(files, 'additional')}
onClear={(idx) => {
if (idx !== undefined) {
setAdditionalImages(prev => prev.filter((_, i) => i !== idx));
diff --git a/packages/studio/src/components/RecastStudio.jsx b/packages/studio/src/components/RecastStudio.jsx
index 1f810372..df57147f 100644
--- a/packages/studio/src/components/RecastStudio.jsx
+++ b/packages/studio/src/components/RecastStudio.jsx
@@ -52,6 +52,8 @@ function MediaPickerButton({
isVideo,
}) {
const inputRef = useRef(null);
+ const [isDragging, setIsDragging] = useState(false);
+ const dragCounterRef = useRef(0);
const handleClick = (e) => {
e.stopPropagation();
@@ -62,24 +64,87 @@ function MediaPickerButton({
inputRef.current?.click();
};
- const handleChange = async (e) => {
- const file = e.target.files?.[0];
+ const fileMatchesAccept = (file) => {
+ if (!accept) return true;
+ const patterns = accept.split(",").map((p) => p.trim()).filter(Boolean);
+ if (patterns.length === 0) return true;
+ return patterns.some((pattern) => {
+ if (pattern === "*" || pattern === "*/*") return true;
+ if (pattern.endsWith("/*")) {
+ return file.type.startsWith(pattern.slice(0, -1));
+ }
+ return file.type === pattern;
+ });
+ };
+
+ const handleFiles = async (files) => {
+ const fileList = Array.from(files || []);
+ const file = fileList.find(fileMatchesAccept) ?? fileList[0];
if (!file) return;
- e.target.value = "";
await onUpload(file);
};
+ const handleChange = async (e) => {
+ const files = Array.from(e.target.files || []);
+ e.target.value = "";
+ await handleFiles(files);
+ };
+
+ const handleDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (uploadState === UPLOAD_STATE.UPLOADING) return;
+ dragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsDragging(true);
+ }
+ };
+
+ const handleDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current -= 1;
+ if (dragCounterRef.current <= 0) {
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ }
+ };
+
+ const handleDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+ if (uploadState === UPLOAD_STATE.UPLOADING) return;
+ const files = e.dataTransfer?.files;
+ if (files && files.length > 0) {
+ handleFiles(files);
+ }
+ };
+
return (
<button
type="button"
title={
uploadState === UPLOAD_STATE.READY
? `${fileName} — click to clear`
- : `Upload ${label.toLowerCase()} file`
+ : `Upload ${label.toLowerCase()} file, or drag and drop`
}
onClick={handleClick}
+ onDragEnter={handleDragEnter}
+ onDragLeave={handleDragLeave}
+ onDragOver={handleDragOver}
+ onDrop={handleDrop}
className={promptMediaButtonClassName({
active: uploadState === UPLOAD_STATE.READY,
+ className: isDragging
+ ? "border-[#22d3ee] bg-[#22d3ee]/10 ring-2 ring-[#22d3ee]/50 scale-105"
+ : "",
})}
>
<input
diff --git a/packages/studio/src/components/VideoStudio.jsx b/packages/studio/src/components/VideoStudio.jsx
index 90e4c6ed..1e1407fa 100644
--- a/packages/studio/src/components/VideoStudio.jsx
+++ b/packages/studio/src/components/VideoStudio.jsx
@@ -191,6 +191,65 @@ function ReferenceUploadButton({
100,
Math.max(0, Math.floor(progress / 10) * 10),
);
+ const [isUploadDragging, setIsUploadDragging] = useState(false);
+ const uploadDragCounterRef = useRef(0);
+
+ const acceptPrefixes = (accept || "")
+ .split(",")
+ .map((token) => token.trim())
+ .filter(Boolean);
+ const fileMatchesAccept = (file) => {
+ if (acceptPrefixes.length === 0) return true;
+ return acceptPrefixes.some((token) => {
+ if (token.endsWith("/*")) {
+ return file.type?.startsWith(token.slice(0, -1));
+ }
+ if (token.startsWith(".")) {
+ return file.name?.toLowerCase().endsWith(token.toLowerCase());
+ }
+ return file.type === token;
+ });
+ };
+
+ const handleUploadDragEnter = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (disabled || uploading) return;
+ uploadDragCounterRef.current += 1;
+ if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
+ setIsUploadDragging(true);
+ }
+ };
+
+ const handleUploadDragLeave = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ uploadDragCounterRef.current -= 1;
+ if (uploadDragCounterRef.current <= 0) {
+ uploadDragCounterRef.current = 0;
+ setIsUploadDragging(false);
+ }
+ };
+
+ const handleUploadDragOver = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ const handleUploadDrop = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ uploadDragCounterRef.current = 0;
+ setIsUploadDragging(false);
+ if (disabled || uploading) return;
+ const droppedFiles = Array.from(e.dataTransfer?.files || []).filter(
+ fileMatchesAccept,
+ );
+ if (droppedFiles.length === 0) return;
+ const filesToUse = multiple ? droppedFiles : [droppedFiles[0]];
+ onChange?.({ target: { files: filesToUse, value: "" } });
+ };
+
return (
<div
className={
@@ -214,7 +273,13 @@ function ReferenceUploadButton({
aria-busy={uploading || undefined}
disabled={disabled}
onClick={onClick || (() => resolvedInputRef.current?.click())}
- className={`${promptMediaButtonClassName()} disabled:cursor-not-allowed disabled:opacity-50`}
+ onDragEnter={handleUploadDragEnter}
+ onDragLeave={handleUploadDragLeave}
+ onDragOver={handleUploadDragOver}
+ onDrop={handleUploadDrop}
+ className={`${promptMediaButtonClassName()} disabled:cursor-not-allowed disabled:opacity-50${
+ isUploadDragging ? " ring-2 ring-primary border-primary bg-primary/10" : ""
+ }`}
>
{uploading ? (
<div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">