Create a TinyMCE Rich Text Editor in React

How to create Editor in React using TinyMCE library


So far we have seen many Editor Frameworks and their usage guides.

May be the simplest of all Editor libraries for React is TinyMCE.

Let’s quickly setup a React project and install the Tiny dependencies.

npx create-react-app myapp
yarn add @tinymce/tinymce-react

Make sure all the dependencies and peer dependencies properly added. Using the Editor component we can setup the editor, similar to draft-js.

import { Editor } from "@tinymce/tinymce-react";

const TinyMceEditor = () => {
  return (
    <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 }"
      }}
    />
  );
};

export default TinyMceEditor;

The configuration was quick, and it is easier to use.

Open the example in Sandbox.

Author: Manoj

Developer and a self-learner, love to work with Reactjs, Angular, Node, Python and C#.Net

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.