check all clipboard contents for Files, not just the first.

This was implemented for the "Copy Image" function of browsers, which on Firefox and Chrome on Linux was tested to give item[0] as "text/html" and item[1] as a file.
This effectively worked in rich text mode anyway as it is able to paste text/html snippets, but was unable to work in plain text mode.
This commit is contained in:
Jarrad Whitaker 2020-07-29 10:53:39 +10:00 committed by Ben Gotow
parent 0061fc9fc0
commit c530d31dd5

View file

@ -277,8 +277,8 @@ export function handleFilePasted(event: ClipboardEvent, onFileReceived: (path: s
if (event.clipboardData.items.length === 0) {
return false;
}
const item = event.clipboardData.items[0];
for (const i in event.clipboardData.items) {
const item = event.clipboardData.items[i];
// If the pasteboard has a file on it, stream it to a temporary
// file and fire our `onFilePaste` event.
if (item.kind === 'file') {
@ -305,6 +305,7 @@ export function handleFilePasted(event: ClipboardEvent, onFileReceived: (path: s
reader.readAsArrayBuffer(blob);
return true;
}
}
const macCopiedFile = decodeURI(ElectronClipboard.read('public.file-url').replace('file://', ''));
const winCopiedFile = ElectronClipboard.read('FileNameW').replace(