vanilla-caret-js

1.1.0 • Public • Published

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`

Package Sidebar

Install

npm i vanilla-caret-js

Weekly Downloads

6,924

Version

1.1.0

License

MIT

Unpacked Size

45.9 kB

Total Files

22

Last publish

Collaborators

  • abhastandon