@richhtmleditor/ai
v1.1.2
Published
AI authoring toolbar plugin for Rich HTML Editor (enterprise).
Downloads
467
Maintainers
Readme
@richhtmleditor/ai
AI authoring toolbar plugin for Rich HTML Editor (enterprise). Adds an AI dropdown with improve, shorten, expand, summarize, tone, grammar, and policy-check actions — requires features.ai from @richhtmleditor/enterprise, built on @richhtmleditor/core.
Current release: 1.1.2 — Depends on @richhtmleditor/core ^1.1.2.
Repository: github.com/rajkishorsahu89/richhtmleditor
Demo: richhtmleditor.vercel.app — demo · guide · API. Doc Preview joint demo: doc-preview-app.vercel.app/demo/enterprise
What's in 1.1.2
createAiPlugin— registers an AI dropdown toolbar tool- Actions — improve, shorten, expand, fix-grammar, summarize, tone-formal, tone-plain, policy-check
onGeneratehook — wire your LLM provider; falls back to local demo transforms when omitted- Selection-aware — replaces selected text or appends a new paragraph when nothing is selected
- Policy check — validates mandatory language (
shall/must) on the current selection
Requires
features.ai: truefrom a valid enterprise licence. Demo key:RHE-ENT-DEMO-2026-FULL.
Keywords: richhtmleditor ai enterprise authoring llm wysiwyg
Install
npm install @richhtmleditor/ai @richhtmleditor/enterprise
# Requires @richhtmleditor/core (via framework wrapper or direct install).Usage — with your LLM
import { createEditor } from "@richhtmleditor/core";
import { createAiPlugin } from "@richhtmleditor/ai";
import { resolveEnterpriseFeatures } from "@richhtmleditor/enterprise/browser";
const gate = resolveEnterpriseFeatures({ token: "RHE-ENT-DEMO-2026-FULL" });
const editor = createEditor({
element: host,
toolbar: { preset: "full" },
features: gate.features,
plugins: [
createAiPlugin({
onGenerate: async ({ action, selectionText, documentHtml }) => {
const res = await fetch("/api/ai", {
method: "POST",
body: JSON.stringify({ action, selectionText, documentHtml })
});
return res.text();
}
})
]
});Usage — demo mode (no backend)
import { createAiPlugin } from "@richhtmleditor/ai";
createEditor({
element: host,
features: { ai: true, toolbarFull: true },
toolbar: { preset: "full" },
plugins: [createAiPlugin()]
});When onGenerate is omitted, local demo transforms are applied (e.g. shorten halves word count, improve prefixes "Improved:").
API
createAiPlugin(options?)
| Option | Type | Description |
| --- | --- | --- |
| onGenerate | (request: AiGenerateRequest) => Promise<string \| null \| undefined> | Wire your LLM; receives action, selection, and full document HTML. |
AiGenerateRequest
| Field | Type | Description |
| --- | --- | --- |
| action | AiAction | Requested AI operation. |
| selectionText | string | Current text selection (may be empty). |
| documentHtml | string | Full editor HTML for context. |
AiAction values
| Action | Description |
| --- | --- |
| improve | Improve writing quality. |
| shorten | Condense selected text. |
| expand | Add detail and clarity. |
| fix-grammar | Basic grammar cleanup. |
| summarize | Summarize the selection. |
| tone-formal | Rewrite in formal tone. |
| tone-plain | Rewrite in plain language. |
| policy-check | Compliance check for mandatory language (selection required). |
Related packages
@richhtmleditor/core— editor engine and plugins API.@richhtmleditor/enterprise— licence gating forfeatures.ai.@richhtmleditor/comments— review comments plugin.@richhtmleditor/workflows— approval workflows plugin.@richhtmleditor/angular— Angular wrapper.@richhtmleditor/react— React wrapper.
