Olddevs UI4.14.0
ReferenceRichTextEditor

Data and security

Markdown

The Markdown engine is the @tiptap/markdown package (the same version range as the rest of Tiptap, in the install command above) and marked (^17, as in the dependencies of @tiptap/markdown): every Editor has its own marked instance, so one Editor's tools set does not change Markdown parsing in another Editor on the same page.

  • Paste. Plain text from the clipboard that contains Markdown syntax — a # heading, a list item (including - [ ]), a > quote, a code fence, a table delimiter row, **bold**, ~~strikethrough~~, `code`, a link ([text](url), with a title [text](url "title"), an autolink <https://…> and a link reference definition line [1]: https://…), *italic* and _italic_ at word boundaries — is turned into Blocks and Marks. Text without this syntax is pasted as paragraphs: "6 = 2 * 3" or file_name_v2 does not become markup. A single line with markup continues a paragraph rather than breaking it.
  • Links. All forms of a Markdown link are understood — inline, with a title, reference-style ([text][1], [text][], [text] and the definition line [1]: address) and an autolink in angle brackets; likewise in setMarkdown. In the Schema a link has only a URL: the title is dropped, the definition line is not carried into the Document, and neither are the angle brackets, and getMarkdown() writes any of them as an ordinary link [text](address). The same URL policy applies to inline links and reference definitions. With allowRelativeLinks, both accept relative paths and fragments on import and paste. Links with an invalid destination retain their text.
  • A copy from a code editor. VS Code, JetBrains IDEs, Sublime Text and the like put HTML on the clipboard next to the text — the same source, colored by syntax highlighting. If this HTML is a single monospace element (a div or pre with a monospace font) with only lines and span coloring inside, its text matches the clipboard's plain text up to whitespace, and the plain text looks like Markdown by the syntax above, then the plain text is parsed as Markdown. The syntax highlighting colors are not carried into the Document: they belong to the code editor's theme, not to the author. Code that does not look like Markdown is pasted as usual.
  • When a paste stays text. If the clipboard holds any other HTML next to the text (a copy from a browser, Word, Google Docs), the usual HTML parsing applies — Markdown is not looked for in it; a copy from an office application is cleaned by pasteCleanup first (see the "Paste from Office" section). Pasting "as plain text" (Ctrl/⌘+Shift+V) and pasting into code also give the original characters. If nothing the Schema can accept is left of the pasted Markdown (with table disabled, a lone table; with codeBlock disabled, a lone code block), the original text is pasted rather than nothing.
  • Tables. A GFM table (| a | b | and a delimiter row, at least --- in a cell for paste recognition) becomes a table, with the first row as the header; getMarkdown() exports the table back, always with a header row (without one, with an empty one). Multiline cell content goes into Markdown as one line, with line breaks as <br>; | in a cell is escaped. Column alignment is preserved in both directions: :---: and ---: become data-align on the column's cells on paste and setMarkdown, and getMarkdown() writes them back; :--- is the default and gives no attribute. Markdown cannot express cell merging: getMarkdown() spreads a merged cell over the grid — the text stays in its top-left position, the covered positions become empty cells, so the columns below do not shift; the merge itself is lost, and setMarkdown(getMarkdown()) returns the table without it.
  • Footnotes. GFM footnotes are read and written: [^1] in the text and [^1]: text definitions (see the "Footnotes" section for the rules); plain text with a definition line is recognized as Markdown on paste.
  • Underline. With the underline Tool, ++text++ loads as underlined text and exports in the same form. This syntax is an extension to Markdown.
  • getMarkdown() is the Document as Markdown, right now, without waiting for changeDelay. An empty Document and a call before mount (there is no engine on the server) give "".
  • setMarkdown(md) replaces the Document with the parsed Markdown. Like clear(), this is a Programmatic replacement: onChange receives the new HTML immediately and only once, and the maxLength limit does not truncate it. Before mount it does nothing.
  • The Schema wins. The parsed result goes through the Editor's Schema: everything not in it now is dropped, setMarkdown included. In this version of the kit the following are lost: images with a URL outside http/https (they are removed entirely, with their alt), links with a URL disallowed by the link policy (the link text stays) and raw HTML inside Markdown (it is removed entirely, except the details and summary of a Details Block). Without the taskList Tool, task lists become ordinary list items, without codeBlock the code block is removed, and without table the table is removed. Markdown never yields a Column layout or a Wrapper without a tone: their Blocks follow one another. A Details Block is read from raw HTML <details><summary> and exported as the same (see the "Details" section). A Wrapper with a tone comes only from a GitHub alert (> [!NOTE] and four more values, see the "Wrapper" section, "Tone"), and getMarkdown() exports it the same way. With heading1, # gives H1, and getMarkdown writes H1 as #. Without it, # is demoted to H2; ##### is demoted to H4 in any case. What exactly is accepted is decided by the set of Tools, not by this list.
  • Video. A video Block is a link: getMarkdown() writes the canonical URL on a line of its own, and setMarkdown() reads such a line back as a Block if the service is on; a link among words, in a list and [text](address) stay links (section "Video by link").
  • Custom Tools. Custom Markdown rules live in the Extensions; without them a custom Block is exported as its content, and an Atom as its Atom text (see the "Custom Tool" section, "Outside the Editor").
  • What is lost on export. Markdown does not express text color and highlight color, Block alignment, a fragment's language, an image's width, alignment and caption, table cell merging, table column widths and a list inside a cell: an image is exported as ![alt](url), getMarkdown() omits the rest, and setMarkdown(getMarkdown()) returns the Document without them. A date mention is exported as its text, and its machine value (datetime) is lost. This is how the format works: for lossless storage use HTML, and for a lossless file use the JSON envelope (see the "JSON" section).

