UNPKG

@blocknote/react

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

21 lines (20 loc) 816 B
export interface UseFocusWithinOptions { onFocus?: (event: FocusEvent) => void; onBlur?: (event: FocusEvent) => void; } /** * Tracks whether focus is within a referenced DOM element. Returns a ref to * attach to the target element and a `focused` boolean that is `true` whenever * the element or any of its descendants has focus. * * Adapted from Mantine's `useFocusWithin` hook. * * @param options - Optional `onFocus` and `onBlur` callbacks fired when focus * enters or leaves the element. * @returns An object with a `ref` to attach to the target element and a * `focused` boolean indicating current focus-within state. */ export declare function useFocusWithin<T extends HTMLElement = any>({ onBlur, onFocus, }?: UseFocusWithinOptions): { ref: React.RefObject<T>; focused: boolean; };