Commit 52e25cd1 authored by Randall Leeds's avatar Randall Leeds

Clean up createAnnotation a bit

parent f53359d6
......@@ -271,21 +271,22 @@ module.exports = class Guest extends Annotator
}
return self.anchoring.describe(root, range, options)
setDocumentInfo = ({metadata, uri}) ->
annotation.uri = uri
if metadata?
annotation.document = metadata
setDocumentInfo = (info) ->
annotation.document = info.metadata
annotation.uri = info.uri
setTargets = ([info, selectors]) ->
source = info.uri
annotation.target = ({source, selector} for selector in selectors)
info = this.getDocumentInfo().then(setDocumentInfo)
info = this.getDocumentInfo()
selectors = Promise.all(ranges.map(getSelectors))
metadata = info.then(setDocumentInfo)
targets = Promise.all([info, selectors]).then(setTargets)
targets.then(=> this.setupAnnotation(annotation))
targets.then(=> this.publish('beforeAnnotationCreated', [annotation]))
targets.then(-> self.setupAnnotation(annotation))
targets.then(-> self.publish('beforeAnnotationCreated', [annotation]))
annotation
......
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