Rich text / foldkit-mixins-richtext

Outline, footnotes, and command palette

  • tableOfContents<Message>(): Renders RichText.outlineOf(document) as a nav list, marking RichText.sectionAt with aria-current="location" and calling chosen(node) on click (returns empty when no headings exist). Slots: root (nav), list (ul), entry (button with --fk-toc-level).
  • footnotePreview<Message>(): Renders when the caret is inside a FootnoteRef (RichText.footnoteAt), showing the note text, a label field emitting RenamedFootnote, and a Go to note button sending opened(definition). Slots: root (role="group"), label (TextInput), text (Container), button (Interactive).
  • commandPalette<Message>(): Searches slashEntries from a standalone role="combobox" dialog driven by { query, index } | null in your Model:
ts
import { commandPalette } from 'foldkit-mixins-richtext'

const commands = slashEntries(event => Message.ChoseCommand({ event }))

model.palette === null
  ? h.empty
  : commandPalette<Message>()(
      {
        id: 'commands',
        entries: commands,
        query: model.palette.query,
        index: model.palette.index,
        changed: (query, index) => Message.ChangedPalette({ query, index }),
        closed: Message.ClosedPalette(),
      },
      h,
    )
SlotCapabilityRenders
rootContainerrole="dialog" palette
inputTextInputrole="combobox" search input
listCollectionrole="listbox" matches
optionInteractiveOption row with data-entry and aria-selected

Show word counts and validation diagnostics

editorStatus<Message>() displays cached word and character counts (RichText.count) alongside any diagnostics you pass from RichText.validate:

ts
import { editorStatus } from 'foldkit-mixins-richtext'

editorStatus<Message>()(
  { document: model.document, diagnostics: RichText.validate(model.document, ArticleKit) },
  h,
)
SlotCapabilityRenders
rootContainerStatus bar wrapper
countsBaseCounts summary with data-status="counts"
problemsCollectionDiagnostics list with data-status="problems"
problemBaseDiagnostic item with data-code and data-node