Rich text / foldkit-mixins-richtext
Add table and code block toolbars
tableToolbar edits rows, columns, and header flags around the caret's cell, while codeToolbar changes a code block's language and dispatches a copy Message:
ts
import { codeToolbar, tableToolbar } from 'foldkit-mixins-richtext'
const table = RichText.tableAt(model.document, model.editor.selection)
table === undefined
? h.empty
: h.div(
[
h.Key(table.table.id),
h.OnMount(blockAnchor({ hostId: 'body', node: table.table.id, gap: 6, side: 'above' })),
],
[
tableToolbar<Message>()(
{ document: model.document, selection: model.editor.selection, wrap: edited },
h,
),
],
)
codeToolbar<Message>()(
{
document: model.document,
node: code.id,
languages: [{ id: 'typescript', label: 'TypeScript' }, { id: '', label: 'Plain text' }],
wrap: edited,
copied: Message.CopiedCode({ node: code.id }),
},
h,
)| Slot | Capability | Renders |
|---|---|---|
TableToolbarSlots.root | Container | Table toolbar wrapper |
TableToolbarSlots.toolbar | Collection | role="toolbar" button row |
TableToolbarSlots.button | Interactive | Action button with data-table |
CodeToolbarSlots.root | Container | role="toolbar" wrapper |
CodeToolbarSlots.language | Interactive | Language <select> |
CodeToolbarSlots.copy | Interactive | Copy button with data-code="copy" |