Skip to content

useTextSelection

Category
Export Size
375 B
Last Changed
5 days ago

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

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
2f41d - fix(core): resolve useTextSelection audit findings (#668)

Released under the MIT License. v0.1.8