Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
uploader.on('upload:done', (response) => {
setUploadState(false)
const result = JSON.parse(response).result
if (result && result.content && result.content.url) {
setEditorState(addImage(getEditorState(), result.content.url))
} else {
console.error(response)
Alert.error('Failed to upload image')
}
})
uploader.on('upload:progress', (progress) => {
const editorState = this.props.getEditorState()
const contentState = editorState.getCurrentContent()
const contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', {url: matchedUrl})
const entityKey = contentStateWithEntity.getLastCreatedEntityKey()
let newState = RichUtils.toggleLink(
editorState,
editorState.getSelection(),
entityKey
)
newState = EditorState.forceSelection(
newState, editorState.getSelection()
)
this.props.setEditorState(newState)
} else if (this.props.type === 'IMAGE') {
this.props.setEditorState(addImage(this.props.getEditorState(), matchedUrl))
}
this.props.closeModal()
}