@mocanvas/mocanvas · interface

EditableTextHandle

interface EditableTextHandle

Everything a label component needs, from either hook.


Properties · 10

handleBlur: () => void

Stop editing when focus leaves the label.

handleDoubleClick: (e: {

Start editing on a double click.

handleFocus: () => void

Select the whole label when it takes focus, so typing replaces it.

handleInputPointerDown: (e: PointerEvent) => void

Swallow pointer-down inside the input so the canvas does not start a drag.

handleKeyDown: (e: KeyboardEvent) => void

Escape commits, Enter commits a single-line label.

handlePaste: (e: ClipboardEvent | ClipboardEvent$1<HTMLTextAreaElement>) => void

Let a paste inside the label reach the label rather than the canvas.

isEditing: boolean

Whether this shape is the one being edited.

isEmpty: boolean | undefined

Whether the label has no text; undefined before it is known.

isReadyForEditing: boolean

Whether the editing surface may mount.

One frame behind isEditing: a contenteditable that mounts in the same commit as the state change steals focus before the canvas has finished handling the click that caused it.

rInput: RefObject<HTMLDivElement | null>

Ref for the element the text is edited in.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.