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" orfile_name_v2does 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 insetMarkdown. 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, andgetMarkdown()writes any of them as an ordinary link[text](address). The same URL policy applies to inline links and reference definitions. WithallowRelativeLinks, 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
divorprewith a monospace font) with only lines andspancoloring 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
pasteCleanupfirst (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 (withtabledisabled, a lone table; withcodeBlockdisabled, 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---:becomedata-alignon the column's cells on paste andsetMarkdown, andgetMarkdown()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, andsetMarkdown(getMarkdown())returns the table without it. - Footnotes. GFM footnotes are read and written:
[^1]in the text and[^1]: textdefinitions (see the "Footnotes" section for the rules); plain text with a definition line is recognized as Markdown on paste. - Underline. With the
underlineTool,++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 forchangeDelay. 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. Likeclear(), this is a Programmatic replacement:onChangereceives the new HTML immediately and only once, and themaxLengthlimit 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,
setMarkdownincluded. In this version of the kit the following are lost: images with a URL outsidehttp/https(they are removed entirely, with theiralt), links with a URL disallowed by the link policy (the link text stays) and raw HTML inside Markdown (it is removed entirely, except thedetailsandsummaryof a Details Block). Without thetaskListTool, task lists become ordinary list items, withoutcodeBlockthe code block is removed, and withouttablethe 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"), andgetMarkdown()exports it the same way. Withheading1,#gives H1, andgetMarkdownwrites 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, andsetMarkdown()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
,getMarkdown()omits the rest, andsetMarkdown(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.
formatis always"olddevs-rich-text",versionis the tree format number (currently1),docis the Document tree with a root node"doc". The node and attribute names indocare the format's contract: if the Schema renames them, the kit bumpsversionand reads old files itself. Do not check or builddocby hand: use whatgetJSON()returned. getJSON()is the Document as an envelope, right now, without waiting forchangeDelay. In Source mode the Source field's edit is applied first, as withgetHTML(). Before mount and on the server it givesnull.setJSON(document): booleanreplaces the Document with an envelope. The parameter isunknown: pass the result ofJSON.parseof the file directly, and the Editor checks the shape. LikesetMarkdown(), this is a Programmatic replacement:onChangereceives the new HTML immediately and only once, themaxLengthlimit does not truncate it, the method does not take focus, and in Source mode the field's text is rewritten.falsemeans 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 differentversion(including its absence), adocwithout a root"doc"node, and a tree from which nodes cannot be built (a malformed node, an empty text node). A bare Tiptap tree fromeditor.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
#rrggbbform,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 thegetJSON()→setJSON()round trip. defaultValuewith an envelope is the initial Document from JSON, uncontrolled mode only (valuewins). It passes the same check assetJSON(), is applied when the engine appears, withoutonChangeand 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"", andisEmpty()evaluates the envelope's tree by therequiredrule.- Custom Tools write no JSON rules: a Block, Atom or Mark of a custom Tool included in
toolsgoes 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
JsonExportImportstory in Storybook for an example. For database storage, use the HTML fromonChange: 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):
| What | Allowed |
|---|---|
| Blocks | p, 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 |
| Marks | strong, em, u, s, code, sup, sub, mark (only with a color), br, a, time (a date mention) |
| Attributes | ol[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 |
| Dates | time[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 |
| Language | span[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 |
| Columns | colgroup, 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 |
| Shares | col[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:
| Attributes | In your own allowlist | Why |
|---|---|---|
id (on li and a), role (on a and section), aria-label (on section), data-footnote-ref (on sup) | Do not copy | They 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 hook | Inert, 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 data | No 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"witharia-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'sToolbar. - Buttons are icons with
aria-label; toggle buttons (bold, italic, underline in the Bubble menu, link, image) announce their state witharia-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 announcesaria-pressedonly if it hasisActive, and its shortcut is in the tooltip and inaria-keyshortcuts; an empty label is replaced with the Tool's name. An action unavailable right now isaria-disabled, notdisabled: 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+BorMeta+Bon Apple). On Apple the label is⌘+⇧+S, elsewhereCtrl+Shift+S, using the same check the engine uses to decide which key ismod. - The Slash menu on
/follows thecomboboxpattern from the WAI-ARIA Authoring Practices Guide (APG): focus stays in the field, the list isrole="listbox"withrole="group"sections, and the field points to it witharia-controlsand to the current row witharia-activedescendant(the row hasaria-selected). The field announcesaria-autocomplete="list".aria-expandedis not set on the field: ARIA 1.2 does not allow it onrole="textbox", and the role of a multiline Document cannot be changed tocombobox. 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'sPopover(Radix): Escape closes only it, not theDialogorDraweraround the field, and what was typed stays as text. "+" is the kit'sMenuwitharia-haspopup, and Escape in it behaves the same way (ADR-0041). - The Keyboard shortcuts popover is the kit's
Popover: a button witharia-haspopup="dialog"andaria-expanded, the popover isrole="dialog"named "Keyboard shortcuts", with atableinside 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 aDialog, only the popover (ADR-0041). Tests:tests/rich-text-editor-shortcuts.test.tsx, in the browsertests-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, pressAlt+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 througharia-describedbyand setsaria-invalid. The "Link" button is a toggle witharia-pressedwhen 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 througharia-describedby, and the URL error (editor.imageInvalid) setsaria-invalid. The width presets are arole="group""Width" of toggle buttons witharia-pressed. The selected image's panel is arole="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 arole="status"live region outside the Document (live regions insidecontenteditableare not read everywhere), and a failure is a visiblerole="alert"line under the field: this is the Field notice, the same one thatshowNoticeshows. - The "¶" menu is the kit's
Menu: radio items (menuitemradio) witharia-checkedon 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; insideDialogandDrawer, 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 asaria-pressed, and the value on the button is announced without opening the menu — ADR-0054. - The "…" menu is the kit's
Menuwith an icon button "More formatting": Marks and "Code block" are checkbox items (menuitemcheckbox) witharia-checked, shortcuts labeled in the items. InsideDialogandDrawerthe 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"andaria-expanded; inside is amenunamed like the button, and the grids are agroupwith a heading ("Text color", "Highlight color"). The swatches aremenuitemradiowitharia-checkedand a name in words ("Red", "Pink"): color is not the only cue (WCAG 1.4.1). "Custom color…" is also amenuitemradio, checked when the color is the author's; "Remove color" and "Remove highlight" aremenuitemwith 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 isrole="status": the screen reader announces its appearance. Escape closes one layer at a time (ADR-0041): the color picker, then the popover, then theDialogorDraweraround the field; focus returns to the Document. - Text part language. The
langof 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 getsaria-disabledwhen 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 witharia-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 asaria-pressed, and the row is four buttons shorter — ADR-0054. - The "Table" menu is the kit's
Menuwith submenus (SubmenuTrigger): a button witharia-haspopup="menu", items with›havingaria-haspopupandaria-expanded, "Header row" ismenuitemcheckbox, column alignment ismenuitemradio, and unavailable items getaria-disabledand stay in the arrow-key order. The "Table ›" submenu is a react-aria popover with a grid (thegridpattern from APG,aria-activedescendant, the size in words in a live region). Escape closes one level at a time, and in aDialogthe dialog goes last (ADR-0041). The "Insert table" dialog is the kit'sDialog: 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 browsertests-visual/rich-text-editor-table-menu.spec.ts. - Emoji. The button is
aria-haspopup="dialog"; the popover isrole="dialog"named "Emoji" (editor.emoji) with arole="grid"("Choose an emoji") where focus stays on the grid andaria-activedescendantnames the current cell, as in the table size grid. Categories are arowgroupwith a name ("Favorites", "Smileys"…), an emoji is agridcellnamed 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
DialogandDraweraround 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.
Tabin a Wrapper is not intercepted — there is no keyboard trap;Enterin an empty last paragraph and the arrow keys at its edge move the caret out of a Wrapper. A tone adds no roles oraria-*— 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'sMenu: radio items witharia-checked, and the submenu item's name includes the current tone. - Details. The opening button is a real
buttonnamed from the catalog (editor.detailsToggle: "Details: {title}") witharia-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. InRichTextViewthe Block is a nativedetailsandsummary: the kit adds no role or name, the browser opens it, from the keyboard and without JavaScript.Tabin 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-invalidand the text "Invalid LaTeX: …"), and Escape returns focus to the text. From the keyboard an inline formula is selected withShift+→, andEnteron a selected one opens editing. InRichTextViewthe 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 nativetextareawith a format-specific name from the message catalog (editor.sourceFieldoreditor.sourceMarkdownField); the hint and error ofFormFieldgo into itsaria-describedby, merged the same way as for the Document;aria-invalidmirrors the Document. Autocorrections are off:spellcheck="false",autocapitalize,autocorrectandautocompleteareoff,dir="ltr". Tab andShift+Tabare 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+F10moves 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 arearia-disabled, in the arrow-key order. A click on theFormFieldlabel and arequiredfailure move focus into the Source field. Tests:tests/rich-text-editor-source.test.tsx, in the browsertests-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 nostatusnotice; an error isrole="alert"under the field. The Status bar is a container withoutroleandaria-live: the kit does not announce it, and the screen wraps "Saved" inrole="status"itself. The line is visible withreadOnlyanddisabled, and the counter stays inaria-describedby. Tests:tests/rich-text-editor-notice.test.tsx; in the showcase —StatusLine,StatusLineReadOnly,FieldNotice. - Text card.
role="dialog"withoutaria-modal, named by the contribution's label (label); focus on open stays in the Document. Arole="status"live region announces the appearance with the phraseeditor.textCardShownincluding the label and theAlt+F10shortcut;Alt+F10moves 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 firstEscin the text selects the Block and does not close aDialogor aDrawer(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, andcontenteditableis not one of them. SoFormFieldpublishes theidof its label through context, and theRichTextEditorinside it references the label througharia-labelledbyand puts focus in the Document on a click on the label. For this the Editor needs noidandFormFieldneeds nohtmlFor(but sethtmlForout of habit — it does no harm). The Editor does not touch the label's DOM, it only listens for the click. An explicitaria-labelandaria-labelledbyoutrank 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
FormFieldhint and error are announced together with the field: theiridvalues go intoaria-describedbyand are merged with its own description from the prop. An error setsaria-invalidand styles the frame as invalid; an explicitaria-invalidprop outranks it. requiredworks 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 forchangeDelay. 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).readOnlyanddisabledare not checked, as with native fields. The asterisk on the label comes only fromFormField required.- How it works: a hidden
<input type="hidden" name>is excluded from constraint validation by the specification, andcontenteditableis not form-associated, so next to it there is an invisible text field withoutname— it carriessetCustomValidity, while the hidden field still puts the value intoFormData. - In the kit's
Form(noValidate) the browser validates no field — there the consumer signals that a field is required throughFormField error, as forTextControl. readOnlyanddisabledare announced witharia-readonlyandaria-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.