HighlightHelper
internal
A helper class for highlighting text matches within HTML elements.
No results
A helper class for highlighting text matches within HTML elements.
Highlights text in the specified fields of the specified element. The fields are specified as a list of field names, like 'name' or 'description'. These are used to find the elements which should contain highlighted matches. The names will be expanded to [data-field="${field}"] selectors.
This function is intended to be used with ColumnSearchField to highlight matches that have been found in the task records. The matchers parameter can be retrieved from a matchers getter.
Matching patterns will be wrapped into a <mark> tag. The highlighting is done in-place, so the original DOM structure is preserved.
highlight() will remove the display style when matches are found. This is necessary because the added tags will otherwise break the text flow. When calling unhighlight(), the original display style will be restored.Removes highlighting from specified fields within the given element by replacing highlighted marks with their text content and merging adjacent text nodes.
This function is intended to be used with ColumnSearchField and in conjunction with highlightMatches().
highlight() added <mark> tags, the original display style will be restored here.Sort matches by start index, and merge overlapping and adjacent matches.