{"id":22486292,"url":"https://github.com/AlbertLucianto/vue-text-highlight","last_synced_at":"2025-08-02T19:31:27.459Z","repository":{"id":32514506,"uuid":"134784628","full_name":"AlbertLucianto/vue-text-highlight","owner":"AlbertLucianto","description":"Text highlighter library for Vue.js :lipstick:","archived":false,"fork":false,"pushed_at":"2022-12-09T23:17:44.000Z","size":1158,"stargazers_count":327,"open_issues_count":29,"forks_count":35,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-27T20:38:32.952Z","etag":null,"topics":["highlight","text-highlighter","vue"],"latest_commit_sha":null,"homepage":"https://albertlucianto.github.io/vue-text-highlight","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlbertLucianto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-25T00:59:54.000Z","updated_at":"2024-11-16T06:37:10.000Z","dependencies_parsed_at":"2023-01-14T21:30:43.106Z","dependency_job_id":null,"html_url":"https://github.com/AlbertLucianto/vue-text-highlight","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertLucianto%2Fvue-text-highlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertLucianto%2Fvue-text-highlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertLucianto%2Fvue-text-highlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertLucianto%2Fvue-text-highlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlbertLucianto","download_url":"https://codeload.github.com/AlbertLucianto/vue-text-highlight/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228500101,"owners_count":17930000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["highlight","text-highlighter","vue"],"created_at":"2024-12-06T17:14:17.406Z","updated_at":"2024-12-06T17:15:41.147Z","avatar_url":"https://github.com/AlbertLucianto.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","UI组件","Components \u0026 Libraries","UI Components [🔝](#readme)","UI Components"],"sub_categories":["杂","UI Components","Miscellaneous"],"readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://albertlucianto.github.io/vue-text-highlight\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg width=\"800\" src=\"./web/assets/vue-text-highlight-header.png\" alt=\"Vue Text Highlight\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://codecov.io/github/AlbertLucianto/vue-text-highlight?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/AlbertLucianto/vue-text-highlight/master.svg\" alt=\"Coverage Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/AlbertLucianto/vue-text-highlight\"\u003e\u003cimg src=\"https://travis-ci.org/AlbertLucianto/vue-text-highlight.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://npmcharts.com/compare/vue-text-highlight?minimal=true\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/vue-text-highlight.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://npmcharts.com/compare/vue-text-highlight?minimal=true\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/vue-text-highlight.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/vue-text-highlight\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vue-text-highlight.svg\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/vue-text-highlight\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/vue-text-highlight.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## See working example [here](https://albertlucianto.github.io/vue-text-highlight).\n\n## Installation\n\n```bash\nnpm install --save vue-text-highlight\n# or\nyarn add vue-text-highlight\n```\n\n## Usage\n\n### Basic Usage\n\n```javascript\nimport Vue from 'vue';\nimport TextHighlight from 'vue-text-highlight';\n\nVue.component('text-highlight', TextHighlight);\n\n// new Vue ...\n```\n\n#### SomeComponent.vue\n\n```html\n\u003ctemplate\u003e\n  \u003ctext-highlight :queries=\"queries\"\u003e{{ description }}\u003c/text-highlight\u003e\n\u003c/template\u003e\n```\n\n```javascript\ndata() {\n  return {\n    queries: ['birds', 'scatt'],\n    description: 'Tropical birds scattered as Drake veered the Jeep'\n  };\n}\n```\n\n#### Output\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"400\" src=\"./web/assets/ss-vue-text-highlight.png\" alt=\"text-highlight\"\u003e\u003c/p\u003e\n\n### More Options\n\nAll available props in `TextHighlight` component are:\n\n* __`queries:`__ `Array\u003cString|RegExp\u003e|String|RegExp`\n\n  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.\n\n* __`[caseSensitive]:`__ `Boolean`\n\n  Whether string being searched is case sensitive.\n\n* __`[diacriticsSensitive]:`__ `Boolean`\n\n  Whether string being searched is diacritics sensitive.\n\n* __`[wholeWordMatch]:`__ `Boolean`\n\n  Whether string being searched as a whole word .\n\n\n* __`[highlightStyle]:`__ `Object|Array|String`\n\n  Styles to be applied to highlighted `\u003cmark\u003e`. 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.](https://vuejs.org/v2/guide/class-and-style#Binding-Inline-Styles)\n\n* __`[highlightClass]:`__ `Object|Array|String`\n\n  Classes to be added to highlighted `\u003cmark\u003e`. Similar to class bindings in vue, it accepts `Array` syntax, `Object` syntax, or class as `String`. [See class binding in Vue.js.](https://vuejs.org/v2/guide/class-and-style#Binding-HTML-Classes)\n\n* __`[highlightComponent]:`__ `Object|String`\n\n  By default vue-text-highlight uses `\u003cmark\u003e` for the highlighting. Pass this props to override with other tag (`string`) or custom component (Vue component definition).\n\n  This component will be passed with two props from `text-highlight`:\n\n  * __`index:`__ `Number`\n\n    Index of highlighted component.\n\n  * __`text:`__ `String`\n\n    Highlighted words, equals to `this.$slots.default[0].text`\n\n  For more details, see [example below](#advanced-usage).\n\n* 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`.\n\n### Advanced Usage\n\nThere 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.\n\n#### OtherComponent.vue\n\n```html\n\u003ctemplate\u003e\n  \u003ctext-highlight\n    :queries=\"queries\"\n    :highlightComponent=\"MyClickableComponent\"\n    :baz=\"foo\"\n    @customlistener=\"alert\"\n  \u003e\n    {{ description }}\n  \u003c/text-highlight\u003e\n\u003c/template\u003e\n```\n\n```js\nimport MyClickableComponent from 'MyClickableComponent';\n```\n\n```js\ndata() {\n  return {\n    queries: ['birds', 'scatt'],\n    description: 'Tropical birds scattered as Drake veered the Jeep'\n    MyClickableComponent,\n    foo: 'bar',\n  };\n},\nmethods: {\n  alert() {},\n}\n```\n\n#### MyClickableComponent.vue\n\n```html\n\u003ctemplate\u003e\n  \u003cmark class=\"custom\" @click=\"$emit('customlistener')\"\u003e\n    \u003cslot\u003e\u003c/slot\u003e\n  \u003c/mark\u003e\n\u003c/template\u003e\n```\n\n```js\nprops: {\n  baz: String, // From OtherComponent.vue\n  index: Number, // From TextHighlight\n  text: String, // From TextHighlight, equals to `this.$slots.default[0].text`\n}\n```\n\n## Changelog\n\nChanges are tracked in the [changelog](CHANGELOG.md).\n\n## License\n\nvue-text-highlight is available under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlbertLucianto%2Fvue-text-highlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlbertLucianto%2Fvue-text-highlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlbertLucianto%2Fvue-text-highlight/lists"}