diff options
Diffstat (limited to 'src/client/views/MainView.tsx')
-rw-r--r-- | src/client/views/MainView.tsx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index bb73df75c..dd8433866 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -57,6 +57,8 @@ import { LinkDescriptionPopup } from './nodes/LinkDescriptionPopup'; import FormatShapePane from "./collections/collectionFreeForm/FormatShapePane"; import HypothesisAuthenticationManager from '../apis/HypothesisAuthenticationManager'; import CollectionMenu from './collections/CollectionMenu'; +import { Hypothesis } from '../apis/hypothesis/HypothesisUtils'; +import { SelectionManager } from '../util/SelectionManager'; @observer export class MainView extends React.Component { @@ -104,6 +106,20 @@ 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 ? sourceDoc.title : "not found"); + + // TO BE FIXED, currently cannot start links from new webpages that don't exist in Dash + const source = sourceDoc || SelectionManager.SelectedDocuments()[0]; + runInAction(() => { + DocumentLinksButton.AnnotationId = annotationId; + DocumentLinksButton.AnnotationUri = annotationUri; + DocumentLinksButton.StartLink = source; + }); + }); } componentWillUnMount() { |