JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1299
  • Score
    100M100P100Q100789F
  • License MIT

Framework-neutral rich text editor engine, command registry, and toolbar system.

Package Exports

  • @richhtmleditor/core

Readme

@richhtmleditor/core

Framework-neutral rich text editor engine — command registry, configurable toolbar, document model, tables, outline panel, TOC auto-sync, selection mini-toolbar, export for preview/DOCX, and a plugins API for enterprise extensions.

Current release: 1.2.9 (v1.2.9 coordinated release)

Repository: github.com/rajkishorsahu89/richhtmleditor

Demo: richhtmleditor.stackkitlabs.comdemo · guide · API. Doc Preview joint demo: doc-preview-app.vercel.app/demo/enterprise

What's new in 1.2.9

  • User-defined templatesallowUserTemplates: true in createTemplatesPlugin; users save current content as named templates stored in localStorage (max 20)
  • Save as Template toolbar buttonsaveAsTemplate tool added to standard/full presets; name + category dialog, max-limit guard
  • My Templates tab — two-tab template modal (All / My Templates); "Mine" badge, hover-reveal delete button with custom confirmation dialog
  • Export / Import JSON — download user templates as my-templates.json; import from file with duplicate-skip merge
  • Category filter chips — filter chips shown below search bar when templates span 3+ categories
  • Append vs Replace — template modal footer now has Append and Replace buttons
  • Custom toast notifications — all native alert()/confirm() replaced with styled in-app toasts (success / error / info, 2.8 s auto-dismiss) and custom modal dialogs

What's new in 1.2.8

  • Embed toolbar button fixinsertEmbed icon now correctly opens the embed modal (was silently broken; slash-menu path was unaffected)
  • Toolbar redesign — undo/redo moved to first position in all presets; standard preset reorganised into 3 logical rows (history + text / insert + blocks / panels); full preset into 4 rows
  • SEO — per-page canonical, description, og:url, og:image, Twitter Card, JSON-LD structured data; robots.txt and sitemap.xml at root
  • UI design — nav active underline indicator, button polish (font-size, radius, weight), install card hover effects, animated link arrows, table alternating rows
  • Support contactsupport@richhtmleditor.com in footer; enterprise enquiries → enquiry@stackkitlabs.com

What's new in 1.2.7

  • Smart typography — 20+ conversions — arrows (-> → →, => → ⇒), guillemets (<< → «, >> → »), plus-minus (+- → ±), en dash (- → –), math (~= → ≈, /= → ≠), symbols ((c) → ©, (r) → ®, (tm) → ™, (deg) → °, (p) → ¶, (s) → §, (/) → ✓, (x) → ✗), fractions (1/2 → ½, 1/4 → ¼, 3/4 → ¾, etc.), heart (<3 → ♥)
  • Smart Typography tab in Help modal? shortcut opens a grouped reference table of all conversions
  • 21 new shapes — Basic (right triangle, octagon, trapezoid, parallelogram, cross, heart, cloud, cylinder), Arrows (diagonal, curved, circular), Flowchart (connector, manual input, delay, preparation), Stars (8-point, burst, shield), new Symbols category (check ✓, cross ✗, info ℹ, warning ⚠, lock)
  • Mobile shape picker — bottom-sheet layout on viewports < 600 px with labelled tabs

What's in 1.2.0

  • createEditor — mount a full WYSIWYG host with toolbar, content area, and command registry
  • Toolbar presetsminimal, standard, and full via TOOLBAR_PRESETS and ToolbarConfig
  • Tables — insert, merge/split cells, row/column ops, header rows, captions, cell styles, and column sort
  • Callout blocksinsertCallout(variant) — info, warning, success, error with colored icon, border, and background; DOCX + PDF export
  • Embed blocks — paste YouTube/Loom/Figma URL to auto-embed <iframe>; insertEmbed toolbar button opens modal dialog
  • Word goalsetWordGoal(n) shows progress bar in status bar; status bar also shows ~N min read
  • Dark mode toggletoggleDarkMode command; flips .de-root--dark class without external state
  • Markdown shortcuts**bold**, _italic_, `code`, ~~strike~~ on closing delimiter
  • Markdown importimportMarkdown command opens .md file picker and converts to editor blocks
  • Case changecaseChange(type) — UPPERCASE, lowercase, Title Case, Sentence case
  • Smart typography — 20+ auto-conversions: curly quotes, dashes, ellipsis, arrows, fractions, symbols, guillemets, math operators (see v1.2.1 for full list)
  • Autolink — URLs auto-convert to <a href> on Space/Enter
  • Preview modalpreviewDocument command; inline split-pane HTML preview
  • Inline CSS exportinlineCSSExport copies document HTML with all styles inlined
  • Link checker panellinkCheckerPanel scans links, shows HTTP status
  • Visual blocks toggletoggleVisualBlocks shows marks and block outlines
  • Autoresizeautoresize: true option; editor height grows with content
  • Task lists — checkbox list items with attrs.checked; click to toggle
  • XLSX / CSV paste — paste spreadsheet data outside a table → new table block
  • Menu barmountMenuBar in engine/menu-bar.ts; File / Edit / Insert / Format / View dropdowns
  • Mobile touchtouchend mini-toolbar and 40 px touch targets on pointer: coarse
  • Outline paneltoggleOutline command; caret-synced heading navigation
  • TOC auto-syncinsertTableOfContents, syncTableOfContents; heading ids stay in sync on edit; TOC links scroll to block
  • Undo history panelundoHistoryPanel sidebar; click any entry to restore that state
  • Selection mini-toolbar — floating format bar on text selection (bold, link, colors, and more)
  • ExportexportForPreview, exportHtmlToDocx, serializeToPublicHTML for clean publish HTML
  • DOCX importimportDocx command; hyperlinks, row spans, image dimensions, page breaks, cell padding, column widths, table style fills, and paragraph spacing all preserved
  • DOCX export round-tripw:tblGrid, w:tcW, w:tcMar, w:tcBorders, w:shd (rgb-safe), and w:vMerge continuation cells generated from document state
  • Plugins APIEditorPlugin with tools and attach lifecycle hooks
  • Slash commands — type / to insert headings, lists, blockquote, code block, table, divider, task list, footnote, or date
  • Block reorder — drag-and-drop grip handles and Alt+Arrow keyboard shortcuts
  • Auto-save — opt-in localStorage draft persistence with configurable key and 7-day expiry
  • Paste special — modal with options to strip formatting, styles, or images before pasting
  • Track changes panel — sidebar review panel with per-hunk accept/reject
  • Emoji picker — categorized grid with search and inline insertion
  • Special characters — symbol picker with categorized grids and quick search
  • Format painter — copy and apply formatting across selections
  • Footnotes, bookmarks, cross-references — structured document references
  • Columns layout — 2-column and 3-column content sections
  • Video embed — inline video player with URL or upload
  • Word count, focus mode, print preview — productivity tools

