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.

SlotCapabilityRenders
rootContainerrole="group" wrapper
inputTextInputAddress input with data-link="address"
applyInteractiveApply/Update button with data-link="apply"
removeInteractiveRemove button with data-link="remove" inside links