Olddevs UI4.14.0
ReferenceRichTextEditor

Toolbar and keyboard

Toolbar

The fixed Toolbar sits above the field and sticks on scroll below the app header: the offset is the CSS variable --topbar-h, published by the kit's TopBar (ADR-0016, ADR-0019). Without a header the variable does not exist, and the Toolbar sticks to the viewport edge. The sticky positioning works inside the field's frame: the Toolbar leaves together with the field when the field is scrolled out entirely. By default the Editor has no scroll of its own — it grows with the Document; a height limit and a height handle are enabled by maxHeight and resizable (see the "Field height" section).

  • toolbar="fixed" (default) — the Toolbar above the field, and above a non-empty selection also the Bubble menu, the same pill as in toolbar="bubble" (turn it off with selectionMenu={false}; it does not exist on a touch screen); toolbar="floating" — the Toolbar above a non-empty selection (below); toolbar="bubble" — the Bubble menu instead of the Toolbar, a compact pill above the selection (below); toolbar="none" — no Toolbar, formatting is available only from the keyboard.

  • In readOnly there is no Toolbar. In disabled the Toolbar is visible, but all buttons are disabled and do not take focus.

  • Keyboard shortcuts popover is the last Toolbar button, with a keyboard icon, at the right edge; only the fixed Toolbar has it (there is none above the selection or in readOnly, and with toolbar="none" there is no Toolbar at all). Details are in the "Keyboard shortcuts popover" section.

  • Contents and order — one compact row; the kit sets the order, not tools. Groups are separated by a divider:

    GroupButtons and menus in order
    Whole Block"+" Slash menu · HTML · "¶" Block type · Alignment ▾
    Marksbold · italic · highlight · "…" (other Marks, code block, quote, clear formatting)
    ListsLists ▾
    Insertlink · image · Table ▾ · emoji
    Historyundo · redo

    At the right edge are Find (the search Tool) and the Keyboard shortcuts popover. "Invisible characters" (the invisibleCharacters Tool) has no button of its own: it is the last checkbox section of the "…" menu of the fixed Toolbar, and "…" is rendered for it alone as well. A button or menu without its Tool enabled is not rendered, and a group without buttons disappears together with its divider: in basic the row is bold, italic, "…" | Lists ▾ | link | undo, redo | find and the Keyboard shortcuts popover at the right edge (a "¶" with only "Text" is not rendered). The floating Toolbar (toolbar="floating") has the same contents and order, only without the "Invisible characters" item, Find and the Keyboard shortcuts popover; the Bubble menu (toolbar="bubble") has its own short set — no alignment, with its own "Lists ▾" and "Color" (below).

  • There are no separate buttons on the Toolbar for alignment, lists, quote, horizontal rule and code block: alignment and lists are menus, quote is a checkbox in "…", the rule is a Slash menu item ("+" and /), the code block is an item in "…" (they are used rarely). When the Toolbar is narrower than its content it wraps onto the next row instead of running past the edge — by whole groups: "Undo · Redo" never split across rows, the divider sits at the end of a group, and a wrapped row starts with a button. The full row in a 640px column takes two rows: "Invisible characters", search and the Keyboard shortcuts popover go to the second one, to the right edge.

The "¶" menu — line type

