aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/MainView.tsx
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-07-31 16:03:03 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-07-31 16:03:03 -0700
commit2b3fb53a5e0ebe21eef2406992257ef5e86b3b2d (patch)
tree2be488ccee4d8eb17eb02e22a9acd00ab1933650 /src/client/views/MainView.tsx
parent3e6dfbb32b9cafaafe178c8e8e427207a17325e2 (diff)
modify link completing from annotations, fix web drag & drop
Diffstat (limited to 'src/client/views/MainView.tsx')
-rw-r--r--src/client/views/MainView.tsx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 93e4d1a6f..954b8b998 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -105,17 +105,26 @@ export class MainView extends React.Component {
});
});
document.addEventListener("linkAnnotationToDash", async (e: any) => { // listen for event from Hypothes.is plugin to link an annotation to Dash
- if (!DocumentLinksButton.StartLink) { // starts link only if there are none already started (else, a listener in DocumentLinksButton will handle link completion)
- const annotationId = e.detail.id;
- const annotationUri = e.detail.uri;
- const sourceDoc = await Hypothesis.getSourceWebDoc(annotationUri);
- console.log("sourceDoc: ", sourceDoc.title);
+ const annotationId = e.detail.id;
+ const annotationUri = e.detail.uri;
+ const sourceDoc = await Hypothesis.getSourceWebDoc(annotationUri);
+ console.log("sourceDoc: ", sourceDoc.title);
+ if (!DocumentLinksButton.StartLink) { // starts link only if there are none already started (else, a listener in DocumentLinksButton will handle link completion)
runInAction(() => {
DocumentLinksButton.AnnotationId = annotationId;
DocumentLinksButton.AnnotationUri = annotationUri;
DocumentLinksButton.StartLink = sourceDoc;
});
+ } else { // if a link's already started in Dash, send event to DocumentLinksButton tofinish the link to the annotation
+ document.dispatchEvent(new CustomEvent<{ id: string, uri: string, sourceDoc: Doc }>("completeLinkToAnnotation", {
+ detail: {
+ id: annotationId,
+ uri: annotationUri,
+ sourceDoc: sourceDoc
+ },
+ bubbles: true
+ }));
}
});