Highlighter

Highlighter

Class representing a highlighter. It inserts itself into the dom behind a textarea. It expects the array of tokens to be ordered and to match the order that text appears inside the textarea. Updating the tokens or color works as expected: the highlighter will not be created anew, but will update it's innerHTML content or CSS styles to ensure each token is properly marked for highlighting.

Constructor

new Highlighter(textarea, tokens, color)

Create a Highligher
Source:
Parameters:
Name Type Description
textarea node The textarea the highlighter will be attached to
tokens Array.<string> The tokens (character sequences) to highlight
color string The 6 digit hexcode color string used for highlighting tokens

Methods

_isWholeWord()

_isWholeWord - private wrapper of isWholeWord
Source:
See:

_offset(targetNode, offsetNode) → {object}

_offset - returns the absolute position and inner size of an element
Source:
Parameters:
Name Type Description
targetNode node The element whos absolute position we want to calculate
offsetNode node The element whos position we offset by the targetNode
Returns:
Type:
object
- An object containing the size and coordinates measured in pixels