5 best open-source WYSIWYG editors for React (2021)

Last updated on September 4, 2021 Guest Contributor Loading... 2 comments

This article walks you through a list of the most popular open-source WYSIWYG (What You See Is What You Get or Rich Text) editors for React. Their order is based on the number of stars they receive on Github and the number of downloads per week on npmjs.com.

Draft.js

Summary:

Draft.js is a highly extensible and customizable JavaScript rich text editor framework, built for React and fits seamlessly into React applications, abstracting away the details of rendering, selection, and input behavior with a familiar declarative API.

Sample use:

import React from 'react';
import ReactDOM from 'react-dom';
import {Editor, EditorState} from 'draft-js';
 
const MyEditor = props => {
  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>
  );
}

React Quill

Summary:

React Quill is a rich text editor that is fully compatible with React hooks and TypeScript. It provides 3 built-in themes:

  • Snow: A Quill’s standard appearance,
  • Bubble: Similar to the inline editor on Medium
  • Core theme: Contains only the bare essentials to allow modules like toolbars or tooltips to work.

Sample code:

import React, { useState } from "react";
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';

const MyEditor = () => {
  const [value, setValue] = useState('');

  return (
    <ReactQuill theme="snow" value={value} onChange={setValue}/>
  );
}

Slate React

Summary:

Slate lets you build rich, intuitive editors like those in Medium, Dropbox Paper or Google Docs without your codebase getting mired in complexity. t can do this because all of its logic is implemented with a series of plugins, so you aren’t ever constrained by what is or isn’t in “core”.

React Draft Wysiwyg

Summary:

This is a lightweight rich text editor built on top of ReactJS and DraftJS. It provides lots of features:

  • Configurable toolbar with option to add/remove controls.
  • Option to change the order of the controls in the toolbar.
  • Support for block types: Paragraph, H1 – H6, Blockquote, Code.
  • Support for coloring text or background.
  • Support for adding / uploading images.
  • Option of undo and redo.

And many more…

Official TinyMCE React component

Summary:

TinyMCE is an advanced open source core rich text editor that can be easily intergrated into your React projects.

It is easy to configure the UI to match the layout design of your site, product, or application. Due to its flexibility, you can configure the editor with as much or as little functionality as you like, depending on your requirements.

With a ton of powerful plugins available, extending and adding additional functionality to TinyMCE is as simple as including a single line of code.

Sample use:

 import React, { useRef } from 'react';
 import { Editor } from '@tinymce/tinymce-react';

 const App = () => {
   const editorRef = useRef(null);
   const log = () => {
     if (editorRef.current) {
       console.log(editorRef.current.getContent());
     }
   };
   return (
     <>
       <Editor
         onInit={(evt, editor) => editorRef.current = editor}
         initialValue="<p>This is the initial content of the editor.</p>"
         init={{
           height: 500,
           menubar: false,
           plugins: [
             'advlist autolink lists link image charmap print preview anchor',
             'searchreplace visualblocks code fullscreen',
             'insertdatetime media table paste code help wordcount'
           ],
           toolbar: 'undo redo | formatselect | ' +
           'bold italic backcolor | alignleft aligncenter ' +
           'alignright alignjustify | bullist numlist outdent indent | ' +
           'removeformat | help',
           content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
         }}
       />
       <button onClick={log}>Log editor content</button>
     </>
   );
 }

export default App;

Conclusion

We’ve gone over a collection of great, free, and open-source rich text editors that you can use in your React applications. Which one will you choose? Please let us know in the comment section.

If you’d like to explore more new and exciting things in React and front-end development, take a look at the following articles:

You can also check our React topic page and React Native topic page for the latest tutorials and examples.

Subscribe
Notify of
guest
2 Comments
Inline Feedbacks
View all comments
John
John
1 month ago

Ty Editor.js
https://editorjs.io

Matheus
Matheus
3 months ago
  1. dasdasd
  2. asdasd
  3. asd
  4. asdasd

Related Articles