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

vue2-input-highlighter

v1.1.0

Published

A Vue.js component that highlights text as you type

Downloads

16

Readme

Vue 2 Input Highlighter

Highlight and style specific words as you're typing.

Install

npm install --save vue2-input-highlighter

Requirements

  • Vue 2 (does not support Vue 3)
  • Node >= 14

Usage

In <template>:

<highlightable-input 
  highlight-style="background-color:yellow" 
  :highlight-enabled="highlightEnabled" 
  :highlight="highlight" 
  v-model="text"
/>

In your component code:

import HighlightableInput from "vue2-input-highlighter"
export default {
  name: 'HelloWorld',
  components : {
    HighlightableInput
  },
  data() {
    return {
      text: '',
      highlight: [
        { text: 'box', classList: ['shape'] },
        { text: 'chicken', style: "background-color: #f37373" },
        { text: 'noodle', style: "background-color: #fca88f" },
        { text: 'soup', style: "background-color: #bbe4cb" },
        { text: 'so', style: "background-color: #fff05e" },
        "whatever",
        { start: 2, end: 5, style: "background-color: #f330ff" }
      ],
      highlightEnabled: true
    }
  },
}

Props

| Name | Type | Default | Description | Reactive | |---|---|---|---|---| | highlight (required) | String or Array | | The string or list of words to highlight. This can be a single string value, a RegExp or you can do an array of strings or RegExp or array of Highlight Objects or array of Range Objects. | Yes | | highlightEnabled | Boolean | true | If true, will highlight the text. | Yes | | defaultClassList | Array | [] | Applies the specified CSS classes to each highlight, if classList is not provided. | Yes | | highlightStyle | String or Object | background-color:yellow | If no style is provided for text, this will act as the global styling for the highlight. Can also be a dictionary instead of string. | Yes | | highlightDelay | Number | 500 | Determines how long in milliseconds to wait before processing the highlights. Setting this to a low value is fine for small text but setting it higher may improve performance significantly for larger text. | Yes | | caseSensitive | Boolean | false | If true, will treat highlight strings with case sensitivity. Can be overridden per highlight object. | Yes | | value (or use v-model) | String | null | Raw text value. | Yes | | fireOn | String | keydown | The dom event on which the highlight event should be fired. This can be any event that the div content editable can handle. | No (onMount only) | | fireOnEnabled | Boolean | true | If true, will process the highlights on the specified (or default) event. | No (onMount only) |

Highlight Object

{
  text: 'chicken', // Required
  classList: ['animal', 'farm'], // Optional - apply CSS classes to this highlighted token, defaulting to `defaultClassList`
  style: "background-color: #f37373", // Optional
  caseSensitive: true // Optional defaults to False
}

Range Object

{
  start: 1, // Required
  end: 9,  // Required, end must be greater than start [start, end)
  classList: ['range'], // Optional
  style: "background-color: #f37373" // Optional
}

Events

| Name | Description | Payload | | --- | --- | --- | | @input | Emits when user types text | str | | @onHighlight | Provides details on which text ranges were stylized | array - [{ start, end, classList, style, text }]

Performance

This component is not designed for large scale text highlighting.

Credits

This project is forked from SyedWasiHaider/vue-highlightable-input.

License

MIT