Content blocks
Rich text
Renders a `RichText` value inline: marks, links, inline code, colors, emoji and mentions. Every text block uses it; use it directly inside your own components.
Mixed bold italic, a link, x^2, and πDocs π
Rich text utilities
Offset-based helpers used by the editor, exported for your own tooling:
splitRichText(value, offset)β[before, after]deleteRange(value, from, to)removes charactersapplyMarks(value, from, to, patch)sets marks (undefinedremoves)hasMark(value, from, to, mark)is true when the whole range has the marknormalizeRichText(value)merges equal adjacent runs and drops empty onesrichTextToHtml(value)/parseRichTextDom(el)round-trip through contenteditable HTML (data-mholds marks)MentionTokenrenders one mention;inlineCodeClassis the inline code chip class
Usage
- Use
RichTextViewto render aRichTextvalue (marks, colors, links, mentions, inline equations) inside any block or custom UI. - Store text as
RichTextsegments rather than HTML so blocks and the editor can share it. - Donβt use it for long-form documents on its own; use
BlockRendererfor aBlock[]tree.
Installation
Install the package (React 19):
terminal
terminal
terminal
Import the styles once, in your app entry or root layout:
/src/main.tsx
Use it anywhere inside your app's <Theme> (see Installation):
/src/RichtextExample.tsx
API Reference
MentionToken
One non-editable mention, as RichTextView renders a span with mention: a page (icon + underlined title), a person (@Name) or a date (@Date). Carries data-mention so parseRichTextDom reads it back.
| Prop | Type | Default |
|---|---|---|
mention | Mention |
RichTextView
| Prop | Type | Default |
|---|---|---|
value | RichText |
TextSpan
One run of RichText.
| Prop | Type | Default |
|---|---|---|
text | string | |
marks | TextMarks | |
mention | Mention |
Accessibility
- Output is inline spans and
<a>links, so it inherits the surrounding semantics. - Emoji are wrapped in an emoji-font span; they are read by their Unicode names.
Β© 2026 Motion. Internal documentation.