Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuvi-emoji-picker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuvi-emoji-picker

Emoji-mart plugin for DraftJS.

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Emoji-mart integration with DraftJS

This plugin for draft-js-editor

Install

npm install -S draft-js-emoji-mart-plugin

Install peer dependencies

npm install -S emoji-mart draft-js

Usage

import Editor from 'draft-js-plugins-editor';
import createEmojiMartPlugin from 'draft-js-emoji-mart-plugin';
import data from 'emoji-mart/data/apple.json';

import 'emoji-mart/css/emoji-mart.css'

const emojiPlugin = createEmojiMartPlugin({
  data,
  set: 'apple'
});

// NimblePicker from emoji-mart binded with draftjs
const { Picker } = emojiPlugin;

const MyEditor = ({ editorState, onChange }) => (
  <div>
    <Editor
      editorState={editorState}
      onChange={onChange}
      plugins={[emojiPlugin]}
    />
    {/*
      Any props supported by emoji-mart NimblePicker.
      Feel free to style it and trigger for view.
    */}
    <Picker
      perLine={7}
      showPreview={false}
    />
  </div>
)

export default MyEditor;

Configuration Parameters

NameRequiredDefaultDescription
datatrueundefinedDataset from emoji-mart. Used for bind picker and replace emoji in editor.
settrueundefinedAddtional param to Dataset, used by emoji-mart.
emojiSizefalse16Size wich pass to Emoji component from emoji-mart.
sheetSizefalseemojiSize * 2Sheet size wich pass to Emoji component from emoji-mart. By default emojiSize * 2.
onChangefalseundefinedCall then DraftJS recieve new state.

Additional plugin feature

Emoji component

Plugin provide Emoji component, wich could replace native utf-8 emoji by NimbleEmoji component from emoji-mart.

// MyEditor.jsx
export const emojiPlugin = createEmojiMartPlugin({
  data,
  set: 'apple'
});

// Text.jsx
import { emojiPlugin } from './MyEditor.jsx';

const { Emoji } = emojiPlugin;

const TextViewer = ({ props }) => (
  <div>
    Useful text with emoji <Emoji decoratedText={'😈'} />
  </div>
);

export default TextViewer;

Emoji RegExp

Useful to find native emoji in string. Could be used with Emoji component provided by plugin for replace emoji in plane text.

import { unicodeEmojiRegexp } from 'draft-js-emoji-mart-plugin/lib/constants';
import { emojiPlugin } from './MyEditor.jsx';

const { Emoji } = emojiPlugin;

// Not for production usage.
const parsedText = 'some string with 😈 '.split(unicodeEmojiRegexp).map(term => {
  if (term.match(unicodeEmojiRegexp)) {
    return <Emoji decoratedText={term} />
  }

  return term;
});

console.log(parsedText); // ['some string with', <Emoji decoratedText={'😈'}>]

// Render it by React
const MyEmojifiedText = () => (
  <div>{parsedText}</div>
);

Keywords

FAQs

Package last updated on 11 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc