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

hightlight-keyword

v1.0.5

Published

hightlight keyword plug-in unit a hight [3~[3~[3~[3~[3~[3~[3~[3~[3~[3~[3~[3~[3~[3~[3~

Downloads

5

Readme

详细信息

关键字高亮

    example

    import {hightlight} from 'hightlight-keyword'

Vue 使用

<div v-html='hightlight(option)'></div>

React 使用

<div dangerouslySetInnerHTML={{
	__html:hightlight({
        sourceText:source,
        keyWords:'零食',
      })
}}></div>

option

    option = {
        sourceText:'', // 必填 文本
        keyWords:''||[], // 必填  关键字,可以是多个 
        // 自定义文字样式设置一个会覆盖未设置,若要使用的地方都不一样,每次使用都要设置样式 
        style:'background: #3d73d5;color: #fbfcff;cursor: pointer', 
    }   



效果

react-light

点击事件

若是搜索的是一个手机号或是省份证,在高亮的同时想知道持有者的信息,就要点击查询,传参数

一般是作为一个全局的事件弹窗挂载到 App.js页面 将处理的事件赋值给全局的事件,下面以react 为例

	

	componentDidMount() {
        //  window.keyEvent为点击的全局事件
        window.keyEvent = this.event
    }

    event(param){
        // 获取点击的节点参数
        console.log("this is event",param)
		let text = param.target.innerText
        // text 为点击高亮的参数 用参数去接口请求
        // 弹出弹窗 用请求道的参数展示数据
    }


	option = {
        sourceText:'', // 必填 文本
        keyWords:''||[], // 必填  关键字,可以是多个 
        style:'background: #3d73d5;color: #fbfcff;cursor: pointer', //自定义文字样式
        // 直接通过设置的图片来添加点击事件  !!!!最好不要用本地图片,用线上图片!!!!
        imagesUrl:'https://pic3.zhimg.com/80/v2-35f2a750f699012eb0d205b03d945fb1_720w.jpg?source=1940ef5c'
    } 


react-light