[annotator-dev] linking to annotations within annotated document
tilgovi at hypothes.is
Wed Feb 25 22:44:26 UTC 2015
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
> 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
> 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...
More information about the annotator-dev