draft-js vs react-quill vs @tinymce/tinymce-react
Rich Text Editors for React Comparison
1 Year
draft-jsreact-quill@tinymce/tinymce-reactSimilar Packages:
What's Rich Text Editors for React?

Rich text editors are essential tools for web applications that require users to input formatted text. These editors allow users to create and edit content with various formatting options, such as bold, italics, lists, links, and images. The choice of a rich text editor can significantly affect the user experience and the complexity of the implementation. The three packages discussed here, @tinymce/tinymce-react, draft-js, and react-quill, each offer unique features and capabilities that cater to different use cases and developer preferences.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
draft-js835,94622,580-9555 years agoMIT
react-quill643,9716,866405 kB423-MIT
@tinymce/tinymce-react327,970993111 kB1812 days agoMIT
Feature Comparison: draft-js vs react-quill vs @tinymce/tinymce-react

Customization

  • draft-js:

    Draft.js provides a high level of customization by allowing developers to define their own content blocks and styles. It offers a flexible API for building custom components and handling content state, making it suitable for applications with unique requirements.

  • react-quill:

    React-Quill is relatively easy to customize, with a straightforward API for modifying the toolbar and adding custom formats. However, it may not offer as many advanced features or plugins compared to TinyMCE.

  • @tinymce/tinymce-react:

    TinyMCE offers extensive customization options through its rich plugin ecosystem, allowing developers to add features like image uploads, media embeds, and custom toolbar buttons. Its configuration options are comprehensive, enabling tailored experiences for different use cases.

Ease of Use

  • draft-js:

    Draft.js has a steeper learning curve due to its lower-level API and the need for more boilerplate code. While it offers powerful features, developers may need to invest more time in understanding its concepts and structure.

  • react-quill:

    React-Quill is very easy to use and integrate into React applications. It provides a simple API and a clean interface, making it an excellent choice for developers who want to quickly implement rich text editing.

  • @tinymce/tinymce-react:

    TinyMCE is designed to be user-friendly, providing a familiar WYSIWYG interface that resembles popular word processors. This makes it easy for end-users to adopt without a steep learning curve.

Performance

  • draft-js:

    Draft.js is designed for performance with a focus on immutability and efficient rendering. It minimizes re-renders by using a content state model, which can lead to better performance in applications with complex text inputs.

  • react-quill:

    React-Quill is lightweight and performs well for basic use cases. However, it may not handle very large documents as efficiently as Draft.js, especially when complex formatting is involved.

  • @tinymce/tinymce-react:

    TinyMCE is optimized for performance, but its extensive feature set can lead to increased bundle size. Developers can selectively load plugins to improve performance based on their needs.

Community and Support

  • draft-js:

    Draft.js is backed by Facebook and has a solid community, but its documentation can be less comprehensive compared to TinyMCE. However, it has a dedicated user base that contributes to its development.

  • react-quill:

    React-Quill has a growing community and decent documentation, but it may not be as extensive as TinyMCE. It is suitable for projects that require community support without the need for extensive customization.

  • @tinymce/tinymce-react:

    TinyMCE has a large community and extensive documentation, making it easy to find resources and support. Its popularity ensures ongoing updates and improvements.

Integration

  • draft-js:

    Draft.js is specifically designed for React, making it a natural fit for React applications. Its integration is straightforward, but custom implementations may require more effort due to its low-level nature.

  • react-quill:

    React-Quill is easy to integrate into React applications and works well with existing React components. Its simplicity makes it a good choice for projects that need quick implementation.

  • @tinymce/tinymce-react:

    TinyMCE integrates seamlessly with various frameworks and platforms, offering plugins for popular content management systems (CMS) and a robust API for custom integrations.

How to Choose: draft-js vs react-quill vs @tinymce/tinymce-react
  • draft-js:

    Select Draft.js if you are looking for a highly customizable editor that allows for fine-grained control over the content state and rendering. It is best suited for applications that require a React-centric approach and custom handling of content.

  • react-quill:

    Opt for React-Quill if you want a simple and lightweight editor that is easy to integrate and use. It is perfect for projects that need basic rich text editing capabilities without the overhead of complex features.

  • @tinymce/tinymce-react:

    Choose TinyMCE if you need a feature-rich editor with extensive customization options and a familiar interface for users. It is ideal for applications that require advanced functionalities like plugins and a WYSIWYG experience.

README for draft-js

draftjs-logo

Draft.js

Build Status npm version

Live Demo


