Coder Social home page Coder Social logo

tonpc64 / vue-highlight-text Goto Github PK

View Code? Open in Web Editor NEW
56.0 3.0 12.0 5.7 MB

๐Ÿ”ฆ Vue component for highlight multiple instances of a word

Home Page: http://vue-highlight-text.surge.sh

License: MIT License

HTML 1.32% Vue 58.41% JavaScript 40.27%
vue-highlight-text vue highlight search

vue-highlight-text's Introduction

vue-highlight-text

NPM version NPM downloads Build Status

Vue component for highlight multiple instances of a word

Installation

# with yarn
yarn add vue-highlight-text

# with npm
npm install --save vue-highlight-text

Use component

import Vue from 'vue';
import HighlightText from 'vue-highlight-text';

Vue.component('HighlightText', HighlightText);

Use directive

import Vue from 'vue';
import highlight from 'vue-highlight-text/public/directive.min.js';

Vue.directive('highlight', highlight);

In file vue

<!-- component -->
<HighlightText :keyword="keyword" :sensitive="sensitive">{{msg}}</HighlightText>
<!-- Directive -->
<span v-highlight="{keyword: keyword}">{{msg}}</span>

Props or value of directive

Name Type Default Description
keyword string '' word for highlight in message.
sensitive bool true highlight with case sensitive
overWriteStyle Object {color: '#00C1E8'} custom highlight for overwrite style by HTML DOM Style Object

vue-highlight-text's People

Contributors

ccfish86 avatar khafang avatar krystian50 avatar mlzzen avatar paretkf avatar tonpc64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-highlight-text's Issues

Problems regarding string matching

Hi, Thanks for the great plugin.
I have a great time playing with it. But I found a strange result when dealing with string-matching.
Sometimes it works like charm. but sometime it doesn't even with only a little difference between two strings. Any suggestion for this?
BTW, what is the new feature of "sensitive", I have tried to change the Boolean value of sensitive, but can't tell the difference.

Best.

Shilik

not-ok
working

Multiple keywords matching

Hi,
Is that the keyword support an array? If I may have multiple keywords needed to be matched, how could I do it?

Thanks!

how to use in a for loop

< ul>
< li v-for="item in data" v-highlight="{keyword: '1'}"> {{ item.name }} < /li>
< /ul>

data : [
{
name: 1
},
{
name: 2
},
{
name: 3
}
]
result:
3
3
3

When the keywords is empty, the effect is unexcepted

vue-highlight-text is very useful for me.
but when we use it with v-html,such as code 'v-highlight="{keyword: keywords, overWriteStyle: {color: '#00C100'}}" v-html="articlesInfo"'. when the keywords is empty string or array contains empty element, the content is alse be replaced as image follows, then , and when the keywords is null/undifined, then content is display as blank.

image

ES6 in your exported bundle

Hi,
which browsers do you want to support with your package? At the moment, it is not usable with IE11 because your exported bundle contains ES6. Looking at your .browserslistrc, IE11 should be supported.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.