useTextSelection

useTextSelection

Window.getSelection に基づいて、ユーザーのテキスト選択をリアクティブに追跡します。

使用法

<script setup lang="ts">
import { useTextSelection } from '@vueuse/core'

const state = useTextSelection()
</script>

<template>
  <p>{{ state.text }}</p>
</template>