Hello

I see that the Annotator has been changing much in the past two years. I
cannot grasp yet what is deprecated and what is seminal, so I read the
code and think.

Today I tried to write a dumb plugin for Annotator 1.2.9 and I cannot
get why I get a console warning
##########################################
"Annotator DeprecationWarning: Direct assignment of plugin constructors
to the Annotator.Plugin namespace is deprecated. Please use
Annotator.Plugin.register('Testplugin', Testplugin) instead!
Automatically re-registering plugin..."
##########################################

Here is the code
------------------------------------------
src/plugin/testplugin.coffee
------------------------------------------
Annotator = require('annotator')

class TestPlugin

  pluginInit: ->
    this.annotator.subscribe('annotationCreated', this.create)

  create: (annotation) ->
    console.log("Annotation created")

Annotator.Plugin.register('TestPlugin', TestPlugin)

module.exports = TestPlugin

------------------------------------------

This is called on a modified version of the default "demo.html" page with
------------------------------------------
<script src="pkg/annotator.testplugin.js"></script>
------------------------------------------
and then
------------------------------------------
<script>
     var elem = document.getElementById('airlock');
        var annotator = new Annotator(elem);
        annotator.addPlugin('TestPlugin');
</script>
------------------------------------------

What am I doing wrong?

Thank you

Ernesto Torresin
_______________________________________________
annotator-dev mailing list
[email protected]
https://lists.okfn.org/mailman/listinfo/annotator-dev
Unsubscribe: https://lists.okfn.org/mailman/options/annotator-dev

Reply via email to