Skip to content

Commit c83b2b9

Browse files
committed
Docs: draft-js-image-plugin integration
1 parent a5c3e49 commit c83b2b9

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const { UnsplashButton } = unsplashPlugin;
2525

2626
## Configuration
2727

28-
| Param | Default | Description |
28+
| Param | Default | Description |
2929
|-------------------|-------------------------------------|-------------------------------------------------------------------|
3030
| theme | Default styles | draft-js-unsplash-plugin/lib/plugin.css |
3131
| options | Default behavior | List of options. |
@@ -37,7 +37,7 @@ const { UnsplashButton } = unsplashPlugin;
3737

3838
### Options
3939

40-
| Option | Default | Description |
40+
| Option | Default | Description |
4141
|-------------|--------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
4242
| accessKey | (Required) | Unsplash Access Key. (https://unsplash.com/oauth/applications) |
4343
| placehoder | 'Type to search Unsplash, and press Enter' | Text as placeholder for the Explorer. |
@@ -228,10 +228,7 @@ class MyEditor extends React.Component {
228228
editorState={editorState}
229229
onChange={this.onChange}
230230
plugins={this.plugins}
231-
ref={(element) => { this.editor = element; }}
232-
placeholder="Share your story"
233-
spellCheck
234-
/>
231+
placeholder="Share your story" />
235232

236233
<SideToolbar />
237234
<AlignmentTool />
@@ -247,6 +244,34 @@ ReactDOM.render(<MyEditor />, document.getElementById('root'));
247244

248245
```
249246

247+
In this other example you can see how integrate the plugin with `draft-js-image-plugin`.
248+
249+
```js
250+
// npm install --save draft-js-image-plugin
251+
252+
import createImagePlugin from 'draft-js-image-plugin';
253+
254+
const imagePlugin = createImagePlugin();
255+
const unsplashPlugin = createUnsplashPlugin({
256+
options: {
257+
accessKey: '<my-access-key>'
258+
},
259+
unsplashType: 'IMAGE' // <- Inserting with this BLOCK TYPE
260+
});
261+
262+
const plugins = [
263+
sideToolbarPlugin,
264+
unsplashPlugin,
265+
imagePlugin // <- Must go AFTER unsplashPlugin.
266+
];
267+
268+
<Editor
269+
editorState={editorState}
270+
onChange={this.onChange}
271+
plugins={plugins}
272+
placeholder="Share your story" />
273+
```
274+
250275
#### Axios
251276
See how to provide your own implementation to fetch the URL.
252277
`onRequest` Must return a `Promise` that resolves to a JSON with the metadata.

0 commit comments

Comments
 (0)