UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

24 lines (23 loc) 850 B
interface TextSelectionState { /** The selected text content. */ text: string; /** The DOMRect object representing the geometry of the selection. */ rect: DOMRect | null; /** The start offset of the selection within its start node. */ startOffset: number | null; /** The end offset of the selection within its end node. */ endOffset: number | null; /** The start node of the selection. */ startNode: Node | null; /** The end node of the selection. */ endNode: Node | null; /** The range object representing the selection. */ range: Range | null; } /** * Hook to track the user's text selection within the document. * * @returns {TextSelectionState} An object containing details about the current text selection. */ export declare function useTextSelection(): TextSelectionState; export {};