draft-js-pasted-emojione-plugin

0.2.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (36)

    Package Sidebar

    Install

    npm i draft-js-pasted-emojione-plugin

    Weekly Downloads

    0

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    14.5 kB

    Total Files

    14

    Last publish

    Collaborators

    • sugarshin