diff --git a/src/App.tsx b/src/App.tsx index 9186282..2f186a6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -77,6 +77,26 @@ export default function App() { const bodyRef = useRef(body); const historySnapshotRef = useRef(null); + useEffect(() => { + let unlisten: (() => void) | null = null; + getCurrentWindow() + .onDragDropEvent(async (event) => { + if (event.payload.type !== "drop") return; + const [path] = event.payload.paths ?? []; + if (!path || !path.toLowerCase().endsWith(".txt")) return; + await createTextFromFile(path); + }) + .then((cleanup) => { + unlisten = cleanup; + }) + .catch((error) => { + console.error("Failed to register drag/drop handler", error); + }); + return () => { + if (unlisten) unlisten(); + }; + }, [createTextFromFile]); + useEffect(() => { bodyRef.current = body; }, [body]);