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

vue-custom-highlight

v1.0.0

Published

vue component using the CSS Custom Highlight API

Downloads

4

Readme

vue-custom-highlight

vue component using the CSS Custom Highlight API

What is CSS Custom Highlight API

CSS Custom Highlight API

Online Demo

https://codesandbox.io/p/github/tjyuanpeng/vue-custom-highlight

Installation

// pnpm
pnpm add vue-custom-highlight

// npm
npm install vue-custom-highlight

// yarn
yarn add vue-custom-highlight

Basic Usage

<script setup lang="ts">
import VueCustomHighlight from 'vue-custom-highlight'
</script>
<template>
  <VueCustomHighlight text="quick">
    The quick brown fox jumps over the lazy dog
  </VueCustomHighlight>
</template>

Component Reference

text

text to highlight

highlightStyle

the style of highlight text

default value is background-color: yellow;

<!-- string -->
<VueCustomHighlight highlightStyle="color: red">text content</VueCustomHighlight>

<!-- css property object -->
<VueCustomHighlight highlightStyle="{ color: 'red' }">text content</VueCustomHighlight>

note that Only certain CSS properties can be used

  • color
  • background-color
  • text-decoration and its associated properties
  • text-shadow
  • -webkit-text-stroke-color, -webkit-text-fill-color and -webkit-text-stroke-width

https://developer.mozilla.org/en-US/docs/Web/CSS/::highlight#allowable_properties

ignoreCase

ignore case sensitive of text, default value is false

uid

custom identifier to register highlight

Note that uid must start with an alphabet

if value is empty, component will generate an id automatically

childrenSelector

deteminate how to select child elements to render

default value is *, it means including component`s child elements self and all sub doms

you can exclude the dom to render

<template>
  <VueCustomHighlight text="button" childrenSelector="*:not(button)" >
    text content outside the button
    <button>I`m a button</button>
  </VueCustomHighlight>
</template>

about :scope in querySelectorAll

renderHighlight

instance method

if dom changed, you can call renderHighlight manually to re-render highlight

clearHighlight

instance method

clear highlight

useCustomHighlight Reference

you can use hook api to render highlight directly

renderHighlight

const { renderHighlight } = useCustomHighlight()
renderHighlight({
  uid: `uid`,
  text: `text`,
  ignoreCase: false,
  nodeList: nodeList,
})
  • uid: custom identifier to register highlight
  • text: text to highlight
  • nodelist: the list of node to highlight
  • ignoreCase: ignore case sensitive of text, default value is false

clearHighlight

const { clearHighlight } = useCustomHighlight()
clearHighlight(`uid`)
  • uid: custom identifier to the registered highlight

getHighlightKeys

get all keys of the registered highlight

const { getHighlightKeys } = useCustomHighlight()
getHighlightKeys()