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:

ts
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.

SlotCapabilityRenders
rootContainerPicker wrapper
toolbarCollectionRow with role="toolbar"
buttonInteractiveStyle 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.

SlotCapabilityRenders
rootContainerWrapper anchoring the menu
triggerInteractiveTrigger with aria-haspopup="menu" and aria-expanded
menuCollectionOpen menu
itemInteractiveStyle row with data-style and aria-checked
iconContainerStyle icon
labelContainerStyle label
checkContainerCheckmark beside the active style