aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/MainView.tsx
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-08-03 14:52:59 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-08-03 14:52:59 -0700
commit1713f5415294b996e6dbbe9ca45f0f4511c69824 (patch)
tree159a8653fc8485817077b3689fd063c69084a5ed /src/client/views/MainView.tsx
parent2b3fb53a5e0ebe21eef2406992257ef5e86b3b2d (diff)
linking bug fixes, WebDocument size fixes
Diffstat (limited to 'src/client/views/MainView.tsx')
-rw-r--r--src/client/views/MainView.tsx43
1 files changed, 2 insertions, 41 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 954b8b998..5c34233b4 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -104,47 +104,7 @@ 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
- 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
- }));
- }
- });
-
- // reaction(() => SelectionManager.SelectedDocuments(), selected => {
- // console.log("selection changed");
- // const selectedWebDocs = selected.map(docView => docView.props.Document).filter(doc => doc.type === DocumentType.WEB);
- // const urls = selectedWebDocs.map(doc => Cast(doc.data, WebField)?.url.href).filter(url => url !== undefined);
- // console.log("urls", urls);
-
- // const frame = document.getElementById('hyp_sidebar') as HTMLIFrameElement;
- // console.log("contentwindow?", frame.contentDocument);
- // if (frame.contentWindow) {
- // frame.contentWindow.postMessage("hello sidebar", window.origin);
- // }
-
- // document.dispatchEvent(new CustomEvent('showAnnotations', {
- // detail: urls,
- // bubbles: true
- // }));
- // });
+ document.addEventListener("linkAnnotationToDash", Hypothesis.linkListener);
}
componentWillUnMount() {
@@ -152,6 +112,7 @@ export class MainView extends React.Component {
window.removeEventListener("pointerdown", this.globalPointerDown);
window.removeEventListener("pointerup", this.globalPointerUp);
window.removeEventListener("paste", KeyManager.Instance.paste as any);
+ document.removeEventListener("linkAnnotationToDash", Hypothesis.linkListener);
}
constructor(props: Readonly<{}>) {