Annotations API Methods
setFormatRenderResult()
Each time a texthighlight is created, you can optimize the highlight information to suit your needs. This method is mostly used when you want to store highlights that will be persisted in multiple elements. For example, formatting the startContainerPath
from “[id=”passage_0”]>p:nth-of-type(2);0”
to “[id^=”passage_”]>p:nth-of-type(2);0”
.
Assuming your application contains multiple elements having the convention id^="passage_[index]
, and after highlighting a text in passage_0
, we can optimize the rendering path to id="passage_"
to make it more generic. During the resume phase, annotations will automatically search for all elements matching id="passage_"
and apply the stored texthighlight information.
Examples
itemsApp.annotationsApp().module('texthighlight').setFormatRenderResult('callback');
Arguments
-
callbackFunction function
-
startContainerPath string
The start DOM element where the texthighlight will start.
-
startOffset string
Start element offset
-
endContainerPath string
The end DOM element where the texthighlight will stop.
-
endOffset string
End element offset
-
Return value
None (undefined
).