new IndependenciaHighlighter(element [, options])
Creates an IndependenciaHighlighter instance for functionality that focuses for highlight independence.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | DOM element to which highlighted will be applied. |
|||||||||||||||||||||||||
options |
object |
<optional> |
additional options. Properties
|
- Source:
Methods
-
deserializeHighlights(json)
-
Deserializes the independent form of highlights.
Parameters:
Name Type Description json
object JSON object with highlights definition.
- Source:
Throws:
exception when can't parse JSON or JSON has invalid structure.
Returns:
- array of deserialized highlights.
- Type
- Array
-
doHighlight(keepRange)
-
Highlights current range.
Parameters:
Name Type Description keepRange
boolean Don't remove range after highlighting. Default: false.
- Source:
-
focusUsingId(id, descriptors)
-
Focuses a highlight, bringing it forward in the case it is sitting behind another
overlapping highlight, or a highlight it is nested inside.Parameters:
Name Type Description id
object The id of the highlight present in the class names of all elements
in the DOM that represent the highlight.In order to utilise this functionality unique ids for highlights should be added to the class list in the highlight
wrapper within the descriptors.
You can do this in the onAfterHighlight callback when a highlight is first created.In the future it might be worth adding more flexiblity to allow for user-defined ways of storing ids to identify
elements in the DOM. (e.g. choosing between class name or data attributes)descriptors
string Optional serialised descriptors, useful in the case a highlight has no representation in the DOM
where empty highlight wrapper nodes are removed to use less dom elements.- Source:
-
getHighlights(params)
-
Returns highlights from given container.
Parameters:
Name Type Description params
Properties
Name Type Argument Description container
HTMLElement <optional>
return highlights from this element. Default: the element the
highlighter is applied to.andSelf
boolean <optional>
if set to true and container is a highlight itself, add container to
returned results. Default: true.grouped
boolean <optional>
if set to true, highlights are grouped in logical groups of highlights added
in the same moment. Each group is an object which has got array of highlights, 'toString' method and 'timestamp'
property. Default: false.- Source:
Returns:
- array of highlights.
- Type
- Array
-
isHighlight(el, dataAttr)
-
Returns true if element is a highlight.
Parameters:
Name Type Description el
element to check.
dataAttr
data attribute to determine if the element is a highlight
- Source:
Returns:
- Type
- boolean
-
normalizeHighlights()
-
Normalizes highlights and the dom. Ensures text nodes within any given element node are merged together, elements with the
same ID next to each other are merged together and highlights with the same ID next to each other are merged together.- Source:
-
removeHighlights(id, element, id)
-
Parameters:
Name Type Description id
string ID of highlight to remove
Removes highlights from element using highlight Id. .
If no id is given, all highlights are removed.element
HTMLElement element to remove highlights from
id
string The unique id of a highlight represented by a collection of elements.
- Source:
-
serializeHighlights(id)
-
Serializes the highlight belonging to the ID.
Parameters:
Name Type Description id
ID of the highlight to serialise
- Source:
Returns:
- stringified JSON with highlights definition
- Type
- string
Type Definitions
-
HighlightDescriptor
-
Deselects a highlight, bringing any nested highlights in the list of descriptors
forward.In order to utilise this functionality unique ids for highlights should be added to the class list in the highlight
wrapper within the descriptors.
You can do this in the onAfterHighlight callback when a highlight is first created.In the future it might be worth adding more flexiblity to allow for user-defined ways of storing ids to identify
elements in the DOM. (e.g. choosing between class name or data attributes)Type:
- object
- Source:
Properties:
Name Type Description id
string serialisedDescriptor
string