Commit 78d8a980 authored by Randall Leeds's avatar Randall Leeds

prototype first publisher API: annotator.addToken

proof of concept only. for localwiki.
parent 5f129777
...@@ -65,6 +65,12 @@ class Annotator.Host extends Annotator ...@@ -65,6 +65,12 @@ class Annotator.Host extends Annotator
parsed[k] = v parsed[k] = v
parsed parsed
# Build a channel for the publish API
@api = Channel.build
origin: '*'
scope: 'annotator:api'
window: @frame[0].contentWindow
# Build a channel for the panel UI # Build a channel for the panel UI
@panel = Channel.build @panel = Channel.build
origin: '*' origin: '*'
...@@ -257,3 +263,8 @@ class Annotator.Host extends Annotator ...@@ -257,3 +263,8 @@ class Annotator.Host extends Annotator
# is needed for preventing the panel from closing while annotating. # is needed for preventing the panel from closing while annotating.
unless event and this.isAnnotator(event.target) unless event and this.isAnnotator(event.target)
@mouseIsDown = true @mouseIsDown = true
addToken: (token) =>
@api.notify
method: 'addToken'
params: token
\ No newline at end of file
...@@ -127,6 +127,16 @@ class Hypothesis extends Annotator ...@@ -127,6 +127,16 @@ class Hypothesis extends Annotator
parsed[k] = v parsed[k] = v
parsed parsed
@api = Channel.build
origin: $location.search().xdm
scope: 'annotator:api'
window: $window.parent
.bind('addToken', (ctx, token) =>
@element.scope().token = token
@element.scope().$digest()
)
@provider = Channel.build @provider = Channel.build
origin: $location.search().xdm origin: $location.search().xdm
scope: 'annotator:panel' scope: 'annotator:panel'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment