All Projects â†’ AlbertLucianto â†’ Vue Text Highlight

AlbertLucianto / Vue Text Highlight

Licence: mit
Text highlighter library for Vue.js 💄

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Text Highlight

Leader Line
Draw a leader line in your web page.
Stars: ✭ 1,872 (+680%)
Mutual labels:  highlight
Chromaterial
ChroMATERIAL is an IntelliJ Platform coloring scheme that expresses the chromatic nature of Material Design within IntelliJ and Android Studio. It is intended to highlight the most import aspects of your code.
Stars: ✭ 143 (-40.42%)
Mutual labels:  highlight
Vue Highlight.js
📜 Highlight.js syntax highlighter component for Vue.
Stars: ✭ 180 (-25%)
Mutual labels:  highlight
Neotags.nvim
Tag highlight in neovim
Stars: ✭ 124 (-48.33%)
Mutual labels:  highlight
Wxparse
微信小程序富文本解析
Stars: ✭ 135 (-43.75%)
Mutual labels:  highlight
Mark.js
JavaScript keyword highlighting. Mark text with with options that fit every application. Also available as jQuery plugin.
Stars: ✭ 2,004 (+735%)
Mutual labels:  highlight
Codeblock Beautifier
A chrome extension for highlighting codes of Medium Articles
Stars: ✭ 109 (-54.58%)
Mutual labels:  highlight
Folioreaderkit
📚 A Swift ePub reader and parser framework for iOS.
Stars: ✭ 2,382 (+892.5%)
Mutual labels:  highlight
Highlight Utils
My tools for converting, importing, and processing Kindle, Instapaper, and Safari Books highlights
Stars: ✭ 143 (-40.42%)
Mutual labels:  highlight
Vue Morphling
Vue filters and directives collection.
Stars: ✭ 179 (-25.42%)
Mutual labels:  highlight
Vue Prism Component
highlight code using prism.js and vue component
Stars: ✭ 126 (-47.5%)
Mutual labels:  highlight
Hexo Theme Casper
New casper theme ported to hexo.
Stars: ✭ 132 (-45%)
Mutual labels:  highlight
Folioreader Android
A Java ePub reader and parser framework for Android.
Stars: ✭ 2,025 (+743.75%)
Mutual labels:  highlight
Jupytergraffiti
Create interactive screencasts inside Jupyter Notebook that anybody can play back
Stars: ✭ 114 (-52.5%)
Mutual labels:  highlight
Markdown Edit
online markdown editor/viewer
Stars: ✭ 188 (-21.67%)
Mutual labels:  highlight
Bepasty Server
binary pastebin server
Stars: ✭ 111 (-53.75%)
Mutual labels:  highlight
Geshi 1.0
Original version of Generic Syntax Highlighter for PHP
Stars: ✭ 149 (-37.92%)
Mutual labels:  highlight
Multilamp
Android library to showcase/highlight the multiple views on same overlay
Stars: ✭ 233 (-2.92%)
Mutual labels:  highlight
Hexo Prism Plugin
Hexo plugin for code highlighting by prism.js, supporting JSX syntax
Stars: ✭ 195 (-18.75%)
Mutual labels:  highlight
Hanabi
💥 Highlight any code, in a colorful way. (seriously 700 bytes)
Stars: ✭ 166 (-30.83%)
Mutual labels:  highlight

Vue Text Highlight

Coverage Status Build Status Downloads Downloads Version License

See working example here.

Installation

npm install --save vue-text-highlight
# or
yarn add vue-text-highlight

Usage

Basic Usage

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

Vue.component('text-highlight', TextHighlight);

// new Vue ...

SomeComponent.vue

<template>
  <text-highlight :queries="queries">{{ description }}</text-highlight>
</template>
data() {
  return {
    queries: ['birds', 'scatt'],
    description: 'Tropical birds scattered as Drake veered the Jeep'
  };
}

Output

text-highlight

More Options

All available props in TextHighlight component are:

  • queries: Array<String|RegExp>|String|RegExp

    This prop accepts string, regex, and array of strings or regex. If array is given, it will highlight the union of matched strings/regex globally.

  • [caseSensitive]: Boolean

    Whether string being searched is case sensitive.

  • [diacriticsSensitive]: Boolean

    Whether string being searched is diacritics sensitive.

  • [wholeWordMatch]: Boolean

    Whether string being searched as a whole word .

  • [highlightStyle]: Object|Array|String

    Styles to be applied to highlighted <mark>. Similar to style bindings in vue, it accepts Array syntax, Object syntax, or plain styling as String. This prop will then be merged with default highlight styles in TextHighlight component. See style binding in Vue.js.

  • [highlightClass]: Object|Array|String

    Classes to be added to highlighted <mark>. Similar to class bindings in vue, it accepts Array syntax, Object syntax, or class as String. See class binding in Vue.js.

  • [highlightComponent]: Object|String

    By default vue-text-highlight uses <mark> for the highlighting. Pass this props to override with other tag (string) or custom component (Vue component definition).

    This component will be passed with two props from text-highlight:

    • index: Number

      Index of highlighted component.

    • text: String

      Highlighted words, equals to this.$slots.default[0].text

    For more details, see example below.

  • Other props and listeners that are not listed above are forwarded to the highlighted component. These props will be merged with higher precendence than index and text passed from text-highlight.

Advanced Usage

There might be a case where you want to do more things with the highlighted words. For that reason, vue-text-highlight supports custom component for the highlighted words. In this case, the following example alerts on click.

OtherComponent.vue

<template>
  <text-highlight
    :queries="queries"
    :highlightComponent="MyClickableComponent"
    :baz="foo"
    @customlistener="alert"
  >
    {{ description }}
  </text-highlight>
</template>
import MyClickableComponent from 'MyClickableComponent';
data() {
  return {
    queries: ['birds', 'scatt'],
    description: 'Tropical birds scattered as Drake veered the Jeep'
    MyClickableComponent,
    foo: 'bar',
  };
},
methods: {
  alert() {},
}

MyClickableComponent.vue

<template>
  <mark class="custom" @click="$emit('customlistener')">
    <slot></slot>
  </mark>
</template>
props: {
  baz: String, // From OtherComponent.vue
  index: Number, // From TextHighlight
  text: String, // From TextHighlight, equals to `this.$slots.default[0].text`
}

Changelog

Changes are tracked in the changelog.

License

vue-text-highlight is available under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].