# v-search-and-highlight

> A Vue plugin for searching the content of an element and highlighting the keyword with the mark element.

Latest version **1.1.0** (published 2018-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install v-search-and-highlight
pnpm add v-search-and-highlight
yarn add v-search-and-highlight
bun add v-search-and-highlight
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-03-22 |
| First published | 2018-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ranwu |
| Maintainers | ranwu |
| Keywords | vue, plugin, directive, search, highlight, mark |

## Links

- npm: https://www.npmjs.com/package/v-search-and-highlight
- Repository: https://github.com/xing-zhi/v-search-and-highlight
- Homepage: https://github.com/xing-zhi/v-search-and-highlight#readme
- Issues: https://github.com/xing-zhi/v-search-and-highlight/issues
- npm.io page: https://npm.io/package/v-search-and-highlight

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-03-22
- 1.0.0 — 2018-03-20

## README

# Vue search and highlight plugin
A Vue plugin for searching the content of an element and highlighting the keyword with the mark element.

The plugin includes a vue directive. It searches the children of the element recursively and replaces the keyword with a mark element.

# Install
## npm
```bash
$ npm i -S v-search-and-highlight
```

## CDN
未压缩版本
```html
<script src="https://cdn.jsdelivr.net/npm/v-search-and-highlight@1.1.0/dist/v-search-and-highlight.js"></script>
```

压缩版本
```html
<script src="https://cdn.jsdelivr.net/npm/v-search-and-highlight@1.1.0/dist/v-search-and-highlight.min.js"></script>
```

# Usage
The directive requires the `keyword` argument and surpports an optional filter function to filter out elements.

## Parameters

|Name|Required|Type|Description|
|:---- | :--- | :--- | :---- |
|keyword|true|String|The keyword to search|
|filter|false|Function/String|If it is a function, it's the function to filter the elements, take the DOM node as parameter and return `true` for handling the element; If it is a string, it's the class name of for elements to filter out.|

## Examples
There are examples in [the examples folder](https://github.com/xing-zhi/v-search-and-highlight/tree/master/examples), and you can view them [here](https://ranwu.me/v-search-and-highlight/).

# Caveats
For data binding, we have to use `v-text` directive other than the mustache syntax.

Because the mustache syntax generates a text node, but this directive replaces text with a html node, which cann't be in a text node.

# License
[MIT](https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/v-search-and-highlight · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
