[annotator-dev] Add ids to annotators

Randall Leeds tilgovi at hypothes.is
Fri Jul 20 21:10:17 UTC 2012


On Fri, Jul 20, 2012 at 9:02 AM, Jamie M Folsom <jfolsom at mit.edu> wrote:
> Hi, Randall,
>
> Great solution. Would you post the one liner you wrote again here too? I left the chat transcript on my office machine...

Something like:

addHighlightId = (a) => if a.highlights[0]? then a.highlights[0].id = a.id

annotatorInstance.subscribe 'annotationsLoaded', (annotations) =>
annotations.map addHighlightId
annotatorInstance.subscribe 'annotationUpdated', addHighlightId

>
> And is it best to listen for those events directly in the page that's loading the Annotator, or in the Annotator class? I'll post an updated gist, or a link to our fork once I have it working.

That's your preference, really. I lean toward doing it in the page or
in a subclass of Annotator if you have more customization you'd like
to do. In general, I consider it a goal that developers should
generally have little need to modify Annotator; it should provide
enough interface to get what you need without modifying its internals.

-Randall




More information about the annotator-dev mailing list