Skip to content

Instantly share code, notes, and snippets.

@levvsha
Last active July 1, 2018 08:00
Show Gist options
  • Save levvsha/2e7f032c0fc9a57f796c9f2739da1cf8 to your computer and use it in GitHub Desktop.
Save levvsha/2e7f032c0fc9a57f796c9f2739da1cf8 to your computer and use it in GitHub Desktop.
handleDroppedFiles(selection, files) {
const filteredFiles = files
.filter(file => (file.type.indexOf('image/') === 0)); // <-- [1]
if (!filteredFiles.length) {
return 'not_handled';
}
this.onChange(addNewBlockAt( // <-- [2]
this.state.editorState,
selection.getAnchorKey(),
'SLIDER',
new Map({ slides: _map(
filteredFiles,
file => ({ url: urlCreator.createObjectURL(file) }) // <-- [3]
)})
));
return 'handled';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment