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.
| Slot | Capability | Renders |
|---|---|---|
root | Container | Source editor wrapper |
text | TextInput | Markdown textarea with data-source="text" |
warnings | Collection | Warnings list with data-source="warnings" |
warning | Base | Warning item with data-code and data-detail |
done | Interactive | Exit button with data-source="done" |
What lives elsewhere
- Editor placeholder and line hints: Configured on
editorAtinfoldkit-richtext-dombecause they live inside thecontenteditabletree. - Floating and block positioning:
selectionAnchor,blockAnchor, andblockDraglive infoldkit-richtext-dom/toolbar.
Next
- Mount the editable host and configure placements:
foldkit-richtext-dom - Style Slots with theme tokens and Behaviors:
foldkit-mixins - Parse and print Markdown for source mode:
foldkit-richtext-markdown