# vanilla-caret-js

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

Latest version **1.1.0** (published 2022-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install vanilla-caret-js
pnpm add vanilla-caret-js
yarn add vanilla-caret-js
bun add vanilla-caret-js
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-07-14 |
| First published | 2019-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 44.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | Abhas Tandon |
| Maintainers | abhastandon |
| Keywords | javascript, es6, es2015, caret position, contenteditable, TextArea |

## Links

- npm: https://www.npmjs.com/package/vanilla-caret-js
- Repository: https://github.com/abhas9/vanilla-caret-js
- Homepage: https://github.com/abhas9/vanilla-caret-js/
- Issues: https://github.com/abhas9/vanilla-caret-js/issues
- npm.io page: https://npm.io/package/vanilla-caret-js

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-07-14
- 1.0.1 — 2019-04-28
- 1.0.0 — 2019-04-28

## README

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

[![NPM version][npm-version-image]][npm-url]
[![NPM size][npm-size-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Donate][donate-image]][paypal-link]
[![MIT License][license-image]][license-url]

# Demo
[![Demo](https://media.giphy.com/media/fndxOJjHJMvZqWEJBT/giphy.gif)](http://abhas9.github.io/vanilla-caret-js)


# Setup
```shell
$ npm i vanilla-caret-js
const VanillaCaret = require('vanilla-caret-js');
```
OR
```javascript
<script src="https://cdn.jsdelivr.net/npm/vanilla-caret-js@1.0.1/dist/VanillaCaret.min.js"></script>
```
# Example Usage

```javascript
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`):

```shell
$ npm install
```

## Available tasks

### Build and test
```shell
$ node make # or also `$ npm run default`
```

### Convert the ES6 code into valid ES5 combining all the modules into one single file
```shell
$ node make build # or also `$ npm run build`
```

### Start a nodejs static server
```shell
$ node make serve # or also `$ npm run serve`
```

[license-url]: LICENSE
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square

[paypal-link]:https://www.paypal.me/abhas9
[donate-image]:https://img.shields.io/badge/donate-%E2%9D%A4-brightgreen.svg?style=flat-square

[npm-url]: https://www.npmjs.com/package/vanilla-caret-js
[npm-version-image]: http://img.shields.io/npm/v/vanilla-caret-js.svg?style=flat-square
[npm-size-image]: https://img.shields.io/bundlephobia/min/vanilla-caret-js.svg?style=flat-square

[travis-url]:https://travis-ci.org/abhas9/vanilla-caret-js
[travis-image]: https://api.travis-ci.org/abhas9/vanilla-caret-js.svg?branch=master&style=flat-square

---
_Source: https://npm.io/package/vanilla-caret-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
