Rich text / foldkit-mixins-richtext
Pick a block style
In the sections below, model holds your document, editor, and chrome state, h is Foldkit's HtmlBuilder, and edited wraps editor Messages into your parent Message.
blockStyles renders a toolbar of buttons for Paragraph and Heading 1–3 using the slash menu labels:
import { blockStyles } from 'foldkit-mixins-richtext'
blockStyles<Message>()(
{ document: model.document, selection: model.editor.selection, wrap: edited },
h,
)Clicking a button sends RetypedBlock through wrap. Inside a code block, buttons show unpressed and retype the block to a paragraph or heading when your vocabulary allows it; with a node selection or no selection, all buttons are disabled. Lists and quotes lift out rather than retyping, so they stay unpressed here.
| Slot | Capability | Renders |
|---|---|---|
root | Container | Picker wrapper |
toolbar | Collection | Row with role="toolbar" |
button | Interactive | Style button with data-style and aria-pressed |
blockStyleMenu<Message>() fits the same options into a dropdown trigger (open and toggled come from your Model), showing the active style's icon and label (or "Text style") and opening a role="menu" list of menuitemradio items.
| Slot | Capability | Renders |
|---|---|---|
root | Container | Wrapper anchoring the menu |
trigger | Interactive | Trigger with aria-haspopup="menu" and aria-expanded |
menu | Collection | Open menu |
item | Interactive | Style row with data-style and aria-checked |
icon | Container | Style icon |
label | Container | Style label |
check | Container | Checkmark beside the active style |