diff --git a/web/src/routes/editor/NoteEditor.svelte b/web/src/routes/editor/NoteEditor.svelte index 181441ef6..4e5cca750 100644 --- a/web/src/routes/editor/NoteEditor.svelte +++ b/web/src/routes/editor/NoteEditor.svelte @@ -350,30 +350,20 @@ return; } - console.log('[paste types]', event.clipboardData.types); - const index = event.clipboardData.types.findIndex((x) => x === 'Files'); - console.log('[paste file index]', index); - - if (index === undefined || index < 0) { - return; - } - - const file = event.clipboardData.items[index].getAsFile(); - - if (file === null) { - console.error('[paste file not found]'); - return; - } + for (const item of event.clipboardData.items) { + console.log('[paste file]', item); + if (item.kind !== 'file' || !item.type.startsWith('image/')) { + continue; + } - console.log('[paste file]', file); + const file = item.getAsFile(); + if (file === null) { + continue; + } - if (file.size > 1024 * 1024) { - console.error('[paste file size > 1MB]', file.size.toLocaleString()); - return; + $mediaFiles.push(file); + $mediaFiles = $mediaFiles; } - - $mediaFiles.push(file); - $mediaFiles = $mediaFiles; } async function mediaPicked({detail: files}: {detail: FileList}): Promise {