@richhtmleditor/react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rajkishor Sahu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # @richhtmleditor/react
2
+
3
+ React component for Rich HTML Editor, built on [`@richhtmleditor/core`](https://www.npmjs.com/package/@richhtmleditor/core). Drop-in WYSIWYG with toolbar presets, dark mode, custom React toolbar tools, and enterprise plugin support.
4
+
5
+ **Current release: 1.0.0** — Depends on `@richhtmleditor/core` **^1.0.0**.
6
+
7
+ **Repository:** [github.com/rajkishorsahu89/richhtmleditor](https://github.com/rajkishorsahu89/richhtmleditor)
8
+
9
+ **Demo:** [richhtmleditor.vercel.app](https://richhtmleditor.vercel.app/) — [demo](https://richhtmleditor.vercel.app/demo) · [guide](https://richhtmleditor.vercel.app/guide) · [API](https://richhtmleditor.vercel.app/api). Doc Preview joint demo: [doc-preview-app.vercel.app/demo/enterprise](https://doc-preview-app.vercel.app/demo/enterprise)
10
+
11
+ ### What's in 1.0.0
12
+
13
+ - **`RichHtmlEditor`** — React wrapper around `createEditor` with lifecycle-safe mount/destroy
14
+ - **Controlled content** — `content` prop syncs HTML into the editor instance
15
+ - **Custom tools** — `customToolIds` + `renderTool` for React-rendered toolbar buttons
16
+ - **Plugins** — pass `plugins` for AI, comments, workflows, and collab
17
+ - Re-exports all public symbols from `@richhtmleditor/core`
18
+
19
+ > Ships as ESM with TypeScript declarations. Peer deps: `react` and `react-dom` ^18 \|\| ^19. Import [`@richhtmleditor/themes`](https://www.npmjs.com/package/@richhtmleditor/themes) CSS in your app entry.
20
+
21
+ **Keywords:** `richhtmleditor` `react` `wysiwyg` `rich-text-editor` `component`
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install @richhtmleditor/react @richhtmleditor/themes
27
+ # Adds @richhtmleditor/core automatically.
28
+ # Peer deps: react ^18 || ^19, react-dom ^18 || ^19.
29
+ ```
30
+
31
+ ## Usage — component
32
+
33
+ ```tsx
34
+ import { useState } from "react";
35
+ import { RichHtmlEditor } from "@richhtmleditor/react";
36
+ import "@richhtmleditor/themes/richhtmleditor.css";
37
+
38
+ export function EditorDemo() {
39
+ const [html, setHtml] = useState("<p>Hello <strong>world</strong></p>");
40
+
41
+ return (
42
+ <RichHtmlEditor
43
+ content={html}
44
+ toolbar={{ preset: "standard" }}
45
+ features={{ tables: true, media: true }}
46
+ onChange={(c) => setHtml(c.html)}
47
+ />
48
+ );
49
+ }
50
+ ```
51
+
52
+ ## Usage — custom React toolbar tool
53
+
54
+ ```tsx
55
+ <RichHtmlEditor
56
+ toolbar={{
57
+ preset: "standard",
58
+ layout: ["bold", "italic", "|", "approve"]
59
+ }}
60
+ customToolIds={["approve"]}
61
+ renderTool={(tool) => (
62
+ <button type="button" onClick={() => alert("Approved!")}>
63
+ Approve
64
+ </button>
65
+ )}
66
+ />
67
+ ```
68
+
69
+ ## Usage — enterprise plugins
70
+
71
+ ```tsx
72
+ import { createAiPlugin } from "@richhtmleditor/ai";
73
+ import { createCommentsPlugin } from "@richhtmleditor/comments";
74
+ import { createWorkflowsPlugin } from "@richhtmleditor/workflows";
75
+ import { resolveEnterpriseFeatures } from "@richhtmleditor/enterprise/browser";
76
+
77
+ const gate = resolveEnterpriseFeatures({ token: "RHE-ENT-DEMO-2026-FULL" });
78
+
79
+ <RichHtmlEditor
80
+ toolbar={{ preset: "full" }}
81
+ features={gate.features}
82
+ plugins={[
83
+ createAiPlugin({ onGenerate: async (req) => callYourLlm(req) }),
84
+ createCommentsPlugin({ author: "Reviewer" }),
85
+ createWorkflowsPlugin({ actor: "Legal", role: "editor" })
86
+ ]}
87
+ />
88
+ ```
89
+
90
+ ## API
91
+
92
+ ### `RichHtmlEditor` props
93
+
94
+ | Prop | Type | Description |
95
+ | --- | --- | --- |
96
+ | `content` | `string` | Controlled HTML content. |
97
+ | `editable` | `boolean` | Enable editing (default `true`). |
98
+ | `dark` | `boolean` | Dark theme tokens. |
99
+ | `theme` | `EditorThemeTokens` | Custom CSS variable overrides. |
100
+ | `toolbar` | `ToolbarConfig \| ToolbarPresetId` | Toolbar preset or custom layout. |
101
+ | `features` | `EditorFeatureFlags` | Feature gates. |
102
+ | `plugins` | `EditorPlugin[]` | Enterprise and custom plugins. |
103
+ | `customToolIds` | `string[]` | Tool IDs to render with `renderTool`. |
104
+ | `renderTool` | `(tool, defaultRender) => ReactNode` | Custom React toolbar renderer. |
105
+ | `onChange` | `(content: EditorContent) => void` | Fired on document edits. |
106
+ | `onSave` | `(content: EditorContent) => void` | Fired on save command. |
107
+ | `className` | `string` | Wrapper class name. |
108
+ | `style` | `CSSProperties` | Wrapper inline styles. |
109
+
110
+ ### React vs Angular naming
111
+
112
+ | React | Angular |
113
+ | --- | --- |
114
+ | `<RichHtmlEditor />` | `<richhtmleditor>` |
115
+ | `onChange` | `(contentChange)` |
116
+ | `onSave` | `(save)` |
117
+ | `content` | `[content]` |
118
+
119
+ ## Related packages
120
+
121
+ - [`@richhtmleditor/core`](https://www.npmjs.com/package/@richhtmleditor/core) — framework-agnostic engine (auto-installed).
122
+ - [`@richhtmleditor/themes`](https://www.npmjs.com/package/@richhtmleditor/themes) — shared CSS.
123
+ - [`@richhtmleditor/angular`](https://www.npmjs.com/package/@richhtmleditor/angular) — Angular component.
124
+ - [`@richhtmleditor/vue`](https://www.npmjs.com/package/@richhtmleditor/vue) — Vue 3 component.
125
+ - [`@richhtmleditor/enterprise`](https://www.npmjs.com/package/@richhtmleditor/enterprise) — licence and feature gates.
126
+ - [`@richhtmleditor/ai`](https://www.npmjs.com/package/@richhtmleditor/ai) — AI authoring plugin.
127
+ - [`@richhtmleditor/comments`](https://www.npmjs.com/package/@richhtmleditor/comments) — review comments plugin.
128
+ - [`@richhtmleditor/workflows`](https://www.npmjs.com/package/@richhtmleditor/workflows) — approval workflows plugin.
129
+
130
+ ## License
131
+
132
+ [MIT](./LICENSE)
@@ -0,0 +1,11 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ import { type CreateEditorOptions, type ResolvedToolbarTool } from "@richhtmleditor/core";
3
+ export type RichHtmlEditorProps = Omit<CreateEditorOptions, "element" | "toolMounts"> & {
4
+ className?: string;
5
+ style?: CSSProperties;
6
+ /** Custom tool IDs to render with React (e.g. ["approve"]). */
7
+ customToolIds?: string[];
8
+ renderTool?: (tool: ResolvedToolbarTool, defaultRender: () => ReactNode) => ReactNode;
9
+ };
10
+ export declare function RichHtmlEditor({ className, style, content, editable, dark, theme, toolbar, features, plugins, customToolIds, renderTool, onChange, onSave }: RichHtmlEditorProps): import("react").JSX.Element;
11
+ //# sourceMappingURL=RichHtmlEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichHtmlEditor.d.ts","sourceRoot":"","sources":["../src/RichHtmlEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EAEzB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,YAAY,CAAC,GAAG;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,KAAK,SAAS,CAAC;CACvF,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACP,EAAE,mBAAmB,+BAiFrB"}
@@ -0,0 +1,77 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import { createEditor } from "@richhtmleditor/core";
5
+ export function RichHtmlEditor({ className, style, content, editable, dark, theme, toolbar, features, plugins, customToolIds, renderTool, onChange, onSave }) {
6
+ const mountRef = useRef(null);
7
+ const editorRef = useRef(null);
8
+ const contentRef = useRef(content);
9
+ const toolRootsRef = useRef(new Map());
10
+ useEffect(() => {
11
+ contentRef.current = content;
12
+ }, [content]);
13
+ const toolMounts = useMemo(() => {
14
+ if (!renderTool || !customToolIds?.length) {
15
+ return undefined;
16
+ }
17
+ const mounts = {};
18
+ for (const id of customToolIds) {
19
+ mounts[id] = (container, editor, api) => {
20
+ const root = createRoot(container);
21
+ toolRootsRef.current.set(id, root);
22
+ const tool = {
23
+ id,
24
+ type: "custom",
25
+ display: "both",
26
+ enabled: true,
27
+ active: false,
28
+ visible: true,
29
+ onClick: () => { }
30
+ };
31
+ root.render(_jsx(_Fragment, { children: renderTool(tool, () => null) }));
32
+ return () => {
33
+ root.unmount();
34
+ toolRootsRef.current.delete(id);
35
+ };
36
+ };
37
+ }
38
+ return mounts;
39
+ }, [renderTool, customToolIds]);
40
+ useEffect(() => {
41
+ const mount = mountRef.current;
42
+ if (!mount) {
43
+ return;
44
+ }
45
+ const editor = createEditor({
46
+ element: mount,
47
+ content: contentRef.current,
48
+ editable,
49
+ dark,
50
+ theme,
51
+ toolbar,
52
+ features,
53
+ plugins,
54
+ toolMounts,
55
+ onChange,
56
+ onSave
57
+ });
58
+ editorRef.current = editor;
59
+ return () => {
60
+ toolRootsRef.current.forEach((root) => root.unmount());
61
+ toolRootsRef.current.clear();
62
+ editor.destroy();
63
+ editorRef.current = null;
64
+ };
65
+ }, [dark, editable, features, onChange, onSave, plugins, theme, toolbar, toolMounts]);
66
+ useEffect(() => {
67
+ const editor = editorRef.current;
68
+ if (!editor || content === undefined) {
69
+ return;
70
+ }
71
+ if (editor.getHTML() !== content) {
72
+ editor.setContent(content);
73
+ }
74
+ }, [content]);
75
+ return _jsx("div", { className: className, style: style, ref: mountRef });
76
+ }
77
+ //# sourceMappingURL=RichHtmlEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichHtmlEditor.js","sourceRoot":"","sources":["../src/RichHtmlEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAsC,MAAM,OAAO,CAAC;AACvF,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,YAAY,EAKb,MAAM,sBAAsB,CAAC;AAU9B,MAAM,UAAU,cAAc,CAAC,EAC7B,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,IAAI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CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC;YACjC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAI,CAAC;AACpE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RichHtmlEditor, type RichHtmlEditorProps } from "./RichHtmlEditor.js";
2
+ export * from "@richhtmleditor/core";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,cAAc,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { RichHtmlEditor } from "./RichHtmlEditor.js";
2
+ export * from "@richhtmleditor/core";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAC/E,cAAc,sBAAsB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@richhtmleditor/react",
3
+ "version": "1.0.0",
4
+ "description": "React wrapper for Rich HTML Editor.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "prepack": "node ../../scripts/assert-pack-ready.mjs"
22
+ },
23
+ "dependencies": {
24
+ "@richhtmleditor/core": "^1.0.0"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "^18.0.0 || ^19.0.0",
28
+ "react-dom": "^18.0.0 || ^19.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^19.0.0",
32
+ "@types/react-dom": "^19.0.0"
33
+ },
34
+ "keywords": [
35
+ "richhtmleditor",
36
+ "react",
37
+ "rich-text-editor",
38
+ "wysiwyg"
39
+ ],
40
+ "license": "MIT",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
46
+ }
47
+ }