Appearance
useTextSelection
Reactively track user text selection based on Window.getSelection
Demo
Usage
tsx
import { useTextSelection } from '@reause/core'
const { text, rects, ranges, selection } = useTextSelection()Type Declarations
ts
export interface UseTextSelectionOptions extends ConfigurableWindow {
}
export interface UseTextSelectionReturn {
text: string;
rects: DOMRect[];
ranges: Range[];
selection: Selection | null;
}
export function useTextSelection(options?: UseTextSelectionOptions): UseTextSelectionReturn