Skip to content
Nana UI

Editor

A full-featured rich text editor built on Lit. It uses a contenteditable surface backed by a plain-JSON document model with snapshot-based undo/redo, HTML round-trip serialization, and Markdown export.

beta since v0.0.14

Type / at the start of an empty line to open the slash-command menu, or use the toolbar for formatting, links, images, tables, and lists.

PropertyTypeDefaultDescription
placeholderstringStart writing…Placeholder when empty
valuestringInitial HTML content
readonlybooleanfalseDisable editing
minHeightstringCSS min-height for the editing area
showWordCountbooleanfalseShow the status bar
MethodReturnsDescription
load(content)voidLoad an EditorDocument or JSON string
getContent()EditorDocumentThe current document
getJSON()stringPretty-printed JSON
getHTML()stringSerialized HTML
getMarkdown()stringMarkdown export
clear()voidReset to an empty document
EventDetailDescription
nana-change{ json, html, markdown, wordCount, charCount, readTime }Fired on every document change
ShortcutAction
Ctrl/⌘ B / I / UBold / Italic / Underline
Ctrl/⌘ KInsert link
Ctrl/⌘ Z / Shift ZUndo / Redo
Ctrl/⌘ Shift S / X / ,Strikethrough / Superscript / Subscript
/Open the slash-command menu
PartDescription
contentThe contenteditable editing surface

The toolbar (<nana-editor-toolbar>) renders command buttons in groups — history, format, color, insert, list, and align — plus submenus for color, link, and image actions. It is registered automatically with the editor.

import "@nana-tec/ui-components/editor";

The subpath also re-exports the model layer for programmatic use:

import {
RichEditor,
serializeToJSON,
serializeToHTML,
serializeToMarkdown,
blocksToHTML,
parseHTMLtoBlocks,
} from "@nana-tec/ui-components/editor";
Explore Editor interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook