draft-js-select-image-plugin
Embed a local image in your draft-js editor
This is a plugin for draft-js-plugins-editor
.
Installation
npm install draft-js-select-image-plugin
Usage
This plugin exposes a button that integrates with the side toolbar.
;const selectImagePlugin = ;const SelectImageButton = selectImagePlugin;
Configuration
Param | Default | Description |
---|---|---|
imageType | IMAGE | Type of entity created when inserting the atomic block. By default it's the same value as draft-js-image-plugin |
Integration
Rendering the image is out of scope, but in the following example you can see how to integrate draft-js-image-plugin
.
;; ;;;; ;;; const imagePlugin = ;const selectImagePlugin = ;const DefaultBlockTypeSelect = <BlockTypeSelect getEditorState=getEditorState setEditorState=setEditorState theme=theme structure= selectImagePluginSelectImageButton />;const sideToolbarPlugin = ;const SideToolbar = sideToolbarPlugin; Component { superprops; thisstate = editorState: EditorState ; thisplugins = sideToolbarPlugin imagePlugin ; } { this; } { return <div className="editor"> <Editor editorState=thisstateeditorState onChange=thisonChange plugins=thisplugins placeholder="Tell a story" /> <SideToolbar /> </div> ; } ReactDOM;