How to get HTML from Remirror editor in Reactjs

How to get HTML from proseMirror editor using Remirror in Reactjs


We have learned how to setup basic proseMirror editor in React using remirror toolkit. How to access the state as HTML ?

Remirror allow us to use a onChangeHTML component and then we have to define handler for accessing a state.

First import the component remirror react.

import { OnChangeHTML } from "@remirror/react"; 

Secondly include the component in Remirror editor as follows

const RichTextEditor = () => {
  return (
    <div>
      <WysiwygEditor placeholder="I am a text">
        <OnChangeHTML onChange={handleChange} />
      </WysiwygEditor>
    </div>
  );
};

Let’s define the handleChange and access the state. For simplicity we output the HTML to console.

const handleChange = (data) => {
  console.log(JSON.stringify(data));
};

That’s all , 😊.

Open the code 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.