A Highlightable represents a span of text, typically a word, and its state.
Highlightable is the unit by which text-wrapping happens. Depending on how the Highlighter is initialized, it's very possible for a Highlightable to consist of just a single whitespace.
Initialize highlightables from a string.
Note that we're transforming all whitespace to spaces, so newlines are not preserved as me move to and from fragments. Spaces will be treated as static elements. Words will be interactive.
Initialize highlightables from a markdown string.
This will get all nri-highlight tags into markded elements, you can add a specific color
using the color attribute. The default color is yellow.
fromMarkdown "for example, <nri-highlight>this phrase</nri-highlight> will show as highlighted"will result in a list of highlightables where "this phrase" is marked with the default marker.
fromMarkdown "for example, <nri-highlight color=" cyan ">this phrase</nri-highlight> will show as highlighted"will result in a list of highlightables where "this phrase" is marked with the cyan marker.
The available highlight colors are listed in the Nri.Colors docs, which are the following:
magenta -> Colors.highlightMagentabrown -> Colors.highlightBrownpurple -> Colors.highlightPurpleblue -> Colors.highlightBlueyellow -> Colors.highlightYellowgreen -> Colors.highlightGreencyan -> Colors.highlightCyanThere is also the empty url syntax, which is currently being deprecated:
fromMarkdown "for example, [this phrase]() will show as highlighted"will result in a list of highlightables where "this phrase" is marked with the default marker.
Get a list of fragment texts and whether or not they are marked. Useful for encoding answers.
Get unique markers that have been used. Note: ignores marks on whitespace.
Fetch the text from a series of highlightables.
Get the highlightable matching the passed-in ID, if any.
A Highlightable comes in two flavors:
Highlightable | Interactive piece of text.
Static | Non-interactive piece of text.
Data for a Highlightable:
text: String to display.
customAttributes: User-supplied, non-interactive HTML attributes.
marked: Current highlights, if any.
index: Unique highlightable index.