feat: upload source by ctrl+v and dropzone

This commit is contained in:
2026-10-04 22:30:21 +05:00
parent 91150a14bf
commit 864f9cdc9f
10 changed files with 137 additions and 19 deletions
@@ -22,6 +22,7 @@
type ToolSchema,
} from "$lib/registry-schema";
import { downloadZip } from "$lib/zip";
import { onMount } from "svelte";
import { SvelteSet } from "svelte/reactivity";
interface Props {
@@ -235,6 +236,25 @@
init();
});
onMount(() => {
if (inputMode !== "image") return;
function onPaste(e: ClipboardEvent) {
const target = e.target as HTMLElement | null;
if (target?.closest("input, textarea, [contenteditable]")) return;
for (const item of e.clipboardData?.items ?? []) {
if (item.kind !== "file" || !item.type.startsWith("image/")) continue;
const file = item.getAsFile();
if (file) {
e.preventDefault();
void handleFile(file);
}
return;
}
}
window.addEventListener("paste", onPaste);
return () => window.removeEventListener("paste", onPaste);
});
$effect(() => {
if (!started) return;
if (inputMode === "image" && !source) return;