Pasted EmojiOne plugin for draft-js-plugins.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
config
example
scripts
src
test
.babelrc
.eslintrc
.gitignore
.node-version
README.md
package.json
server.js
webpack.config.js
yarn.lock

README.md

draft-js-pasted-emojione-plugin

CircleCI Codecov

npm version License

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.

Demo

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

MIT

© sugarshin