weasel API - v0.8.0
    Preparing search index...

    Interface UseTextEditOptions

    Options for useTextEdit.

    interface UseTextEditOptions {
        container: HTMLElement | null;
        getRuns?: (id: string) => readonly StyledRun[] | undefined;
        getScreenPose: (id: string) => TextEditScreenPose | null;
        getStyle: (id: string) => TextStyle | undefined;
        getText: (id: string) => string;
        isEditorChrome?: (el: Element) => boolean;
        setRuns?: (id: string, runs: StyledRun[]) => void;
        setText: (id: string, text: string) => void;
    }
    Index

    Properties

    container: HTMLElement | null

    Element the overlay is appended to. Must be position: relative/absolute.

    getRuns?: (id: string) => readonly StyledRun[] | undefined

    Optional: read the current rich-text runs for id. When provided AND returns a non-empty array, the overlay renders the runs as styled <span data-run> elements; otherwise the overlay is seeded with plain text via getText.

    getScreenPose: (id: string) => TextEditScreenPose | null

    Read screen-space pose for id. Called per frame while editing.

    getStyle: (id: string) => TextStyle | undefined

    Read style for id (used for font setup on the overlay).

    getText: (id: string) => string

    Read the current text for id.

    isEditorChrome?: (el: Element) => boolean

    Is el part of the editor's own chrome — a character-options bar, a color popover, anything whose whole purpose is to style the text being edited? Focus moving into one does not end the edit.

    Without this, the controls the feature exists for are exactly what destroys it: clicking a size field blurs the overlay, blur commits, and the caret the control was about to act on is gone. Toggle buttons can dodge it by preventDefault()-ing their own mousedown, but a field the user has to type into cannot.

    Chrome focus does not disturb the reported selection either — see UseTextEditReturn.selection.

    setRuns?: (id: string, runs: StyledRun[]) => void

    Optional: commit rich-text runs back to the node. When omitted, only setText is called with the plain-text form on commit. When provided, commit calls both setText (with runsToPlainText(runs)) and setRuns(id, runs) — but only when runs are actually in play: the node already had some, or the edit produced styling. A plain-text edit of a plain-text node still calls setText alone, so a node that has never been styled doesn't grow a single-run runs array just for being edited.

    setText: (id: string, text: string) => void

    Commit text. Caller wraps in op/undo.