Created
September 12, 2016 13:18
-
-
Save huozhi/44293fed22ada79548d66d63d6280c92 to your computer and use it in GitHub Desktop.
paste image from clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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