import { ObservableMaybe } from 'woby'; /** * A hook that provides reactive access to the browser's Selection API. * * This hook returns observables for all selection properties and automatically * updates them when the text selection changes. It's useful for building * rich text editors or other applications that need to track text selection. * * @param element - Optional element to listen for selection changes on (defaults to document) * @returns An object containing: * - selection: The raw Selection object * - anchorNode: An observable containing the anchor node * - anchorOffset: An observable containing the anchor offset * - focusNode: An observable containing the focus node * - focusOffset: An observable containing the focus offset * - isCollapsed: An observable boolean indicating if the selection is collapsed * - rangeCount: An observable number indicating the number of ranges * - type: An observable string indicating the selection type * - ranges: An observable array containing the selection ranges * * @example * ```tsx * const { isCollapsed, type } = useSelection() * * return ( *
*

Selection type: {type}

*

Is collapsed: {() => isCollapsed() ? 'Yes' : 'No'}

*
* ) * ``` * * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Selection|Selection API documentation} * @see {@link https://github.com/vobyjs/woby|Woby documentation} for more information about observables */ export declare function useSelection(element?: ObservableMaybe): { selection: Selection; anchorNode: import("woby").Observable; anchorOffset: import("woby").Observable; focusNode: import("woby").Observable; focusOffset: import("woby").Observable; isCollapsed: import("woby").Observable; rangeCount: import("woby").Observable; type: import("woby").Observable; ranges: import("woby").Observable; }; //# sourceMappingURL=useSelection.d.ts.map