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]
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});
}
Most helpful comment
Sorry my bad I forgot to set the new state :