1.1.0 • Published 2 years ago

vanilla-caret-js v1.1.0

Weekly downloads
48
License
MIT
Repository
github
Last release
2 years ago

Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript

NPM version NPM size Build Status Donate MIT License

Demo

Demo

Setup

$ npm i vanilla-caret-js
const VanillaCaret = require('vanilla-caret-js');

OR

<script src="https://cdn.jsdelivr.net/npm/vanilla-caret-js@1.0.1/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`