So i noticed everytime i paste some file, if i have more than 1 file on my clipboard area it only pastes 1 file, the others my code just don't process.
Here is the snippet to reproduce, even if i have more than 1 file on clipboard it only inserts 1 item in the array. I'm trying to figure out what is happening. (use image files to test).
const inputFileToBase64 = file => new Promise((resolve, reject) => {
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => resolve(reader.result)
reader.onerror = error => reject(error)
})
const getBase64Files = async (items) => {
const base64Files = []
for (const item of items) {
const base64 = await inputFileToBase64(item.getAsFile())
base64Files.push(base64)
}
return base64Files
}
document.addEventListener('paste', async (event) => {
console.log('pasted')
const items = event.clipboardData.items
const files = await getBase64Files(items)
console.log(files)
})
PASTE HERE