[annotator-dev] linking to annotations within annotated document

Randall Leeds tilgovi at hypothes.is
Wed Feb 25 22:44:26 UTC 2015

Hi, Shauna!

Responses inline:

On Wed, Feb 25, 2015 at 2:15 PM, Shauna Gordon-McKeon <shaunagm at gmail.com>

> Hi all,
> I've been working with the Annotator for the last few days and have
> successfully got it working with my app (using Django & Django Rest
> Framework api).  I'd like to be able to link users to annotations.  I'm not
> talking about as a lone object, as for instance
> annotatorjs.org/annotateit.org do, but embedded in the document which
> it's annotating.

Excellent. I'm glad you've been able to get started.

> My first guess at how to do this would be to attach the annotation's
> unique ID as the highlighted span's ID so it can be used as an anchor on
> the document.  Some nosing around suggests that highlightRange
> <https://github.com/openannotation/annotator/blob/0041995f944e7f1f1373b03e20565bb69e226b52/src/ui/highlighter.js#L18>
> is where that span is created.  Is there a way to get this behavior via a
> plugin, or should I modify highlightRange directly?  It seems that in order
> to modify highlightRange, I'd need to pass in the annotation ID but I
> can't, from searching the git repo and reading the docs, tell where
> highlightRange is even being called.

First question is whether you've built your own annotator from the source
or if you've used a pre-packaged version. Since we haven't yet had a 2.0
release the code you linked to has not been published as a built
annotator.js yet. If you've built it yourself from git, that's great and
I'm really glad to see people kicking the tires on master. If you're
working from a 1.2 series release, then the code is a bit different.

> Do folks have any suggestions?  I'm new to JQuery and pretty inexperienced
> with Javascript generally, so my apologies if these are questions with
> obvious answers.

I've stayed away from assigning ids to highlights because there is
sometimes more than one highlight span associated with an annotation. This
happens frequently when annotations overlap and the text needs to be split
into several spans. Technically, there should only be one element with a
given id on any page. Browsers are pretty tolerant, but I've nonetheless
avoided adding ids for this reason.

However, it might be very reasonable to add another attribute. For
instance, maybe using jQuery to select for a different attribute would make
this work for you.


or something like this.

Unfortunately, that would not get the scroll-to behavior that having an id
/ anchor gets, where the URL can simply be set to #someid. However, since
Annotator loads after the page is rendered this would not allow linking
users directly to an annotation using the built-in browser support for
anchors anyway. That may not be a concern, though.

Hopefully, that helps explain the problem space a bit and gives you a sense
of where to look next. If there's anything we can add to the highlighter to
make this easier, I'd be glad to help with those modifications.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20150225/f92c579d/attachment-0004.html>

More information about the annotator-dev mailing list