# angular-text-input-highlight

> A component that can highlight parts of text in a textarea. Useful for displaying mentions etc

Latest version **1.4.3** (published 2020-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install angular-text-input-highlight
pnpm add angular-text-input-highlight
yarn add angular-text-input-highlight
bun add angular-text-input-highlight
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.3 |
| Published | 2020-10-27 |
| First published | 2017-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 170.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 56 |
| Author | Matt Lewis |
| Maintainers | mattlewis92 |
| Keywords | angular4, angular2, angular, highlight, textarea |

## Links

- npm: https://www.npmjs.com/package/angular-text-input-highlight
- Repository: https://github.com/mattlewis92/angular-text-input-highlight
- Homepage: https://github.com/mattlewis92/angular-text-input-highlight#readme
- Issues: https://github.com/mattlewis92/angular-text-input-highlight/issues
- npm.io page: https://npm.io/package/angular-text-input-highlight

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.4.3 (latest) — 2020-10-27
- 1.0.5-alpha.1 (alpha) — 2017-09-01
- 1.4.2 — 2020-03-05
- 1.4.1 — 2020-02-12
- 1.4.0 — 2018-06-20
- 1.3.1 — 2018-05-05
- 1.3.0 — 2017-11-13
- 1.2.2 — 2017-11-09
- 1.2.1 — 2017-11-02
- 1.2.0 — 2017-10-11
- 1.1.1 — 2017-09-26
- 1.1.0 — 2017-09-01
- 1.0.5-alpha.0 — 2017-09-01
- 1.0.4 — 2017-08-14
- 1.0.3 — 2017-08-07
- … 3 more at https://npm.io/package/angular-text-input-highlight/versions

## README

# angular text input highlight
[![Build Status](https://travis-ci.org/mattlewis92/angular-text-input-highlight.svg?branch=master)](https://travis-ci.org/mattlewis92/angular-text-input-highlight)
[![codecov](https://codecov.io/gh/mattlewis92/angular-text-input-highlight/branch/master/graph/badge.svg)](https://codecov.io/gh/mattlewis92/angular-text-input-highlight)
[![npm version](https://badge.fury.io/js/angular-text-input-highlight.svg)](http://badge.fury.io/js/angular-text-input-highlight)
[![devDependency Status](https://david-dm.org/mattlewis92/angular-text-input-highlight/dev-status.svg)](https://david-dm.org/mattlewis92/angular-text-input-highlight?type=dev)
[![GitHub issues](https://img.shields.io/github/issues/mattlewis92/angular-text-input-highlight.svg)](https://github.com/mattlewis92/angular-text-input-highlight/issues)
[![GitHub stars](https://img.shields.io/github/stars/mattlewis92/angular-text-input-highlight.svg)](https://github.com/mattlewis92/angular-text-input-highlight/stargazers)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/mattlewis92/angular-text-input-highlight/master/LICENSE)

## Demo
https://mattlewis92.github.io/angular-text-input-highlight/

## Table of contents

- [About](#about)
- [Installation](#installation)
- [Documentation](#documentation)
- [Development](#development)
- [License](#license)

## About

A component that can highlight parts of text in a textarea. Useful for displaying mentions etc

## Installation

Install through npm:
```
npm install --save angular-text-input-highlight
```

Include the stylesheet somewhere in your app:
```
node_modules/angular-text-input-highlight/text-input-highlight.css
```

Then include in your apps module:

```typescript
import { NgModule } from '@angular/core';
import { TextInputHighlightModule } from 'angular-text-input-highlight';

@NgModule({
  imports: [
    TextInputHighlightModule
  ]
})
export class MyModule {}
```

Finally use in one of your apps components:
```typescript
import { Component, ViewEncapsulation } from '@angular/core';
import { HighlightTag } from 'angular-text-input-highlight';

@Component({
  template: `
    <div mwlTextInputHighlightContainer>
      <textarea
        mwlTextInputElement
        [(ngModel)]="text"
        #textarea>
      </textarea>
      <mwl-text-input-highlight
        [tags]="tags"
        [textInputElement]="textarea">
      </mwl-text-input-highlight>
    </div>
  `,
  styles: [
   `
     // by default you won't see the highlighted tags until
     // you add a CSS class with a background color
     .bg-blue {
       background-color: lightblue;
     }
     .bg-pink {
       background-color: lightcoral;
     }
   `
  ],
  encapsulation: ViewEncapsulation.None
})
class MyComponent {

  text = 'this is some text';

  tags: HighlightTag[] = [{
    indices: { start: 8, end: 12 },
    cssClass: 'bg-blue',
    data: { user: { id: 1 } }
  }];

}
```

You may also find it useful to view the [demo source](https://github.com/mattlewis92/angular-text-input-highlight/blob/master/demo/demo.component.ts).

### Usage without a module bundler
```
<script src="node_modules/angular-text-input-highlight/bundles/angular-text-input-highlight.umd.js"></script>
<script>
    // everything is exported angularTextInputHighlight namespace
</script>
```

## Documentation
All documentation is auto-generated from the source via [compodoc](https://compodoc.github.io/compodoc/) and can be viewed here:
https://mattlewis92.github.io/angular-text-input-highlight/docs/

## Credits
This component borrows heavily from the ideas of the [ui-mention](https://github.com/angular-ui/ui-mention) package.

## Development

### Prepare your environment
* Install [Node.js](http://nodejs.org/) and NPM
* Install local dev dependencies: `npm install` while current directory is this repo

### Development server
Run `npm start` to start a development server on port 8000 with auto reload + tests.

### Testing
Run `npm test` to run tests once or `npm run test:watch` to continually run tests.

### Release
```bash
npm run release
```

## License

MIT

---
_Source: https://npm.io/package/angular-text-input-highlight · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
