npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

draft-js-emoji-mart-plugin

v1.0.1

Published

Emoji-mart plugin for DraftJS.

Downloads

496

Readme

Ci Status Npm version Draft.js version React.js version

Emoji-mart integration with DraftJS

This plugin for draft-js-editor

Demo

Package includes its TypeScript Definitions

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;

Checkout stories/CustomEditor.tsx for detailed example.

Configuration Parameters

| Name | Required | Default | Description | | ---- | -------- | ------- | ----------- | | data | true | undefined | Dataset from emoji-mart. Used for bind picker and replace emoji in editor. | | set | true | undefined | Addtional param to Dataset, used by emoji-mart. | | sheetSize | false | 32 | Sheet size wich pass to Emoji component from emoji-mart. | | emojiSize | false | sheetSize / 2 | Size wich pass to Emoji component from emoji-mart. By default sheetSize / 2. | | onChange | false | undefined | Call 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>
);

Older versions

Last version with supports draft-js 0.10 and draft-js-plugins-editor 2.x

There is no changes on plugin usage

npm install -S [email protected]

Development

Run development env

npm run watch # for build ts on change
npm run storybook # run sandbox with base example

Local build

npm run lint
npm run build # build ts by babel and generate typings

Active maintenance with care and ❤️.

Feel free to send a PR.