Ships as ESM with TypeScript declarations. Import @richhtmleditor/themes CSS for toolbar and content chrome.

Keywords: richhtmleditor wysiwyg rich-text-editor toolbar tables toc typescript

Install

npm install @richhtmleditor/core @richhtmleditor/themes

Usage — quick start

import { createEditor } from "@richhtmleditor/core";
import "@richhtmleditor/themes/richhtmleditor.css";

const editor = createEditor({
  element: document.getElementById("editor")!,
  content: "<p>Hello <strong>world</strong></p>",
  toolbar: { preset: "standard" },
  features: { tables: true, media: true },
  onChange: (content) => console.log(content.html)
});

editor.commands.bold();
editor.commands.insertTable(3, 4);

Usage — toolbar configuration

import { createEditor, filterToolbarPreset, registerToolbarTool } from "@richhtmleditor/core";

registerToolbarTool({
  id: "mySave",
  type: "button",
  label: "Save",
  icon: "save",
  onClick: (ed) => fetch("/api/save", { method: "POST", body: ed.getHTML() })
});

// Option A — filterToolbarPreset() then pass layout
createEditor({
  element: el,
  toolbar: {
    layout: filterToolbarPreset("standard", {
      include: ["bold", "italic", "link", "undo", "redo", "mySave"]
    }),
    tools: { mySave: { display: "both" } }
  }
});

// Option B — include / exclude on preset (no layout)
createEditor({
  element: el,
  toolbar: {
    preset: "standard",
    exclude: ["insertImage", "find", "replace"]
  }
});

When layout is set it replaces the preset (include / exclude are ignored). Use tools[id].visible: false to hide tools without changing layout.

Usage — plugins

import { createEditor, type EditorPlugin } from "@richhtmleditor/core";

const myPlugin: EditorPlugin = {
  id: "my-plugin",
  tools: [
    {
      id: "approve",
      type: "button",
      label: "Approve",
      onClick: (editor) => editor.emit("approved")
    }
  ],
  attach: (editor) => {
    const off = editor.on("change", () => { /* sync */ });
    return () => off();
  }
};

createEditor({ element: el, plugins: [myPlugin] });

Usage — export for preview

const result = editor.exportForPreview({
  workflowState: "approved",
  includePrintCss: true,
  commentsHtml: "<aside>…</aside>"
});

// result.fullHtml — standalone HTML for iframe or @doc-preview
// result.watermarkText — workflow watermark when applicable

API

createEditor(options)

Option Type Description
element HTMLElement Required. Host element for the editor chrome.
content string Initial HTML.
editable boolean Enable editing (default true).
dark boolean Apply dark theme tokens.
theme EditorThemeTokens CSS variable overrides (primary, toolbarBg, …).
toolbar ToolbarConfig | ToolbarPresetId Preset or custom layout.
features EditorFeatureFlags Gate tables, media, AI, comments, workflows, toolbarFull.
plugins EditorPlugin[] Enterprise and custom plugins.
onChange (content: EditorContent) => void Fired on document edits.
onSave (content: EditorContent) => void Fired on save command.
autoSave boolean | string Enable localStorage auto-save; pass a string key to namespace drafts.
onUploadImage (file: File) => Promise<string> Resolve image uploads to a URL.

EditorInstance

Member Description
commands All formatting and authoring commands (bold, insertTable, syncTableOfContents, …).
getHTML() / getJSON() Serialize document as HTML or JSON model.
setContent(html, options?) Replace content; { silent: true } skips change callbacks.
exportForPreview(options?) Publish-ready HTML with workflow watermark/stamp.
setToolbar(config) Hot-swap toolbar layout at runtime.
registerTool(tool) Add a toolbar tool after mount.
on(event, handler) Subscribe to change, save, focus, blur, and plugin events.
destroy() Tear down DOM, listeners, and plugin cleanups.

Toolbar presets

Preset Description
minimal Bold, italic, underline, undo/redo.
standard Full authoring toolbar with lists, links, images, tables, find/replace.
full Enterprise layout — TOC, outline, track changes, AI/comments slots, table ops.

License

MIT