Document content
Links
The link Tool: the "Link" button on the Toolbar and Ctrl/⌘+K open a popover with a URL field next to the selected text.
- Enter (or "Apply") turns the selection into a link and returns focus to the Document. Without a selection the URL is inserted as the link text. With the caret in an existing link, the field shows its URL, Enter changes it for the whole link text, and the "Remove link" button removes the link and leaves the text. An empty field plus Enter is the same removal.
- Escape cancels and returns focus to the Document, to the previous selection. Inside
DialogandDrawer, Escape closes only the popover: the kit'sPopover, dialogs and drawers are one Radix layer stack ([ADR-0041 (ADR-0041)). A click elsewhere closes the popover, and focus stays where you clicked. - By default the URL field accepts absolute
http:,https:andmailto:addresses. It turnsexample.comintohttps://example.comandteam@example.comintomailto:team@example.com. - Set
allowRelativeLinksfor documents that need links such as./spec.md,../GLOSSARY.md,/docs/spec.md,README.mdor#part. The Editor reads this setting at mount. Remount it to switch policies. The popover keeps a scheme-less address as entered, so use an explicit scheme for a website or email address. Relative destinations use the displaying page's base URL. Supply destination IDs on that page for named fragments. - Both settings reject other schemes, protocol-relative addresses (
//host), backslashes, control characters and malformed percent escapes, including obfuscated forms. A rejected input shows an error under the field. Use the sameallowRelativeLinkssetting when sanitizing the Document on the server. - Autolink while typing: a URL in the text (
example.com,https://…, an email address) becomes a link when you type a space after the word. Pasting a URL over a selection turns the selection into a link. Both paths go through the same protocol check. A URL in pasted text becomes a link too, withhttps://when it has no scheme, as while typing. A pasted link keeps its own address even when its text looks like another address:<a href="https://example.com/docs?page=1#top">example.com/docs</a>from Word or a web page stays a link to the full address. - In the Editor a link does not open on click — a click puts the caret, as in any text.
RichTextViewand areadOnlyfield open links like ordinary<a>elements. - On output every link is
<a href="…" rel="noopener noreferrer">.target,class,titleandrelfrom incoming HTML are dropped: whether a link opens in a new tab is for the page that shows the Document to decide, not the data.
Code block
The codeBlock Tool: the "Code block" checkbox item of the "…" menu and a Slash menu item, Ctrl/⌘+Alt+C and a ``` fence at the start of a line. A Block has a language and syntax highlighting — the decision of ADR-0051: lowlight with highlight.js grammars, only in the @olddevs/ui/editor entry point (the kit's CodeView still does not highlight code, ADR-0039).
The Schema lists the canonical names in RICH_TEXT_SCHEMA.codeLanguages.
A language is saved as a class on <code>, for example
<pre><code class="language-python">…</code></pre>. The Editor displays the tokens
as decorations. getHTML() returns the code text and its language class.
| Language | Canonical name | Aliases |
|---|---|---|
| Python | python | py |
| TypeScript | typescript | ts, tsx |
| JavaScript | javascript | js, jsx |
| Go | go | golang |
| HTML | html | htm |
| JSON | json | |
| YAML | yaml | yml |
| Markdown | markdown | md |
| Bash | bash | sh, shell, zsh, shellscript |
| SQL | sql | |
| Dockerfile | dockerfile | docker |
| TOML / INI | toml | ini |
| Diff | diff | patch |
| CSS | css |
- Aliases resolve to the canonical name when the Editor loads or pastes HTML, parses Markdown, or opens a typed fence. Names are case-insensitive. Typing
```pyfollowed by a space opens a Python Block. TOML and INI share the same grammar. The Editor treatsjsoncandjson5as plain text. - An unknown language (
```rust,class="language-rust") becomes plain text: the Block stays, the class does not. - Plain text is not highlighted, even if it looks like code: the language is not guessed either in the Editor or on the server, so the same Block looks the same when edited and when displayed.
- Markdown: a fence with a language ↔ a Block with a language;
getMarkdown()writes the name (```python), not the alias the Block arrived with.
The Block header. Above the code there is a thin strip (about 28 px) with a bottom line in the divider token: the language on the left, "Copy" on the right. Both parts are always visible — on desktop and on touch screens, without hover. The code starts right under the strip with the Block's usual padding, and the buttons do not cover it: a long first line can be scrolled through in full. The strip is a service element of the Block's interface, not content: it has contenteditable="false" and select-none, the caret does not enter it, it is not part of the selection or of a copy of the Document, and it is absent from getHTML(). The same strip appears on the Blocks in RichTextView.
Choosing the language. On the left of the header is a button with the current language and a chevron ("Python", "Plain text"). It opens the kit's Menu with a list of languages — a radio group with the current one checked; choosing a language changes it in one undo step (Ctrl/⌘+Z brings the previous one back, the code is untouched) and returns focus to the code at the previous caret position. The button's name is "Language: Python" (in the Russian locale, "Язык: Python"; messages.editor.codeLanguage), and the menu is named the same. The menu is a kit overlay built on react-aria-components and takes part in the layer stack (ADR-0041): inside a Dialog, Escape closes the menu, not the dialog. In readOnly and disabled a label with the language replaces the button: there is nothing to change, but knowing which language the code is in is still useful. A Block without a language has no label in these modes — the "Plain text" string comes from the message catalog and is used by the menu button; RichTextView, which has no message catalog, behaves the same way.
Copying. On the right of the header is the kit's CopyButton (an icon, no label) with the tooltip "Copy code" (in the Russian locale, "Копировать код"; messages.editor.codeCopy), which for two seconds after a press changes to "Copied" (in the Russian locale, "Скопировано"). The button's name and the announcement of the result in the live region are the standard CopyButton ones: "Copy" → "Copied" (in the Russian locale, "Копировать" → "Скопировано"; messages.copyButton); the code block has no name of its own. What goes to the clipboard is the Block's text as a string (node.textContent): as typed, without highlight tokens (they are decorations) and without markup. This is the rule of ADR-0039: a string is copied, not the DOM. The button is there in any mode — in readOnly and in disabled too: editing is not allowed, copying is. If the clipboard refuses (an insecure context, a denied permission), the button shows "Could not copy" (in the Russian locale, "Не удалось скопировать") and does not switch to the "copied" icon.
Keyboard. Both header buttons are outside the Tab order (tabindex="-1"): otherwise every code block would add two stops between the field and the next form element. You can get into the header with the same Alt+F10: with the caret in a code block it moves focus to the language button of that Block (as on a selected image it moves focus to the image's panel), not to the Toolbar. Navigating the header:
Alt+F10from the language button goes to "Copy", once more to the Toolbar; so the shortcut cycles through language → copy → Toolbar;- the Right Arrow key moves from the language button to "Copy", the Left Arrow key moves back;
- on the language button
Enter,Spaceor the Down Arrow key open the menu; the arrow keys,Home,Endand the first letter choose;Enterapplies,Escapecloses the menu; - on "Copy",
EnterorSpacecopies; Escapeon either button returns focus to the code, with the caret where it was.
The language button has aria-keyshortcuts="Alt+F10". In readOnly and disabled there is no caret, and Alt+F10 is unreachable from the Block, so there "Copy" is in the normal Tab order (in an editable Editor its tabindex is -1, in the other modes the standard one). Tab in a code block still takes focus out of the field: indents in code are written with spaces.
The highlight theme is made up of ready-made highlight.js themes: GitHub Light in the light theme, GitHub Dark in dark and dim. It has two parts. The colors are the --rte-hl-* and --rte-code-block-* variables in styles.css on elements with data-theme (and on :root without the attribute), so the code block takes the theme of the nearest ancestor with data-theme: a Document in a nested data-theme="light" inside a dark app gets GitHub Light, a dark area on a light page gets GitHub Dark. The .hljs-* rules are Tailwind classes on the Document container (src/editor/styles/codeTheme.ts, part of prose.ts); they read only the variables, so neither style nor separate CSS is needed: the rules come with @import "@olddevs/ui/styles.css" and the @source line from getting-started.md. The variables are declared with zero specificity (:where), so the consumer overrides any of them with their own rule. The code block takes the highlight theme's background and main color (#ffffff / #0d1117), not the kit's background: GitHub's colors hold the 4.5:1 contrast only on their own background. There is one departure from GitHub Light — built_in and symbol are darker (#953800 instead of #e36209: that one is 3.49:1 on white). This is a second color system in the kit, and it is used only in the Editor's code block; inline code still uses tokens.
Display. RichTextView does not highlight by itself — otherwise lowlight would ship with every display of a Document. Saved HTML is highlighted on the server by the highlightCodeBlocks(html) helper from @olddevs/ui/editor/highlight after sanitization — the order is on the RichTextView page.
Images
The image Tool (in full, not in basic): the "Image" button on the Toolbar, the "Image" item in the Slash menu (/img) and Markdown  on paste. An image is written into the Document as a Block:
<figure>
<img src="https://cdn.example.com/a.png" alt="Lake" data-width="50" />
<figcaption>Caption</figcaption>
</figure>An image the text wraps around carries data-align on the figure:
<figure data-align="left">
<img src="https://cdn.example.com/a.png" alt="Lake" data-width="33" />
</figure>- The image popover has a URL field and an alternative text field. The URL is entered as in a browser's address bar:
cdn.example.com/a.pngbecomeshttps://cdn.example.com/a.png. Only absolutehttpandhttpsURLs are accepted: the field does not acceptdata:,blob:,mailto:,javascript:or a relative URL — an error appears under it. Enter inserts the image in place of the empty paragraph under the caret (or next to the current Block), and the caret goes into the caption. Escape cancels. Inside aDialog, Escape closes only the popover (ADR-0041). - Alternative text is optional: an empty
alt=""means "decorative image", and the screen reader skips it. Thealtattribute is always written — without it the screen reader would read the file name from the URL. - The caption is a
figcaptionunder the image, with Marks and links. An empty caption is not written to HTML at all; in the field, an empty caption shows the placeholder "Caption (optional)". Enter on a selected image puts the caret into the caption, Enter in the caption starts a new paragraph under the image, and Backspace at the start of the caption selects the image. A heading, a list or a code block cannot be created in a caption: inside afigure, the Schema allows only the caption. - Width is one of five values: 25%, 33%, 50%, 75% or 100% of the width of its container (
data-width,RICH_TEXT_SCHEMA.imageWidths); without the attribute, the image's own size, but not wider than the Document. The image is centered unless it is aligned (below). With the mouse, there are handles on the sides of a selected image: the width changes smoothly, and on release it snaps to the nearest of the five values (one edit — one undo). From the keyboard, there are the toggle buttons "25%" to "100%" in the selected image's popover and on its panel; a pressed button is cleared by pressing it again. An image never hasstyle. - Image alignment (the term is in the glossary) puts the image at the left or right edge and lets the text of the next Blocks wrap around it, as in Word. There are three positions: Left and Right wrap the text, Center is the default, a line of its own. There is no alignment without wrapping: next to text there are Column layouts. It is part of the
imageTool, with no Option and no Tool of its own;data-align="left"or"right"goes on thefigure, and the centre is the absence of the attribute. It uses the same word as Block alignment, with one difference: for a paragraphleftis the default and is never written, for an imageleftmeans wrapping and is written. The toggles are on the selected image's panel (before the widths) and in the "Edit image" popover, witharia-pressed; the keys are described below.- Only narrower than the container. Text cannot wrap an image that is as wide as the Document, so an aligned image is 25%, 33%, 50% or 75%. Choosing Left or Right for an image at its own size or at 100% sets 50% in the same edit (one undo brings back both), and 100% on an aligned image puts it back in the centre. A Document that arrives with a side and no width, or with 100%, opens with 50%.
- What wraps. Paragraphs, lists and quotes flow around the image. A heading, a table, a code block, a divider, a centred image, a Column layout, a Wrapper, a Details Block, a video and the footnote list start below it, so a new section does not stick to the picture of the old one. An image on the left and an image on the right can stand side by side.
- A narrow Document does not wrap. From 30 rem (480 px) of the Document's own width the image floats; narrower (a Drawer, a small Dialog) there is no room for a column of text beside it, and the image stays on a line of its own, in the centre, at its own width. The Document root becomes a container for this, as it does for a Column layout. The width is a share of the image's container, so in a column of a Column layout, in a Wrapper or in the content of a Details Block the image is a share of that column or Wrapper, and the container holds it (a tall image at the end of a Wrapper does not hang out of the frame).
- Not in a table cell. The toggles are unavailable there and an aligned
figurethat arrives in a cell keeps its attribute in the Document, but the styles do not apply it: the image stays in the centre. - Handles. A centred image has two handles and grows to both sides (the edge follows the mouse at twice the shift). An aligned image has one handle, on the side of the text: it grows one pixel for one, and snaps to 25%, 33%, 50% or 75% (not to 100%).
- Keys.
Ctrl/⌘+Shift+L,+Eand+R, the alignment keys of thealignTool, align the image when it is selected as a whole (left, centre, right). With the caret in the caption or anywhere else they align the text as before. The image has the keys even without thealignTool. In the Keyboard shortcuts popover the rows keep the names "Align left", "Align center" and "Align right". - Appearance.
RichTextViewand the Editor draw the same float and the same gap (prose.ts, nostylein the Document). The theme, the Paper sheet and the tones of a Wrapper do not change the image or the wrapping. - Email. A mail client that does not know
float(Outlook for Windows) shows the aligned image on a line of its own; the text is not lost.
- A selected image (selected by clicking it or with the arrow keys) shows its own panel above it: the alignment toggles, the width options, "Edit image" (a popover with the URL and the alternative text) and "Remove image".
Alt+F10on a selected image moves focus to this panel, not to the formatting Toolbar; the floating Toolbar does not appear above an image. The Toolbar's "Image" button is pressed (aria-pressed) while an image is selected and opens this image's popover rather than inserting a new one.
Uploading files: onUploadImage
<RichTextEditor
value={html}
onChange={setHtml}
onUploadImage={async (file) => {
const body = new FormData();
body.set("file", file);
const response = await fetch("/api/uploads", { method: "POST", body });
if (!response.ok) throw new Error(String(response.status));
return (await response.json()).url; // an absolute https URL
}}
/>- With an upload handler (
onUploadImage) an image can be pasted from the clipboard (a screenshot, "Copy image" in the browser), dropped into the field as a file, or chosen with the "Upload from device" button in the popover. Several files are uploaded one by one and land in file order. - While the promise is pending, a placeholder "Uploading photo.png…" appears where the image will be (with a preview where the browser supports
blob:), and the Document has no image: not ingetHTML(), not inonChange, not in the form. The upload progress is announced by the Field notice's live region (role="status", see "Status bar and Field notice"). - On success the image takes the placeholder's place in one edit:
Ctrl/⌘+Zremoves exactly that image. On failure (the promise is rejected or the URL is outsidehttp/https, for exampledata:or a relative one), the placeholder disappears, the Document does not change, nothing is added to the edit history, and under the field there is arole="alert"line: "Couldn't upload photo.png. The document is unchanged." The next edit clears it. This is a Field notice: file messages go through the same channel asshowNotice, and a new one replaces the previous one. - Without an upload handler, files pasted from the clipboard or dropped into the field are not accepted: under the field there is a hint to insert the image by URL. "Copy image" from the browser still works — alongside the file the clipboard holds HTML with the image URL, and the image is inserted by URL if the protocol policy allows it (
http/https). - What is not uploaded. A non-image file (
notes.pdf) is rejected with a message. A paste from Word and from pages where the clipboard holds HTML with text next to the file goes through ordinary HTML parsing: Word also puts a snapshot of the selection as a picture on the clipboard, and uploading it would be a mistake. - The upload handler is read at the moment of insertion — it can be swapped on the fly. A form submitted during an upload goes out without the image not yet uploaded.
- There is no "image removed from the Document" signal (ADR-0058, section 13): editing, undo and cut-and-paste would give false positives, and Documents are also changed without going through the Editor. The server finds uploaded files that the Document no longer references — the recipe for comparing
srcon the server.
Color, highlight and alignment
color, highlight and align are part of preset="full", but not of basic. The palette is written into the Document by names, not by CSS values: <span data-color="danger">, <mark data-color="danger">, <p data-align="center">. There is no style attribute on load, on paste or in getHTML() — except for one narrow case, the author's color (see the "Custom color" section below). Alignment from an external style is not lost, though: it is converted to data-align (below). The theme (dark, light, dim) substitutes the concrete palette color, so saved text reads in any of them — in the Editor and in RichTextView alike: the classes are shared (prose.ts).
There are two palettes, and they share no names. Text color is six kit status tones; the highlight is nine colors: three bright ones (yellow, green, pink) and six muted Notion colors. Both are written into data-color, but on different tags: span[data-color] takes its name from the text palette, mark[data-color] from the highlight palette; a highlight name on a span is dropped (<span data-color="yellow"> together with the element), while the six earlier text-color names on a mark are read as the nearest highlight color (below).
Text color (span, the "Text color" grid of the "Color" popover). The strong step of the tone:
data-color name | Swatch (en / ru) | Text color |
|---|---|---|
accent | Accent / Акцентный | accent-strong |
success | Green / Зелёный | success-strong |
warning | Amber / Жёлтый | warning-strong |
danger | Red / Красный | danger-strong |
lime | Lime / Лаймовый | draft-strong |
muted | Gray / Серый | fg-2 |
Highlight (mark, the "Highlight" button and the "Highlight color" grid of the "Color" popover). Bright, like a real highlighter pen: the three bright colors are the same in all themes (dark, light, dim) and on the Paper (surface="paper"), and the text on the three bright highlights is always dark — the --marker-text token (#1a1a1a). The values are --marker-<name> tokens of the component layer (theming.md), substituted per theme by styles.css.
All nine are in the grid (the owner's decision), by hue, as in Notion: gray, brown, orange, yellow, green, blue, purple, pink, red. Previously the menu offered only the three bright ones, while the six muted Notion colors remained available: the Schema, sanitization and RichTextView accepted and rendered them, but they could not be chosen in the menu. They differ in text color on the highlight, not in support: all nine are accepted the same way:
Bright:
data-color name | Swatch (en / ru) | Token | All themes | Dark text contrast (--marker-text) |
|---|---|---|---|---|
yellow | Yellow / Жёлтый | --marker-yellow | #ffea80 | 14.4 |
green | Green / Зелёный | --marker-green | #aaff80 | 14.4 |
pink | Pink / Розовый | --marker-pink | #ff80bf | 7.5 |
Muted Notion colors (each theme has its own values; the text on them is the theme's main text, not dark):
data-color name | Name (en / ru) | Token | light | dark and dim | Main text contrast, worst of the themes |
|---|---|---|---|---|---|
blue | Blue / Синий | --marker-blue | #d3e5ef | #28456c | 8.93 |
gray | Gray / Серый | --marker-gray | #e3e2e0 | #5a5a5a | 6.33 |
brown | Brown / Коричневый | --marker-brown | #eee0da | #603b2c | 8.92 |
orange | Orange / Оранжевый | --marker-orange | #fadec9 | #854c1d | 6.32 |
purple | Purple / Фиолетовый | --marker-purple | #e8deee | #492f64 | 10.28 |
red | Red / Красный | --marker-red | #ffe2dd | #6e3630 | 8.63 |
The names yellow, green and pink are the same as before: saved Documents that use them become brighter on their own — the value belongs to the theme, not to the Document. The accessible name of the "Highlight" button includes the current color ("Highlight: Blue").
The swatch uses the same token; the color name on the swatch is for screen reader users (aria-label), and sighted users recognize the color by the swatch.
-
Contrast is checked in all themes (
npm run contrast, the pairs are generated fromsrc/editor/styles/palette.ts): text color holds 4.5:1 on all app backgrounds (the worst values areaccentanddanger, around 4.6); the dark--marker-texttext on each of the three bright highlights is at least 4.5:1 (7.5:1 on pink, 14.4:1 on yellow and green) indark,light,dimand the brand; the main textfg-0on the six muted ones also holds (the worst isorange, 6.32). The gate does not measure colored text over a highlight: the author chooses the combination. -
The highlight follows the nearest theme. The
--marker-*tokens are declared on[data-theme]of any element, not just on the root, and theprose.tsclasses read the variable itself (bg-(--marker-yellow)), without an@themebridge and without per-theme rules on descendants. A Document area in a nesteddata-theme="light"container inside a dark app gets the light values of the muted colors; the app around it gets its own. The three bright colors and the dark text do not depend on the theme. The other kit tokens (--fg-0, surfaces) are declared on:root[data-theme]and do not support a nested theme — the Paper (surface="paper") works around this with the--rte-*roles (see the "Surface" section). -
Old highlight names are converted. Before the Notion palette the highlight shared names with the text color. The
<mark data-color="accent">and five other names saved back then are read on load (value,defaultValue) and on paste as the nearest new color, andgetHTML()already returns the new name;RichTextViewrenders the old name in the same color. The conversion is based on the shade of the background, not on the meaning of the tone:Was ( mark)Now Why accentbluethe kit's accent is blue by default successgreenthe color of the same name warningyellowthe amber of warning-softis closer to yellow than to orangedangerredthe color of the same name limegreenthe lime background reads as green; yellow is taken by warning, and a "draft" must not become a warningmutedgraythe color of the same name A saved Document changes its look: the shades are now Notion-like rather than the
softsteps of the tones. You do not have to rewrite the names in the consumer's database — the Editor andRichTextViewread both spellings; on the serversanitizeRichTextconverts them (RichTextView). -
Text
accentis the app's accent color, not a fixed blue: after the accent or brand changes, it changes together with the rest of the interface. Thebluehighlight does not depend on the accent or brand. The other text names do not depend on the accent. -
Names outside their palette are dropped together with the element, and the text stays:
data-color="hotpink",data-color="#ff0000", a highlight name on aspan, a name in a different case (Yellow), and a highlight withoutdata-colororstyle(a bare<mark>is rendered yellow by the browser, and in a dark theme it glows over the Document). A color fromstyle="color: …"in a paste (Word, Google Docs) is not converted to the nearest palette color, andstyleis kept only in the strict form of the author's color — otherwise it is dropped: a conversion would guess on the author's behalf. A background in a paste from an office application is different: withpasteCleanupit becomes the marker of the nearest hue (see the "Paste from Office" section). A highlight is a meaning the author set on purpose, and the marker palette has a named color for it, while a text color in Office is more often the document's style than a meaning (ADR-0075). -
Code has no color. Inline code does not combine with color and highlight: the
codeMark excludes the others. -
Alignment is for a paragraph and H1–H4 headings (H1 with
heading1; including a paragraph inside a list or a quote):data-align="center"or"right". "Align left" is the default, the attribute is not written, anddata-align="left"from external HTML is read as its absence. Alignment from external HTML (value,defaultValueand a paste from Word, Excel, Google Docs) is also read asstyle="text-align: center|right"(any case and spaces) and as the obsoletealign="center|right"attribute onpandh1–h4: it becomesdata-align, andstyleandalignthemselves do not end up in the Document.left,startandjustifygive "no attribute". Without thealignTool, such alignment is dropped together withstyle. "Justify" (justify) is deliberately absent in v1: without hyphenation, text gets torn into whitespace "rivers", and WCAG (1.4.8) advises against it. The alignment is physical (left and right), not logical: for Documents in right-to-left scripts the set would have to be extended. -
An image has its own alignment on the
figure:data-align="left"or"right"(the text wraps around the image), the centre without an attribute. The words are the same, the meaning differs (see "Images");pandth/tdnever get it from an image, and the paragraph keys act on a selected image only. -
A disabled Tool removes the attribute from the Schema:
data-color, the author's colorstyleanddata-alignfrom a paste and fromvalueare dropped, and the text stays. -
Markdown does not express color, highlight and alignment:
getMarkdown()keeps the text, and==text==does not become highlight markup (otherwise it would appear without a color).
Custom color
Besides the palette colors, the author picks any other: "Custom color…" (editor.colorCustom) next to the heading of each grid of the "Color" popover opens a kit popover with a ColorPicker: a button with a swatch and value expands a saturation area, a hue strip and a HEX field; below are a contrast warning, "Apply" and "Cancel". The popover opens at the selection, like the link popover. If the selection already has an author's color, the popover opens on it, and "Custom color…" is checked in the grid; the "Highlight" button's name includes the author's highlight value: "Highlight: Custom #ffe066". After "Apply", "Cancel" or Escape, focus is in the Document.
How the color is stored. Strictly style and nothing else, on a span for text and on a mark for highlight:
<span style="color:#00aa55">text</span> <mark style="background-color:#ffe066">highlight</mark>Lowercase letters, exactly six digits, no spaces and no ;; no other properties in style and never together with data-color on one element — a Mark has one color, the palette's or the author's, and a new choice replaces the previous one. This is the only exception to the rule "no style in the Document": the author's color has no name, and in HTML, a value is carried by style. The owner accepted the exception; it is described in the Schema (RICH_TEXT_SCHEMA.customColor), and sanitizeRichText (RichTextView) checks it with a hook.
What is accepted from external HTML (value, paste): only this declaration, one per element, color on a span, background-color on a mark; letter case and surrounding spaces are normalized to the Editor's form (#00AA55 → #00aa55). Everything else — #abc, rgb(0, 170, 85), red, var(--x), !important, a second declaration alongside (color:#00aa55;font-size:40px from Google Docs), style on another tag — is dropped together with the element, and the text stays. Converting rgb() to #rrggbb is technically simple, but it would widen parsing with formats that the consumer's sanitizer must also support, and the kit rejects guessing on the author's behalf for the palette as well. A color copied from the Editor itself and pasted back is preserved without loss.
How style is written into the DOM. The Editor sets the attribute through setAttribute, not through style.cssText, as ProseMirror does for an array description. The difference is significant: the browser rebuilds cssText into its own notation (color: rgb(0, 170, 85);), and the Document would not pass strict parsing on its next load.
Contrast is a warning, not a ban. The popover measures the color against the current theme: the Editor's background and main text are --rte-background and --rte-foreground on the Document. For text it is the color itself against the background, for a highlight it is the dark text on the highlight (--marker-text), not the theme's main text: on a bright highlight and on the author's color the text is dark. The threshold is 4.5:1 (WCAG 1.4.3). Below the threshold a line with the number appears in the popover's live region (role="status") ("Low contrast: 2.1:1 against the editor background (4.5:1 needed)"); the color is still applied when you press "Apply". If the theme could not be read (no styles), there is no warning: "not measured" does not mean "bad".
The author's color does not follow the theme. The palette consists of tokens, and one saved text reads in dark, light and dim. #ffff00 is the same in all themes: yellow text that reads on a dark background blends into a light one. The Editor warns when the color is chosen and says so in the popover (editor.customColorThemeNote), but it does not recompute or replace the color. For Documents shown in different themes, use the palette.
Size. ColorPicker pulls in the react-aria-components color subsystem — 61 kB gzip (ADR-0038), as much as the whole kit, so the popover loads lazily (React.lazy) the first time "Custom color…" is opened. If you never open it, you do not pay for those kilobytes; they are not part of the @olddevs/ui/editor entry point, but the consumer's bundler moves them into a separate chunk.
Text part language
The language Tool (present in full, not in basic) marks a piece of text with its language: an English term inside Russian text, or the other way round. Then a screen reader reads the piece by that language's rules, the browser spell-checks it with the right dictionary, and hyphenation breaks it correctly. This is the WCAG 2.2 criterion 3.1.2 Language of Parts (level AA). The name in editors is Text part language (CKEditor 5); Language of Parts is its WCAG synonym.
<RichTextEditor /> // "Language ›" is in the "…" menu: English and Russian
<RichTextEditor tools={[...RICH_TEXT_PRESETS.full, tool("language", { languages: ["en", "de", "fr"] })]} />- A Mark, nothing else. The Document holds
<span lang="en">…</span>. There is no language of a Block: a paragraph in another language is the same Mark over all the text of the Block, and there is no second mechanism that could disagree with the first. - A standard attribute. It is
lang, notdata-lang: a screen reader, spell checking and hyphenation read it with no code of the kit, in the Editor, inRichTextView, in an email and in a PDF. The Mark is the outermost one, so one language mark covers a phrase of mixed formatting as one element:span[lang] › span[data-color] › mark › a › strong. - The menu. "Language ›" is a submenu of the "…" menu of the Toolbar and of the selection menu (the Bubble menu and the floating Toolbar). There is no Toolbar button and no shortcut: the
fullToolbar in a 640 px column is already full. The submenu has the languages of thelanguagesoption as radio items (menuitemradio, the current one checked), and "Remove language mark" below them. Names are drawn byIntl.DisplayNamesin the interface language ("English", "Russian"; a Russian interface says them in Russian). A language under the selection that the option does not list (it came from Word or from another screen) is added to the submenu, checked, so the author sees what the text carries. A selection that mixes two languages has none checked. - The primary language. It is the
langof the field's nearest ancestor that has one (usually<html lang>), the language a screen reader already reads the field in. Without any, it is the interface locale (UiProvider). The submenu marks it "primary", and choosing it is the same as "Remove language mark": a mark with the primary language is never set. A mark that repeats the page's language, or the bare language of a regional one (enon a page inen-US), adds nothing for the reader. A more specific tag (en-GBon a page inen) is a real mark. There is nodocumentLanguageoption: it would have to match the page'slang, or the screen reader and the Editor would disagree. - Any language is accepted. The Schema and the sanitizer accept a
langof any language, not only the ones in the menu: only the shape of a BCP 47 tag is checked (en,pt-BR,zh-Hant-TW), because HTML withlang="de"arrives from other screens and from Word, and the server's sanitizer has no Options of the screen. A value that is not a tag (x-none,english, an empty string) loses the Mark, and the text stays. The tag is written in its canonical case,EN-US→en-US. - Look. Only in the Editor: a thin dotted underline in the color of secondary text (
--rte-secondary, the theme's and Paper's own value), so the author sees where a mark begins and ends.RichTextViewdraws nothing: a reader sees the text as it is, and the screen reader hears the language. - Clear formatting does not remove it. The "Clear formatting" item and
Ctrl/⌘+\clear the looks; a language is meaning, not looks. It is removed by "Remove language mark". - Paste. A paste from Word, Google Docs and a browser keeps
lang: Word's<span lang=EN-US>becomesen-US. A pasted mark in the page's language is dropped at once, whatever its region: Word writeslang=EN-USon every run, and on<html lang="en">it would otherwise cover the whole text with marks (en-US,en-GBandenon a page inen;ru-RUonru). A regional mark on a page in another language (en-GBonru) stays. Only a paste is this loose:set("en-GB")on anenpage, and avalue, keep the exact comparison. Without the Tool the words stay and the mark is lost, like any Mark of a disabled Tool. - Typography. With the
typographyTool, a"typed inside anen…mark gives curly quotes, and inside aru…mark it gives guillemets, whatever the catalog or thequotesoption say. Any other language, and text with no mark, use the usual set. - Markdown. Markdown has no language.
getMarkdown()keeps the text and drops the mark, andsetMarkdown(getMarkdown())returns the Document without it, as with color. For lossless storage use HTML or the JSON envelope, which keeps the Mark. The row is in "What is lost on export" (the "Markdown" section). - Search and invisible characters do not see the Mark.
The message catalog strings are editor.language ("Language", the submenu item and its name), editor.languagePrimary (the label of the page's own language in the list) and editor.languageRemove ("Remove language mark"); the icon is LanguageIcon. The decision is ADR-0078.
Text part language options
| Option | Meaning | Default |
|---|---|---|
languages | The languages of the "Language ›" submenu, as BCP 47 tags, in this order. An array is replaced whole. An invalid tag or an empty list is replaced with the default, with one console.error in development. It fills the menu only: the Schema accepts any language. | ["en", "ru"] |
Text part language state and commands
useRichTextToolState(ref, "language") reads the state and ref.current?.tool("language") calls the commands. The general rules for both are in the "Handle (ref) and a custom toolbar outside the field" section.
| State field | Meaning |
|---|---|
current | The language mark under the selection: the tag at the caret, or the one tag of the whole selection. null for no mark, and for a selection that mixes languages. |
primary | The page's primary language, in the canonical case (en-US): the one the reader hears where there is no mark. |
| Command | What it does |
|---|---|
set(language) | Marks the selection with a BCP 47 tag (any language, not only the languages option). A caret in a marked word changes the whole word; a caret elsewhere sets the language for the text typed next. The primary language removes the mark instead. false for a value that is not a tag, in readOnly and in the Source mode. |
unset() | Removes the mark from the selection, or from the whole marked word at the caret. false in readOnly and in the Source mode. |
function LanguageBadge({ html }: { html: string }) {
const ref = useRef<RichTextEditorHandle>(null);
const current = useRichTextToolState(ref, "language", (state) => state.current);
return (
<>
<p>{current ?? "page language"}</p>
<button type="button" onClick={() => ref.current?.tool("language")?.set("de")}>
Mark as German
</button>
<RichTextEditor ref={ref} aria-label="Article text" defaultValue={html} />
</>
);
}Tables
The table Tool is part of preset="full", not of basic. It needs the @tiptap/extension-table package (in the install command above).
One "Table ▾" button on the Toolbar does both insertion and actions, as in TinyMCE. A table icon with a chevron, aria-haspopup="menu"; the button is always there, and outside a table the items that do not apply there are unavailable (aria-disabled) but stay in the arrow-key order — the ARIA Authoring Practices Guide (APG) recommends this so that an arrow key does not silently skip an item. Whether an item is available is decided by a trial run of its engine command, not editor.can(): that one answers "yes" to deleting the only row, which then silently does not get deleted.
| Item | Outside a table | What it does |
|---|---|---|
| Table › | available | A submenu with a size grid (up to 10×10): choosing a size inserts an N×M table with a header row, the menu closes, and the caret goes into the new table's first cell. The selection in the grid sits at the last size chosen in this Editor (3×3 the first time); the grid itself shows at least 5×5 cells |
| Insert table… | available | A dialog (the kit's Dialog) with the "Columns" and "Rows" fields — up to 20×50, the initial values are the last size; Enter in either field inserts, "Cancel" and Escape close without a table. A size from the dialog is remembered the same way as from the grid |
| Cell › | unavailable | "Merge cells" — available when several cells are selected (by mouse across cells or Shift with the arrow keys); "Split cell" — on a merged cell |
| Row › | unavailable | "Insert row above / below", "Delete row" (unavailable for a one-row table — there is "Delete table"), "Header row" — a toggle (menuitemcheckbox): the first row of th ↔ td |
| Column › | unavailable | "Insert column left / right", "Delete column"; then "Wider" / "Narrower" (a step of 5%) in a group named with the current width; then a radio group (menuitemradio) "Align column left / center / right" — the alignment of the column under the caret. The common alignment of the column is checked; with mixed alignment nothing is checked |
| Sort › | unavailable | "Sort ascending", "Sort descending" — by the column under the caret (rules below). In a table with merged cells both items are unavailable, and the submenu's section label explains why |
| Equal columns | unavailable | Makes all the columns of the table the same width (shares in steps of 5%, the spare steps to the leading columns); unavailable when they are already equal. The next item, "Fit columns to content", removes all the widths, and the table is sized by its content again; unavailable when there are none |
| Delete table | unavailable | Removes the whole table; the item is red (danger) and separated by a divider |
A table inserted from the menu or the dialog lands as a new Block after the current one; in an empty paragraph, it takes the paragraph's place; from inside a table, it goes after that table: the Editor does not create nested tables. The "Table" item of the Slash menu (/table, /grid, "+") still inserts 3×3 immediately, without a size choice and without remembering it.
Keyboard. To open the menu, press Alt+F10 (it moves focus into the Toolbar), use the arrow keys to reach "Table ▾", then press Enter or ↓.
| Key | Where | Action |
|---|---|---|
↓ / ↑ | menu, submenu | Next / previous item, unavailable ones too |
→ | item with › | Open the submenu; focus goes to the first item, and for "Table ›" into the grid once the submenu has been positioned |
← | submenu | Close the submenu, focus goes back to its item. In the grid, ← moves the selection and does not close the submenu: the horizontal arrow keys belong to the grid |
← → ↑ ↓, Home End | grid | Choosing the size, the grid grows up to 10×10 (the grid keys are in "The size selection grid" below) |
Enter | item, grid | Run; the action returns focus to the Document, and the caret stays in the cell it came from |
Escape | any level | Close only the top level: the grid or submenu → the menu → the button. In a Dialog only the next Escape closes the dialog (ADR-0041) |
Focus is put into the grid when the submenu's popover itself reports that it has been positioned: the position is computed and the enter animation has finished (the react-aria render props placement and isEntering). A grid that took focus right at mount broke the menu inside a dialog, and the earlier 50 ms timer was a race against the device; the popover's signal does not depend on device speed. A submenu opened with the mouse leaves focus on its item — hover moves the grid.
Cell merging. colspan and rowspan are written into HTML and survive saving and loading; a table from Word, Excel and Google Docs is pasted with its merges. The value is an integer from 2 to the Schema limit (RICH_TEXT_SCHEMA.tableSpans: 20 horizontally, 50 vertically — as many as the largest insertable table); zero, a non-integer number, 2px, a negative number and a number over the limit are read as 1 (the cell stays, the merge falls apart): otherwise colspan="10000" from external HTML would become ten thousand empty cells. "Merge cells" does not perform a merge that would go past the limit. A row fully covered by a merge from above stays an empty <tr></tr>.
Column alignment is data-align="center|right" on every cell of the column (th and td), with the same values as Block alignment: left is the default, no attribute. The styling comes from shared prose.ts classes, so the column is aligned the same way in RichTextView. A paragraph in a cell with its own alignment (the align Tool) wins over the column. The alignment of an external table — style="text-align: center|right" or align="center|right" on th and td from Word, Excel, Google Docs or value — is converted to the cell's data-align (with the table Tool enabled, regardless of align); style and align themselves are not written. From Markdown, alignment arrives with the :---: delimiter.
Column widths (ADR-0080) are shares of the table's width, in steps of 5%. A table has widths only when the author set them or they came with a paste; a saved Document without them, and a table inserted from the menu, stay sized by their content, as before. The Document keeps them as <colgroup><col data-width="35"><col data-width="35"><col data-width="30"></colgroup> before the table body: one col per column of the grid, each a multiple of 5 from 5 to 95, and the sum is 100 (RICH_TEXT_SCHEMA.tableColumnShares). There is no style, and no width of the table itself: a table with widths fills the Document and follows its width in the View, in an email, in a PDF and on a phone. A list that breaks the rule (the sum is not 100, a value is not a step, the number of col is not the number of columns) is read as no widths: the table and its text stay, and the Sanitizer removes such a colgroup whole. There is no Option and no new Tool: this is part of table.
- With the pointer (a mouse or a finger): with the caret in a table, or the pointer over it, every boundary between two neighboring columns gets a handle. With a mouse it is invisible until the pointer is over the boundary, then a bar shows, as in Notion and Google Docs; on a touch screen the bars are always visible and wider. Drag it: the bar follows the pointer smoothly, and on release the boundary snaps to the nearest 5%. Only the two columns around the boundary trade width, the rest stay put; each keeps at least 5%. The last column has no bar. A drag is one edit:
Ctrl/⌘+Ztakes it back whole. The first drag in a table without widths first rounds the widths it has on screen, for all the columns, to 5%, then moves the boundary. A click without a drag changes nothing. The bars are not in areadOnlyordisabledfield. - From the keyboard: "Column › Wider" and "Narrower" take a step of 5% at the expense of the neighbor on the right (on the left for the last column); a column or a neighbor at 5% stops the step, and the item is unavailable. The "Column" menu's group is named with the current width ("Column width: 35%", or "fits content"). The bars are for the pointer only and are not in the
Taborder (aria-hidden): in a tableTabalready walks the cells, and a stop per boundary would be dozens of stops in a big table. "Table › Equal columns" and "Fit columns to content" set or remove the widths of the whole table. Every action is one edit. - Announcement. After a step, a drag, "Equal columns" and "Fit columns to content" the result is announced through the Field notice (
role="status"): "Column width: 35%". - The minimum column width wins. A column is never narrower than 6 rem: where a share is less than that on the current width of the Document, the column stays at 6 rem and the table scrolls inside itself, as a table without widths does. The shares in the Document do not change.
- Insert and delete carry the widths along (the menu and the
addColumnBefore,addColumnAfteranddeleteColumnengine commands alike). A new column takes half of the share of the column it was inserted beside, rounded down to 5% (beside a column at 5% the widest column gives a step instead); with no room (twenty columns, or every column at 5%) the widths are dropped. A deleted column gives its share to the neighbor on the left, and the first one to the new first column. The sum stays 100. Merging and splitting cells and sorting do not touch the widths. Anything else that changes the number of columns (a paste of cells that grows the table) drops the widths: shares for the wrong number of columns would size every column wrongly. - A paste turns the widths of the source into shares: Excel and Google Sheets (the
colwidths, points and pixels), Google Docs (col width), Word (thewidthof the cells of a row, and%) — a step of the paste cleanup for the source (see "Paste from Office") — and for other HTML with acolgroup(col widthorstyle="width"in px, pt, %), the table itself. The values are rounded to steps of 5% with a sum of 100; a column with no width, a hidden column, a single column and more than 20 columns leave the table sized by its content. - In Markdown the widths are lost (a row in "What is lost on export"); the JSON envelope keeps them (
getJSON()→setJSON()without loss).
Sorting reorders rows by the column under the caret:
- the header row stays first; a table without one is sorted whole;
- a column where all non-empty cells are numbers is compared as numbers: digit groups separated by a space (a non-breaking one too), an apostrophe, a comma or a dot, a decimal part separated by a comma or a dot, a minus sign,
%. Where there is a single separator and it occurs once, the interface locale decides:1,234is one thousand two hundred thirty-four inenand a number with a fractional part inru;1.2.3is not a number; - a column where all non-empty cells are ISO dates (
2026-10-06, with time afterTor a space) orDD.MM.YYYYis compared as dates.10/06/2026is not read: the order of day and month differs between locales; - otherwise, text is compared with
Intl.Collatorfor the interface locale withnumeric: "ё" in its proper place, "item 2" before "item 10"; - empty cells go to the end in either direction; the order is stable (equal rows are not shuffled); the whole reorder is one edit,
Ctrl/⌘+Zundoes it whole; the caret travels with its row; - with merged cells, sorting is unavailable: a row with a merge cannot be moved without cutting the merge.
Other keys in the Document.
TabandShift+Tab— to the next and previous cell in reading order (the cell's content is selected).Tabin the last cell adds a row and moves into it, as in Word, Google Docs and Notion; this is standard Tiptap behavior, which the kit keeps. The trade-off:Tabdoes not leave the table the way it leaves the rest of the Document — you can leave with the arrow keys (↓/→from the last cell put the caret after the table, including when it is the last Block of the Document) or withAlt+F10into the Toolbar.Alt+↓(⌥↓on macOS) — inserts a row below the current one, and the caret lands in the same column of the new row; one edit,Ctrl/⌘+Zremoves the whole row. It is the same as "Row › Insert row below", and the menu item shows this shortcut. It works only in a table: outside it the shortcut stays with the browser. On macOS, inside a cell,⌥↓does not move the caret to the end of the paragraph: the shortcut overrides this system action. There are no shortcuts for columns or forAlt+↑— the owner's decision.- A mouse selection across several cells highlights them (
.selectedCell, the--selectionselection background);Delete/Backspacewith all cells selected deletes the table, with part of them selected clears the cells.
The size selection grid (src/editor/features/table/TableSizeGrid.tsx, not exported) is in the "Table ›" submenu. The grid opens at 5×5 cells and grows by a column or row when the selection reaches its edge, up to 10×10; when the selection moves back, the grid shrinks. The top row is shaded and underlined as a header (insertion always makes the first row of th). Under the grid is the size in words ("3 columns, 4 rows", pluralized for the locale). There are no numeric fields in the menu — they are in the "Insert table…" dialog: an input inside a react-aria Menu would close the menu, and Tab does not move focus in a menu. The grid itself supports fields (fields); only its stories use this.
| Key | Action |
|---|---|
← → ↑ ↓ | Move the selection by one cell; the grid grows at the edge and stops at 10×10 |
Home / End | The first column / the last visible column of the row; with Ctrl, the grid corners |
Enter | Insert a table of the chosen size |
Escape | Close the grid, focus goes to the "Table ›" item |
The grid follows the APG grid pattern: role="grid" → row → gridcell. Focus stays on the grid itself, and aria-activedescendant points to the current cell (a roving tabindex was rejected: up to a hundred Tab stops instead of one); aria-selected is on the cells of the chosen rectangle. A cell's name and the live region (role="status", polite) read the same text — the chosen size in words; mouse hover moves the same selection as the arrow keys, but it is not the only way.
The output. <table><tbody><tr><th>…</th></tr><tr><td>…</td></tr></tbody></table>, a cell is <th><p>…</p></th>. A cell has only colspan, rowspan and data-align; no style, colwidth, class or scope; thead and caption are not written (the header row is an ordinary first row of th), and a colgroup of col[data-width] is written only for a table with column widths (see "Column widths" above). The standard Tiptap extension writes style="min-width: …" on the table, a colgroup with pixel widths, colwidth and style="text-align" on cells — the kit turns this off (src/editor/features/table/tables.ts), and such attributes are dropped on load and paste; the alignment in them is kept as data-align, and the widths in a colgroup as shares.
- Column widths are shares, not pixels. The engine's own resize handles stay off (the Tiptap option
resizable: false): they write pixels into the cells, the table gets wider than the Document, and the proportions break on another width of the View. The kit's bars write shares on the table instead (see "Column widths"). A table without widths is sized by the browser from the content. - Rows with a different number of cells (external HTML with an error or with a merge over the limit) are evened out with empty cells when the Editor starts — without
onChange: this is not a User edit. - A cell holds any Schema Blocks (paragraphs, lists, a quote, a code block), not only paragraphs: if a cell accepted only one paragraph, inserting a list would cut the table in two.
- A disabled
tableremoves the button, the menu item and the extension: a table from a paste and fromvaluearrives as the text of the cells, as paragraphs. - Scrolling on a narrow screen. A table wider than its block scrolls horizontally inside itself (
display: block; overflow-x: autoon<table>,prose.ts) and does not stretch the page; the minimum column width is 6 rem, and it wins over a share (see "Column widths"). There is no wrapping element:RichTextViewrenders the saved HTML as is, and scrolling must work on a bare<table>. Details and the trade-off are on the RichTextView page.
Live examples are the stories TableMenu, TableMerged, TableSortAndAlign, TableRussian, TableNarrow, TableInsertSlash; for column widths TableColumnWidthHandle, TableColumnWidthMenu, TableColumnWidthNarrow, TableColumnWidthExcelPaste and TableColumnWidthRussian; and, for the grid alone, TableSizeGrid, TableSizeGridFields, TableSizeGridRussian.
Column layout
The layout Tool (present in full, not in basic) is a Block of columns. It is inserted with the "Layout" item of the Slash menu (/layout or "+"): two equal columns, the caret in the first. Six variants — Single column, Two columns, Three columns, Four columns, 60/40, 40/60 — are chosen in the Block handle menu: "Add › Layout ›" inserts a Column layout under the Block (from a column, under the whole Column layout), and the variant is switched with "Layout ›" in the handle of a Block in a column and with "Format ›" in the handle of a Column layout selected as a whole (Backspace on the Block under it); in both, the current variant is checked. The Column layout has no button of its own on the Toolbar.
-
The Blocks of a column have their own handle, at the left edge of the column at the level of the Block's first line (for the right column, in the gap between the columns). For them a column works like the Document: "Add ›" puts a new Block below in the same column, "Move up" and "Move down" do not leave it, "Delete" on the only Block leaves an empty column, "Format ›" changes the type of the Block itself. The Column layout's variant is a separate "Layout ›" item: the caret is almost always in a column, and the handle of the whole Column layout is rarely visible.
-
A column is a separate area. It holds any Blocks except another Column layout: there is no nesting at the Schema level, so you cannot create a nested Column layout by pasting or from
value. A Column layout is only a top-level Block: the "Layout" item from a column, list or quote puts a new Column layout under the current top-level Block (from a column, under the whole Column layout), and a Column layout from the clipboard pasted into a column, list, quote or cell unwraps into its Blocks. The other "Insert" items from a column land under the current Block in the same column; moving (Alt+Shift+↑/↓) and duplicating a Block do not leave the column either. -
In the Editor the columns are outlined with a gray dashed line; in
RichTextViewthere is no outline — the border is for the author, not the reader. The variant sets the column widths, and dragging does not change them. -
Changing the variant does not lose text. If there are fewer columns, the Blocks of the extra columns move to the end of the last remaining one (empty extra columns simply go away); if there are more, empty ones are added. Insertion and a variant change are one edit, undone with one
Ctrl/⌘+Z. "Single column" is a Column layout of one column; to remove the whole Column layout, use "Delete" on its handle orBackspaceon the Block under it (the first press selects the Column layout, the second deletes it). -
A narrow screen. Columns sit side by side only when the Document itself is wide enough: two columns from 30 rem (480 px), three from 40 rem (640 px), four from 48 rem (768 px); at a smaller width they stack in reading order. The threshold is based on the Document's width (a container query), not the window's width, so in a narrow
Draweron a wide monitor the columns also stack. The root of a Document with a Column layout becomes a container (container-type: inline-size); in a shrink-to-fit context (a flex-row item without a width), give the field orRichTextViewa width.
| Key in a column | What it does |
|---|---|
Tab / Shift+Tab | To the start of the next / previous column. In a list, table and code block, Tab keeps its own behavior; from the outermost column it goes to the browser — focus leaves the Editor |
→ / ← at the text edge | To the start of the neighboring column on the right / to the end of the one on the left; from the outermost one, out of the Column layout |
↓ / ↑ at the bottom / top line | Out of the Column layout — to the Block under it / above it; at the Document edge, a gap cursor (a caret between two Blocks where an ordinary caret cannot go) |
Backspace at the start of a column | Columns do not merge and text does not leave the Column layout; an empty heading, as everywhere, becomes text |
The markup is a div with data-block; the widths are set by the variant in data-layout, with no style (the column shares in percent, joined by hyphens):
<div data-block="layout" data-layout="60-40">
<div data-block="column"><p>Wide column</p></div>
<div data-block="column"><p>Narrow column</p></div>
</div>The data-layout values are 100, 50-50, 33-33-33, 25-25-25-25, 60-40, 40-60 (RICH_TEXT_SCHEMA.layouts). HTML from another editor with div[data-block="column"] columns and widths in style="flex-basis: 40%" is read as the Column layout of the nearest variant, and style is dropped. If the number of columns disagrees with the variant, the Editor adjusts the variant to the number of columns. Without the layout Tool, a Column layout from value and paste unwraps into Blocks one after another.
Markdown does not support columns: getMarkdown() exports the columns' Blocks one after another, left to right, and setMarkdown() does not create a Column layout, even from raw HTML. The strings are editor.layout and editor.layoutVariant in the English and Russian message catalogs; the item's icon is ColumnLayoutIcon. The decision is ADR-0056.
Wrapper
The wrapper Tool (present in full, not in basic) is a Block that gathers a group of Blocks, like the Wrapper in Redactor. Without a tone the Wrapper has no look of its own: it keeps Blocks together — they can be moved, duplicated and deleted as one Block. With a tone it becomes a note or a warning, like alerts in GitHub and callouts in Notion (see the "Tone" subsection below). It is inserted with the "Wrapper" item of the Slash menu (/wrapper or "+") and with "Add › Wrapper" in the Block handle: an empty Wrapper with one paragraph lands under the current Block, and the caret goes into the paragraph inside. The Wrapper has no button of its own on the Toolbar.
- Inside — any Blocks: a paragraph, a heading, lists, a quote, a code block, a table, an image, a horizontal rule, but not another Wrapper or a Column layout. There is no nesting at the Schema level, so you cannot create a nested Wrapper or Column layout by pasting or from
value. A Wrapper pasted into a Wrapper, list, quote or cell unwraps into its Blocks, and a Column layout inside a Wrapper unwraps into the columns' Blocks. - Placement. A Wrapper can appear in the Document and in a column of a Column layout. From a column, the "Wrapper" item puts it under the current Block in the same column; from a Wrapper, list, quote or cell, under their Block. Insertion is one edit, undone with one
Ctrl/⌘+Z. - The Blocks of a Wrapper have their own handle at the left edge of the Wrapper. For them a Wrapper works like the Document: "Add ›" puts a new Block below in the same Wrapper, "Move up", "Move down" and
Alt+Shift+↑/↓do not leave it, and "Delete" on the only Block leaves an empty paragraph. - The Wrapper's own handle appears when it is selected as a whole (
Backspaceon the Block under it): "Move up", "Move down", "Duplicate" and "Delete" act on it together with its content. - "Unwrap" is a Block action of the
wrapperTool: an item of the handle menu on the Wrapper itself and on a Block directly in it, in the Tools' actions section before "Delete". The Blocks take the Wrapper's place, and the caret stays in its text. One edit, one undo. - In the Editor a Wrapper without a tone is outlined with a gray dashed line and inner padding — the same look as the columns of a Column layout; in
RichTextViewthere is no outline, and the spacing between Blocks is as in the Document: the border is for the author, not the reader. A Wrapper with a tone is visible to the reader too — with the same look as in the Editor.
| Key in a Wrapper | What it does |
|---|---|
Enter in an empty last paragraph | If the Wrapper has other Blocks, the paragraph moves under the Wrapper, and the caret with it: a way out without the mouse. A sole paragraph stays inside |
Backspace at the start / Delete at the end | Text does not leave the Wrapper and does not merge with a Block outside; an empty heading, as everywhere, becomes text |
Backspace in the only empty paragraph | Removes the empty Wrapper whole: an empty paragraph takes its place, with the caret in it (in a column, in the same column). One edit, one undo. Delete does not remove a Wrapper |
↑ / ↓ at the Wrapper edge | To the Block above it / below it; at the Document edge, a gap cursor, so you can put a paragraph before or after the Wrapper |
Tab / Shift+Tab | Not intercepted: as in the Document (in a column, moving across columns). No keyboard trap |
The markup is a div with data-block="wrapper" and Blocks inside; the only attribute of its own is the tone data-tone, and without a tone there is none:
<div data-block="wrapper">
<h3>Before you start</h3>
<p>Check your repository access.</p>
</div>This is Redactor's markup: its HTML with a Wrapper is read as is on paste and in value, and class, style and other attributes on it are dropped. Without the wrapper Tool, a Wrapper from value and paste unwraps into Blocks one after another, and the text is not lost — the tone goes away with it.
Tone
A tone turns a Wrapper into a note: a soft tone background and a 3 px stripe on the left in the color of the tone's strong step, the text is ordinary Document text, and the inner padding is like that of Alert (12 px at the sides, 10 px top and bottom). The look is the same in the Editor and in RichTextView: a Wrapper with a tone has no dashed outline even in the Editor — the boundary is visible from the background and the stripe, and the author does not see a second outline that the reader does not have. A Wrapper without a tone looks as described above: a dashed outline in the Editor only.
It is chosen in the "Tone ›" submenu of the handle menu — on a Block directly in a Wrapper and on the Wrapper itself selected as a whole; "Unwrap" is below it, in the actions section before "Delete". The items are radio (menuitemradio): "None" and five tones named by the meaning of the note: "Note", "Tip", "Important", "Warning", "Caution" (like GitHub alert keywords); next to the name is a small swatch of the background and stripe. The current one is checked, and the name of the "Tone ›" item includes the current tone: "Tone: Note" (in the Russian locale, "Тон: Заметка"), and without a tone, "Tone: None". A tone change is one edit, one undo; the caret stays in place, and focus is in the Document. Choosing the current tone makes no edit.
data-tone | Menu item (ru / en) | GitHub alert | Background (theme) | Stripe (theme) | Paper (paper): background / stripe |
|---|---|---|---|---|---|
accent | Заметка / Note | > [!NOTE] | --accent-soft | --accent-strong | --accent-soft / --accent ¹ |
success | Совет / Tip | > [!TIP] | --success-soft | --success-strong | --od-green-2-a12 / --od-green-1 |
neutral | Важно / Important | > [!IMPORTANT] | --bg-3 | --fg-3 | --od-cloud-11 / --od-cloud-4 |
warning | Внимание / Warning | > [!WARNING] | --warning-soft | --warning-strong | --od-amber-2-a14 / --od-amber-1 |
danger | Осторожно / Caution | > [!CAUTION] | --danger-soft | --danger-strong | --od-red-3-a12 / --od-red-1 |
¹ In a light app, the "Note" stripe on the Paper is the light theme's accent-strong, like a link (see the "Surface" section).
-
The names are the kit's
Tonevocabulary, not the menu words:data-tone="warning"goes to the database, and neither the menu label nor the interface language changes it. The theme substitutes the color, as withdata-color: a saved Document reads indark,light,dim, with any accent and brand. The values are the roles--rte-tone-<tone>-backgroundand--rte-tone-<tone>-border(src/editor/styles/tokens.ts): in a theme they resolve to the kit's status tokens, on the Paper (surface="paper") to the primitives of the light theme. The Schema does not support a custom tone color (style). -
"Important" is a neutral tone, and it has two departures from
TONE_TOKENS.neutral. The background isbg-3, notbg-2: the Editor's field itself sits onbg-2, and in the field "Important" would be left without a background;bg-3is the app background that the text tokens are calibrated for, and in weight it is closer to the soft backgrounds of the other tones in dark themes thanbg-4is. In the light theme this background is almost white — the stripe carries the tone there. The stripe isfg-3, not the decorativeline: it carries meaning and holds 3:1. -
Contrast (
npm run contrast, the color pairs for Callout tones): the Document's text on each background is at least 4.5:1 (the worst iswarning, 7.15 in the dark theme onsurface-elevated; on the Paper 13.3), the stripe is at least 3:1 both against the app background around the Wrapper (the worst is 4.51 for "Note" on the Paper) and against its own fill (the worst is 3.68, "Note" on the Paper; in the app theme 4.60). This holds in all themes, accents and brands, and on the Paper. -
Secondary text in a Wrapper with a tone uses higher-contrast roles. The
fg-1–fg-3andaccent-strongsteps are calibrated for app backgrounds, and on the colored tone backgrounds the contrast of a quote would be 4.23:1, of a link 3.97, of a caption and gray text 3.59. So inside a Wrapper with a tone a link, a quote (and the language label in the code block header), an image caption, a done task list item, gray text color (data-color="muted") and the empty caption placeholder use the roles--rte-tone-link,-secondary,-muted,-muted-foreground:What Role outside a tone In the app theme On the Paper ( paper)link --rte-link--fg-0--od-cloud-1quote, code block header --rte-secondary--fg-0--od-cloud-2image caption, done item, gray text color --rte-muted,-text-muted--fg-0--od-cloud-3empty caption placeholder --rte-muted-foreground--fg-0--od-cloud-3In the app theme, on all five backgrounds only
fg-0holds 4.5:1 (fg-1gives 4.23 on "Note"), so inside a tone secondary text uses the main text's colors: a quote is still told apart by the stripe, a done item by strikethrough, a caption by font size, a link by underline (a Document link always has it). On the Paper,cloud-2andcloud-3pass on the tone backgrounds too and stay; the link (the accent gave 3.68) and the placeholder are moved to higher-contrast roles. The worst pair is 7.15:1 in a theme (warning, dark theme), 5.30:1 on the Paper (caption and placeholder on "Note"). Outside a Wrapper and in a Wrapper without a tone, the roles do not change. The gate does not measure the author's text color — palette and custom color — on a tone background: that is the author's choice. -
An unknown tone is dropped — both on parsing (
value, paste, Source mode) and insanitizeRichText:data-tone="purple","Accent"anddata-toneon any other tag are removed, and the Wrapper stays without a tone. A Wrapper in a Wrapper, list, quote or cell is unwrapped into its Blocks, and its tone goes away. If unsanitized HTML with an unrecognized tone reachesRichTextView, it renders the Wrapper without any tone styling. -
A tone is styling. The saved HTML has no ARIA roles (
note,alert) and noaria-*attributes: the screen reader reads the Wrapper's Blocks like the Blocks around it. So the meaning of a note is stated in words in its text — "Warning: …", "Tip: …": the background color must not be the only way the meaning is conveyed (WCAG 1.4.1). -
HTML source shows
data-toneon a Wrapper as is; the field text passes through the Schema, likevalue.
Markdown — GitHub alerts. getMarkdown() exports a Wrapper with a tone as a quote whose first line holds the alert keyword ([!NOTE]), followed by its Blocks inside the quote:
> [!WARNING]
>
> ### Before you upgrade
>
> Back up the database.setMarkdown() and a Markdown paste read such a quote back into a Wrapper with a tone: the keyword is alone on the first line, in any case ([!note]). An ordinary quote, a keyword with text on the same line (> [!NOTE] text), an unrecognized keyword ([!INFO]) and an alert inside a list or quote stay a quote — GitHub does not show an alert in these cases either. Pasting an alert quote where a Wrapper is not allowed (inside a Wrapper, list, quote or cell), and setMarkdown() without the wrapper Tool, give Blocks one after another, without the keyword — like a Wrapper from HTML in the same place. A Wrapper without a tone is still just Blocks one after another in Markdown, and a raw <div data-block="wrapper"> inside Markdown does not create a Wrapper.
The strings are editor.wrapper ("Wrapper"), editor.unwrap ("Unwrap"), editor.wrapperTone ("Tone: {current}"), editor.wrapperToneNone ("None") and editor.wrapperToneName (the names of the five tones) in the English and Russian message catalogs; the icons are WrapperIcon, UnwrapIcon and PaletteIcon (for "Tone ›"). The decision is ADR-0057.
Details
The details Tool (present in full, not in basic) is a Block made of a title and content that the reader opens and closes: details under a heading, like a spoiler on GitHub or a toggle in Notion. The engine is the Details extension from Tiptap, and the API follows it (ADR-0048). It is inserted with the "Collapsible block" item of the Slash menu (/collapsible, /details or "+") and with "Add › Collapsible block" in the Block handle: an empty open Block with the caret in the title. Insertion is one edit, undone with one Ctrl/⌘+Z.
- Title and content. The title (
summary) is one line of text with Marks, with no line breaks or Blocks. The content is any Blocks: a paragraph, a heading, lists, a quote, a code block, a table, an image, a horizontal rule, another Details Block. There are no Column layouts or Wrappers inside: there is no nesting at the Schema level, and a Column layout or a Wrapper fromvalueor paste unwraps into its Blocks. The Block itself stands wherever any Block can: in the Document, a column of a Column layout, a Wrapper, a quote, a cell and the content of another Block. The Slash menu puts it under the handle's Block: from a paragraph, under it; from a list or a quote, under the whole list or quote; from a Wrapper, a column or the content of another Block, inside them. - Opening. In the Editor, to the left of the title there is a button with a chevron: a real
buttonnamed from the catalog ("Details: {title}") witharia-expanded. It is in the Tab order (from the Document, Tab leads to the button of the nearest Block below the caret), Enter and Space open and close the Block, and focus stays on the button. Collapsed content is hidden from the caret as well: the arrow keys do not take it inside. InreadOnlythe Block still opens and closes. - The
persistoption.tool("details", { persist: true }),falseby default (as in Tiptap). Without it the open state lives only in the display: opening does not reach the Document, the undo history oronChange,openis not written to the HTML and is not read fromvalue, and a Block opened during editing is not published open without anyone asking. Withpersist: truean open Block writesopen="",openis read fromvalue, paste andsetMarkdown(), and opening or closing is an edit of the Document (onChange, undo). A Block inserted from the menu is open with anypersist. The options are read once, when the engine is created; an invalid value (not a boolean) is replaced by the default with aconsole.errorin development. - The Block handle works like a Wrapper's. The handle at the title is the handle of the whole Block: "Move up", "Move down", "Duplicate" and "Delete" take it with its content. The Blocks in the content have their own handle at the left edge of the content: "Add ›" puts a new Block below in the content, "Move up", "Move down" and
Alt+Shift+↑/↓do not leave it. There is no "Tone ›" for the Block. "Remove collapsing" is a Block action of thedetailsTool: an item on the Block itself and on a Block directly in its content, in the Tools' actions section before "Delete". The title becomes a paragraph, the content Blocks follow it, and the caret stays in its text. One edit, one undo. - In the Editor the Block is outlined with a frame (
--rte-hr) and inner padding, the title is semibold, and thesummarymarker is replaced by the button; inRichTextViewthere is the same frame and the same title, but with the browser's native marker.
| Key | What it does |
|---|---|
Enter in the title of an open Block | The caret goes into the content: into the empty first paragraph if there is one, otherwise into a new paragraph at the start |
Enter in the title of a collapsed Block | A new paragraph under the Block |
Enter in the empty last content paragraph | A way out: the paragraph moves under the Block, and the caret with it |
Backspace at the start of the title | The Block falls apart, like "Remove collapsing" |
Backspace further into the title | Deletes one character; an emoji or a composed character whole |
↓ / → from the title of a collapsed Block | A gap cursor right under the Block, past the hidden content |
Tab / Shift+Tab | Not intercepted: as in the Document. No keyboard trap |
The markup is the kit's tags details and summary and the content wrapper div[data-type="detailsContent"], with no classes or style:
<details>
<summary>How to build the package</summary>
<div data-type="detailsContent"><p>Run the gates, then the build.</p></div>
</details>open is written only with persist, and empty: <details open="">. HTML without the content wrapper (GitHub, browsers: <details><summary>…</summary><p>…</p></details>) reads the same way — the Schema completes it; a Block without content gets an empty paragraph. Without the details Tool a Block from value and paste unwraps: the title becomes a paragraph, the content Blocks follow, and no text is lost.
The sanitizer lets details, summary and the content wrapper through only in this shape. summary only directly in details; div[data-type="detailsContent"] only directly in details and only with that data-type value; open only on details and only empty (open="open" is removed, and the Block stays closed). Outside such a place the tags lose their wrapper, and their content stays as Blocks in a row. iframe, class, style and handlers are stripped, as everywhere. The allow-list is not narrowed by the tools set: open passes even with persist: false — another screen may have written it, and a server has no right to cut what it did not write.
Markdown is raw HTML, as on GitHub. getMarkdown() writes the Block with details and summary tags and Markdown inside:
<details>
<summary>How to build the package</summary>
Run the gates, then the build.
</details>The blank line after summary makes GitHub read the content as Markdown, and the Block collapses there. The title is inline Markdown on one line: GitHub will show its asterisks as they are, but the getMarkdown() → setMarkdown() round trip loses nothing; < in a title is written as <. With persist an open Block is written as <details open>. setMarkdown() reads such a Block back — with nested Blocks, lists and code, where </details> inside a fence is not taken for the closing tag; <details open> without persist gives a closed Block. A tag with no matching </details> stays text. This differs from a Column layout and a Wrapper without a tone, which unwrap in Markdown: a Details Block has a common form in Markdown, and columns do not. Without the details Tool the same lines unwrap into Blocks in a row (an empty paragraph may remain after the closing tag).
The strings are editor.details ("Collapsible block"), editor.unwrapDetails ("Remove collapsing") and editor.detailsToggle ("Details: {title}", "Details: no title" for a Block without a title) in the message catalog (English and Russian); the icons are DetailsIcon for the insert item and UnwrapIcon for "Remove collapsing". The decision is ADR-0048 ("for the future": there was no customer at release).
Formulas
The mathematics Tool is LaTeX formulas: inline in a paragraph and block on a line of their own. The engine is the Mathematics extension from Tiptap and KaTeX, and the API follows the extension (ADR-0048); the decision about KaTeX is ADR-0070. The Tool is in no Preset — neither full nor basic: KaTeX is heavy, and the Presets do not load it. You switch it on by name or with a tool() entry:
import { RICH_TEXT_PRESETS, RichTextEditor, tool } from "@olddevs/ui/editor";
<RichTextEditor tools={[...RICH_TEXT_PRESETS.full, "mathematics"]} />;
// A custom KaTeX macro: \RR works in the Editor and in RichTextView with the same `tools`.
<RichTextEditor
tools={[...RICH_TEXT_PRESETS.full, tool("mathematics", { macros: { "\\RR": "\\mathbb{R}" } })]}
/>;- Inserting. Two Slash menu items ("/", "+" and the Block handle's "Add ›"): "Formula" (
/formula,/latex,/math) goes into the line at the caret, and "Block formula" is a Block of its own: in place of an empty paragraph with the caret, otherwise right after the Block that holds the caret. A paragraph always follows a block formula, so there is somewhere to put the caret. The item opens a Popover with a LaTeX field, focus goes straight into it; the formula is inserted with the "Insert" button or a key (table below). An insertion is one edit, undone with oneCtrl/⌘+Z. There is no Toolbar button: two more buttons would pushfullonto a second row. The typing rules of the Tiptap extension work:$$x^2$$in a line gives an inline formula,$$$x^2$$$in an empty paragraph a block one. - Editing. A click on a formula or
Enteron a selected one opens a kit Popover at the formula itself instead of Tiptap's built-in editing: a LaTeX field, a live preview and the error in the field. From the keyboard an inline formula is selected withShift+→orShift+←from a caret next to it: a plain arrow moves the caret across an inline atom without selecting it (that is how ProseMirror works). A block formula is selected with the arrows, like any Block atom. "Apply" changes the formula in place (one edit), "Remove formula" deletes it, Escape closes the Popover without touching the Document and returns focus to the text. InreadOnlyand in a disabled field a formula is only shown. - Invalid LaTeX never changes the Document. Parsing runs on every keystroke: while KaTeX cannot read the formula, the field shows its message ("Invalid LaTeX: …",
aria-invalid; the KaTeX text is in English — the engine does not translate it) and the apply button is disabled. An unreadable formula already in the Document is not lost: in the Editor it stays as source, underlined with a wave in the error color, and can be fixed in the Popover. - Only the source is in the Document. The HTML is the same as Tiptap's, with no classes and no
style; the rendered KaTeX markup is not in the Document, so changing the KaTeX version does not touch saved Documents, and the HTML is compatible with other Tiptap editors. - The atom text is the LaTeX.
getText(),getSelectedText(), copying as text and themaxLengthcounter see the LaTeX source (x^2weighs 3). Search (search) searches that LaTeX: a match inside a formula highlights the whole formula and counts in "N of M", while "Replace" and "Replace all" leave formulas alone (the "Find and replace" section). - Lazy and on demand. KaTeX, the extension, the Popover and the KaTeX CSS are brought by the Tool's Loader (ADR-0058, item 11.1), and only to an Editor that names
mathematicsintools;basicandfulldo not load them. While the chunk is on its way the field shows the Skeleton: formulas as LaTeX source in monospace, a block formula at least 4 rem tall, so the field hardly jumps when the chunk arrives (nobody knows the exact height before rendering: a fraction is taller than this reserve, a formula without one is shorter). - KaTeX CSS and fonts come with the same chunk. The chunk imports
katex/dist/katex.min.cssfrom thekatexpackage the consumer installs with the command above: the bundler (Next.js, Vite, webpack) emits the lazy chunk's CSS itself and takes the fonts from the same package. The consumer has no step, and a page without formulas gets neither CSS nor fonts.katex.renderdraws formulas into the DOM: KaTeX sets sizes through the elements'styleproperties, not as a string of attributes in HTML. KaTeX's output is HTML and MathML (htmlAndMathml): a screen reader reads the MathML, and the visual HTML is hidden from it. - View.
RichTextViewdraws formulas with an Island. The server puts the LaTeX source into the empty element, so without JS and before rendering it is visible as text; after mounting, the lazy Island loads KaTeX with its CSS and draws each formula fromdata-latexin place. The Island is mounted only for a Document that has formulas; without them nothing is loaded. There is no new prop and no server helper: formulas are drawn for any Document, and the View'stoolsis needed only so that the formula options (macros) match the Editor's. An unreadable formula stays as source with thedata-math-errorattribute.
| Key | What it does |
|---|---|
Shift+→ / Shift+← from a caret by an inline formula | Selects the formula |
Enter on a selected formula | Opens the edit Popover, does not split the paragraph |
Enter in the inline formula field | Applies |
Enter in the block formula field | Line break: a block formula is a column (aligned, matrices) |
Ctrl/⌘+Enter in the block formula field | Applies |
Escape in the Popover | Closes without changes, focus returns to the text |
Backspace / Delete on a selected formula | Deletes the formula |
Options. tool("mathematics", { macros, strict }) are the KaTeX options that do not affect the saved HTML. macros are custom macros: a name with a backslash and its substitution ({ "\\RR": "\\mathbb{R}" }). strict is what to do with non-LaTeX input (Unicode in math mode): "ignore" (the default), "warn" or "error"; the default is "ignore", not "warn" as in KaTeX, so the console does not chatter on every typed character. The options are read once, when the engine is created; a wrong value (from JS without types) is replaced by the default, with one console.error in development. The options are data, and RichTextView reads the same ones from its tools. The kit turns KaTeX's trust off (\href, \url and \includegraphics do not work) and limits sizes (\rule and spaces to 50 em at most), so a formula from someone else's Document cannot stretch the page. A macro defined with \gdef inside a formula works only in that formula: every render (the Editor's, its Popover's and RichTextView's) gets a fresh copy of macros, so the next formula does not see it and the Editor agrees with the View.
Markup is Tiptap's, with no classes and no style:
<span data-type="inline-math" data-latex="e^{i\pi} + 1 = 0"></span>
<div data-type="block-math" data-latex="\int_0^1 x^2\,dx"></div>The sanitizer lets span[data-type="inline-math"] and div[data-type="block-math"] with data-latex through: the pair is open only on these two tags and only with these values; data-latex on another tag or next to a foreign data-type is removed. A formula element is a leaf: rendered KaTeX markup from someone else's HTML is cut, and an element without data-latex loses its wrapper. A < is allowed in data-latex — it is LaTeX text, which DOMPurify escapes on output; in any other Schema attribute value < is still not allowed, and the boundary is pinned by a test (tests/editor-sanitize-mathematics.test.tsx). The tools set does not narrow the allow list: formulas pass even where the Tool is off. A space in the pairs DOMPurify cuts. DOMPurify 3 removes an attribute whose value contains ]>, -->, --!> or </style, </script and the like (the check runs before the kit's hooks), yet LaTeX legitimately contains such text: \left[0,1\right]>x. So the Editor writes data-latex with a space inside the pair (]> → ] >, --> → -- >, --!> → --! >, </ → < /), and the saved HTML passes the consumer's sanitizer whole; sanitizeRichText does the same to foreign HTML before DOMPurify's check. In math mode KaTeX does not render spaces, so the formula looks the same. The limit: inside \text{…} the space is visible (\text{</b>} shows < /b>).
Markdown is $…$ in a line and $$…$$ on lines of their own; the getMarkdown() → setMarkdown() round trip loses nothing.
Euler's identity: $e^{i\pi} + 1 = 0$.
$$
\int_0^1 x^2\,dx = \frac{1}{3}
$$The parsing rules are stricter than the Tiptap extension's, for the sake of money in text: there is no space after the opening $, none before the closing one, and no digit after the closing one, so "costs $5 or $6" stays text. An escaped sign (\$) inside a formula is part of the formula. A block formula needs lines of its own: $$a$$ and text on one line stays text. Pasting plain text with $…$ does not create a formula unless the text has other Markdown (the paste signs are headings, lists, code, **bold** and links, not dollars); setMarkdown() always reads formulas.
Without the Tool a formula from value, defaultValue, a JSON envelope and a paste is not lost: an Editor without mathematics reads it as text — an inline one as $…$, a block one as a $$…$$ paragraph. The author sees the LaTeX, on save it stays in the Document as plain text, and without the Tool getMarkdown() and setMarkdown() know no formulas ($…$ stays text). The server sanitizer lets formulas through with any tools set.
The strings are editor.mathInline ("Formula"), editor.mathBlock ("Block formula"), editor.mathLatex, editor.mathPreview, editor.mathEmpty, editor.mathInvalid, editor.mathInsert, editor.mathApply and editor.mathRemove in the message catalog (English and Russian); the icons are FormulaIcon and BlockFormulaIcon. The decision is ADR-0070 ("for the future": ADR-0048, there was no customer at release).
Footnotes
The footnotes Tool is footnotes: a reference with an automatic number in the text, and the footnotes' texts collected in a list at the end of the Document. It is in full and not in basic (a comment does not need footnotes). The decision is ADR-0076; the model is the one GFM, Plate and tiptap-footnotes use, not the Word and Google Docs one, where the text lives inside the reference and the list is only drawn: without JS a View has no such list, and Markdown could not be written one to one.
Terms: a Footnote holds the text, a Footnote reference is the number in the text, and the Footnote list is the block at the end (the words follow GFM; the Editor has no pages, so there is one word, "footnote", and Word's "endnote" is only a synonym for search).
- Inserting. The "Footnote" item of the Slash menu (
/footnote) and of the "…" menu of the Toolbar. The reference goes at the end of the selection (the selected text stays), the footnote goes to its place in the list, and the caret moves into the footnote's text. One edit, oneCtrl/⌘+Z. There is no shortcut:Ctrl/⌘+Alt+F, which is Word's, is Find and replace here, and typing[^is not caught. - Where a reference can stand. Anywhere there is running text: a paragraph, a heading, a list item, a table cell, an image caption, a quote, the title and the content of a Details Block, a Column layout column, a Wrapper. It cannot stand in a code block, in inline code, in a formula, and in a footnote (there are no nested footnotes). Where it cannot, the item is unavailable and
insert()returnsfalse. - One reference, one footnote. As in Word and Google Docs. A second reference to a footnote (a
[^x]used twice in Markdown, a duplicated paragraph, a paste) becomes its own footnote with a copy of the text, so no text is lost. - The kit keeps the list. A footnote exists while its reference does: deleting the reference deletes the footnote in the same edit, and
Ctrl/⌘+Zbrings back both. Moving text moves the footnotes and renumbers them. A footnote cannot be deleted from the list directly, and an empty footnote stays. A Document with no footnotes has no list. The list is always the last Block of the Document, and there is one of it: a Block that lands after the list (the caret in the gap below it, a paste) is put before it. - A footnote is one paragraph of text with Marks, links and hard breaks (
Shift+Enter), not Blocks. In the Editor it has no Block handle, no Slash menu and no "+". - Jumps. A click, or
Enteron a selected reference, puts the caret at the end of its footnote and scrolls to it. The number button of every footnote ("Back to text, footnote 2") andEnterin a footnote put the caret right after the reference. The jumps work inreadOnly(the Document does not change) and not in a disabled field.
| Key | In a footnote or on a reference |
|---|---|
Enter on a selected reference | To the end of its footnote |
Enter in a footnote | Back to the text, right after the reference |
Shift+Enter in a footnote | A hard break; it stays one footnote |
Backspace at the start of a footnote | Nothing: footnotes do not merge |
Delete at the end of a footnote | Nothing |
↑ / ↓ | Between the text and the list, as between Blocks |
- Atom text. The reference's text is its number in square brackets:
getText(),getSelectedText(), copying as text and themaxLengthcounter see[1](it weighs 3). The footnotes' texts count as ordinary text. The Table of contents does not show the reference's number in a heading. - Clipboard. Copy and cut carry the text of the footnote with the reference. A paste into the same or another Editor makes a new footnote with a new key and the same text; a cut and paste moves the footnote with its text. A footnote list in the clipboard is not pasted on its own (its footnotes already travel with their references), and a footnote whose reference is not there becomes a paragraph. An Editor without the Tool follows the general rule: the markup goes and the text stays.
- Incomplete HTML is repaired without losing text — from
value,defaultValue, HTML source, the JSON envelope and a paste. It is the kit's repair, not the author's edit: noonChangeand no history step for a loaded Document. A reference without a footnote gets an empty footnote. A footnote without a reference becomes a paragraph before the list. A list that is not at the end, or several lists, are collected into one at the end. A repeated key gives the second reference its own footnote with a copy of the text. The numbers are recomputed.
Markup. The key is eight lowercase letters and digits, random, and it does not change when the footnotes are renumbered; the number is computed at display time and the number in the HTML is a snapshot (the order of the references is the source of truth).
<p>
Text<sup data-footnote-ref="k3x9q2mf"
><a href="#fn-k3x9q2mf" id="fnref-k3x9q2mf" role="doc-noteref">1</a></sup
>
</p>
<section data-block="footnotes" role="doc-endnotes" aria-label="Footnotes">
<ol>
<li id="fn-k3x9q2mf">
<p>Footnote text</p>
<a href="#fnref-k3x9q2mf" role="doc-backlink">↩</a>
</li>
</ol>
</section>The roles are DPUB-ARIA. The list's name (aria-label) is the catalog's editor.footnotes in the language of the Editor's message catalog, written into the HTML like the rest of the Document's text. The list has a short rule above it, small secondary text and no visible heading.
The sanitizer. The Schema limits these attributes to the footnote markup: id only as fnref-<key> on the reference's anchor and fn-<key> on a footnote in the list; footnote href values as #fn-<key> on the reference's anchor and #fnref-<key> on the backlink, to the same key; role only as doc-noteref, doc-endnotes and doc-backlink in their places; aria-label only on the list. Footnote links work with either allowRelativeLinks setting. Ordinary fragments require the opt-in. A section without the footnotes marker, or not at the top level, loses its wrapper, and the reference is rebuilt to the form above whatever stood inside it. Because the keys differ, two Documents on one page (a feed of comments) do not collide, and the anchors work in the View, in an email and in a PDF made from the same HTML. The Editor's own DOM carries these ids with a prefix of its instance (rte<n>-fn-<key>), and the saved HTML does not: an Editor next to a RichTextView preview of the same HTML does not collide with it, and a link to #fn-<key> from outside lands on the View. Two Views of the same Document on one page do share their ids (the keys belong to the Document, not to the rendering), so a jump in the second goes to the first. The bare richTextSanitizeConfig() stays closed to them: only sanitizeRichText admits them, with its hooks. A sanitizer of your own must not copy id, role, aria-label or data-footnote-ref from RICH_TEXT_SCHEMA.attributes as plain attributes: it would admit any id on any tag. Leave them out and the footnotes keep their text without the jumps (see "Schema and security").
Markdown is GFM, with nothing lost in either direction.
Text[^1] and more[^2].
[^1]: The first note.
[^2]: The second note.getMarkdown() writes [^1] … [^n] and the definitions at the end; a hard break inside a footnote continues on an indented line. Reading: a label ([^note]) becomes a number; a reference with no definition stays the text [^note]; a definition with no reference becomes a paragraph at the end, with its label; a label used twice gives two footnotes; the second and later paragraphs of a definition (indented by four spaces) are joined to the first with a hard break, because a footnote is one paragraph. Plain text with a definition line is recognized as Markdown on paste. This adds nothing to "What is lost on export".
Without the Tool a Document with footnotes opened in an Editor does not lose its text: the reference's number stays as text (1, superscript if superscript is on), the footnotes' paragraphs follow it without the "↩" arrow (it would lead nowhere), and Markdown keeps [^1] and its definition as text.
Lazy. The Tool is a lazy built-in (ADR-0058, item 11.1): the nodes with their node view, the keys, the upkeep of the list, the jumps and the Markdown rules are a separate chunk that the Tool's Loader brings, and only to an Editor that has footnotes in tools (full does, basic does not). The Editor requests the chunk on its first render in the browser and shows the Skeleton until it arrives; the Skeleton draws the references and the list from value in the same markup the Editor saves, with the list named in the interface language. The Slash menu item, the Schema and the sanitizer are not in the chunk, so sanitizeRichText and RichTextView import nothing extra. Before Readiness handle.tool("footnotes") is null, like any Tool's commands, and a command that is called without the chunk returns false.
View. RichTextView shows the references and the list and follows the jumps as plain anchors: no JS, no Island. Run the Document through sanitizeRichText first (see "Schema and security").
State and commands. useRichTextToolState(ref, "footnotes") returns FootnotesToolState: footnotes is the list in order, each { number, text } (a hard break is a line break), and current is the number of the footnote the caret is in or whose reference is selected, otherwise null. handle.tool("footnotes") returns FootnotesToolCommands, and every command returns a boolean. The Tool has no options.
| Command | What it does |
|---|---|
insert() | The same as the "Footnote" item: a reference at the end of the selection, its footnote, the caret in it. One undo step |
goToFootnote(n) | The caret at the end of footnote n (from 1), scrolled into view; works in readOnly |
goToReference(n) | The caret right after the reference of footnote n, scrolled into view; works in readOnly |
insert() is false in readOnly, in a disabled field, in Source mode, where a reference cannot stand, and when the character limit would be exceeded. The jumps are false for a number that has no footnote, in a disabled field and in Source mode.
The strings are editor.footnote ("Footnote"), editor.footnotes (the list's name) and editor.footnoteBack (the number button's name) in the message catalog (English and Russian); the icon is FootnoteIcon. Stories: Inputs/RichTextEditor, Footnotes, FootnotesRenumbering, FootnotesMarkdown, FootnotesReadOnly and FootnotesRussian.
Date mention
The date Tool is a date inside a line of text: an inline Atom that is chosen in the kit's Calendar, stored in a form a machine can read, and shown in the author's format. The term is Date mention (as in Notion); the decision is ADR-0079. The Tool is in full and not in basic (in a comment, a date is typed as text). It is a plain name, and the format is set with a tool() entry:
import { RICH_TEXT_PRESETS, RichTextEditor, tool } from "@olddevs/ui/editor";
<RichTextEditor
tools={[...RICH_TEXT_PRESETS.full, tool("date", { format: { dateStyle: "long" } })]}
/>;- Inserting. The Slash menu item "Date" (
/date,/today, and the Russian words for them; "/" and "+", but not the Block handle's "Add ›", which means a new Block below, and a mention is inline) opens a Popover at the caret with theCalendarand the focus on today. Picking a day, by a click orEnter, inserts the mention at once, soEnteralone inserts today. The "Time" switch adds a time field (HH:MM); with it on, a picked day does not insert, and the "Insert" button orEnterin the time field does. A typed date in the text is never turned into a mention by itself. The insertion is one edit, undone with oneCtrl/⌘+Z. There is no Toolbar button. - Editing. A click on a mention or
Enteron a selected one opens the same Popover on its day: another day (without the time switch) changes the mention in one edit, "Remove time" turns a date with a time back into a date, "Delete date" deletes the mention,Escapecloses the Popover without changes. A mention is selected from the keyboard withShift+→orShift+←from a caret next to it (a plain arrow moves the caret across an inline atom, that is how ProseMirror works). The words are re-written in the current locale of the author at every edit. InreadOnlyand in a disabled field a mention is only shown, with no Popover. - The value is
YYYY-MM-DDorYYYY-MM-DDTHH:MM±HH:MM. A date has no zone and never shifts by a day. A date with a time carries the UTC offset of the author's browser at the moment of insertion (2026-10-18T15:00+03:00). The kit does not know time zones (ADR-0008): it writes the offset down and never recalculates it, so the reader's zone plays no part. - The text is written once, in the author's locale.
<time datetime="2026-10-18">Oct 18, 2026</time>: the Document holds the words the reader will see.RichTextViewshows them as is, so a page reads the same with no JS, in a letter and in a PDF, and never differs between the server and the browser. The words come from the locale ofUiProviderand theformatoption. A reader in another locale sees the author's format; the same date can be written differently by different authors (Oct 18, 2026and18 Oct 2026), whiledatetimeis one. - The atom text is the visible text.
getText(),getSelectedText(), copying as text and themaxLengthcounter see the words ("Oct 18, 2026" weighs 12). Find and replace (search) steps over a mention like over any other Atom and does not search its words. A mention is a plain Atom: the Bubble menu does not surround it. - Lazy in part. The Calendar, react-aria and the Popover are a separate chunk, loaded when a mention is inserted or edited for the first time. The node and the Slash menu item are in the start bundle and weigh little, so the Skeleton already shows a mention as a
timewith its words. - View. There is no Island and no new prop: a mention is a
timeelement with text, readable without JS. The View'stoolsis not needed for it.
Options. tool("date", { format }), where format is an Intl.DateTimeFormatOptions object for the date; by default it is the format of formatDate, { day: "2-digit", month: "short", year: "numeric" }. It is data, not a function, so the text of a Document does not depend on the screen's code. It is replaced as a whole, not merged with the default ({ dateStyle: "long" } next to day would be an error in Intl). For a date with a time the kit adds hours and minutes in the locale's own cycle (15:00 in German, 3:00 PM in English; timeStyle: "short" next to dateStyle). Only date fields are allowed: a value with hour, minute, second, timeStyle, timeZone, hourCycle and the like, or a combination Intl rejects, is a mistake and is replaced by the default, with one console.error in development. The options are read once, when the engine is created.
Command. ref.current?.tool("date")?.insert(value?) inserts a mention at the caret in one edit: value is a date YYYY-MM-DD or a date with a time YYYY-MM-DDTHH:MM±HH:MM, and its text is written by the current locale and format. Without value it opens the Popover, as the Slash menu item does. It returns true when the mention is inserted or the Popover is opened, and false for a read-only field, Source mode, or a value that is not a date in these two forms (a day that does not exist, a time without an offset, Z). There is no Tool state: a screen reads the dates from the HTML by time[datetime].
Markup:
<p>
Due <time datetime="2026-10-18">Oct 18, 2026</time>, meeting at
<time datetime="2026-10-18T15:00+03:00">Oct 18, 2026, 3:00 PM</time>.
</p>The sanitizer lets time[datetime] through when datetime is exactly YYYY-MM-DD or YYYY-MM-DDTHH:MM±HH:MM and a real calendar date (2026-02-29, month 13, hour 24 and Z instead of an offset are not): the same check as in the Editor. The element keeps only text; marks and tags inside it are cut. A time in any other form loses its wrapper and keeps its words. The tools set does not narrow the allow list.
Someone else's <time> (a value, a paste, HTML source) becomes a mention when datetime is in the two forms above, and its text is kept as it is: the words are not re-written until the author edits the mention. An empty element gets its text from format. A time with a period, a year, a week, a time without an offset or a Z, and one that wraps more than 120 characters (page markup, not a date) stays ordinary text, losslessly.
Without the Tool a mention from value, defaultValue, a JSON envelope and a paste is not lost: the Editor reads it as its words. The server sanitizer lets time[datetime] through with any tools set.
Markdown writes the text of a mention; the machine value is lost on export (a line in "What is lost on export"), and setMarkdown() reads the words as plain text. For a lossless copy use HTML or the JSON envelope.
The strings are editor.date ("Date"), editor.dateTime, editor.dateTimeField, editor.dateTimePlaceholder, editor.dateRemoveTime, editor.dateRemove, editor.dateInsert and editor.dateApply in the message catalog (English and Russian); the icon is DateMentionIcon. The decision is ADR-0079.
Video by link
The youtube and twitch Tools put video in the Document: a link to a video, recording or clip that the reader watches in a player on the page. It is one shared Block, video, and the tools set decides which services are allowed: only youtube, only twitch or both. The kit does not use the Youtube and Twitch extensions from Tiptap: link recognition and the player URL are the kit's own code modelled on them, so there is nothing to install, and the API follows them (ADR-0048: there was no requesting screen at release). The decision is ADR-0071. The Tools are in no Preset, neither full nor basic: the player pulls in a third-party service (CSP, privacy), and a kit update must not do that where nobody asked for it.
import { RICH_TEXT_PRESETS, RichTextEditor } from "@olddevs/ui/editor";
// Both services; YouTube only is "youtube", Twitch only is "twitch".
<RichTextEditor tools={[...RICH_TEXT_PRESETS.full, "youtube", "twitch"]} />;- The Document holds a link, not a player. The Block stores the service, the link to the video in canonical form and an ordinary link inside. The link is what a reader without JavaScript, Markdown and any other view sees. The Document holds neither the player URL nor the page domain: a Document saved in an admin screen works on a public site with another domain, and the player parameters change without rewriting Documents.
- The kit draws the player at display time, and by default it stands at once. In the Editor it is a node view, in
RichTextViewan Island of the kit that is mounted only if the HTML has a video block. In place of the video there is the service'siframewithloading="lazy", in the same 16:9 frame that the Skeleton and the server HTML reserve, so the height of the Block does not jump. An empty placeholder in place of a video would read as broken. There is no autoplay: the player is on the page but does not play. If the player URL cannot be built, the link to the video stays in its place. - The player URL is built at display time. YouTube is always
https://www.youtube-nocookie.com/embed/<id>(a playlist is/embed/videoseries?list=<id>, a start time is?start=). Twitch ishttps://player.twitch.tv/?video=<id>&parent=<page domain>&autoplay=false(a channel ischannel=, a clip ishttps://clips.twitch.tv/embed?clip=<name>&parent=…);parentis thelocation.hostnameof the current page. Theiframegets atitle("YouTube video", "Twitch video"),loading="lazy", anallowwithfullscreen,autoplayandpicture-in-picture, andreferrerpolicy="strict-origin-when-cross-origin"(YouTube does not start the player without a referrer).nocookiecannot be turned off andparentcannot be configured. - The
autoloadoption.tool("youtube", { autoload: false })andtool("twitch", { autoload: false })bring back the earlier behavior, a placeholder with the service name, the link and a "Play" button: not a single request goes to the service until the reader presses it (in the Editor too, so that editing does not pull in the player). The button is named "Play YouTube video" (the visible label is contained in the name in full); after the click theiframestarts playing at once (autoplay=1for YouTube,autoplay=truefor Twitch) and focus moves into the player. The default istrue. The options type isVideoToolOptions, one for both Tools. A Tool's option applies only to the blocks of its own service:youtubewithautoload: falseandtwitchwith no entry give a placeholder for YouTube videos and an immediate player for Twitch. The option does not change the Document: it still holds only a link,iframenever enters the Document, and the sanitizer does not change.RichTextViewreads the same option from itstools. A wrong value (from JS without types) is replaced with the default, with a singleconsole.errorin development. - Privacy. Unless
autoloadis turned off, the reader's browser contacts YouTube and Twitch when the page opens: once the frame scrolls near the screen (loading="lazy"), not on a click. YouTube goes throughyoutube-nocookie.com, but the request is made all the same. For screens where this matters (consent for third-party services, internal systems with a data policy), setautoload: false: then nothing goes to the service until the reader presses "Play". - One "Video" item inserts it. In the Slash menu ("+",
/video,/youtube,/twitch) and in "Add ›" of the Block handle: a popover with a link field, and the service is detected from the URL among the enabled Tools. A link of another service and a link of a service that is not intoolsare the same error in the field ("Enter a link to a YouTube / Twitch video", naming only the enabled services). The Block lands in place of an empty paragraph or after the current Block, and there is always a paragraph with the caret below it; the insertion is one undo step. - A bare link in an empty paragraph. A video link pasted from the clipboard into an empty paragraph becomes a Block at once; one typed alone in a paragraph (as text or as a link) does on
Enter. A link among words, in a non-empty paragraph, and a link of a disabled service stay plain text or a link. - The Block is an Atom. Arrow keys (from a neighboring paragraph) and a click on the frame select it, and the Block handle moves, duplicates and deletes it, like an image;
BackspaceandDeleteon the selected Block remove it together with the player. A click and keys inside theiframebelong to the player, not the Editor: the field hands it focus, and the Block cannot be selected by clicking the player itself. Keyboard focus leaves the player the usual way, as from anyiframe:TabandShift+Tab. Its Atom text is the link (it goes into themaxLengthcounter,getTextand copying). The Block stands wherever an image Block does: at the top level, in a Column layout column, in a Wrapper, in a quote and in the content of a Details Block. - A lazy Tool. The node, the node view with the player and the link field live in a separate chunk (ADR-0058, item 11.1) and load only if
toolshasyoutubeortwitch; until Readiness the Skeleton shows the Block as its link.
Which links are read
The canonical form is what goes into the Document, whatever form the author pasted. http and a link without a scheme are accepted on input, but in the Document the URL is always https.
| Service | Read | In the Document |
|---|---|---|
| YouTube | youtube.com/watch?v=, youtu.be/, /shorts/, /live/, /embed/; m. and music.; a time t=, start= | https://www.youtube.com/watch?v=<id> (a time is &t=<seconds>) |
| YouTube | youtube.com/playlist?list=, /embed/videoseries?list= | https://www.youtube.com/playlist?list=<id> |
| Twitch | twitch.tv/videos/<number>, a time ?t=1h2m3s | https://www.twitch.tv/videos/<number> |
| Twitch | clips.twitch.tv/<name>, twitch.tv/<channel>/clip/<name> | https://clips.twitch.tv/<name> |
| Twitch | twitch.tv/<channel> — the channel's live stream | https://www.twitch.tv/<channel> |
Another host, youtube.com.evil.example, a login or a port in the URL, and service sections of Twitch (/directory, /videos without a number…) give no video.
The HTML of the Tiptap extensions (div[data-youtube-video] iframe, div[data-twitch-video] iframe, a lone iframe with a player URL) turns into the same Block when pasted into the Editor and in value: the player URL (youtube-nocookie.com/embed/…, player.twitch.tv/?video=…, clips.twitch.tv/embed?clip=…) is translated back into the link to the video, and the player parameters and parent are dropped. An iframe never gets into the Document.
Markup and sanitizing
<div
data-block="video"
data-provider="youtube"
data-src="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
>
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" rel="noopener noreferrer"
>https://www.youtube.com/watch?v=dQw4w9WgXcQ</a
>
</div>The sanitizer is not loosened: iframe is always stripped, also with youtube or twitch in tools (ADR-0058, items 2.3 and 12.6 stay as they are). The new rules are ordinary ones: div[data-block="video"], data-provider is youtube or twitch, data-src is the canonical https link to a video of that service (https://www.youtube.com/watch?v=<id> with an optional &t=, https://www.youtube.com/playlist?list=<id>, https://www.twitch.tv/videos/<number>, https://www.twitch.tv/<channel>, https://clips.twitch.tv/<name>), that is, exactly what the Editor writes; the link inside follows the kit's link policy. A readable but non-canonical form (youtu.be, a host without www), a player URL such as youtube-nocookie.com and a foreign host do not pass: a Block with them loses its wrapper, and the link stays. So does a Block without a valid service and a video Block inside a video Block. Names of kit Tools do not narrow the allowlist: the Block passes sanitizing with any tools, and the decision "show a player or not" is made by the Editor or RichTextView. The bare richTextSanitizeConfig() does not let data-src through; only sanitizeRichText does, after checking the URL.
Without the Tool a Block becomes its link instead of vanishing. A video Block from value, defaultValue, a JSON envelope and a paste, when its service is off (neither youtube nor twitch in tools, or only the other one is on), unfolds into a paragraph with the link: with the link Mark, or the URL as text if there is none. The same value with the right Tool shows a player.
Video in Markdown
Video in Markdown is a link: getMarkdown() writes the canonical URL on a line of its own between blank lines.
Watch the recording:
https://www.youtube.com/watch?v=dQw4w9WgXcQ
The rest follows.setMarkdown() reads such a line (a bare URL or a URL in <…>) back as a Block if the service is on: the round trip through the Handle loses nothing, and the URL comes back in canonical form. Markdown counts everything else as no player and leaves a link: a URL among words, [text](address), a URL in a list item or a quote, a URL of a disabled service. Markdown creates a player only at the top level of the Document.
The View and CSP
RichTextView does not sanitize HTML (see "Schema and security") and, with no engine, shows the Block as its link, the server HTML. The Island is mounted only if the HTML has data-block="video": it finds the blocks whose service and URL pass isVideoSrc and puts the player in their place; the others stay a link. Without JavaScript a reader sees the link. The Island is a separate chunk, so a page without video does not pay for it. Pass tools for video only if the Editor has autoload: false: tool("youtube", { autoload: false }) in the View's tools brings back the "Play" placeholder there; with no entry the player stands at once, as in the Editor by default.
The page that shows the player has to allow it an iframe: add this line to the Content-Security-Policy (only the hosts of the services you need)
frame-src https://www.youtube-nocookie.com https://player.twitch.tv https://clips.twitch.tv;Without it the browser blocks the iframe (at once, or after the click with autoload: false): the frame stays empty, and the Document and the link do not suffer. The frame-src permission is needed whatever the value of autoload.
The strings are editor.video ("Video"), editor.videoLink, editor.videoInsert, editor.videoNotFound, editor.videoPlay ("Play"), editor.videoPlayLabel and editor.videoPlayer in the message catalog (English and Russian); the service names are brand names and are not translated. The icons are VideoIcon for the Insert item and PlayIcon for the placeholder's button.
Emoji
The emoji Tool (present in full, not in basic) is the "Emoji" button on the Toolbar right after "Table ▾", before undo and redo. It opens a kit popover (Popover) with a grid of a curated set: "Favorites" (20) and six categories of ten — "Smileys", "Gestures", "Animals", "Food", "Activities", "Travel". There is a single grid; the categories follow one another, each under its label. There is no full Unicode set, search, "recent", skin tones or :shortcodes:, and there never will be: this is a quick path to familiar symbols, not an OS emoji picker.
An emoji is plain text. It has no Block or Mark of its own, like clearFormatting: the Schema, the sanitizer and Markdown do not change, and the inserted symbol ends up in the output HTML, into RichTextView and into getMarkdown like any other text. To turn the button off, remove emoji from tools; the whole grid goes with it.
- Insertion. Click a cell or press
Enteror Space in the grid. With an empty selection the emoji is inserted at the caret position, with a non-empty one at the end of the selection, without erasing it. The caret is placed right after the emoji, the popover closes, and focus returns to the Document. One undo reverts the insertion. maxLength. Insertion is an ordinary edit, so the limit stops it: if the limit is reached, the emoji is not inserted; if less room remains than the symbol takes (most emoji take two UTF-16 code units, aslengthcounts them), it is not inserted either: an emoji is never inserted partially.- Nowhere to insert (an image or table cells are selected) — the button is
aria-disabled, and the popover does not open. - The set's content is data in one server-safe module without React or DOM: categories in order, and for each emoji the symbol and a name key. One emoji may appear in two categories ("Favorites" repeats part of the others). There is no emoji library.
Keyboard. When the popover opens, focus is on the grid, as in the table size grid; aria-activedescendant identifies the current cell.
| Key | Action |
|---|---|
← / → | Previous / next emoji, across a category boundary |
↑ / ↓ | A row up / down (ten emoji per row) |
Home / End | To the start / end of the row; with Ctrl, first / last |
Enter, Space | Insert the current emoji |
Escape | Close the popover and return focus to the Document |
Inside Dialog and Drawer, you can choose an emoji with both the mouse and the keyboard, and Escape closes only the popover: Radix layers share one stack (ADR-0041). The strings are editor.emoji (the button's name), editor.emojiGrid (the grid's name), editor.emojiCategory (category labels) and editor.emojiName (the name of each emoji) — in the message catalog, in English and Russian.
Typography
The typography Tool is replacements while typing: a straight " becomes a quotation mark, -- a dash, ... an ellipsis, -> an arrow, (c) the © sign. The engine is the Typography extension from Tiptap, and the API follows it (ADR-0048); the kit adds quotes by the language of the message catalog and nested guillemets. The Tool is in no Preset, neither full nor basic: it changes the text being typed, and a kit update must not do that where nobody asked for it. Switch it on by name or with a tool() entry:
import { RICH_TEXT_PRESETS, RichTextEditor, tool } from "@olddevs/ui/editor";
<RichTextEditor tools={[...RICH_TEXT_PRESETS.full, "typography"]} />;
// A Russian Document under an English interface: the quote set is explicit,
// and sizes like 3x3 must not turn into 3×3.
<RichTextEditor
tools={[...RICH_TEXT_PRESETS.full, tool("typography", { quotes: "ru", multiplication: false })]}
/>;- Input rules only. The Schema, the sanitizer and Markdown do not change:
valueandgetHTML()get plain Unicode characters with no new tags or attributes, andRichTextViewshows them like any other text. The Tool has no Toolbar button, no Slash menu item, no state and no commands. - It works while typing. A rule fires on a character the author typed on the keyboard. Pasted text,
value,defaultValue,setMarkdown()andinsertText()are left as they are. - It does not fire inside code. In the
codeMark and in a code Block,--,"and(c)stay as typed: code does not break. - Every replacement is undone in one step.
Backspaceright after a replacement brings the typed characters back (--instead of—).Ctrl/⌘+Zright after a replacement does the same: the replacement is a separate history step, the first press brings the typed characters back, the second removes them. After the next character,Backspaceis ordinary.
Rules
All the Tiptap rules are on. Each has an option of the same name: false switches the rule off, a string replaces the character.
| Typed | Result | Option |
|---|---|---|
-- | — | emDash |
... | … | ellipsis |
<-, -> | ←, → | leftArrow, rightArrow |
(c), (tm) | ©, ™ | copyright, trademark |
(sm), (r) | ℠, ® | servicemark, registeredTrademark |
1/2 , 1/4 , 3/4 | ½, ¼, ¾ | oneHalf, oneQuarter, threeQuarters (with a space after) |
+/-, != | ±, ≠ | plusMinus, notEqual |
<<, >> | «, » | laquo, raquo |
2x3, 2*3 | 2×3 | multiplication |
^2, ^3 | ², ³ | superscriptTwo, superscriptThree |
" | a quote | openDoubleQuote, closeDoubleQuote and the quotes set |
' | ‘, ’ | openSingleQuote, closeSingleQuote |
The multiplication rule fires on any 2x3 and 2*3, so "a 3x3 grid" becomes "a 3×3 grid": if the Document is full of sizes, set multiplication: false. An empty string and an invalid value are replaced by the default, with one console.error per Tool in development. Options are read once, when the engine is created.
Quotes by the catalog language
The quotes option picks the set for ": "auto" (default), "ru" or "en". "auto" takes the set from the message catalog, from the editor.typographyQuotes string: "ru" in @olddevs/ui/locales/ru, "en" in the English fallback and in any catalog without that string. The set is read when the quote is typed, so a catalog change on a mounted field is picked up without a remount. An explicit set is for a Document whose language differs from the interface.
| Set | " at the start of a Block, after a space or a bracket | " after a word |
|---|---|---|
en | “ | ” |
ru | « (inside «…» — „) | » (inside „…“ — “) |
In the Russian set quotes nest by what is open in the current Block before the caret: typing "He said "hi"" gives «He said „hi“». An opening quote inside «…» gives „, a closing quote inside „…“ gives “, and a closing quote inside «…» with nothing nested closes the guillemet. A closing quote with nothing open is just ». Russian typography has no third level: an opening quote inside „…“ gives « again. Open quotes are counted within one Block.
A single ' does not depend on the set and follows the Tiptap rules in both: after a space or at the start of a Block it is ‘, otherwise ’ (which is also the apostrophe: it's → it’s).
An explicit openDoubleQuote or closeDoubleQuote string beats the quotes set and switches nesting off: the quotes go as a pair, the opening one after a space, the start of a Block or a bracket and the closing one everywhere else, and the one of the pair that is not given comes from the set. false switches the rule off; with both off, " stays straight.
The message catalog string is editor.typographyQuotes: not text for the screen but the language of the quote set, "ru" or "en". The decision is ADR-0048 ("for the future": there was no requesting customer at release).
Paste from Office
Word, Excel, Google Docs, Google Sheets and SharePoint do not put plain HTML on the clipboard. A Word list arrives as paragraphs with "1." typed into the text, a highlight as a background style, the bold header of an Excel table as a class rule in a <style> block. The Schema keeps only what it knows, so without help a list from Word becomes paragraphs with frozen numbers, and a marker disappears. The pasteCleanup Tool (in full and basic) turns this HTML into markup the Schema reads, before the Schema reads it: it can only change what the Schema then sees, never widen it.
// In both Presets already; an exact list keeps it by name.
<RichTextEditor
tools={["history", "bold", "bulletList", "orderedList", "highlight", "pasteCleanup"]}
/>- Picture side and width. A picture that names a side comes in aligned, from Word or from a web page:
align="left|right"on theimgor thefigure,float: left|rightin thestyle, the WordPress classesalignleftandalignrighton theimgor thefigure(its theme keeps the float in a stylesheet the clipboard does not carry;aligncenterandalignnonegive no side), and Word'smso-wrap-style: none(in line with the text) gives no side. This step has a sign of its own, not an application: a picture withfloat,align,mso-wrap-styleor one of those two classes in its tag. The width in the source goes to the nearest preset that leaves room for text when it is a percentage (width: 40%gives 33%,100%gives 75%), and a size in pixels, points or ems gives 50%, because the width of the target Document is unknown. A picture with no side comes in at its own size, as before. The result is the Image alignment of theimageTool, so without the Tool the picture is dropped, as any picture is. - Only office sources. Except for the picture side, the cleanup runs when the clipboard HTML carries the marks of its application: the Office namespaces and
Mso*classes of Word, theExcel.SheetProgId, thedocs-internal-guid-…wrapper of Google Docs, thedata-sheets-*attributes of Google Sheets, thedata-ccp-propsandOutlineElementmarkup of SharePoint and Word Online. A copy from a web page, an IDE or another editor comes in exactly as before: a code-highlighting background from a docs site does not become a marker. - Word lists become
ulandolagain, with their nesting and withstartwhen a numbered list does not begin at 1. The markers Word types into the text ("1.", "a.", "•") are removed. The Schema keeps no numbering kind, so a nested list shows letters and Roman numerals by the kit's list styles, not by the source. Lists from a Word that writes nomso-list(Word 2007 on Windows through Firefox) are recognized by the list paragraph class and the marker. - Office junk is removed: Word bookmarks and every link inside the copied document (a table of contents copied from Word keeps its text),
<o:p>, Office-only conditional comments, a<br>between two Blocks. Safari'sApple-converted-spacespans become plain spaces. External links and empty paragraphs the author made stay. - Horizontal lines. A top or bottom paragraph border (Word, and Google Docs for a document that came from Word) becomes a divider (
hr) when thehorizontalRuleTool is on: an empty bordered paragraph is replaced by it, a paragraph with text keeps the text and gets the divider on the bordered side. Left and right borders (a box or a bar) and table borders are not lines. A line inserted in Google Docs ("Insert → Horizontal line") becomes one divider too, without the empty paragraphs Docs wraps it in. A row of---or___typed as text stays text. - SharePoint and Word Online. A paragraph with
role="heading"andaria-levelbecomes a heading of that level (the heading Tools then decide which levels stay, as for any pasted heading: H5 and H6 become paragraphs); flat lists, where every item is a separate list with its level in an attribute, are rebuilt into nested lists, also across the chunks Word for the web splits a long copy into; end-of-paragraph markers and the empty boundaries a table of contents leaves behind are removed. Word for the web does not put paragraph borders on the clipboard, so a bordered paragraph gives no divider there. - Excel cells. From the class rules of a cell only the meaning is taken: bold, italic, underline, strikethrough, horizontal alignment and the fill. Fonts, sizes, borders, number formats and text colors are not carried over. Safari drops the class rules of an Excel copy but writes their values into each cell, and the result is the same.
- Table column widths (OLDSUI-310). The widths a table from Word, Excel, Google Docs or Google Sheets carries become the column widths of the table, as shares of its width rounded to steps of 5% (see "Tables", "Column widths"): Excel and Sheets write a
colper column (points and pixels, the exact points win), Docs writescol width, and Word writeswidthon the cells, which are read from a row without merged cells. A hidden column (width: 0), a column with no width, a single column and a table of more than 20 columns are left to the content, as before the step. The pixels, points andstylethemselves are not kept. - Background → marker. A background on text, on a table cell or on a paragraph becomes the
highlightMark with the palette marker of the nearest hue. A low-saturation background givesgray; white, black and transparent backgrounds are dropped. A text color is not mapped to the palette (see the "Color, highlight and alignment" section). - Without the target Tool the result of a step is cut by the Schema, as before: with
highlightoff the text comes without a marker, withhorizontalRuleoff there is no divider, withoutheading1an H1 becomes a paragraph. - If a step fails, the paste goes in without cleanup, exactly as the Editor pasted before the Tool existed, and a development build writes a warning to the console. The author does not see a message. The steps load in their own chunk as soon as the Editor mounts, so they do not weigh on the start of the field; a paste in the first moments after mount, before the chunk has arrived, also goes in without cleanup.
- What is not done. Zero-margin paragraphs of Google Docs are not merged into line breaks (they are the author's paragraphs), the formatting of the first pasted paragraph is not carried onto an empty paragraph, and Word equations come in as Word renders them. Images in a paste follow the "Images" section.
What was checked. The behavior is tested on real clipboard captures: Word for Mac, Word for the web, Excel for Mac, Google Docs and Google Sheets copied into Chrome, Safari and Firefox; Word and Excel (Microsoft 365) on Windows copied into Chrome and Firefox; Word 2007 on Windows through Firefox; Google Docs through Chromium. Cases the captures do not hold (a SharePoint list that starts at another number, heading levels 5 and 6) are covered by synthetic HTML in the same shape. Edge and Opera are Chromium, like Chrome, and were not captured separately. Report a paste that comes out wrong, with the clipboard HTML.
Without pasteCleanup in tools (an exact list without it) the Editor pastes office HTML the way it did before: through the Schema alone.
Source mode
The source Tool is in the full preset and available by name in tools. Its toggle sits right after "+" on the fixed Toolbar. It opens a monospace field with the Document's source. Press the toggle again to return to the visual Editor. The Keyboard shortcuts popover stays available while editing the source.
<RichTextEditor preset="full" value={html} onChange={setHtml} /> // the "HTML" button is already on the Toolbar
<RichTextEditor tools={["bold", "italic", "link", "history", "source"]} /> // or explicitly in tools
<RichTextEditor sourceFormat="markdown" value={html} onChange={setHtml} />sourceFormat is read on mount. Remount the Editor to change it. With the default "html", the button says "HTML" and the field displays formatted HTML. Each top-level Block starts on its own line and nested Blocks are indented by two spaces. Text whitespace and the content of pre are preserved. With "markdown", the button says "Markdown" and the field displays the same Markdown as getMarkdown(). An empty Document opens as an empty field in both formats.
The Editor's HTML value contract applies to value, string defaultValue, onChange and the hidden name field in either format (ADR-0050 and ADR-0061). Use the Handle's setMarkdown() and getMarkdown() to load and read Markdown.
Look. The field is always dark, using the kit's colors, not the code block's syntax highlighting palette: in dark and dim, the theme's deepest background with its text and border; in light and on the Paper (paper), the same values of the dark theme (the variables --rte-source-background, --rte-source-foreground, --rte-source-border, which can be overridden). On the Paper (paper), the light sheet stays under the dark field: the sheet's contents change, not the sheet itself. The corner radius is as for code, the font is monospace 13 px, as in CodeView; the padding is as for the Document area. On entry the height is at least the Document's height, then the field grows with its content and can be stretched vertically by hand. With maxHeight or resizable the field lives in the same scroll area as the Document (see the "Field height" section). Text selection in the field also comes from the dark theme for the current accent (--selection-dark), with the field's light text: the light theme's light selection was unreadable on the dark field.
Applying the draft. HTML follows the same parsing as value. Markdown follows the same parsing as setMarkdown(), including the enabled Tools and the Markdown format limits. Applying an edited Markdown draft can discard formatting that Markdown cannot represent, such as Block alignment and the width and caption of an image. Either format applies through the Schema in one edit, and one Ctrl/⌘+Z in the Document undoes it. The Editor applies a draft on the following actions.
- leaving the mode with the Source toggle;
- focus leaving the field (
blur) — the field's text is not reformatted: the author continues with their own text, and the fresh formatting is visible at the next entry; - form submission (
submit, in the capture phase — before the consumer'sonSubmit) and buildingnew FormData(form); ref.getHTML(),ref.getMarkdown(),ref.getText()andref.getJSON(), and the insertionsref.insertHTML()andref.insertText();- switching to
readOnlyand the button disappearing (atoolbarchange) — the mode closes; - unmounting the Editor, including when Escape in the Source field closes the surrounding
Dialog.
Opening and closing the mode without editing preserves the original Document, including formatting absent from its Markdown representation. A draft that parses to the same Document also leaves the history and onChange untouched. Applying a change updates the hidden name field and calls onChange with the new HTML immediately, regardless of changeDelay.
The required check uses the parsed draft on every change because the browser validates a form before the submit event. A draft that parses to an empty Document blocks form.requestSubmit(). A horizontal rule (--- in Markdown or <hr> in HTML) counts as content. The Editor waits until applying to parse drafts in fields without required.
Programmatic replacements. A new value, setMarkdown(), setJSON() or clear() replaces the Document and updates the field in its current format. When the parent feeds back the last emitted value, the draft stays as typed.
maxLengthdoes not truncate the text when it is applied — likesetMarkdown: the counter shows the excess. In the mode the counter reflects the last applied state.disabledand<fieldset disabled>disable the Source field and toggle while keeping the mode open.- What is off in the mode. The other Toolbar buttons and menus are
aria-disabled(they stay in the arrow-key order but do not fire); there is no Block handle, Bubble menu or/Slash menu. The engine stays mounted and hidden: the edit history is preserved. - Where the button is absent. The button is absent from the floating Toolbar and the Bubble menu (
toolbar="floating","bubble"): they appear above a selection in the Document, and in this mode there is no Document; withtoolbar="none"and inreadOnlythere is no Toolbar. On a touch screen the Toolbar is always fixed — so the mode exists there. - SSR. The mode is internal state, not a prop; it always starts visual, so the server output is the same as without the
sourceTool.
The message catalog defines the toggle and field labels with editor.source and editor.sourceField for HTML and editor.sourceMarkdown and editor.sourceMarkdownField for Markdown.