Draft-js-plugins: Image plugin : Images not showing in editor

Created on 4 Jul 2017  路  2Comments  路  Source: draft-js-plugins/draft-js-plugins

I can't make the Image plugin to work, I have the following handler that is executed after I get an image url from my api :

  handleAddImage(url) {
    console.log(url); // show the correct url, I can view it in browser
    imagePlugin.addImage(this.state.editorState, url);
  }

but the editor's content does not change.

Here are the other parts of the code :

...
import 'style-loader!css-loader!draft-js-image-plugin/lib/plugin.css';
import createImagePlugin from 'draft-js-image-plugin';
...

const imagePlugin = createImagePlugin();
...

              <Editor
                editorState={this.state.editorState}
                handleKeyCommand={this.handleKeyCommand}
                onChange={this.onChange}
                onTab={this.onTab}
                ref="editor"
                spellCheck={false}
                placeholder={_('Write here ...')}
                plugins={[linkifyPlugin, imagePlugin]}
              />
...

I'm using [email protected]

Most helpful comment

Sorry my bad I forgot to set the new state :

  handleAddImage(url) {
    const editorState = imagePlugin.addImage(this.state.editorState, url);
    this.setState({editorState});
  }

All 2 comments

By the way, when i open the css file draft-js-image-plugin/lib/plugin.css it's empty, is this normal ?

.draftJsEmojiPlugin__image__192TI {}

Sorry my bad I forgot to set the new state :

  handleAddImage(url) {
    const editorState = imagePlugin.addImage(this.state.editorState, url);
    this.setState({editorState});
  }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

GaborLeskoFlach picture GaborLeskoFlach  路  3Comments

icd2k3 picture icd2k3  路  3Comments

kaustubh-karkare picture kaustubh-karkare  路  3Comments

joehua87 picture joehua87  路  4Comments

albertomr86 picture albertomr86  路  4Comments