Skip to content

Preact

The same API as the React package, on preact/hooks. Use class instead of className.

On this page

Install

Terminal
npm install @open-wysiwyg-editor/preact

Usage

import { useState } from "preact/hooks";
import { RichTextEditor } from "@open-wysiwyg-editor/preact";
import "@open-wysiwyg-editor/preact/style.css";

export function Article() {
  const [html, setHtml] = useState("<p>Hello</p>");
  return <RichTextEditor value={html} onChange={setHtml} class="article-editor" />;
}

Good to know

  • Props and options are the same as in the React package, with class for the wrapper.
  • SSR-safe: the server renders an empty container and the hidden input.

Always sanitize on the server

The editor sanitizes what it loads and produces, but that is not a security boundary: anyone can post any string to your API. Sanitize the HTML again with a library you trust before you store it or render it for other users.

Edit this page on GitHub