aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/MainView.tsx4
-rw-r--r--src/client/views/nodes/DocumentView.tsx11
2 files changed, 15 insertions, 0 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 15f818d1f..65d585a2a 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -108,6 +108,10 @@ export class MainView extends React.Component {
}
});
});
+ document.addEventListener("linkComplete", (e: any) => { // event used by Hypothes.is plugin to tell Dash when an annotation has been linked
+ const annotatedUrl = e.details;
+ console.log("This website " + annotatedUrl + " has a linked annotation");
+ });
}
componentWillUnMount() {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index b38db9a1e..2285cb7e1 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -755,6 +755,17 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
const cm = ContextMenu.Instance;
if (!cm) return;
+ cm.addItem({
+ description: "make hypothesis link", event: () => {
+ const docUrl = Utils.prepend("/doc/" + this.props.Document[Id]);
+ const docTitle = StrCast(this.layoutDoc.title);
+ document.dispatchEvent(new CustomEvent<{ url: string, title: string }>("linkRequest", {
+ detail: { url: docUrl, title: docTitle },
+ bubbles: true
+ }));
+ }, icon: "eye"
+ });
+
const customScripts = Cast(this.props.Document.contextMenuScripts, listSpec(ScriptField), []);
Cast(this.props.Document.contextMenuLabels, listSpec("string"), []).forEach((label, i) =>
cm.addItem({ description: label, event: () => customScripts[i]?.script.run({ this: this.layoutDoc, self: this.rootDoc }), icon: "sticky-note" }));