Skip to content

React Plugin Architecture for DraftJS including Slack-Like Emojis, FB-Like Mentions and Stickers

License

Notifications You must be signed in to change notification settings

ianstormtaylor/draft-js-plugins

 
 

Repository files navigation

DraftJS Plugins

Draft JS Plugins Logo

High quality plugins with great UX on top of DraftJS.

Available Plugins

Build Status

Live Example & Documentation

Checkout the website!

Usage

First, install the editor with npm:

$ npm install draft-js-plugins-editor --save

and then import it somewhere in your code and you're ready to go!

import Editor from 'draft-js-plugins-editor';

Documentation

draft-js-plugins-editor

Editor

An editor component accepting plugins.

Props Description Required
editorState see here *
onChange see here *
plugins an array of plugins
all other props accepted by the DraftJS Editor see here

Usage:

import React, { Component } from 'react';
import Editor from 'draft-js-plugins-editor';
import createHashtagPlugin from 'draft-js-hashtag-plugin';
import createLinkifyPlugin from 'draft-js-linkify-plugin';
import { EditorState } from 'draft-js';

const hashtagPlugin = createHashtagPlugin();
const linkifyPlugin = createLinkifyPlugin();

const plugins = [
  hashtagPlugin,
  linkifyPlugin,
];

export default class UnicornEditor extends Component {

  state = {
    editorState: EditorState.createEmpty(),
  };

  onChange = (editorState) => {
    this.setState({
      editorState,
    });
  };

  render() {
    return (
      <Editor
        editorState={this.state.editorState}
        onChange={this.onChange}
        plugins={plugins}
        ref="editor"
      />
    );
  }
}

How to write a Plugin

Feel free to copy any of the existing plugins as a starting point. Feel free to directly contact @nikgraf in case you need help or open a Github Issue!

More documentation is coming soon…

Discussion and Support

Join the channel #plugin-editor after signing into the DraftJS Slack organization!

Development

You must have Node.js v5 or later installed to develop DraftJS plugins.

npm install
cd docs
npm install
npm start

Publishing Github Pages

Run ./script/publishGithubPages.sh

The build script renames the .babelrc files of all plugins to avoid issues with the build. In the future we might be able to remove this again.

License

MIT

About

React Plugin Architecture for DraftJS including Slack-Like Emojis, FB-Like Mentions and Stickers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.1%
  • CSS 5.4%
  • Shell 1.5%