@yi-note/text-highlighter
v1.0.0
Published
Fork of TextHighlighter(http://mir3z.github.com/texthighlighter/) in ES6 module
Downloads
3
Readme
TextHighlighter-esm
This is a fork of mir3z/texhighlighter.
What's new
- Migrate to ES module system.
- Use
Rollup
as module bundler. - Export in both
es module
andiife
format for browser use. - Publish in npm.
Installation
npm i @yi-note/text-highlighter --save-dev
Getting started
Use ES module
import TextHighlighter from '@yi-note/text-highlighter'
Use IIFE
Add minified script file to head section of your web page, the file can be find in node_modules/@yi-note/text-highlighter/dist/bundle.min.js
. Feel free to upload it into CDN or move to the src folder.
Include minified lib file in HTML
<script type="text/javascript" src="bundle.min.js"></script>
How to use
var hltr = new TextHighlighter(document.body);
For more details see API reference or Wiki pages on GitHub.
Development
Install dependencies
npm install
Local dev
npm run dev
Run static pages (index, demos, doc) locally
npm run static
For more informatin, please refer to scripts
section in package.json.
Features
- Highlighting of selected text.
- Highlighting all occurrences of given text (find & highlight).
- Removing highlights.
- Selecting highlight color.
- Serialization & deserialization.
- Works well in iframes.
- Keeps DOM clean.
- No dependencies. No jQuery or other libraries needed.
Compatibility
Should work in all decent browsers and IE >= 9.
Demos
Documentation
You may check API reference or Wiki pages on GitHub.