Skip to content

Commit

Permalink
Merge pull request #709 from SnowCait/paste-multiple-images
Browse files Browse the repository at this point in the history
Paste multiple images
  • Loading branch information
SnowCait authored Oct 13, 2023
2 parents 79cb826 + c246d9a commit f287a33
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions web/src/routes/editor/NoteEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down

1 comment on commit f287a33

@vercel
Copy link

@vercel vercel bot commented on f287a33 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nostter – ./

nostter.vercel.app
nostter-snowcait.vercel.app
nostter-git-main-snowcait.vercel.app

Please sign in to comment.