The "¶" button opens the line type menu under the caret: Text (Ctrl/⌘+Alt+0), Heading 1 (only with heading1, Ctrl/⌘+Alt+1), Heading 2–4 (Ctrl/⌘+Alt+2…4). The shortcut is shown on every item: ⌘, ⌥, ⇧ joined with a plus on Mac and iOS (⌘+⌥+2), Ctrl, Alt, Shift elsewhere.

  • There are no lists or quote in "¶" (the owner's decision): lists have the "Lists ▾" menu (on the Toolbar and in the Bubble menu), quote has the "Quote" checkbox in "…". They stay in the Block handle's "Format ›" and in the Slash menu ("/", "Turn into"): there a Block is turned into anything, rather than a line type being chosen.
  • The items come from the enabled Tools (heading, heading1) plus the "¶" items of custom Tools; "Text" is always there as long as there is at least one other item. Without headings there is no "¶" button — that is the case in basic.
  • The line under the caret decides: a paragraph in a list item or in a quote is "Text", a heading in a quote is its level. This type is checked, and it also appears in the button's accessible name ("Block type: Heading 2") and on the icon: the heading level (H1–H4), the icon of a custom Tool's item, and "¶" for text (before that the icon was always "¶", ADR-0054). In a code block the button says "Code block", the icon is "¶", and no item is checked: the code block is an item of "…".
  • A choice changes the line type in place and keeps the text: a heading in a quote stays in the quote. Where the Schema does not allow this type for the line (a heading first in a list item), the Slash menu's "Turn into" takes over: the lists and quotes around the line are removed, the type is set. It is one edit, and Ctrl/⌘+Z undoes it whole. Choosing the current type changes nothing. Focus returns to the Document.

The "…" menu — More formatting

The "…" button (tooltip and name — "More formatting", editor.moreFormatting) comes right after the "Highlight" button (in the Bubble menu, after "Color") and opens the menu of the remaining formatting: Inline code (Ctrl/⌘+E), Underline (Ctrl/⌘+U), Strikethrough (Ctrl/⌘+Shift+S), Superscript (Ctrl/⌘+.), Subscript (Ctrl/⌘+,), Language › (a submenu), Code block (Ctrl/⌘+Alt+C), Quote (Ctrl/⌘+Shift+B), Footnote (no shortcut), Clear formatting (Ctrl/⌘+\). There are no colors in "…" — they have their own buttons (below). The shortcuts shown on the items come from the same table as the Toolbar tooltips and the Keyboard shortcuts popover. There are no shortcuts borrowed from familiar editors (⌘H, ⌘L, ⌘⇧M): macOS and the browser intercept them, and the label would promise something that does not fire.

  • The items come from the enabled Tools (code, underline, strike, superscript, subscript, language, codeBlock, blockquote, footnotes, clearFormatting). Without any of them there is no "…" button; with one, the menu has a single item. In basic, "…" has inline code, strikethrough and quote. A Mark that has a button in the row of the Toolbar or the Bubble menu is not repeated in that menu's "…": the Bubble menu has no underline in "…" because it is in the row.
  • Marks are items with a check (menuitemcheckbox, aria-checked): the Marks of the selection or caret are checked. A choice sets or removes the Mark in one edit (Ctrl/⌘+Z undoes it whole), closes the menu and returns focus to the Document. An item that does not apply here (a Mark inside a code block) is unavailable.
  • The code block is a separate section right after the Marks (before that it was a Toolbar button between "HTML" and "¶"). It is a Block, not a Mark, so it comes after a divider, but it is the same checkbox item with a shortcut: all the toggles of "…" are listed one after another, and "Clear formatting" comes after them.
  • The code block item is checked when the caret is in a code block; choosing it turns the selection's Blocks into a code block or back into text — in one edit, like Ctrl/⌘+Alt+C. It is unavailable where the engine does not allow a code block.
  • The same item is in the "…" menu of the Bubble menu: the Bubble menu had no code block button, and that is where turning selected lines into code is convenient.
  • Quote is a checkbox next to the code block (before that it was a "¶" item): checked when the caret is in a quote; choosing it wraps the selection's Blocks in a quote or removes it — in one edit, like Ctrl/⌘+Shift+B. Unavailable where the engine does not allow a quote. Present only if blockquote is enabled.
  • Footnote is an action, not a toggle, in a section of its own between the quote and "Clear formatting", and without a shortcut (Ctrl/⌘+Alt+F is Find and replace here). Choosing it inserts a footnote reference at the end of the selection, makes its footnote and moves the caret into the footnote's text — in one edit, as the Slash menu item does. It is unavailable where a reference cannot stand: in a code block, in inline code and in a footnote. Present only if footnotes is enabled; with that Tool alone the "…" button still appears.
  • "Language ›" is a submenu (the language Tool) in a section of its own after the Marks: radio items for the languages of the option, with "Remove language mark" below them. See the "Text part language" section.
  • On a narrow screen the submenu goes under the item (narrower than 640px): there is no room at the side on a phone, so the submenu of the Block handle "⋮" and the "Table" menu (together with the size grid) open under their item on top of the parent menu. On a wide screen they open at the side, as before.
  • There are no separate buttons on the Toolbar for inline code, underline, strikethrough, superscript, subscript, code block and clearing: "…" replaces them. The menu is built in the shared formatting menu module (MoreFormatMenu in FormatMenus.tsx) — the same "…" appears in the Bubble menu too.
  • The row of frequently used Marks is shared by the Toolbar and the Bubble menu (rowMarks.ts): on the Toolbar it is bold and italic, in the Bubble menu also underline.
  • The "view" section at the end holds the display modes of the Document, not formatting: Invisible characters (fixed Toolbar only), Focus mode (Ctrl/⌘+Shift+J), Fullscreen (Ctrl/⌘+Shift+F) and, only while the field is in fullscreen, Full width, each a checkbox item; the two modes show their shortcut, invisible characters and Full width have none. "Focus mode" and "Fullscreen" are in the "…" menu of the Bubble menu too: with toolbar="bubble" it is the only menu there is. The floating Toolbar has no view section.

The "Highlight" and "Color" buttons

Color is chosen by eye, from swatches, in one click — as in Tiptap's Notion-like template. Before that, text color and highlight were submenus of "…", and the "Highlight" button applied yellow in one click.

Which button goes where (the owner's decision — no duplicates): on the Toolbar (fixed and floating) there is only "Highlight", in the Bubble menu there is only "Color", which also has the highlight grid. Without the color Tool, the Bubble menu has "Highlight" — otherwise there would be no way to set a highlight there. The trade-off of this decision: text color is chosen only from the Bubble menu. Buttons cannot set it where there is no Bubble menu: with selectionMenu={false}, with toolbar="floating" and on a touch screen (there the fixed Toolbar replaces the Bubble menu). The Handle and engine commands remain.

  • "Highlight" (the highlight Tool, tooltip — editor.highlightToggle): a click opens a row of nine highlights by hue — gray, brown, orange, yellow, green, blue, purple, pink, red — and "Remove highlight" (a crossed-out circle with a tooltip, editor.highlightRemove). The button's name states the current highlight ("Highlight: Pink", "Highlight: Custom #ffe066", "Highlight: None"), so it is audible without opening the popover; while the selection has a highlight, the button looks pressed. A click on the button itself no longer applies yellow: yellow is set by clicking its swatch.
  • "Color" (the color Tool, editor.color): the letter "A" in the current text color and an arrow. The popover has two grids: "Text color" (editor.textColorSection: six tones, a swatch with the letter "A" in that color, and "Remove color" as the last cell, editor.colorRemove) and "Highlight color" (editor.highlightSection: the same nine highlights, and "Remove highlight" as the last cell). The highlight grid is there only if highlight is enabled too. Removal is a crossed-out circle with a tooltip at the end of the grid, as in "Highlight", not a white swatch at the start: that one looked like one more color and was checked when there is no color. With no color, nothing in the grid is checked, and focus on open is on the first swatch. Next to each grid's heading is "Custom color…": it opens a ColorPicker popover (see the "Custom color" section below).
  • Roles — as in a WAI-ARIA Authoring Practices (APG) menu, not a radio group: the popover is a menu, the grids are a group with a heading, the swatches and "Custom color…" are menuitemradio with aria-checked (the current one is marked with a ring around the swatch), "Remove color" and "Remove highlight" are menuitem. In a radio group an arrow key would choose right away and close the popover; here the arrow keys only move between swatches: ← → — the neighboring swatch, ↑ ↓ — the same column in the row above or below (five per row), Home and End — the first and the last; Enter, Space and click apply.
  • Focus. On open, it is on the checked color (or the first one). A choice applies the color in one edit (Ctrl/⌘+Z undoes it whole), closes the popover and returns focus to the Document, to the previous selection. Escape closes only the popover and returns focus to the button — in both Dialog and Drawer the dialog or drawer stays open (ADR-0041).
  • In the Bubble menu the button itself holds the popover: while it is open, the button has aria-expanded="true" and the Bubble menu does not hide. In Source mode and on inline code the buttons are unavailable (aria-disabled) and do not open the popover. In basic neither button exists: neither color nor highlight is part of it.

The "Alignment" and "Lists" menus

Both are menus from the same shared module as "¶" and "…" (AlignMenu and ListMenu in FormatMenus.tsx): radio items (menuitemradio) with the current value checked and shortcut labels from the shared table. The button's icon is the icon of the current value, its name is the value in words; a choice returns focus to the Document and is undone by a single Ctrl/⌘+Z.

  • Alignment ▾ (the align Tool): Align left (Ctrl/⌘+Shift+L), Align center (Ctrl/⌘+Shift+E), Align right (Ctrl/⌘+Shift+R). On an image selected as a whole the same three keys align the image instead of the text (see "Images"). The button's name is "Alignment: Align center"; for a Block without data-align, "Align left" is checked, and so it is for a selection with mixed alignment. Choosing the checked item changes nothing and puts no empty edit into history; choosing "Align left" restores the default. There is no justify — the decision is below, in "Color, highlight and alignment" (WCAG 1.4.8).
  • Lists ▾ (any of bulletList, orderedList, taskList): Bulleted list (Ctrl/⌘+Shift+8), Numbered list (Ctrl/⌘+Shift+7), Checklist (Ctrl/⌘+Shift+9) — the same kinds as in "Format ›" of the Block handle, only from the enabled Tools. The kind of the nearest list around the caret is checked (also in a quote inside an item), the button's name is "List: numbered", and outside a list it is "Lists" with the generic list icon. Choosing another kind works the same way as the Slash menu's "Turn into": the Block leaves the list and the quote and is wrapped again in one edit. Choosing the checked kind again removes the list, like the old toggle button. A menu with a single enabled kind stays a menu.
  • Without the align Tool there is no alignment menu; without any list kind there is no "Lists" menu. In basic there is "Lists" with two items and no alignment.

Floating Toolbar

toolbar="floating" shows the same Toolbar — the same buttons in the same order — above the selected text. The Toolbar hides on an empty selection (just a caret), and then it is gone from the screen, from the Tab order and from the screen reader. It shows with a short delay after the selection stops changing: while the mouse drags the selection, the Toolbar does not flicker. Tiptap's BubbleMenu (floating-ui) computes the position and the flip at the screen edge.

  • A touch screen gets the fixed Toolbar. If the primary pointer is a finger (pointer: coarse: phone, tablet), the Editor renders the fixed Toolbar instead of the floating one: on iOS and Android the system "Copy / Paste" menu appears above the selection, and a floating Toolbar would compete with it for the same space. The media query is tracked live — a tablet with a mouse attached gets the floating one.
  • The Toolbar lives in the Editor's DOM, not in a portal: it travels with the text in any scroll container (window, drawer, card). So an ancestor with overflow: hidden clips it at its edge — do not put the Editor in such a container right against the top, or use toolbar="fixed".
  • The layer is the OVERLAY_LAYER.popover step, like popovers. The Toolbar does not take part in the Escape stack: there is nothing to close in it, and Escape stays with the dialog or drawer around the Editor.

Bubble menu: selectionMenu and toolbar="bubble"

By default the Bubble menu also appears on top of the fixed Toolbar (toolbar="fixed", the selectionMenu prop, true by default): the Toolbar at the top is for everything; the Bubble menu keeps the mouse near the text. In that case Alt+F10 moves focus to the Toolbar. toolbar="bubble" puts the Bubble menu in place of the Toolbar — a compact pill above the selected text, as in Notion and Medium. It sits on an inverse surface: dark in the light theme, light in dark and dim — so it blends neither with the text nor with the field under it.

  • The set is defined by the kit and is not configurable: "¶" (line type, the same menu as on the Toolbar) · Lists ▾ (the same menu as on the Toolbar) · bold · italic · underline · Color ▾ (both grids — text and highlight; without color, "Highlight") · "…" (the other Marks and the code block — the same menu as on the Toolbar, but without underline: it is in the row here) · link (the same popover as Ctrl/⌘+K) · emoji (the same grid). A button of a disabled Tool is not rendered: basic has no emoji, and with tools={["italic", "link"]} two buttons remain. There is no undo, redo, Keyboard shortcuts popover or rare Marks in the Bubble menu — it is about the selected text.
  • Bold, italic and underline are toggles with aria-pressed; the tooltip names the shortcut from the same table as the Toolbar's, and the button announces it with aria-keyshortcuts.
  • Display and position are as in the floating Toolbar: the Bubble menu appears when the selection has settled, and hides on an empty selection, on a selected image (it has its own panel) and when focus has left the Editor. At the edge of the viewport or a scroll container it flips below the selection and shifts inward. In readOnly there is no Bubble menu.
  • A touch screen gets the fixed Toolbar, for the same reason as with floating: the system selection menu of iOS and Android appears in the same place.
  • Menus and popovers opened from the Bubble menu use the regular popover surface, not the inverse one: "¶", "…", the link field and the emoji grid look the same as when opened from the Toolbar. Escape in an open menu closes only the menu and returns focus to its button in the Bubble menu; inside Dialog and Drawer the dialog or drawer stays open.
  • The Bubble menu lives in the Editor's DOM, like the floating Toolbar: it travels with the text in a scroll container, and an ancestor with overflow: hidden clips it at its edge. The layer is OVERLAY_LAYER.popover.
  • The Bubble menu's name is editor.selectionToolbar ("Selection formatting" in English, "Форматирование выделения" in Russian): the screen reader tells it apart from the Toolbar.
  • The colors are inverse surface tokens --surface-inverse, --surface-inverse-hover, --surface-inverse-pressed, --text-on-inverse and the focus outline --accent-on-inverse (palette.md). On the Paper (surface="paper") the Bubble menu stays in the app theme, like the Toolbar.

Glass on overlays

Everything the Editor shows above the Document sits on Glass — a semi-transparent background of its surface that blurs what is behind it: the floating Toolbar and the image panel, the Bubble menu, menu lists ("¶", "…", alignment, lists, table, Slash menu, Block handle, code block language), popovers (link, image, custom color, emoji, Keyboard shortcuts popover, popovers of the buttons, Insert items and Block actions of a custom Tool) and the Text card. The background is 82% of the surface token in color-mix; the blur is 14px, as in toasts (ADR-0010); tooltips keep their own 85% and 10px.

  • The color is the token of its own surface: the Toolbar and popovers use --bg-1, menu lists use --surface-elevated, the Bubble menu uses --surface-inverse. The theme changes the token, and the Glass changes with it.
  • A solid background under prefers-reduced-transparency: reduce and prefers-contrast: more: under a semi-transparent background, text contrast depends on what lies beneath the menu, and a user who asked the system to remove transparency or raise contrast gets the old solid surface without blur.
  • A solid background on iOS: in Safari on iOS 27 the menu's Glass background was not rendered at all, and the items ended up on top of the Document text. So on iOS (the condition @supports (-webkit-touch-callout: none), which only WebKit on iOS understands) the Glass is replaced with a solid surface without blur; desktop Safari, Chrome and Firefox keep the Glass.
  • The Editor only. The kit's Menu and Popover outside the Editor stay solid: the Editor passes the Glass to them as a class, and the public API did not change.

Keyboard: Alt+F10

Alt+F10 (⌥F10 on Mac) from the Document moves focus to the first button of the Toolbar — fixed, floating or the Bubble menu; the key shows the floating Toolbar and the Bubble menu at once, without waiting for the delay. The shortcut is the same as in CKEditor and TinyMCE: APG has none of its own, and one shortcut for all editors is easier to remember. Tab is not an option here — in the Document it indents a list item.

  • Inside the Toolbar, the arrow keys, Home and End work as usual. A button that has fired returns focus to the Document, to the same selection; if nothing was pressed, Shift+Tab moves focus back: the floating Toolbar sits in the DOM right after the Document.
  • The Toolbar does not intercept Escape: in a dialog or drawer it closes it (see "Accessibility and forms").
  • On an empty selection of the floating Toolbar and the Bubble menu, and with toolbar="none", the key does nothing and passes on.
  • The Toolbar announces the shortcut with aria-keyshortcuts="Alt+F10" — the screen reader names it on the Toolbar itself.
  • From the Source field, Alt+F10 moves focus to the Source toggle ("HTML" or "Markdown"). Enter on it switches back to visual mode. See Source mode.
  • An open Text card takes priority over the Toolbar: Alt+F10 moves focus into it, Escape returns the caret; while the Text card is hidden or closed, the key moves focus to the Toolbar (see the "Text card" section).
  • With the caret in a code block, Alt+F10 moves focus first to that Block's language button, then to "Copy", then to the Toolbar (see the "Code block" section). Likewise, on a selected image the key moves focus to its panel.

Keyboard shortcuts popover

The button with a keyboard icon ("Keyboard shortcuts") is the last one on the fixed Toolbar, at the right edge. It opens the kit's Popover with a "command — shortcut" list that is read-only: the rows are not clickable, this is not a command palette.

  • There is no button on a phone. On a touch screen without hover (@media (hover: none) and (pointer: coarse) — a phone, a tablet without a trackpad) there are no shortcuts, so the Keyboard shortcuts button is hidden, and menu items ("¶", "…", table, Slash menu, Block handle) do not show shortcut labels. A tablet with a trackpad and a laptop with a touch screen keep the tooltips.
  • The markup is a table with the column headers "Command" and "Shortcut"; the shortcut is the kit's Kbd (<kbd>). A screen reader reads a row as a "command — shortcut" pair.
  • Custom buttons. The shortcut of a custom Tool's button (the shortcut field) goes into the Keyboard shortcuts popover as a separate group without a heading after the kit's groups, in tools order; the label uses the UiProvider locale. Keyboard shortcuts bound by a custom Tool's Extensions do not appear here — see the "Custom Tool's button" section.
  • Group order: selection (the first ⌘A selects the Block's text, the second the whole Document; with the blockSelection Tool also Esc — select the Block — and Shift+↑/↓ — extend the selection), undo and redo, Block commands (duplicate, up, down, handle menu), clear formatting, Marks (bold, italic, strikethrough, underline, inline code, superscript and subscript), Block type (text, headings, quote, code block), lists and item indent (⌘] and ⌘), alignment, link, search (Ctrl/⌘+F, Ctrl/⌘+Alt+F), view (Ctrl/⌘+Shift+F — fullscreen, Ctrl/⌘+Shift+J — focus mode), moving to the Toolbar (Alt+F10).
  • The set depends on tools. A row exists only for the command of an enabled Tool: basic has no headings, underline, superscript and subscript, alignment, task list or code block, and the item indent is there with any of the three lists. Heading 1 only with heading and heading1 together. Commands without a Tool of their own are always there: selection, duplicating and reordering a Block, the Block handle menu, Alt+F10.
  • Custom Tools. The shortcuts of their Insert items and Block actions (the shortcut field) form a group without a heading after the kit's groups, one group per Tool, in tools order; a row's label is the UI contribution's label in the current locale.
  • Width follows the content: the popover is as wide as the longest row, with no empty gap between the command and the shortcut; the screen edge limits it, and a long list scrolls.
  • Labels. Keys are joined with a plus on all platforms: ⌘+⇧+Z on Apple and Ctrl+Shift+Z elsewhere. The macOS run-together form (⌘⌥⇧↑) reads as one word in a long list. The Apple detection is the same as ProseMirror's, that is, the one the engine uses to decide which key is mod. Kbd renders the symbols ⌘ ⌥ ⇧ ⌃ in a proportional font: a monospace stack has no ⇧, and the fallback glyph comes out thin.
  • One command table is the source of truth. The tooltips and aria-keyshortcuts of Toolbar buttons, the labels in the Slash menu and the Keyboard shortcuts popover read shortcuts from one table (src/editor/core/shortcuts.ts: command id, Tool, keyboard shortcut, a label from the message catalog). The extensions bind the keyboard shortcuts, and the table labels them; so that a label never promises what is not there, tests/rich-text-editor-shortcuts.test.tsx presses every shortcut of the table in a live Editor and checks the result.
  • Closing. Escape and a click outside close the popover and return focus to the button (if the click itself put focus on a field or button, it is not taken away). Inside Dialog and Drawer, Escape closes only the Keyboard shortcuts popover, not the dialog or drawer ([ADR-0041 (ADR-0041)).
  • Not shown: in readOnly, with toolbar="none", above the selection in toolbar="floating" and in the Bubble menu (toolbar="bubble"); on a touch screen they are replaced by the fixed Toolbar, but the Keyboard shortcuts button is hidden there by the rule at the start of the section: on a phone and on a tablet without a trackpad it is absent.

Message catalog strings: editor.shortcuts (the name of the button and popover), shortcutsCommand and shortcutsKeys (column headers), and the labels of commands without a button of their own — selectBlock, selectDocument, duplicateBlock, moveBlockUp, moveBlockDown, blockActions, indentListItem, outdentListItem, focusToolbar, and with the Block selection Tool blockSelectionSelect and blockSelectionExtend.

Block handle "⋮"

A Block with the caret in it gets a "⋮" button to the left of its first line — the Block handle ("Block actions"). Hovering the mouse does not show the handle (the owner's decision): it does not flicker at every paragraph under the pointer. It is visible while focus is in the Document, on the handle itself or in its menu; in readOnly it does not exist, nor does it in a disabled field. A Document being edited has a left margin for the handle (it is wider by the same amount on the Paper), and the handle does not cover the text.

A click or Ctrl/⌘+/ from the Document opens a menu — the kit's Menu:

ItemAction
Add ›A submenu with the Insert items of the enabled Tools (paragraph, headings, lists, quote, code block, horizontal rule, table, image). A choice puts a new Block under the current one and the caret in it; without insertMenu the item is absent
Format ›A submenu with the Block types (Text, Heading 1–4, Quote, three kinds of lists): turns the Block into the chosen type; the current type is checked. A table, an image and a rule cannot be turned — the item is visible but unavailable (aria-disabled)
SelectWith the blockSelection Tool: selects the Blocks whole (see the "Block selection" section). It is the way in on a touch screen; it is not shown when Blocks are already selected. It stands above Up, leading the items that act on the Block whole
Up, DownSwap the Block with its neighbor; for the first and last Block the matching item is unavailable
DuplicateA copy under the Block, the caret goes into the copy
DeleteA red item (the danger tone of a Menu item). Deletes the Block, the caret goes into the Block above (below for the first one); if it is the only Block, it is replaced with an empty paragraph
Wrap in ›Over a group or a selected Block: puts the Blocks into one Wrapper, one quote or one collapsible Block (see "A group of Blocks" below); only the containers whose Tools are enabled
  • The Block as a whole. The handle sits at a Document Block: a paragraph, a heading, a whole list, a task list, a quote, a code block, a table, an image, a horizontal rule. With the caret in a list's second item, the handle is at the list's first line, and the menu actions apply to the whole list; "Format › Heading 2" turns all its items into headings. A selection across several Blocks keeps the handle at the first Block it touches, and the menu acts on all of them (see "A group of Blocks" below).
  • Shortcut labels only when the shortcut does the same thing. For a top-level paragraph or heading the items are labeled: ⌥+⇧+↑/↓, ⌘+⇧+D, the "¶" shortcuts in "Format ›". In a list item ⌥⇧↑ moves the item, not the list, so there are no labels; in a table ⌥⇧↑/↓ belong to rows, so "Up" and "Down" have no label, while ⌘⇧D copies the whole table, so "Duplicate" has one. "Add ›" has no labels: the shortcuts change the current Block, and the item puts a new one.
  • One edit to undo, and focus after the action is in the Document. Escape closes the submenu, then the menu, and returns focus to the Document; inside Dialog and Drawer the dialog or drawer does not close (ADR-0041).
  • Keyboard. The handle is outside the Tab order (in the Document Tab indents a list item); Ctrl/⌘+/ moves focus to it — like "Block actions" in Notion, and browsers and systems leave this shortcut free in a field. The row is in the Keyboard shortcuts popover; the handle has aria-keyshortcuts.
  • Tool actions. Custom Block actions (blockActions of a Tool description, like "Unwrap" of the Wrapper) appear as a separate section before "Delete": only for Blocks whose names are listed in blocks, and filtered by a visibility predicate; run receives the Block's position. Custom Insert items go into "Add ›" and "Format ›" (see the "Custom Tool" section).
  • There is no dragging by the handle (the owner's decision).
  • Column layout (see the "Column layout" section). A column is a container of Blocks, like the Document: a Block in a column has its own handle at the column's left edge, and its actions do not leave the column. In "Add ›" the Column layout is a submenu of six variants; a Block in a column has the "Layout ›" item (a variant of its Column layout), and for a Column layout selected as a whole, "Format ›" holds these six variants with the current one checked.
  • Wrapper (see the "Wrapper" section). A Wrapper is also a container of Blocks: a Block in it has its own handle at the Wrapper's left edge, and its actions do not leave it. The items "Tone ›" and "Unwrap" are available for a Block directly in a Wrapper and for the Wrapper itself selected as a whole (Backspace on the Block under it); for the Wrapper, "Up", "Down", "Duplicate" and "Delete" apply to the Wrapper together with its content, and "Format ›" is unavailable — it has no Block type.
  • Placement. The handle lives in the Editor's DOM and travels with the text in any scroll container, in Dialog and Drawer; the sticky Toolbar and popovers cover it. The position is recomputed on every edit and on resize.

A group of Blocks

When a text selection touches several Blocks (or Block selection holds one or more), the handle stands at the first of them and its menu acts on the whole row (ADR-0077). This is in the core: every Editor has it, with or without the blockSelection Tool.

  • What a Block is. With the text selection it is the same whole Block as for one: a list touched at one item is the whole list. With Block selection it is the unit (the Block of its container; in a list, the item), exactly what is highlighted.
  • Items. Format ›, Wrap in ›, Up, Down, Duplicate, Delete (and Select, if the Tool is on). There is no "Add ›", no "Layout ›" or "Tone ›", and no Block actions of Tools: those are written for one Block. A selected single Block has the whole single-Block menu plus "Wrap in ›".
  • Delete removes all the Blocks (the container is never left empty: the last Block yields to an empty paragraph), Duplicate copies the row under itself, Up and Down swap the row with the neighbour.
  • Format › turns every text Block of the row into the chosen type. A table, an image, a rule and the containers (Wrapper, Column layout, Details) stay as they are; the item is unavailable when nothing in the row can change. A list is one list: neighbouring Blocks turned into a list become one list of that many items, and a Block that stays ends the run, so a table in the middle makes two lists. "Text" breaks a list into paragraphs. A quote is one quote in the same way: neighbouring text Blocks become one quote of that many paragraphs. The current type is checked when all text Blocks share it.
  • Wrap in › puts all the Blocks into one container: a Wrapper, a quote or a collapsible block (the caret goes into its empty title, and it is open). The Schema decides where it is allowed: a Wrapper does not hold a Wrapper or a Column layout and stands only in the Document or a column, nothing goes into a list, so there the item is unavailable. Items of Tools that are off are absent.
  • One edit. Every action of a group is one transaction: one Ctrl/⌘+Z undoes it. After it focus is in the Document, and the screen reader hears the result through the Field notice (status): "Blocks deleted: 3", "Blocks wrapped: 3".

Message catalog strings: editor.blockActions (the name of the handle, menu and Keyboard shortcuts popover row), blockAdd, blockFormat, blockMoveUp, blockMoveDown, blockDuplicate, blockDelete, and for a group blockSelect, blockWrap and the results blocksDeleted, blocksDuplicated, blocksMoved, blocksChanged, blocksWrapped. Icons — MoreVerticalIcon, AddIcon, ParagraphIcon, ArrowUpIcon, ArrowDownIcon, DuplicateIcon, DeleteIcon, BlockSelectIcon, WrapperIcon, QuoteIcon, DetailsIcon from @olddevs/ui/icons.

Keyboard: Block commands

Block commands work as in Notion and Google Docs. They have no markup of their own, so they exist with any tools set (except clear formatting — it comes with the clearFormatting Tool). Every command is one edit: Ctrl/⌘+Z undoes it whole. In readOnly and disabled, editing commands do not change the Document and hand the shortcut back to the browser; ⌘A works there too — it does not change the Document, only the selection.

Shortcut (Mac / others)Action
⌘⇧D / Ctrl+Shift+DDuplicate a Block: the copy lands right under it, and the caret goes into the copy at the same place
⌥⇧↑ / Alt+Shift+↑Move the Block up
⌥⇧↓ / Alt+Shift+↓Move the Block down
⌘/ / Ctrl+/Open the Block handle menu (see the "Block handle "⋮"" section)
⌘A / Ctrl+AThe first press selects the current Block's text, the second the whole Document. If the Block's text is already selected or the Block is empty, the first press selects the Document at once
⌘] and ⌘[ / Ctrl+] and [Indent and outdent a list or task list item — the same as Tab and Shift+Tab
⌘\ / Ctrl+\Clear the selection's formatting — the same as the "Clear formatting" item of the "…" menu (clearFormatting)
  • What a Block is. A top-level Block of the Document — a paragraph, a heading, a quote, a code block, an image, a whole table, a horizontal rule, a whole list. In a list a Block is an item: the copy lands in the same list, and an item moves among its neighbors and never leaves the list. A selection across several Blocks is duplicated and moved whole.
  • A group of Blocks. The same keys act on all the Blocks of a Block selection (see the "Block selection" section), and the handle's menu acts on all the Blocks a text selection touches.
  • At the edge of the Document or a list, moving does nothing: there is no neighbor. The shortcut is still swallowed — otherwise on Mac it would extend the selection.
  • In a table ⌥⇧↑/↓ does not work: a selection inside one table moves neither the table nor its rows, and Alt+↓ still adds a row (see the "Tables" section). A table moves when the selection starts or ends outside it. Duplicating from a cell copies the whole table.
  • ⌘] and ⌘ outside a list do nothing and hand the shortcut back to the browser (in Chrome on Mac these are "Forward" and "Back"): the Schema has no paragraph indent. In a list item the shortcut is swallowed even when there is nowhere to indent.
  • Why not the shortcuts of familiar editors. On Mac ⌘⇧↑/↓ means "select to the start or end of the document", and ⌘⇧A in Chrome is tab search: you cannot take them from the system. Moving is ⌥⇧↑/↓, as in VS Code.
  • The "Clear formatting" item of the "…" menu is labeled ⌘\ (Ctrl+\ elsewhere).

Block selection

The blockSelection Tool (in full, not in basic) selects Blocks whole, as in Notion (ADR-0077): the Blocks are highlighted, there is no caret and no text selection, and the keys and the clipboard act on the Blocks. The term is Block selection; it is not a text selection and not the selection of an Atom (an image, a formula). The Tool has no Block and no markup: the Schema, the sanitizer, Markdown, JSON and RichTextView do not change, and the saved HTML shows no trace of the mode. The Block handle over a row of Blocks (the previous section) is in every Editor; the mode is this Tool.

<RichTextEditor /> {/* Esc in the text selects the Block */}
<RichTextEditor preset="basic" /> {/* no Block selection: a comment field in a Dialog closes on one Esc */}
<RichTextEditor tools={RICH_TEXT_PRESETS.full.filter((name) => name !== "blockSelection")} />
  • The unit is the Block of its container, the same rule as Ctrl/⌘+Shift+D and Alt+Shift+↑/↓: a child of the Document, of a column, of a Wrapper or of the content of a Details Block. In a list the unit is the item; a table is one Block as a whole, even when a cell holds a list. A row is always neighbours of one container; a set from different places is several rows (below).
  • The way in. Esc in the text selects the current Block (a text selection across Blocks gives all of them; Esc in a table cell gives the whole table). Shift+↑/↓ grows the selection by a neighbour, and the same keys shrink it back; the anchor stays where the selection started. Shift+click on another Block draws the selection to it. The "Select" item of the Block handle's menu does the same as Esc; on a touch screen, after "Select" a tap on another Block draws the selection to it, as Shift+click does, while a tap in the text of a selected Block puts the caret there. There is no frame drawn by the mouse and no dragging of the selected Blocks (the owner's decision, as with the handle).
  • A set from different places (ADR-0083). In the mode, Cmd+click on a Mac (Ctrl+click elsewhere, the modifier ProseMirror selects a node with) adds a Block from anywhere in the Document to the set, and takes a selected Block out of it; the last Block taken out returns the caret. In the text the same click is the engine's own: the set starts with Esc or "Select". A Block and its container are never in the set together: a click on a Block inside a selected container puts that Block in its place. The last clicked Block is the anchor of the active row: Shift+click and Shift+↑/↓ change that row only and keep the rest of the set, and ↑/↓ collapse the set onto one Block. Neighbouring Blocks of the set join into one row, and a set of one row behaves exactly as above. A set of several rows takes Backspace, Delete, the clipboard copy and cut, and "Format ›" (each row on its own: two rows of paragraphs become two lists); moving, duplicating, "Wrap in ›" and Ctrl/⌘+V do nothing over it, since there is no one row to act on, and their handle menu items are unavailable. There is no keyboard way to a set with gaps, and a touch screen, without a modifier, stays with one row.
  • The borders go up a level. Shift+↑/↓ past the edge of a column, a Wrapper, the content of a Details Block or a list selects the container whole and goes on at its level; through two columns it is the whole Column layout, the row Ctrl/⌘+Shift+D takes. Shift+click in another container lifts the row the same way.
  • ↑/↓ moves a single selection to the neighbour; a group collapses onto the Block just beyond its edge. At the edge of the container the selection stays.
  • Esc goes one level at a time. The first Esc in the text selects the Block and is taken: it does not close a Dialog or a Drawer around the field. The second Esc ends the selection (the caret goes to the end of the first Block, as with Enter) and goes on, so it closes the layer (ADR-0041). In a Dialog this is two Esc instead of one, like any nested layer; a screen that does not want it removes the Tool from tools. A layer of the Editor that owns Esc (the Slash menu, a Text card, a popover, a menu) keeps it: Esc closes that layer, and nothing is selected.
  • Keys inside the selection. Backspace and Delete remove the Blocks (one edit, the caret goes to the neighbour); Ctrl/⌘+Shift+D and Alt+Shift+↑/↓ duplicate and move the group; Ctrl/⌘+/ opens the handle's menu; Enter returns the caret to the end of the first Block; a printable character is ignored (one key must not erase a section); a click into the text is an ordinary caret.
  • The clipboard. Ctrl/⌘+C and Ctrl/⌘+X put whole Blocks (HTML and text), Ctrl/⌘+V replaces the selected Blocks with the pasted content. From a set with gaps the copy takes the Blocks in document order, a list item inside a list of its own kind; a paste over such a set inserts nothing and the screen reader hears why. Ctrl/⌘+Z brings the Blocks back selected; the selection also follows an edit made around it.
  • The look. The Blocks are painted whole on --rte-selection with the Document's radius, the same role as selected table cells and selected text, in every theme and on the Paper. The root gets data-block-selection while it lasts, and the native selection paint and the caret are hidden. The "⋮" stands at the first Block of the group.
  • Announcements. The Field notice (status) tells the screen reader "Blocks selected: 3" on every change of the count, "Block selection cleared", and the result of an action: "Blocks deleted: 3", "Blocks duplicated", "Blocks moved", "Blocks changed", "Blocks wrapped", "Blocks copied", "Blocks cut", "Blocks replaced", and "Cannot paste over blocks in different places". An identical text twice in a row is not announced again.
  • readOnly and disabled. In readOnly, Esc, Shift+↑/↓ and Shift+click work, and of the actions only Ctrl/⌘+C (there is no handle). A read-only Document has no tabindex of its own, so with the Tool on it gets tabindex="0": it is in the Tab order and a click into it takes focus, which is what the keys need (this is the accessibility cost of the Tool in a read-only field; RichTextView is unaffected). A disabled field does nothing and stays out of the Tab order.
  • Bubble menu. The text pill does not show over selected Blocks.
  • Lazy. The keys, the highlighting and the announcements are a separate chunk that the Tool's Loader brings (ADR-0058, item 11.1), only to an Editor that names blockSelection in tools; basic does not load it. In full it arrives with the code block and the table chunks, and until then the field is a Skeleton: no Esc handling, no "⋮" menu, and the Tool's commands return false. The BlockSelection class and the Block handle over a row of Blocks are in the Editor's start chunk, because every Editor reads them.

Block selection state and commands

useRichTextToolState(ref, "blockSelection") reads the state and ref.current?.tool("blockSelection") calls the commands. The general rules for both are in the "Handle (ref) and a custom toolbar outside the field" section.

State fieldMeaning
countHow many Blocks are selected, every row of a set included; 0 means a caret or a text selection, no Block selection
CommandWhat it does
selectCurrent()Select the Blocks under the selection, the same as Esc, without moving focus. Works in readOnly. false in the Source mode, in a disabled field and where the selection is in no Block (a gap cursor between Blocks)
clear()End the selection and put the caret at the end of the first Block, like the second Esc (without letting the key through). false when no Blocks are selected

There are no options. Message catalog strings: editor.blockSelect, blockSelectionSelect, blockSelectionExtend and the announcements blocksSelected, blockSelectionCleared, blocksCopied, blocksCut, blocksReplaced, blocksPasteScattered (and the results of the group actions listed in the previous section). Icon — BlockSelectIcon from @olddevs/ui/icons.

Slash menu

A list of Blocks that opens on / in the text and on the "+" button, the first button on the Toolbar (the insertMenu Tool, included in full). It has two sections of items:

  • "Insert" — a new Block after the current one: code block, horizontal rule, table, image, Column layout (two columns; the other variants are in the Block handle), Wrapper. An image opens the URL popover and lands in place of a prepared empty paragraph. If the caret is in an empty paragraph, the Block takes its place; otherwise it goes as a new Block right after the current top-level Block, not inside a quote or a list; with an image selected, after it. The current Block's text is not touched. The Block handle's "Add ›" inserts a Block the same way, except that it always adds a new Block below, even from an empty paragraph.
  • "Footnote" (footnotes, in the "Insert" section) is the one inline item: it does not make a Block but puts a reference at the caret, in the text, so the menu opens no paragraph below for it, and the Block handle's "Add ›" does not offer it. /foot and /footnote find it (and its Russian name, in any interface language). There is no Slash menu inside a footnote (a line of running text), and the "+" button is unavailable there; see the "Footnotes" section.
  • "Turn into" — change the current Block's type, keeping the text: paragraph, H2–H4 (and H1 with heading1), bulleted list, numbered list, task list, quote, code block. The Block first leaves its list or quote, then becomes the chosen type: "Turn a list item into a heading" gives a heading outside the list.

An item has an icon, a label and a shortcut hint: a Markdown shortcut (##, -, >, ---), and where there is none, a keyboard shortcut. Items exist only for enabled Tools: a disabled codeBlock disappears from both sections, and a section without items is not shown. A menu without items other than the paragraph does not appear at all.

/ opens the menu at the start of a Block or after a space. Inside a word (and/or), in a code block and in inline code, / is an ordinary character. The menu appears at the caret; what is typed after "/" filters the items — by the label in the interface language, by the English label and by short names (h2, ul, hr, todo), ignoring case and the difference between е and ё. If nothing is found, the "Nothing found" row appears. A space ends the command: the menu closes, and what was typed stays as text.

KeyThe list on / (focus in the field)
LettersFilter: the query after /
↓ / ↑Next / previous item, wrapping around
EnterApply the item; /query is removed in the same edit, undone with one Ctrl/⌘+Z
EscapeClose, keeping what was typed; the menu does not reopen on the same /
SpaceEnd the command: the menu closes, the text stays

A custom Trigger character (@) opens a similar list, independently of "/" — the "Custom Trigger character" section. Custom Tools add items to both sections by description, without editing the menu: they appear at the end of a section, in tools order, and are found by the label in the current locale, by the en-US label and by aliases (see the "Custom Tool" and "Insert items and Block actions" sections).

"+" on the Toolbar is an ordinary menu button (the kit's Menu): it supports the arrow keys, Enter, Escape and the first letter of the label; an item applies to the Block under the caret or to the selection, after which focus returns to the Document.

Find and replace

The search Tool (present in full and in basic) is find and replace over the Document. The "Find" button (a magnifying glass icon) sits at the right edge of the fixed Toolbar, before the Keyboard shortcuts popover; Ctrl/⌘+F with focus in the Document opens the find panel (outside the field the browser's find works), Ctrl/⌘+Alt+F opens it with focus in the replace field, and the open command of the Tool (ref.current?.tool("search")?.open()) opens it from screen code.

<RichTextEditor preset="basic" /> // the "Find" button and Ctrl/⌘+F are already there
<RichTextEditor tools={["bold", "italic", "history", "search"]} /> // or explicitly in tools
  • The find panel is non-modal, under the right edge of the Toolbar (without a fixed Toolbar, in the field's top corner; on a narrow screen, full width). On top are the counter "3 / 12", "Previous match", "Next match" and "Close find and replace" as three icon buttons; below are the find field, the replace field, the "Match case" and "Whole words" checkboxes, the "Regular expression" switch, and the "Replace" and "Replace all" buttons. Focus is not trapped: what was found is edited in the Document, and you return to the field.
  • Opening. Selected text within one Block becomes the query (a selection across Blocks does not: a match does not cross a Block boundary). A repeated Ctrl/⌘+F with the find panel open puts focus into the find field and selects its text. The "Find" button is a toggle with aria-pressed.
  • Match highlighting. All matches get a soft fill in the warning tone, the current one has a stronger fill and a border; when you navigate, type the query or click "Replace", the current match is selected, and if it is not visible, it is scrolled to the middle of the free area: below the sticky Toolbar and the find panel, inside a field with maxHeight; a visible match does not move. Matches are recomputed in the same transaction that changes the Document. The classes rte-search-match and rte-search-current are decorations and are not stored in the Document.
  • Scope. The text of Blocks, including table cells and code blocks. A match does not cross the boundary of a Block or an inline Atom (an image, a mention, a hard break); Marks inside do not interfere — "bold" is found as "bold". Formulas (mathematics) are the exception: their LaTeX source is searched as a separate string, and a match inside an inline or block formula highlights the whole formula, selects it as a node when you step onto it and counts once in "N of M", however many times the query repeats inside. A match with the neighbouring text does not cross the edge of a formula.
  • Options. When "Match case" is unchecked, case is ignored. "Whole words" finds word boundaries by Unicode letters and digits, so it works for Cyrillic too (JavaScript's \b recognizes only Latin letters). With "Regular expression" the query is a JavaScript expression; an invalid one shows an error under the find field (aria-invalid) and highlights nothing. Empty matches of the expression (x*) are skipped.
  • Keys. Enter in the find field goes to the next match, Shift+Enter to the previous one, wrapping around; Enter in the replace field is "Replace". Escape closes the find panel, removes the highlighting and puts the caret on the current match.
  • Replacing. "Replace" replaces the current match, one edit and one undo; the next one then becomes current. "Replace all" is one transaction and one undo. The new text takes the Marks of the start of the match; an empty replacement deletes what was found. Search finds formulas but does not replace them: they are edited only through the Popover. "Replace all" leaves them, and the counter after it shows what remains (the formulas with the query inside); if the current match is a formula, "Replace" takes the nearest following text match; when only formulas are left, both buttons are disabled. With a regular expression, the groups $1…$9, $& (the whole match) and $$ (a dollar sign) work in the replacement — against the text where the match was found, so expressions with lookbehind and lookahead replace correctly too; without the expression, $ is an ordinary character. In readOnly there is no replace field or buttons — only find.
  • Accessibility. The panel is a role="search" region named "Find and replace"; the counter is announced through a live region with aria-live="polite" ("3 of 12", "No matches"), the fields have labels, and the switch is role="switch".
  • Weight. The match highlighting plugin and the shortcuts are in the engine from the start; the find panel (fields, checkboxes, switch) is a lazy chunk that loads the first time the panel opens and does not delay Readiness.

Message catalog strings: editor.search (the button and the Ctrl/⌘+F Keyboard shortcuts popover row), searchReplace (Ctrl/⌘+Alt+F), searchPanel, searchField, replaceField, searchPrevious, searchNext, searchClose, searchMatchCase, searchWholeWord, searchRegex, replaceOne, replaceAll, searchCount({ current, total }), searchNoMatches, searchInvalid.

Find options

A tool("search", options) entry sets the starting flags: the panel opens with them, and the commands use them until the search is closed. The flags stay switchable in the panel, and the kit does not remember them between openings: closing the panel returns them to the starting values.

OptionMeaningDefault
matchCaseThe panel opens with "Match case" onfalse
wholeWordThe panel opens with "Whole words" onfalse
regexThe panel opens with "Regular expression" onfalse
// Searching code in Documents: case matters, so nobody has to switch the flag on each time.
<RichTextEditor tools={[...RICH_TEXT_PRESETS.full, tool("search", { matchCase: true })]} />

Find state and commands

The state is read with useRichTextToolState(ref, "search"), and the commands are called on ref.current?.tool("search"). The general rules for both are in the "Handle (ref) and your own toolbar outside the field" section.

State fieldMeaning
openThe find panel is open.
queryThe query. Closing the panel removes the query and the highlighting; without a panel, the setQuery command sets it.
flagsThe flags { matchCase, wholeWord, regex }. Closing the panel returns them to the starting values from the options.
totalHow many matches of the query are in the Document.
currentThe index of the current match, from 0; -1 means no matches.
errorThe error text if the query is an invalid regular expression (the JavaScript engine's message, not localized); otherwise null. With an error there are no matches.

The state has no match positions.

CommandWhat it does
open({ replace?, query? })Opens the panel, like the "Find" button and Ctrl/⌘+F. query puts the query in the field and in the Document highlighting at once; without it, the text selected within one Block becomes the query. replace: true puts focus in the replace field. false in Source mode.
close()Closes the panel and removes the highlighting. Focus and the caret stay where they were, unlike Escape in the panel. A panel that is already closed is not an error.
setQuery(query, flags?)Sets the query. Flags not named in flags (and flags set to undefined) come from the open panel, or from the options when there is none. A non-empty query scrolls to the first match after the caret. true means the query was applied, even with no matches; false in Source mode.
next(), previous()They select the next or previous match, wrapping around at either end, and scroll the field's scroll area or the window to it, even when focus is outside the Document; they do not take focus. false means no matches.
replace(text)Replaces the current match: one edit, one undo; the next match becomes current. Formulas are skipped. false means no text matches or a field the author cannot edit.
replaceAll(text)Replaces all text matches: one edit, one undo; formulas stay and count in total. The conditions are the same as for replace.

The query and the flags live in the engine, so setQuery, next and replace work without an open panel: you can build your own find interface on them. The panel and the commands share one search, so a replacement made from code shows up in the panel. Scrolling after next, previous and setQuery arrives a moment after the call: its code loads on first use and is not part of the Editor's entry chunk.

A counter in the Status bar. While the find panel is open, the screen can show "3 of 12" next to the character counter. Closing the panel removes the query, and the counter disappears.

import { useRef } from "react";
import { RichTextEditor, useRichTextToolState } from "@olddevs/ui/editor";
import type { RichTextEditorHandle } from "@olddevs/ui/editor";

function ArticleBody({ html }: { html: string }) {
  const ref = useRef<RichTextEditorHandle>(null);
  // `null` before mount and on the server, so the screen renders the same in both places.
  const search = useRichTextToolState(ref, "search");

  return (
    <RichTextEditor
      ref={ref}
      aria-label="Article body"
      defaultValue={html}
      status={
        search?.open && search.query ? (
          <span>{search.total ? `${search.current + 1} of ${search.total}` : "No matches"}</span>
        ) : null
      }
    />
  );
}

Invisible characters

The invisibleCharacters Tool (present in full, not in basic) shows the invisible characters of the Document: spaces (·), hard breaks Shift+Enter (↵) and paragraph ends (). This is how you find double spaces, a trailing space and stray empty paragraphs. The engine is the Invisible Characters extension from Tiptap, and the API follows it (ADR-0048); the Tool has no Block, and the Schema, the sanitizer and Markdown do not change. The "Invisible characters" checkbox item (a pilcrow with an arrow) is the last section of the "…" menu of the fixed Toolbar, set off from "Clear formatting" by a divider; from screen code the toggle command switches the characters.

<RichTextEditor /> // the item in "…" is there, the characters are hidden
<RichTextEditor tools={[...RICH_TEXT_PRESETS.full, tool("invisibleCharacters", { visible: true })]} /> // shown from the start
  • Display only. The marks are decorations over the Document: they are not in it. value, onChange, getHTML(), getMarkdown(), getJSON(), getText(), the edit history, maxLength, copying and RichTextView do not see them. Showing and hiding is not an edit: onChange is not called and there is no undo step.
  • Hidden by default. In Tiptap the extension starts shown (visible: true); in the kit it starts hidden: the Tool is in full, and a kit update must not change how every Editor on that Preset looks. The author turns the display on with the "…" menu item or the visible option.
  • What is shown. Every ordinary space of the text (in a code block too) is ·; a hard break is ↵; the end of every paragraph is , including an empty one and one in a list, quote, cell, column or Details Block. A heading and a code block have no end mark: the extension puts it on a paragraph only. A non-breaking space and other Unicode whitespace are not shown. In an empty field the paragraph mark gives way to the placeholder.
  • Look. The kit's CSS draws the marks, not text: a muted color (--rte-muted-foreground, recomputed for its background inside a toned Wrapper) and zero width. The text does not shift or wrap differently, the marks cannot be selected and the mouse does not catch them. The kit does not load the extension's own CSS (injectCSS: false): it would write its own <style> into the page head, bypassing the theme tokens.
  • The menu item. A checkbox (menuitemcheckbox) with aria-checked: the characters are shown; choosing it toggles the display and closes the menu. There is no separate Toolbar button: an extra button wrapped the full Toolbar onto a second row in a column of about 640 px, so the item sits in "…", whose button does not make the row longer. It has no shortcut, like "HTML", and there is no Slash menu item: this is a display mode, not an insertion. The item exists only on the fixed Toolbar; the floating Toolbar, the Bubble menu and readOnly do not have it. If no other item of "…" is among the Tools, the "…" menu is rendered for this one alone. In the Source mode the Document is not on screen, so "…", like the other Toolbar menus, gets aria-disabled and does not open; the toggle command returns false there. In a disabled field "…" is disabled. From the keyboard the item is reached like the others: Enter, Space or ↓ opens "…", then the arrows move and Enter or Space toggles the display.
  • Weight. The extension is in the engine from the start and has no lazy chunk. It builds the marks over the whole Document when the engine is created and over the changed range on every transaction, shown or hidden: on very long Documents this is noticeable at load.

The message catalog string is editor.invisibleCharacters ("Invisible characters"): the name of the "…" menu item; the icon is InvisibleCharactersIcon. The decision is ADR-0048 ("for the future": there was no customer at release).

Invisible characters options

A tool("invisibleCharacters", options) entry sets only the start: after that the button and the command control the display.

OptionMeaningDefault
visibleThe characters are shown from the start, before any pressfalse

Invisible characters state and command

useRichTextToolState(ref, "invisibleCharacters") reads the state and ref.current?.tool("invisibleCharacters") calls the command. The general rules for both are in the "Handle (ref) and a custom toolbar outside the field" section.

State fieldMeaning
visibleThe characters are shown. Follows the button, the command and the visible option at start.
CommandWhat it does
toggle()Show the characters if hidden and hide them if shown: the same as the button. The new value is read from the state. false in the Source mode. The kit added no show and hide: toggle and visible are enough.
import { useRef } from "react";
import { RichTextEditor, useRichTextToolState } from "@olddevs/ui/editor";
import type { RichTextEditorHandle } from "@olddevs/ui/editor";

function ProofreadingToggle({ html }: { html: string }) {
  const ref = useRef<RichTextEditorHandle>(null);
  // `null` before mount and on the server: the screen renders the same in both places.
  const visible = useRichTextToolState(ref, "invisibleCharacters", (state) => state.visible);

  return (
    <>
      <button
        type="button"
        aria-pressed={visible === true}
        onClick={() => ref.current?.tool("invisibleCharacters")?.toggle()}
      >
        Invisible characters
      </button>
      <RichTextEditor ref={ref} aria-label="Article text" defaultValue={html} />
    </>
  );
}

On this page