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

    Interface UseSceneTextEditReturn

    Return shape extends UseTextEditReturn with an onDoubleClick binding for the canvas container. Double-clicking inside a text node enters edit mode with the caret seeded at the clicked glyph.

    interface UseSceneTextEditReturn {
        applyStyleToSelection: (patch: RunStylePatch) => void;
        cancelEdit: () => void;
        commit: () => void;
        editingId: string | null;
        isEditing: (id: string) => boolean;
        onDoubleClick: (e: MouseEvent<HTMLElement>) => void;
        rangeStyle: RangeStyle | null;
        selection: TextEditSelection | null;
        startEdit: (id: string, opts?: StartEditOptions) => void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    applyStyleToSelection: (patch: RunStylePatch) => void

    Write patch over selection. A no-op with no active edit, with a collapsed caret (there is no range to style — patch the node's TextStyle instead), or with an empty patch. The caret survives, so a second style can be applied without re-selecting, and rangeStyle reflects the write before this returns.

    cancelEdit: () => void
    commit: () => void
    editingId: string | null
    isEditing: (id: string) => boolean
    onDoubleClick: (e: MouseEvent<HTMLElement>) => void

    Bind to the element wrapping <SceneCanvas> (the same element passed as container, or any ancestor that receives the dblclick bubble). The handler looks up the canvas via e.target, hits the top-most text node under the cursor via pointInTextPose, resolves a caret offset via caretIndexAt, and starts edit on that node.

    rangeStyle: RangeStyle | null

    The styling shared by every run in selection — a concrete value where the range agrees, MIXED where it doesn't. null exactly when selection is null. A collapsed caret reports {}: no run is in range, so the range reader has nothing to say and the node's style is what applies.

    selection: TextEditSelection | null

    The caret's character range, or null when nothing is being edited. A collapsed caret reports { start: n, end: n }, so null and "caret at n" stay distinguishable — a character-styling control routes the collapsed case to the node's TextStyle instead of to a range.

    Follows the DOM selection, which browsers (and jsdom) report from a task rather than synchronously; anything this hook writes itself updates it synchronously. A DOM selection that leaves the overlay does not clear it: that is what happens when the user clicks a styling control, and reporting null there would read as "collapsed caret" and send the control's patch to the node instead of to the range. It is cleared on startEdit and when the edit ends.

    startEdit: (id: string, opts?: StartEditOptions) => void