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

    Interface UseSceneTextEditOptions<TData>

    All-optional projections + fontSize fallback.

    interface UseSceneTextEditOptions<TData> {
        defaultFontSize?: number;
        getRuns?: (data: TData) => readonly StyledRun[] | undefined;
        getStyle?: (data: TData) => TextStyle | undefined;
        getText?: (data: TData) => string;
        isEditorChrome?: (el: Element) => boolean;
        setRuns?: (data: TData, runs: StyledRun[]) => TData;
        setText?: (data: TData, text: string) => TData;
        view?: View;
    }

    Type Parameters

    • TData
    Index

    Properties

    defaultFontSize?: number

    Fallback fontSize when style.fontSize is unset. Default 16.

    getRuns?: (data: TData) => readonly StyledRun[] | undefined

    Read rich-text runs from data. Default: data.runs.

    getStyle?: (data: TData) => TextStyle | undefined

    Read style from data. Default: data.style.

    getText?: (data: TData) => string

    Read plain text from data. Default: data.text ?? ''.

    isEditorChrome?: (el: Element) => boolean

    Forwarded to useTextEdit: is el part of the editor's own chrome? Focus moving into it does not end the edit. Wire it to whatever renders the character controls.

    setRuns?: (data: TData, runs: StyledRun[]) => TData

    Produce updated data with new runs. Default: { ...data, runs }.

    setText?: (data: TData, text: string) => TData

    Produce updated data with new text. Default: { ...data, text }.

    view?: View

    Current viewport. Supply it on a canvas that pans or zooms: the overlay is then positioned at the node's projected screen origin and CSS-scaled by the view, so every typographic metric on it — including the fontSize / letterSpacing a run carries — stays in world units and scales together. Omit it and the node's world box is passed through as screen pixels (correct at {x: 0, y: 0, scale: 1}).

    The overlay takes a single scale factor, so a non-uniform view scale is represented by its scale.x; text under scale.x !== scale.y will not match the canvas.