Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

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

Keywords

install

npm i draft-js-pasted-emojione-plugin

Downloadsweekly downloads

4

version

0.2.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability