Rich text / foldkit-mixins-richtext

Switch to Markdown source mode

Pair sourceEditor<Message>() (and optionally sourcePreview<Message>() for split view) with openSource and closeSource from foldkit-richtext-markdown while model.source is non-null:

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

model.source === null
  ? h.empty
  : sourceEditor<Message>()(
      {
        session: model.source,
        document: model.document,
        drafted: draft => DraftedSource({ draft }),
        moved: caret => MovedInSource({ caret }),
        done: LeftSource(),
      },
      h,
    )

The textarea sets initial focus and caret position from session.caret on mount, emits drafted and moved as the user types or moves, lists any conversion warnings computed from closeSource, and emits done when leaving source mode so update can inspect warnings before committing closed.document.

SlotCapabilityRenders
rootContainerSource editor wrapper
textTextInputMarkdown textarea with data-source="text"
warningsCollectionWarnings list with data-source="warnings"
warningBaseWarning item with data-code and data-detail
doneInteractiveExit button with data-source="done"

What lives elsewhere

  • Editor placeholder and line hints: Configured on editorAt in foldkit-richtext-dom because they live inside the contenteditable tree.
  • Floating and block positioning: selectionAnchor, blockAnchor, and blockDrag live in foldkit-richtext-dom/toolbar.

Next