fix: text compose papercuts (#270)
* make fixes * cleanup
This commit was merged in pull request #270.
This commit is contained in:
@@ -48,16 +48,22 @@ export function useFileInput({
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
|
||||
// Capture phase so file pastes always become attachments — ProseMirror
|
||||
// would otherwise inline pasted images as ephemeral blob: URLs. Mixed
|
||||
// clipboards (e.g. Excel/Word ship an image rendition alongside the text)
|
||||
// must still paste as text, so only file-only pastes are intercepted.
|
||||
const handlePaste = (e: ClipboardEvent) => {
|
||||
const files = Array.from(e.clipboardData?.files ?? []);
|
||||
if (files.length > 0) {
|
||||
e.preventDefault();
|
||||
onFilesRef.current(files);
|
||||
}
|
||||
const data = e.clipboardData;
|
||||
if (!data) return;
|
||||
const files = Array.from(data.files);
|
||||
if (files.length === 0 || data.types.includes('text/plain')) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
onFilesRef.current(files);
|
||||
};
|
||||
|
||||
window.addEventListener('paste', handlePaste);
|
||||
return () => window.removeEventListener('paste', handlePaste);
|
||||
window.addEventListener('paste', handlePaste, true);
|
||||
return () => window.removeEventListener('paste', handlePaste, true);
|
||||
}, [enabled]);
|
||||
|
||||
// Drag and drop handlers
|
||||
|
||||
Reference in New Issue
Block a user