fn
useTextSelection
v0.0.15testeddemoReactively track the user's text selection via `Window.getSelection`.
Example
ts
const { text, rects, ranges, selection } = useTextSelection();
watch(text, (value) => console.log('selected:', value));Demo
Loading demo…
Signature
ts
export function useTextSelection(
options: UseTextSelectionOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseTextSelectionOptions | Options (custom `window`, `document`) |
Returns
UseTextSelectionReturnReactive `text`, `rects`, `ranges`, and the raw `selection`