openannotation / annotator

Annotation tools for the web. Select text, images, or (nearly) anything else, and add your notes.
http://annotatorjs.org
Other
2.67k stars 532 forks source link

1.2.10 "annotationCreated", function (annotation) returns a annotation object with functions #700

Closed nickatrons closed 5 years ago

nickatrons commented 5 years ago

Hi, so I'm making a plugin to 1.2.10 of annotatorjs. I want to get the annotation object and send it to my nodejs server for storage.

But, when I use $.post or $.ajax it throws back

RangeError {type: "start", message: "Error while finding start node: undefined: TypeError: Cannot read property 'substring' of undefined", parent: TypeError: Cannot read property 'substring' of undefined at Object.Util.nodeFromXPath

This I can somewhat handle with

var serializedData = JSON.stringify(data); var trueJson = JSON.parse(serializedData); I assume this is because something in the annotation objects Range and Highlights is calling this method. I dont understand why. Am I missing something?

tilgovi commented 5 years ago

It's likely the highlights. The built-in Store plugin removes those when serializing: https://github.com/openannotation/annotator/blob/v1.2.x/src/plugin/store.coffee#L461

nickatrons commented 5 years ago

Yeah, had to remove them too. Just kinda annoying, so wanted to hear if this was intended :)

tilgovi commented 5 years ago

This is the intended behavior.