diff options
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 3311bfa33..0e5b09f8b 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -43,6 +43,7 @@ import React = require("react"); import { DocumentLinksButton } from './DocumentLinksButton'; import { MobileInterface } from '../../../mobile/MobileInterface'; import { LinkCreatedBox } from './LinkCreatedBox'; +import { Hypothesis } from '../../apis/hypothesis/HypothesisApiUtils'; library.add(fa.faEdit, fa.faTrash, fa.faShare, fa.faDownload, fa.faExpandArrowsAlt, fa.faCompressArrowsAlt, fa.faLayerGroup, fa.faExternalLinkAlt, fa.faAlignCenter, fa.faCaretSquareRight, fa.faSquare, fa.faConciergeBell, fa.faWindowRestore, fa.faFolder, fa.faMapPin, fa.faLink, fa.faFingerprint, fa.faCrosshairs, fa.faDesktop, fa.faUnlock, fa.faLock, fa.faLaptopCode, fa.faMale, @@ -755,6 +756,32 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu const cm = ContextMenu.Instance; if (!cm) return; + cm.addItem({ + description: "make hypothesis link", event: async () => { + const docUrl = Utils.prepend("/doc/" + this.props.Document[Id]); + const docTitle = StrCast(this.layoutDoc.title); + const getResponse = await Hypothesis.getAnnotation("melissaz", "placeholder"); + if (getResponse && getResponse.rows.length > 0) { + const annotationId = getResponse.rows[0].id; + document.dispatchEvent(new CustomEvent<{ url: string, title: string, id: string }>("linkRequest", { + detail: { url: docUrl, title: docTitle, id: annotationId }, + bubbles: true + })); + } else { + console.log("no placeholder annotation found"); + } + }, icon: "eye" + }); + + cm.addItem({ + description: "pretend we made an annotation", event: () => { + document.dispatchEvent(new CustomEvent("fakeLinkStarted", { + detail: "fakefakefakeid", + 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" })); |