How to use the draft-js-image-plugin/lib/modifiers/addImage function in draft-js-image-plugin

To help you get started, we’ve selected a few draft-js-image-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appirio-tech / connect-app / src / components / RichTextArea / ImageUploadPlugin.jsx View on Github external
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) => {
github appirio-tech / connect-app / src / components / RichTextArea / AddLinkButton.jsx View on Github external
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()
  }

draft-js-image-plugin

Image Plugin for DraftJS

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis