draft-js vs react-quill vs @ckeditor/ckeditor5-react
Rich Text Editors for React Comparison
3 Years
draft-jsreact-quill@ckeditor/ckeditor5-reactSimilar Packages:
What's Rich Text Editors for React?

Rich text editors are web-based text editing tools that allow users to format text, insert images, create lists, and perform other content editing tasks directly within a web application. Unlike simple text areas, rich text editors provide a WYSIWYG (What You See Is What You Get) interface, enabling users to see how their formatted content will appear in real time. These editors are commonly used in content management systems, blogging platforms, and any application that requires user-generated content with advanced formatting capabilities. @ckeditor/ckeditor5-react is a modern, highly customizable rich text editor built on the CKEditor 5 framework, offering a wide range of features, plugins, and a modular architecture. It provides excellent support for collaborative editing, real-time collaboration, and is designed for accessibility and internationalization. draft-js is a framework for building rich text editors in React, developed by Facebook. It provides a set of APIs and components for creating highly customizable editors with support for inline styles, block types, and custom content. react-quill is a React wrapper for the Quill rich text editor, known for its simplicity and ease of use. It offers a clean API, lightweight design, and supports basic formatting, custom themes, and modules, making it a great choice for projects that need a straightforward yet powerful editing solution.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
draft-js808,010
22,680-9545 years agoMIT
react-quill727,429
6,982405 kB428-MIT
@ckeditor/ckeditor5-react236,370
451436 kB79a month agoSEE LICENSE IN LICENSE.md
Feature Comparison: draft-js vs react-quill vs @ckeditor/ckeditor5-react

Customization and Extensibility

  • draft-js:

    draft-js provides a high level of customization, allowing developers to define their own content models, styling, and behavior. It is designed to be flexible, enabling the creation of unique editing experiences, but requires more effort to implement advanced features.

  • react-quill:

    react-quill allows for some customization, particularly in terms of toolbar configuration and styling. However, it is more limited compared to CKEditor and Draft.js in terms of extensibility, making it less suitable for highly specialized use cases.

  • @ckeditor/ckeditor5-react:

    @ckeditor/ckeditor5-react offers extensive customization options, including the ability to create custom plugins, toolbar configurations, and themes. Its modular architecture allows developers to include only the features they need, making it highly extensible.

Collaboration Features

  • draft-js:

    draft-js does not provide built-in collaboration features, but its architecture allows developers to implement custom solutions for real-time editing and collaboration if needed. This requires additional development work and integration with external services.

  • react-quill:

    react-quill does not have native support for collaboration. However, developers can implement collaborative features using third-party libraries or by integrating with real-time databases, but this would require additional coding and setup.

  • @ckeditor/ckeditor5-react:

    @ckeditor/ckeditor5-react includes built-in support for real-time collaboration, allowing multiple users to edit the same document simultaneously. This feature is particularly useful for team environments and applications that require collaborative content creation.

Ease of Integration

  • draft-js:

    draft-js is designed for seamless integration with React, but its flexibility and customization capabilities may require a steeper learning curve for developers who want to fully leverage its potential. The documentation is thorough, but building a fully-featured editor can be time-consuming.

  • react-quill:

    react-quill is very easy to integrate into React projects, thanks to its simple API and lightweight nature. It requires minimal setup, making it a great choice for developers who need to add rich text editing capabilities quickly.

  • @ckeditor/ckeditor5-react:

    @ckeditor/ckeditor5-react is relatively easy to integrate into React applications, especially with its well-documented API and examples. However, its extensive feature set may require some time to configure and customize according to specific needs.

Code Example

  • draft-js:

    draft-js Example

    import React, { useState } from 'react';
    import { Editor, EditorState } from 'draft-js';
    import 'draft-js/dist/Draft.css'; // Import default styles
    
    const MyDraftEditor = () => {
        const [editorState, setEditorState] = useState(EditorState.createEmpty());
    
        const handleEditorStateChange = (state) => {
            setEditorState(state);
        };
    
        return (
            <div>
                <Editor
                    editorState={editorState}
                    onEditorStateChange={handleEditorStateChange}
                    placeholder="Type something..."
                />
            </div>
        );
    };
    
    export default MyDraftEditor;
    
  • react-quill:

    react-quill Example

    import React, { useState } from 'react';
    import ReactQuill from 'react-quill';
    import 'react-quill/dist/quill.snow.css'; // Import Quill styles
    
    const MyQuillEditor = () => {
        const [value, setValue] = useState('<p>Hello, world!</p>');
    
        return (
            <div>
                <ReactQuill 
                    value={value} 
                    onChange={setValue} 
                    theme="snow" 
                />
            </div>
        );
    };
    
    export default MyQuillEditor;
    
  • @ckeditor/ckeditor5-react:

    @ckeditor/ckeditor5-react Example

    import React from 'react';
    import { CKEditor } from '@ckeditor/ckeditor5-react';
    import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
    
    const MyEditor = () => {
        return (
            <CKEditor
                editor={ClassicEditor}
                data="<p>Hello, world!</p>"
                onReady={editor => {
                    // You can store the editor instance and use it later if needed.
                    console.log('Editor is ready to use!', editor);
                }}
                onChange={(event, editor) => {
                    const data = editor.getData();
                    console.log({ data });
                }}
                onBlur={(event, editor) => {
                    console.log('Blur.', editor);
                }}
                onFocus={(event, editor) => {
                    console.log('Focus.', editor);
                }}
            />
        );
    };
    
    export default MyEditor;
    
How to Choose: draft-js vs react-quill vs @ckeditor/ckeditor5-react
  • draft-js:

    Choose draft-js if you want complete control over the editor's behavior and appearance. It is ideal for developers who need to create a highly customized editing experience and are comfortable building out features like toolbars and formatting options from scratch.

  • react-quill:

    Choose react-quill if you need a lightweight, easy-to-integrate editor with a good balance of features and simplicity. It is perfect for projects that require basic rich text editing capabilities without the overhead of a large library.

  • @ckeditor/ckeditor5-react:

    Choose @ckeditor/ckeditor5-react if you need a feature-rich, highly customizable editor with built-in support for collaboration, advanced formatting, and a wide range of plugins. It is suitable for enterprise-level applications where flexibility and extensibility are important.

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.