Rich text / foldkit-mixins-richtext
Edit and remove links
linkEditor provides an address input with Apply/Update and Remove buttons, returning AppliedMark or ClearedMark through wrap:
ts
import { linkEditor } from 'foldkit-mixins-richtext'
const linkDraft = RichText.linkAt(model.document, model.editor.selection)?.href ?? ''
linkEditor<Message>()(
{
document: model.document,
selection: model.editor.selection,
draft: model.linkDraft,
drafted: href => DraftedLink({ href }),
wrap: edited,
},
h,
)URLs are sanitized with RichText.safeUrl before emitting, and Apply stays disabled unless a valid URL and either a text range or a link around the caret exist. Pass closed to catch Escape, and pass submitted so fast Enter presses compute linkEdit(document, selection, model.linkDraft) from the latest Model draft rather than the last rendered props.
| Slot | Capability | Renders |
|---|---|---|
root | Container | role="group" wrapper |
input | TextInput | Address input with data-link="address" |
apply | Interactive | Apply/Update button with data-link="apply" |
remove | Interactive | Remove button with data-link="remove" inside links |