Rich text / foldkit-mixins-richtext
formattingToolbar
function · packages/mixins-richtext/src/formatting.ts:421
function formattingToolbar<Message>(): SlotView.SlotView<
typeof FormattingToolbarSlots,
FormattingToolbarInput<Message>,
Message
>The toolbar as a slot view, with the APG toolbar's keys: one tab stop (the control roving
names, else the first), ArrowLeft and ArrowRight (mirrored under rtl), Home and End moving
focus between controls, wrapping. Controls are never skipped, since an unavailable one stays
focusable. ArrowDown on a closed menu's trigger opens it; on an open one it moves into the menu,
whose items the arrows, Home and End then walk and whose Escape closes it and returns to the
trigger. Escape on a trigger closes its open menu. Opening by Down does not enter the menu, since
its items are not drawn yet: a second Down does.
A control that is on is aria-pressed (a mark the selection carries, a link, an open menu is
aria-expanded); the text style trigger names the current style. Marks and wraps need a
selection, the text style menu a text selection, and link a selection that covers text. Lists
and quote are not toggles here: wrapping again wraps deeper, as in the slash menu.
The root is marked as the editor's controls (CONTROLS_ATTRIBUTE), so a pointer press on a
control or a menu entry leaves the focus, and the browser's selection, in the text. A control
reached by key does hold the focus: every command then reads the selection the editor keeps in
the Model, and the editor draws that selection as a decoration until the focus returns.