Commit ee7b3c18 authored by Randall Leeds's avatar Randall Leeds

beforeAnnotationCreated before setupAnnotation

When always on highlights and the highlighter mode were introduced in
ddf17189fbf2d428b21fd31065a1c2d2bc6ab08b the beforeAnnotationCreated
event was not fired in the guest frame. Instead, a special inject call
was added to the bridge to send the annotation and the event fired in
the iframe first. Later, when I removed this, I added the event after
the call to setupAnnotation.

The change in 3613c7d91682a438b1d243b9573cb941b26cdc43 uses the
annotationsLoaded event to notify listeners when highlights change as a
result of realizing anchors. This presents a problem because the bridge
ignores the beforeAnnotationCreated event for annotations that have
already been tagged by the bridge, but this load event causes the new
highlight to be tagged and serialized.

Move the beforeAnnotationCreated event to before the setupAnnotation
call, which is the order of things in non-highlighter mode, so that
the event is properly propagated to the sidebar iframe.

Close #1240
parent 33a2e7b9
......@@ -337,21 +337,12 @@ class Annotator.Guest extends Annotator
# Add a flag about what's happening
@creatingHL = true
# Create the annotation right away
# Don't use the default method to create an annotation,
# because we don't want to publish the beforeAnnotationCreated event
# just yet.
#
# annotation = this.createAnnotation()
#
# Create an empty annotation manually instead
# Create the annotation
annotation = {inject: true}
this.publish 'beforeAnnotationCreated', annotation
# Set up the annotation
annotation = this.setupAnnotation annotation
# Notify listeners
this.publish 'beforeAnnotationCreated', annotation
this.publish 'annotationCreated', annotation
else
super
......
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