JSON

A JSON envelope is the Document for a file, a template or a transfer between products without loss: it keeps everything Markdown loses (color, highlight, alignment, a fragment's language, an image with width, alignment and caption, cell merging, column widths, Column layout, a Wrapper with a tone). The envelope is an exchange format alongside HTML, not instead of it: value, onChange, the hidden form field, RichTextView and server sanitization still work with HTML (ADR-0061).

import type { RichTextDocument } from "@olddevs/ui/editor";

// { format: "olddevs-rich-text", version: 1, doc: { type: "doc", content: [...] } }
const saved: RichTextDocument | null = ref.current?.getJSON() ?? null;
const opened: boolean = ref.current?.setJSON(JSON.parse(fileText)) ?? false;
  • Shape. format is always "olddevs-rich-text", version is the tree format number (currently 1), doc is the Document tree with a root node "doc". The node and attribute names in doc are the format's contract: if the Schema renames them, the kit bumps version and reads old files itself. Do not check or build doc by hand: use what getJSON() returned.
  • getJSON() is the Document as an envelope, right now, without waiting for changeDelay. In Source mode the Source field's edit is applied first, as with getHTML(). Before mount and on the server it gives null.
  • setJSON(document): boolean replaces the Document with an envelope. The parameter is unknown: pass the result of JSON.parse of the file directly, and the Editor checks the shape. Like setMarkdown(), this is a Programmatic replacement: onChange receives the new HTML immediately and only once, the maxLength limit does not truncate it, the method does not take focus, and in Source mode the field's text is rewritten. false means the envelope was rejected or there is no engine yet; the Document is untouched, and what to tell the user ("the file does not fit") is up to the screen.
  • What is rejected entirely: not an object, an unrecognized format, a different version (including its absence), a doc without a root "doc" node, and a tree from which nodes cannot be built (a malformed node, an empty text node). A bare Tiptap tree from editor.getJSON() is rejected too: without an envelope an Editor file cannot be told from any other JSON.
  • The Schema wins — for JSON too. An envelope goes through the Schema as strictly as HTML: a Block of a disabled Tool unwraps into its text, a Mark that is not in the Schema is removed, and attributes are checked by the same rules as for HTML. A dangerous link or image URL, a color outside the palette, an author's color not in the #rrggbb form, data-* outside the Schema's list, and values of custom Tools outside their rules are dropped in the Document itself, not only on output. The author's whitespace is not collapsed by the getJSON() → setJSON() round trip.
  • defaultValue with an envelope is the initial Document from JSON, uncontrolled mode only (value wins). It passes the same check as setJSON(), is applied when the engine appears, without onChange and without an undo step; a rejected one gives an empty Document and one error in the development console. Until Readiness, with an envelope the Skeleton is a frame without a Document, getHTML() is "", and isEmpty() evaluates the envelope's tree by the required rule.
  • Custom Tools write no JSON rules: a Block, Atom or Mark of a custom Tool included in tools goes through the round trip itself and is checked by the rules of its description; a disabled one unwraps, and an Atom without content is removed, as in HTML.
  • The kit has no "Download" and "Open file" buttons — that is screen code made of the kit's primitives; see the JsonExportImport story in Storybook for an example. For database storage, use the HTML from onChange: the server sanitizes it (sanitizeRichText), and the kit has no server-side JSON sanitization.

Schema and security

The Schema is the only source of allowed markup. Everything not in it is dropped both when value is loaded and on paste: <script>, on* handlers, the style attribute (except the author's color, below), links that fail the link policy, images with a URL outside http/https (data: — base64 — and blob: included), width, height and class on <img>, disallowed tags. Text from a dropped tag is kept; only the tag is lost. Footnote markup uses its own rules for id and fragment links (see the "Footnotes" section).

The allowlist of this release with preset="full" (disabled Tools narrow it):

WhatAllowed
Blocksp, h1, h2, h3, h4, ul, ol, li, blockquote, hr, pre, table, tbody, tr, th, td; label, input, span — only inside a task list item; div — there too, and also the Column layout and its columns (a Column layout only at the top level, a column only directly in it) and the Wrapper (at the top level and directly in a column, not in another Wrapper), and video (the same div with the value "video" of data-block and an ordinary link inside; there is no player in the Document, an iframe is always stripped); details — the Details Block, with summary and a content div inside it (both only directly in details; outside it the tags are removed); figure — an image, with img and an optional figcaption inside it (they do not exist outside figure); formulas — an inline span and a block div with the attributes "data-type" and "data-latex", both elements empty; footnotes — the list at the end of the Document is section with the value "footnotes" of data-block, only at the top level, holding an ol of li with a p and the backlink; the reference is the sup and a that are in Marks
Marksstrong, em, u, s, code, sup, sub, mark (only with a color), br, a, time (a date mention)
Attributesol[start] — only when numbering does not start at 1; ul[data-type], li[data-type], li[data-checked] — a task list; input[type], input[checked] — its checkbox; code[class] — only language-<name> with a canonical name from the code language table. A plain text block has no class; span[data-color], mark[data-color] — text color and highlight, only names from the Editor's own palette — text color on span, highlight on mark; span[style], mark[style] — an arbitrary author's color, only color:#rrggbb and background-color:#rrggbb, and not together with data-color; p[data-align], h1[data-align], h2[data-align], h3[data-align], h4[data-align] — Block alignment, center or right; th[colspan], td[colspan] — horizontal merge, an integer from 2 to 20; th[rowspan], td[rowspan] — vertical, from 2 to 50; th[data-align], td[data-align] — column alignment, center or right, on each of its cells; a[href] — http:, https: and mailto: by default, plus the footnote anchors below. The Editor accepts relative paths and fragments with allowRelativeLinks. Use the same option when sanitizing on the server; a[rel] — noopener noreferrer on ordinary links; img[src] — only absolute http or https, no data and blob; img[alt] — always, empty for an image without a description; img[data-width] — 25, 33, 50, 75 or 100; figure[data-align] — image alignment, left or right, the text wraps around the image (the centre has no attribute); div[data-block] — the Column layout (layout), its column (column), the Wrapper (wrapper) and video (video); div[data-layout] — the Column layout variant, column shares in percent: 100, 50-50, 33-33-33, 25-25-25-25, 60-40 or 40-60; div[data-tone] — the Callout tone, only on it: neutral, accent, success, warning or danger (no attribute without a tone); div[data-type] — the content wrapper of a Details Block ("detailsContent", only directly in details) and a block formula ("block-math"); span[data-type] — an inline formula, only the value "inline-math"; span[data-latex], div[data-latex] — the LaTeX source of a formula, only next to its "data-type", and the only attribute value where "<" is allowed; div[data-provider] — the service of a video Block, only on it: "youtube" or "twitch"; div[data-src] — the link to a video of that service in canonical form, only on a video Block and only "https": on www.youtube.com (a video or a playlist) or on www.twitch.tv and clips.twitch.tv (a recording, a channel, a clip); details[open] — an open Block, only an empty "open", written with the "persist" option; sup[data-footnote-ref] — a footnote reference, the key of its footnote: eight lowercase letters and digits; a[id], a[role] — only on the anchor inside the reference ("fnref-" and the key, "doc-noteref") and on the backlink ("doc-backlink"); li[id] — "fn-" and the key, only on a footnote in the list; section[data-block], section[role], section[aria-label] — the footnote list: "footnotes", "doc-endnotes" and its name; the Schema retains only these footnote id values. A footnote reference links to #fn-<key> and its backlink links to #fnref-<key> with the same key
Datestime[datetime] — a date mention, only on time: exactly YYYY-MM-DD or YYYY-MM-DDTHH:MM±HH:MM and a real calendar date; the element holds only the author's text
Languagespan[lang] — the language of a fragment: any BCP 47 tag (en, pt-BR, zh-Hant-TW), written in its canonical case, and only on a plain span
Columnscolgroup, col — column widths of a table: one colgroup, the first child of a table, with 2 to 20 col directly in it. A colgroup that breaks the rule of the next row is removed whole, and the table is sized by its content
Sharescol[data-width] — a column's share of the table's width in percent: a multiple of 5 from 5 to 95, and the shares of one colgroup add up to 100 (RICH_TEXT_SCHEMA.tableColumnShares)

Tiptap writes a task list item like this: <li data-type="taskItem" data-checked="true"><label><input type="checkbox" checked><span></span></label><div><p>…</p></div></li>. A sanitizer should let input, label, span and div through only inside such an item, and input only with type="checkbox".

A table is table > tbody > tr > th|td; a cell has only colspan and rowspan (colspan is an integer from 2 to 20, rowspan from 2 to 50) and data-align (center or right), no style and no colwidth. thead, tfoot and caption are not in the Schema and the Editor does not write them (the header row is the first row of th); column widths are an optional colgroup of col[data-width] before tbody (the two rows above), and sanitizeRichText removes the whole colgroup unless it is the first one in the table with 2 to 20 col, each a valid share, adding up to 100; tbody, tr, th and td outside a table are thrown out by the HTML parser itself, so no hook is needed for them.

There are no other classes, no style (except the author's color), no id, role or aria-* (except the footnote markup, see the "Footnotes" section) and no data-* (except the twelve Schema names: data-type (a task list, the content wrapper of a Details Block and formulas), the data-latex of a formula, data-checked, data-color, data-align, data-width, data-block, data-layout, data-tone, data-provider, data-src and data-footnote-ref; custom Tools add data-mark and data-<name> to them) in the emitted HTML: typography lives on the container, not on the Document's nodes.

style is a narrow exception. The author's color is written as <span style="color:#rrggbb"> and <mark style="background-color:#rrggbb">, and nothing else is ever in style: no other properties, no other tags, no other color forms. DOMPurify's ALLOWED_ATTR is shared by all tags and does not check values, so the bare richTextSanitizeConfig() has no style at all, and only sanitizeRichText lets it through (RichTextView), checking the tag and value against RICH_TEXT_SCHEMA.customColor.styles.

The Schema is not sanitization. Client-side cleaning does not protect against XSS: a request that bypasses the interface can carry anything. User HTML is sanitized by the consumer's server — sanitizeRichText(html, DOMPurify) against the allowlist above. The list grows with the set of Blocks, and the helper with it; it and the closed config richTextSanitizeConfig() are described on the RichTextView page. The table above repeats src/editor/core/schema.ts and is verified by a test. Until Readiness the Skeleton shows value already parsed by the Schema in the browser (see the "Custom Tool" section), and on the server it renders no Document, so the Editor, unlike RichTextView, does not put unsanitized HTML into the page. This does not replace server-side sanitization: the value goes on into the database and into RichTextView.

An allowlist of your own. RICH_TEXT_SCHEMA.attributes is data: it names the attributes, but not the tag, the place and the shape of value each one is allowed in. That rule lives in the hooks of sanitizeRichText, so copying the names into another sanitizer's allowlist is safe only for the attributes that are harmless whatever stands in them. Sanitize with sanitizeRichText (or richTextSanitizeConfig() together with its hooks) whenever you can. If you cannot, sort the attributes this way:

AttributesIn your own allowlistWhy
id (on li and a), role (on a and section), aria-label (on section), data-footnote-ref (on sup)Do not copyThey are the footnote markup. As plain attributes they pass on every tag with any value: an author's id clobbers the page's named elements and getElementById (DOM clobbering) or collides with its anchors, role makes any element pose as a button or an alert, aria-label renames any element for a screen reader. sanitizeRichText admits each one only as fn-<key>, fnref-<key>, doc-noteref, doc-endnotes or doc-backlink, on its own tag, in the footnote markup. Without them the footnotes keep their text and lose the jumps
lang (on span)Better with the hookInert, nothing reads it but the browser and assistive technology, so it is not an injection. A plain copy lets any tag and any string through, and that changes the voice a screen reader reads with. The kit's closed config leaves it out
time[datetime], col[data-width], figure[data-align], img[data-width]Safe as plain dataNo script, address or style: the kit's styles select only the fixed values (left, right, a share from 5 to 95, a width preset), and any other value does nothing. The bare config has them. What the hooks add is the shape of the value (the two datetime forms, shares that add up to 100); the Editor re-checks it on load anyway. img itself and its src still need the hooks

Accessibility and forms

  • The editable area is role="textbox" with aria-multiline.
  • The Toolbar is role="toolbar" named from the message catalog (editor.toolbar, "Formatting") with one Tab stop: Tab enters the Toolbar, the Left and Right arrow keys move between the buttons, Home and End go to the edges, and the next Tab moves focus to the Document. The Toolbar remembers where focus was. It is built on the kit's Toolbar.
  • Buttons are icons with aria-label; toggle buttons (bold, italic, underline in the Bubble menu, link, image) announce their state with aria-pressed — a screen reader announces whether italic is on at the caret. One-off actions (undo, redo) are ordinary buttons. A button of a custom Tool announces aria-pressed only if it has isActive, and its shortcut is in the tooltip and in aria-keyshortcuts; an empty label is replaced with the Tool's name. An action unavailable right now is aria-disabled, not disabled: it stays in the arrow-key order.
  • A hover and focus tooltip names the action and the shortcut; the shortcut is also announced with aria-keyshortcuts (Control+B or Meta+B on Apple). On Apple the label is ⌘+⇧+S, elsewhere Ctrl+Shift+S, using the same check the engine uses to decide which key is mod.
  • The Slash menu on / follows the combobox pattern from the WAI-ARIA Authoring Practices Guide (APG): focus stays in the field, the list is role="listbox" with role="group" sections, and the field points to it with aria-controls and to the current row with aria-activedescendant (the row has aria-selected). The field announces aria-autocomplete="list". aria-expanded is not set on the field: ARIA 1.2 does not allow it on role="textbox", and the role of a multiline Document cannot be changed to combobox. A row's name is its label; the ## shortcut hint is not read to the screen reader.
  • The list on / is a layer of the kit's Popover (Radix): Escape closes only it, not the Dialog or Drawer around the field, and what was typed stays as text. "+" is the kit's Menu with aria-haspopup, and Escape in it behaves the same way (ADR-0041).
  • The Keyboard shortcuts popover is the kit's Popover: a button with aria-haspopup="dialog" and aria-expanded, the popover is role="dialog" named "Keyboard shortcuts", with a table inside having column headers (columnheader) and a row header (rowheader) for each command, and each shortcut is marked up with <kbd>. Escape and a click outside close the popover and return focus to the button; in a Dialog, only the popover (ADR-0041). Tests: tests/rich-text-editor-shortcuts.test.tsx, in the browser tests-visual/interactions.spec.ts ("RichTextEditor inside Dialog: Escape closes the shortcuts reference").
  • The floating Toolbar is the same role="toolbar" with one Tab stop and the same arrow keys; it appears above a non-empty selection, and on a touch screen it is replaced by the fixed one. To move from the Document to any Toolbar, press Alt+F10 (see the "Keyboard: Alt+F10" section).
  • The link popover is role="dialog" named "Link" (editor.link); the field is labeled (editor.linkAddress), the URL error (editor.linkInvalid) is associated with the field through aria-describedby and sets aria-invalid. The "Link" button is a toggle with aria-pressed when the caret is in a link.
  • Image. The popover is role="dialog" named "Image" (editor.image); the "Image address" and "Alternative text" fields are labeled, the second one's hint is associated through aria-describedby, and the URL error (editor.imageInvalid) sets aria-invalid. The width presets are a role="group" "Width" of toggle buttons with aria-pressed. The selected image's panel is a role="toolbar" "Image" with one Tab stop. The width handles are for the mouse only (aria-hidden, no focus): the same width is in the popover and on the panel. Upload progress is a role="status" live region outside the Document (live regions inside contenteditable are not read everywhere), and a failure is a visible role="alert" line under the field: this is the Field notice, the same one that showNotice shows.
  • The "¶" menu is the kit's Menu: radio items (menuitemradio) with aria-checked on the current Block type, shortcuts labeled in the items. Enter, Space and ↓ on the button open the menu; the arrow keys move between the items. Escape closes the menu and returns focus to the button; inside Dialog and Drawer, only the menu, not the dialog (ADR-0041). The button's name includes the current type: "Block type: Text"; the menu is named by its button. The state is in a menu rather than in a row of toggle buttons: a checked item announces it the same way as aria-pressed, and the value on the button is announced without opening the menu — ADR-0054.
  • The "…" menu is the kit's Menu with an icon button "More formatting": Marks and "Code block" are checkbox items (menuitemcheckbox) with aria-checked, shortcuts labeled in the items. Inside Dialog and Drawer the items are chosen with both mouse and keyboard, and Escape does not close the dialog while the menu is open (ADR-0041).
  • The "Highlight" and "Color" popovers — a button with aria-haspopup="menu" and aria-expanded; inside is a menu named like the button, and the grids are a group with a heading ("Text color", "Highlight color"). The swatches are menuitemradio with aria-checked and a name in words ("Red", "Pink"): color is not the only cue (WCAG 1.4.1). "Custom color…" is also a menuitemradio, checked when the color is the author's; "Remove color" and "Remove highlight" are menuitem with a tooltip. The selected swatch has a ring around it on the popover's background, and focus is an accent outline outside that ring: both cues are visible at the same time. The "Highlight" button's name includes the current color ("Highlight: Pink"). Navigation follows APG menu roles over the grid: the arrow keys move rather than choose.
  • The custom color popover is role="dialog" named "Custom text color" or "Custom highlight color"; focus on open is on the color picker button, whose visible name states the value ("Color #d92d20") and changes with it. The contrast warning is role="status": the screen reader announces its appearance. Escape closes one layer at a time (ADR-0041): the color picker, then the popover, then the Dialog or Drawer around the field; focus returns to the Document.
  • Text part language. The lang of a marked fragment is what a screen reader switches its voice by (WCAG 3.1.2, level AA). "Language ›" is a submenu of the "…" menu: radio items (menuitemradio, aria-checked) in words, with the page's own language marked "primary", and "Remove language mark", which gets aria-disabled when there is nothing to remove. The dotted underline is not the only carrier of the meaning: it only helps the author see the border, and the View draws nothing.
  • The "Alignment" and "Lists" menus are like "¶": a button with aria-haspopup="menu" and the current value in its name ("Alignment: Align center", "List: numbered"), radio items with aria-checked, shortcuts labeled in the items; Enter, Space and ↓ open, Escape closes only the menu and returns focus to the button. Alignment and lists are menus rather than three toggle buttons each in a row: a value announced in the button's name and a check in the menu convey the same as aria-pressed, and the row is four buttons shorter — ADR-0054.
  • The "Table" menu is the kit's Menu with submenus (SubmenuTrigger): a button with aria-haspopup="menu", items with › having aria-haspopup and aria-expanded, "Header row" is menuitemcheckbox, column alignment is menuitemradio, and unavailable items get aria-disabled and stay in the arrow-key order. The "Table ›" submenu is a react-aria popover with a grid (the grid pattern from APG, aria-activedescendant, the size in words in a live region). Escape closes one level at a time, and in a Dialog the dialog goes last (ADR-0041). The "Insert table" dialog is the kit's Dialog: focus on open is in the "Columns" field, and on close it goes back to the Document. Tests: tests/rich-text-editor-table-menu.test.tsx, in the browser tests-visual/rich-text-editor-table-menu.spec.ts.
  • Emoji. The button is aria-haspopup="dialog"; the popover is role="dialog" named "Emoji" (editor.emoji) with a role="grid" ("Choose an emoji") where focus stays on the grid and aria-activedescendant names the current cell, as in the table size grid. Categories are a rowgroup with a name ("Favorites", "Smileys"…), an emoji is a gridcell named from the message catalog (editor.emojiName: "Fire", "Red heart"), not by the symbol: screen readers pronounce symbols differently, and sometimes stay silent. The symbol in the cell is hidden from the screen reader. Escape closes the popover and returns focus to the Document.
  • Column layout. Columns go in the markup left to right — the screen reader reads them in the same order, and they stack in the same order on a narrow screen. A column has no role of its own: it is a group of Document Blocks, not a widget. A Tab press that the Document handles (columns, list, table) does not reach the focus trap of the Dialog and Drawer around the field; a Tab press that it lets through (the last column on Tab, the first on Shift+Tab; a paragraph outside a list) moves focus on — there is no keyboard trap.
  • Wrapper. It has no role of its own: it is a group of Document Blocks, not a widget, and the screen reader reads its Blocks in order, like the Blocks around it. Tab in a Wrapper is not intercepted — there is no keyboard trap; Enter in an empty last paragraph and the arrow keys at its edge move the caret out of a Wrapper. A tone adds no roles or aria-* — it is styling only: the meaning of a note ("Warning: …") is written by the author in words (WCAG 1.4.1). The "Tone ›" submenu is the kit's Menu: radio items with aria-checked, and the submenu item's name includes the current tone.
  • Details. The opening button is a real button named from the catalog (editor.detailsToggle: "Details: {title}") with aria-expanded; it is in the Tab order, Enter and Space open the Block, and focus stays on the button. The content of a collapsed Block is hidden from both the screen reader and the caret. In RichTextView the Block is a native details and summary: the kit adds no role or name, the browser opens it, from the keyboard and without JavaScript. Tab in the Block is not intercepted — there is no keyboard trap.
  • Formulas. KaTeX outputs HTML and MathML: a screen reader reads the MathML (which also carries the LaTeX source as an annotation), and the visual HTML is hidden from it with aria-hidden. The Popover is a dialog named "Formula" or "Block formula", focus goes straight into the LaTeX field, the error is in the field itself (aria-invalid and the text "Invalid LaTeX: …"), and Escape returns focus to the text. From the keyboard an inline formula is selected with Shift+→, and Enter on a selected one opens editing. In RichTextView the LaTeX source is visible before rendering.
  • Source mode. The Source button is a toggle with aria-pressed, in the Toolbar's arrow-key order like any button. The field is a native textarea with a format-specific name from the message catalog (editor.sourceField or editor.sourceMarkdownField); the hint and error of FormField go into its aria-describedby, merged the same way as for the Document; aria-invalid mirrors the Document. Autocorrections are off: spellcheck="false", autocapitalize, autocorrect and autocomplete are off, dir="ltr". Tab and Shift+Tab are native: the field inserts no tab character, and there is no keyboard trap; undo inside the field is the ordinary text field undo. Entering puts focus in the field (caret at the start), leaving with the button puts it in the Document (caret at the end). Alt+F10 moves focus from the field to the Source toggle, as from the Document to the Toolbar: the Toolbar announces this shortcut in the mode too. The other Toolbar buttons in the mode are aria-disabled, in the arrow-key order. A click on the FormField label and a required failure move focus into the Source field. Tests: tests/rich-text-editor-source.test.tsx, in the browser tests-visual/rich-text-editor-source.spec.ts.
  • Field notice and Status bar. A role="status" live region is present in every Editor and is empty while there is no status notice; an error is role="alert" under the field. The Status bar is a container without role and aria-live: the kit does not announce it, and the screen wraps "Saved" in role="status" itself. The line is visible with readOnly and disabled, and the counter stays in aria-describedby. Tests: tests/rich-text-editor-notice.test.tsx; in the showcase — StatusLine, StatusLineReadOnly, FieldNotice.
  • Text card. role="dialog" without aria-modal, named by the contribution's label (label); focus on open stays in the Document. A role="status" live region announces the appearance with the phrase editor.textCardShown including the label and the Alt+F10 shortcut; Alt+F10 moves focus into the Text card, and Escape returns the caret and hides it. See the "Text card" section.
  • Block selection. The Field notice's role="status" announces the count ("Blocks selected: 3"), the end of the selection and the results of actions; the highlight is for sighted users only. The first Esc in the text selects the Block and does not close a Dialog or a Drawer (the second does): see the "Block selection" section.
  • A task list item's checkbox is named from the message catalog (editor.taskCheckbox): "Done: ".
  • Name. The browser associates <label for> only with native form controls, and contenteditable is not one of them. So FormField publishes the id of its label through context, and the RichTextEditor inside it references the label through aria-labelledby and puts focus in the Document on a click on the label. For this the Editor needs no id and FormField needs no htmlFor (but set htmlFor out of habit — it does no harm). The Editor does not touch the label's DOM, it only listens for the click. An explicit aria-label and aria-labelledby outrank the label. If none of this is set, the name comes from the message catalog (editor.label) — there is no nameless field, but such a name says nothing about the content: give your own.
  • The FormField hint and error are announced together with the field: their id values go into aria-describedby and are merged with its own description from the prop. An error sets aria-invalid and styles the frame as invalid; an explicit aria-invalid prop outranks it.
  • required works like the native one. An empty Document (no text, no Atom — hr, an image, a custom Atom — and no table) blocks submission of an ordinary <form>: the browser shows a validation message with the text from the message catalog (editor.required, follows the kit's locale), and focus goes to the Editor. As soon as the Document has content, the block is lifted immediately, without waiting for changeDelay. In Source mode, emptiness is decided by the Source field's text parsed by the Schema — also immediately, while typing (see the "Source mode" section). readOnly and disabled are not checked, as with native fields. The asterisk on the label comes only from FormField required.
  • How it works: a hidden <input type="hidden" name> is excluded from constraint validation by the specification, and contenteditable is not form-associated, so next to it there is an invisible text field without name — it carries setCustomValidity, while the hidden field still puts the value into FormData.
  • In the kit's Form (noValidate) the browser validates no field — there the consumer signals that a field is required through FormField error, as for TextControl.
  • readOnly and disabled are announced with aria-readonly and aria-disabled.
  • All strings come from the editor.* message catalog, with the Russian locale from @olddevs/ui/locales/ru. Key names in tooltips (Ctrl, Shift) are not translated: they are the legends on the keys.

Manual testing — outside CI, before releasing significant changes to the Editor: VoiceOver on macOS and iOS, NVDA, input through an IME (Japanese and Chinese), Android Chrome with Gboard, paste from Word and Google Docs.

On this page