vue-text-selection
Overview
It's a vue 2.X directive of text-selection. Base on Selection
and Range
API, It can get the innerText of the selected range.
Installation
NPM
npm install vue-selectable --save
<script>
Include
Direct
Usage
NPM
; // Register a global custom directive called v-selectionVue; // Register the directive locally instead el: '#app' directives: selection methods: { // fixStr - the string that fix the boudary of the dom use the directive of the selection // allStr - the string of the selection } ;
<script>
Include
Direct el: '#app' directives: selection: selectiondefault methods: { // fixStr - the string that fix the boudary of the dom use the directive of the selection // allStr - the string of the selection } ;
HTML
Text here!
Option
v-selection
requires one mandatory parameter - directive parameter - object with one function, getSelection
, to get the fixStr ( the string that fix the boudary of the dom use the directive of the selection ) and the allStr ( the string of the selection ).
v-selection
has an optional modifiers, fix
, to auto limit the selection in the boundary of the dom use the directive.
Examples
You can find the example in examples directory. Examples for v2 were tested against version 2.5.9.