[annotator-dev] Creating A JS Plugin For Voting/Likes/Recommend
steph at endpoint.com
Wed Mar 4 18:11:48 UTC 2015
On 03/04/2015 12:25 PM, King'ori J. Maina wrote:
> I’ve been able to get some sample plugin code setup and being used by
> annotator but I’m struggling to figure out how to add the actual
> functionality of up-voting and down-voting. Getting exhausted while
> trying to learn/figure out coffee script. The idea was that I have
> some sample code to refer to as a base implementation of the
> Any ideas as to a plugin that’s written in vanilla JS that I can poke
> into and learn?
Edge Annotator is in vanilla JS, so everything in
https://github.com/openannotation/annotator/tree/master/src should now
be JS only, although some of those don't necessarily demonstrate plugin
Here's one I'm working on:
It is compatible with Annotator 1.2.*. I've also worked on Annotator 2.0
and the plugin API is not much different. Here are some important bits:
called when a plugin is initialized, but before data loaded. Here's
where you would call addField on the viewer or editor.
* hook for annotationsLoaded, called after Annotator finishes loading
annotations. Here's where you may manipulate annotations / UI after
* hooks for annotationUpdated, annotationCreated, called after
annotation updated / created. Here's where you may manipulate the UI
based on annotation data.
* hook for annotationEditorSubmit, called right after user clicks
"save", but before data is sent to the backend. Here's where you would
modify the annotation data getting sent to the backend.
* __bind calls on various plugin methods to set scope
There are quite a few more hooks, but I think these are likely to be the
Another option is to use something like http://js2.coffee/ to convert
another plugin in CoffeeScript to JS.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the annotator-dev