textSelectionStore

Reactive element size

Demo

You can select any text on the page.

Selected Text: No selected

Selected rects:
[]

Usage

<script>
import { textSelectionStore } from "svelte-legos";

const selectionStore = textSelectionStore();

// $selectionStore.text => current selected text
// $selectionStore.selection => window.getSelection()
// $selectionStore.ranges => all selection ranges
// $selectionStore.rects => all selection ranges DOMRect
</script>

<div>
    {$selectionStore.text}
</div>