npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-input-highlighter

v1.0.1

Published

Rich-text Angular input that decorates text dynamically created components on the fly for target words, allowing for local lookups by string or items at designated indices.

Downloads

81

Readme

npm version

ng-input-highlighter

Rich-text input that decorates text with a designated css class

Checkout the demo

This Angular library creates a rich-text input that decorates text with a designated css class without using separate div's, allowing normal html web interactions such as selecting and right-click. The entire textbox is a contenteditable div with conjoined Angular directives rendered on the fly.

Key Features

Flexibility with Internal or External Parsing

Allow the Component to perform simple quick lookups and find indices of select target words or provide an array of items and indices for the Component to render. This lets your parsing be as advanced as you'd like, using outputs from NLP APIs such as IBM Watson or as simple as a string match.

Use Normal CSS Classes For Decorations

The Component sets the class of identified target words to whatever class you want. Just give it the string name for the target, and it will set it on the rendered directive. For examples of CSS used in the demo, checkout the bottom of the page.

Normal HTML Accessibility

While the Component is actually several divs and spans, it appears and functions as one. Clicking and dragging allows for normal fluid selection. Clicks in the empty spaces brings the caret position to the end of the input naturally and bring focus to the entire textbox. Double clicks inside the textbox select all text.

Ability to Add Actions and Pop Up Menus

Since each identified word is its own component, the Component has the ability to attach unique menus with descriptions such as Entity Type, Confidence as well as allow for suggested replacements of words identified.

Requirements

Angular 6.0+

Importing

In your app.module.ts or whatever module you are using it in:

import { NgInputHighlighterModule } from 'ng-input-highlighter';

Add to your imports array:

imports: [ NgInputHighlighterModule ]

And then you have two options- for local analysis, meaning letting the component look for a defined set of words, place the component in your html with:

<lib-ng-input-highlighter [localAnalysis]="true" [targetItems]="targetItems"></lib-ng-input-highlighter>

With the targetItems array input as targetItems: object[]

With objects as:
targetItem: { text: string, css: string } If you'd like to add menus and replacement options, refer to the documentation and demo for optional attributes on the targetItem class.

If you choose to do external analysis, meaning letting a separate parsing service look for specific entities, place the component in your html with:

<lib-ng-input-highlighter [localAnalysis]="false" [targetItems]="targetItems"></lib-ng-input-highlighter>

With objects as:
targetItem: { text: string, css: string, location: [start, end] }

For more information on use with further customization, check out the demo

To run the local demo app

Run npm install then run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.