Draft.js is a JavaScript rich text editor framework, built for React and backed by an immutable model.

  • Extensible and Customizable: We provide the building blocks to enable the creation of a broad variety of rich text composition experiences, from basic text styles to embedded media.
  • Declarative Rich Text: Draft.js fits seamlessly into React applications, abstracting away the details of rendering, selection, and input behavior with a familiar declarative API.
  • Immutable Editor State: The Draft.js model is built with immutable-js, offering an API with functional state updates and aggressively leveraging data persistence for scalable memory usage.

Learn how to use Draft.js in your own project.

API Notice

Before getting started, please be aware that we recently changed the API of Entity storage in Draft. The latest version, v0.10.0, supports both the old and new API. Following that up will be v0.11.0 which will remove the old API. If you are interested in helping out, or tracking the progress, please follow issue 839.

Getting Started

npm install --save draft-js react react-dom

or

yarn add draft-js react react-dom

Draft.js depends on React and React DOM which must also be installed.

Using Draft.js

import React from 'react';
import ReactDOM from 'react-dom';
import {Editor, EditorState} from 'draft-js';

class MyEditor extends React.Component {
  constructor(props) {
    super(props);
    this.state = {editorState: EditorState.createEmpty()};
    this.onChange = (editorState) => this.setState({editorState});
    this.setEditor = (editor) => {
      this.editor = editor;
    };
    this.focusEditor = () => {
      if (this.editor) {
        this.editor.focus();
      }
    };
  }

  componentDidMount() {
    this.focusEditor();
  }

  render() {
    return (
      <div style={styles.editor} onClick={this.focusEditor}>
        <Editor
          ref={this.setEditor}
          editorState={this.state.editorState}
          onChange={this.onChange}
        />
      </div>
    );
  }
}

const styles = {
  editor: {
    border: '1px solid gray',
    minHeight: '6em'
  }
};

ReactDOM.render(
  <MyEditor />,
  document.getElementById('container')
);

Since the release of React 16.8, you can use Hooks as a way to work with EditorState without using a class.

import React from 'react';
import ReactDOM from 'react-dom';
import {Editor, EditorState} from 'draft-js';

function MyEditor() {
  const [editorState, setEditorState] = React.useState(
    EditorState.createEmpty()
  );

  const editor = React.useRef(null);

  function focusEditor() {
    editor.current.focus();
  }

  React.useEffect(() => {
    focusEditor()
  }, []);

  return (
    <div onClick={focusEditor}>
      <Editor
        ref={editor}
        editorState={editorState}
        onChange={editorState => setEditorState(editorState)}
      />
    </div>
  );
}

Note that the editor itself is only as tall as its contents. In order to give users a visual cue, we recommend setting a border and a minimum height via the .DraftEditor-root CSS selector, or using a wrapper div like in the above example.

Because Draft.js supports unicode, you must have the following meta tag in the <head> </head> block of your HTML file:

<meta charset="utf-8" />

Further examples of how Draft.js can be used are provided below.

Examples

Visit http://draftjs.org/ to try out a basic rich editor example.

The repository includes a variety of different editor examples to demonstrate some of the features offered by the framework.

To run the examples, first build Draft.js locally. The Draft.js build is tested with Yarn v1 only. If you're using any other package manager and something doesn't work, try using yarn v1:

git clone https://github.com/facebook/draft-js.git
cd draft-js
yarn install
yarn run build

then open the example HTML files in your browser.

Draft.js is used in production on Facebook, including status and comment inputs, Notes, and messenger.com.

Browser Support

| IE / Edge
IE / Edge | Firefox
Firefox | Chrome
Chrome | Safari
Safari | iOS Safari
iOS Safari | Chrome for Android
Chrome for Android | | --------- | --------- | --------- | --------- | --------- | --------- | | IE11, Edge [1, 2]| last 2 versions| last 2 versions| last 2 versions| not fully supported [3] | not fully supported [3]

[1] May need a shim or a polyfill for some syntax used in Draft.js (docs).

[2] IME inputs have known issues in these browsers, especially Korean (docs).

[3] There are known issues with mobile browsers, especially on Android (docs).

Resources and Ecosystem

Check out this curated list of articles and open-sourced projects/utilities: Awesome Draft-JS.

Discussion and Support

Join our Slack team!

Contribute

We actively welcome pull requests. Learn how to contribute.

License

Draft.js is MIT licensed.

Examples provided in this repository and in the documentation are separately licensed.