vanilla-caret-js
v1.1.0
Published
Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript
Downloads
49,881
Maintainers
Readme
Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript
Demo
Setup
$ npm i vanilla-caret-js
const VanillaCaret = require('vanilla-caret-js');
OR
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/VanillaCaret.min.js"></script>
Example Usage
var caret = new VanillaCaret(document.getElementById('root')); // Initialize
caret.setPos(4); // Set
document.getElementById('currentPosition').value = caret.getPos(); // Get
Development
Once you've downloaded the files in this repo please run the following command in your terminal from the project folder (it may require sudo
):
$ npm install
Available tasks
Build and test
$ node make # or also `$ npm run default`
Convert the ES6 code into valid ES5 combining all the modules into one single file
$ node make build # or also `$ npm run build`
Start a nodejs static server
$ node make serve # or also `$ npm run serve`