Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Rich editor

A Tiptap editor with a slash menu, an image toolbar and a Markdown bridge.

Installation

pnpm add @heyramzi/ui

Usage

import { RichEditor } from "@heyramzi/ui/editor";
<RichEditor content={doc} onContentChange={(json) => (doc = json)} minHeight="14rem" />

Keyboard and accessibility

Key Does
/ At the start of a line or after a space, opens the command menu.
Arrow Down Arrow Up In the command menu, moves the highlight.
Enter In the command menu, runs the highlighted command.
Esc Closes the command menu, or the image toolbar with focus back in the text.
Arrow Right Arrow Left In a toolbar, moves to the next or previous button, wrapping at the ends.
Home End In a toolbar, moves to the first or last button.
Cmd B Bold.
Cmd I Italic.
Cmd U Underline.
Cmd Shift S Strikethrough.
Cmd E Inline code.
Cmd Alt 1 Cmd Alt 2 Cmd Alt 3 Cmd Alt 4 Heading 1 to 4. The notes preset stops at 3.
Cmd Alt 0 Back to a paragraph.
Cmd Shift B Quote.
Cmd Shift 8 Bullet list.
Cmd Shift 7 Numbered list.
Cmd Shift 9 Checklist, in the full preset.
Cmd Alt C Code block.
Shift Enter Cmd Enter Line break inside the paragraph.
Cmd K Opens the link field, or removes the link under the cursor. Not in the page variant, which has no toolbar.
Alt Shift Arrow Up Alt Shift Arrow Down Moves the block holding the cursor up or down, the same block the drag handle moves. A whole list or table moves as one.
Tab Shift Tab Indents or outdents a list item. In a table, moves to the next or previous cell, and Tab in the last cell adds a row.
Cmd Z Undo.
Cmd Shift Z Cmd Y Redo.
  • Cmd is Ctrl on Windows and Linux.
  • The writing area is named by label, "Text editor" by default.
  • In the link field, Enter applies the link and Esc cancels and returns focus to the text.
  • The toolbar is one Tab stop named Formatting, and Shift+Tab from the text comes back to the button you left. Tab leaves it.
  • H1 to H3 are one pick: radio buttons, the current heading checked. The other buttons report pressed.
  • Each toolbar button shows its name and shortcut in a tooltip on hover or keyboard focus.
  • Focus stays in the text while the command menu is open. The text points at the highlighted command, so a screen reader reads it as it moves.
  • The link field's Cancel button is named Cancel link.
  • Arrowing onto an image selects it and opens its toolbar while focus stays in the text. Tab moves into the toolbar, one Tab stop named Image: the arrows move between Align left, Align center, Align right and Delete image, and Esc closes it and returns to the text.
  • Checklist boxes are named by their line.
  • The Image and YouTube commands open a dialog that asks for the link, with focus in the field. Enter inserts and Esc cancels, and either way focus goes back to the text.
  • A link the dialog can't use shows its error under the field, read out as an alert, and focus stays in the field.

API reference

content Record<string, unknown> | null
Default null
onContentChange (json: Record<string, unknown>) => void
placeholder string
Default "Start writing..."
minHeight string
Default "28rem"
preset "full" | "notes"
Default "full"
blockIds boolean
Default false
variant "box" | "page"
Default "box"
`box` is the framed editor with a toolbar. `page` is a document: no frame, no toolbar, type set by `.doc-surface` (see doc-page.css), heading anchors on.
copyLinkLabel string
Default "Copy link"
The word on a heading's hover button, for `page`.
onCopyLink (url: string, id: string) => void
A heading's link was copied.
instance bindable Editor | null
Default null
The live editor, for a host that needs focus or the document.
label string
Default "Text editor"
The editable region's accessible name.
Prop Type Default
content Record<string, unknown> | null null
onContentChange (json: Record<string, unknown>) => void
placeholder string "Start writing..."
minHeight string "28rem"
preset "full" | "notes" "full"
blockIds boolean false
variant

`box` is the framed editor with a toolbar. `page` is a document: no frame, no toolbar, type set by `.doc-surface` (see doc-page.css), heading anchors on.

"box" | "page" "box"
copyLinkLabel

The word on a heading's hover button, for `page`.

string "Copy link"
onCopyLink

A heading's link was copied.

(url: string, id: string) => void
instance bindable

The live editor, for a host that needs focus or the document.

Editor | null null
label

The editable region's accessible name.

string "Text editor"