# textarea-caret-ts

> fork of the textarea-caret package

Latest version **4.1.1** (published 2020-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install textarea-caret-ts
pnpm add textarea-caret-ts
yarn add textarea-caret-ts
bun add textarea-caret-ts
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2020-11-06 |
| First published | 2019-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | the_real_syler |
| Keywords | textarea, caret, position |

## Links

- npm: https://www.npmjs.com/package/textarea-caret-ts
- Repository: https://github.com/theRealSyler/textarea-caret-position
- Homepage: https://github.com/theRealSyler/textarea-caret-position#readme
- Issues: https://github.com/theRealSyler/textarea-caret-position/issues
- npm.io page: https://npm.io/package/textarea-caret-ts

## 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

- 4.1.1 (latest) — 2020-11-06
- 4.1.0 — 2019-09-21
- 4.0.4 — 2019-06-26
- 4.0.3 — 2019-06-26
- 4.0.2 — 2019-06-26
- 4.0.1 — 2019-06-26
- 4.0.0 — 2019-06-23

## README

# Textarea Caret Position Typescript version

is a fork of [this](https://github.com/component/textarea-caret-position) repo, with new functions.

## Example

> Note: the package has only been tested in angular but should also work in vue, react or other frameworks.

```ts
import { Caret } from 'textarea-caret-ts';

@ViewChild('caretElement', { static: true }) caretElement: ElementRef<HTMLInputElement>;
@ViewChild('divElement', { static: false }) divElement: ElementRef<HTMLDivElement>;

ngAfterViewInit() {
  this.caretElement.nativeElement.addEventListener('keydown', event => {
    // gets the Relative position of the caret (the original function only slightly changed).
    Caret.getRelativePosition(this.caretElement.nativeElement)
    // gets the Absolute position of the caret (not in  the original package).
    Caret.getAbsolutePosition(this.caretElement.nativeElement)
    // sets the position of the div element based on the caret position (not in  the original package).
    Caret.setElementPositionBasedOnCaret(this.divElement.nativeElement, this.caretElement.nativeElement, { left: 10, top: 12 });
  });
```

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