texthighlight:add
Triggered whenever a text highlight is added.
Examples
annotationsApp.on('texthighlight:add', function (textHighlightInfo) {
var textHighlightModule = annotationsApp.module('texthighlight');
var id = textHighlightInfo.id;
var startElement = textHighlightModule.utils.deserializePath(
textHighlightInfo.startContainerPath,
textHighlightInfo.startOffset,
);
var endElement = textHighlightModule.utils.deserializePath(
textHighlightInfo.endContainerPath,
textHighlightInfo.endOffset,
);
console.log('The text selection with id ' + id + ' ranges between:', startElement, endElement);
});
Callback arguments
-
id stringThe unique id of the text highlight.
-
startContainerPath stringA string representing the location of the DOM node that contains the start of the selection.
-
endContainerPath stringA string representing the location of the DOM node that contains the end of the selection.
-
startOffset numberThe offset, in characters, of the start of the selection within the start container.
-
endOffset numberThe offset, in characters, of the end of the selection within the end container.