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,
)
SlotCapabilityRenders
TableToolbarSlots.rootContainerTable toolbar wrapper
TableToolbarSlots.toolbarCollectionrole="toolbar" button row
TableToolbarSlots.buttonInteractiveAction button with data-table
CodeToolbarSlots.rootContainerrole="toolbar" wrapper
CodeToolbarSlots.languageInteractiveLanguage <select>
CodeToolbarSlots.copyInteractiveCopy button with data-code="copy"