[annotator-dev] highlight ranges gets broken on load

Nick Stenning nick at whiteink.com
Thu Sep 8 15:44:41 UTC 2011

Hey Ewald,

I haven't been able to deduce what's wrong with your copy of the annotator,
primarily because the repository you've pointed me to shares no commit
history with our repository at https://github.com/okfn/annotator. This makes
it rather tedious to find out what has changed between the repositories.

Can I suggest you a) delete your existing repository on Github and b) fork
the annotator using the handy "Fork" button in the top-right of the
above-linked page? You can then merge your changes into your own fork, and
it will be much easier to work out what's going on.

All that said, I suspect I know what's going on here. In my earlier email to
you, you'll note that in order to implement the different colours of
annotation, I merely *added* a class to the relevant highlight elements, but
did not replace or remove the "annotator-hl" class. This class is used to
determine which elements are the result of the Annotator's dicing and
slicing of the DOM, and elements with that class are carefully ignored in
serialization/deserialization of the annotations.

You should have no problems if you colour your highlights differently by
simply adding *additional* classes to the highlight elements. Please let me
know if I'm wrong and this does indeed cause you problems.

Lastly, I can't emphasise how useful it would be if you could make a proper
fork of the annotator repository. That way, when your changes are working
and tested, we might be happy to include your plugin in the official
annotator distribution.

Best wishes,

On Thu, Sep 8, 2011 at 14:46, Ewald Zietsman <ewald at siyavula.com> wrote:

> Hi,
> I've hacked and broken the annotator code now adding a categories plugin
> (and support for different highlight colours for different annotations).
> I've run into a problem that I can't seem to figure out although I have some
> idea what might be the problem.
> My version of the annotator is here:  git at github.com:
> ezietsman/siyavula-annotator.git
> When I create annotations they appear on the page as expected. They even
> have the correct colours I have specified. When I inspect their 'ranges'
> attribute its looks ok. However, when I make two of them overlap the whole
> thing breaks on page load and I get the error: "Uncaught TypeError: Cannot
> read property 'nodeType' of undefined"
> After quite a search I have found out that the last annotation added that
> overlaps with another annotation causes this error and that the 'range'
> attribute that gets loaded has its 'startOffset' or 'endOffset' set for the
> amount relative to the annotation it overlaps with, instead of relative to
> the original DOM. The crash happens because the annotation it overlaps with
> is not in the DOM yet and therefore the element that defines its highlight
> range is not defined yet. Can anyone point me in a direction to get around
> this? I'm thinking highlights should always be defined relative to the
> original DOM before any highlights were put in? Maybe loading them in
> reverse order could make this go away?
> --
> *
> Ewald Zietsman
> Technical Coor**dinator*
> *
> *
> *
> *
> Website: www.siyavula.com
> The Open Innovation Studio, 27 Buitenkant Street, Cape Town, 8001
> A Shuttleworth Foundation Seeded Project
> Website: www.shuttleworthfoundation.org
> _______________________________________________
> annotator-dev mailing list
> annotator-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/annotator-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20110908/d8355089/attachment-0002.html>

More information about the annotator-dev mailing list