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

Inline editor

A single-block text editor with marks and lists, driven by a toolbar.

Installation

pnpm add @heyramzi/ui

Usage

import InlineEditor, {
  type InlineDoc,
  type InlineEditorApi,
} from "@heyramzi/ui/editor/inline-editor";
<InlineEditor
  {doc}
  placeholder="Write a note"
  onDocChange={(next) => (doc = next)}
  onExit={() => api?.focus()}
  onReady={(editor) => (api = editor)}
/>

Keyboard and accessibility

Key Does
Cmd B Bold.
Cmd I Italic.
Cmd Shift X Cmd Shift S Strikethrough.
Cmd E Inline code.
Cmd Shift 8 Bullet list.
Cmd Shift 7 Numbered list.
Cmd K Asks the host for a link, through onLink.
Cmd Z Undo.
Cmd Shift Z Cmd Y Redo.
Enter In a list, starts a new item.
Shift Tab In a list, lifts the item out. From a plain paragraph, leaves the field.
Tab Does nothing, so lists stay flat.
Esc Calls onExit. The host decides where focus goes.
  • Cmd is Ctrl on Windows and Linux.
  • The field is a multi-line text box named by label, "Text editor" by default.
  • With inline set, the list keys are off and only the marks work.
  • The page's shortcuts don't hear what you type in the field, except Cmd+S.
  • Typing [ ] and a space starts a checklist, and every box is a real checkbox named by its line, like "Task item checkbox for Buy milk".

API reference

doc required InlineDoc
placeholder string
Default ""
class string
Default ""
inline boolean
Default false
Marks only: bold, italic, strike, code and link. No lists, so a table cell stays a line of words.
at { x: number; y: number }
Where the click landed, so the caret opens there. Without it the caret goes to the end.
selectAll boolean
Default false
Opens with all the text selected, so the first key replaces it.
seed string
Opens with the text replaced by these characters and the caret after them.
onDocChange required (doc: InlineDoc) => void
onExit required () => void
onLink () => void
onState () => void
onReady (api: InlineEditorApi) => void
label string
Default "Text editor"
The editable region's accessible name.
Prop Type Default
doc required InlineDoc
placeholder string ""
class string ""
inline

Marks only: bold, italic, strike, code and link. No lists, so a table cell stays a line of words.

boolean false
at

Where the click landed, so the caret opens there. Without it the caret goes to the end.

{ x: number; y: number }
selectAll

Opens with all the text selected, so the first key replaces it.

boolean false
seed

Opens with the text replaced by these characters and the caret after them.

string
onDocChange required (doc: InlineDoc) => void
onExit required () => void
onLink () => void
onState () => void
onReady (api: InlineEditorApi) => void
label

The editable region's accessible name.

string "Text editor"