0.2.0 • Published 6 years ago
draft-js-pasted-emojione-plugin v0.2.0
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 (📷) when you copy n paste.
So EmojiOne's emoji image will be converted as well. This is not an assumed behavior.
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