draft-js-pasted-emojione-plugin
EmojiOne plugin for draft-js-plugins.
yarn add draft-js-pasted-emojione-plugin
# or
npm install draft-js-pasted-emojione-plugin
Usage
import React, { Component } from 'react'
import { EditorState } from 'draft-js'
import Editor from 'draft-js-plugins-editor'
import createPastedEmojionePlugin from 'draft-js-pasted-emojione-plugin'
const pastedEmojionePlugin = createPastedEmojionePlugin()
const plugins = [pastedEmojionePlugin]
export default class DemoEditor extends Component {
state = { editorState: EditorState.createEmpty() }
onChange = editorState => this.setState({ editorState })
render() {
return (
<Editor
editorState={this.state.editorState}
plugins={plugins}
onChange={this.onChange}
/>
)
}
}
Motivation
draft-js will convert <img />
to the emoji of camera (
ref: https://github.com/facebook/draft-js/pull/1378
Option
config
createPastedEmojionePlugin(config)
Property | Type | Default |
---|---|---|
config.selector |
string | 'img.emojione' |
config.getUnicode |
function | img => img.getAttribute('alt') |
license
© sugarshin