Skip to content

Instantly share code, notes, and snippets.

@huozhi
Created September 12, 2016 13:18
Show Gist options
  • Save huozhi/44293fed22ada79548d66d63d6280c92 to your computer and use it in GitHub Desktop.
Save huozhi/44293fed22ada79548d66d63d6280c92 to your computer and use it in GitHub Desktop.
paste image from clipboard
export const onPasetImage = (event, onLoadImageDataURI) => {
const items = (event.clipboardData || event.originalEvent.clipboardData).items
for (let index in items) {
const item = items[index]
if (item.kind === 'file') {
const blob = item.getAsFile()
const reader = new FileReader()
reader.onload = (event) => {
onLoadImageDataURI(event.target.result)
}
reader.readAsDataURL(blob)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment