Edit Generated HTML

The RichTextEditor component is primarily designed for creating rich-text documents. However, it also supports editing previously generated content using the optional initialValue prop

Using the initialValue Prop for Editing

Let's understand this with an example. Assume that you've fetched previously generated HTML content from the database and stored it in a variable named fetched_html.

Here's how you can utilize the RichTextEditor component for editing:

// import RichTextEditor component & useRichTextEditor hook
 
export default function Demo() {
 
  // ...
 
  return (
    <RichTextEditor
        // set the initial content for editing
        initialValue={fetched_html} 
 
        // pass other required and optional props
    />
  )
}

Code Explanation:

  • initialValue: An optional prop that accepts the HTML string that was previously generated by the "RichTextEditor" component. This sets the initial content for the editor, allowing users to pick up right where they saved last time.