diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/apis/hypothesis/HypothesisApiUtils.ts | 3 | ||||
-rw-r--r-- | src/client/views/MainView.tsx | 4 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentLinksButton.tsx | 33 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 9 |
4 files changed, 13 insertions, 36 deletions
diff --git a/src/client/apis/hypothesis/HypothesisApiUtils.ts b/src/client/apis/hypothesis/HypothesisApiUtils.ts index 9cd4b9f80..9ba481c8c 100644 --- a/src/client/apis/hypothesis/HypothesisApiUtils.ts +++ b/src/client/apis/hypothesis/HypothesisApiUtils.ts @@ -65,7 +65,8 @@ export namespace Hypothesis { // Construct an URL which will scroll the web page to a specific annotation's position export const makeAnnotationUrl = (annotationId: string, baseUrl: string) => { - return `https://hyp.is/${annotationId}/${baseUrl}`; + return `https://hyp.is/${annotationId}/${baseUrl}`; // embeds the generic version of Hypothes.is client, not the Dash version + // return baseUrl + '#annotations:' + annotationId; }; // Extract username from Hypothe.is's userId format diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index cf1129895..81195b550 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -111,10 +111,6 @@ 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/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index 223d9fbf8..535711193 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -38,27 +38,17 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp @observable public static AnnotationUri: string | undefined; componentDidMount() { - // window.addEventListener("annotationCreated", (e: any) => { // event used by Hypothes.is plugin to tell Dash when an unlinked annotation has been created - // const id = e.details; - // const source = SelectionManager.SelectedDocuments()[0]; - // runInAction(() => { - // DocumentLinksButton.AnnotationId = id; - // DocumentLinksButton.StartLink = source; - // }); - // }); - console.log("window", window); - window.addEventListener("fakeAnnotationCreated", async (e: any) => { // event used by Hypothes.is plugin to tell Dash when an unlinked annotation has been created - if (e.handled) return; - e.handled = true; - console.log("Helo fake annotation make"); - // const id = e.detail; - const response = await Hypothesis.getPlaceholderId("bobzel", "placeholder"); // delete once eventListening between client & Dash works - const source = SelectionManager.SelectedDocuments()[0]; - response && runInAction(() => { - DocumentLinksButton.AnnotationId = response.id; - DocumentLinksButton.AnnotationUri = response.uri; - DocumentLinksButton.StartLink = source; - }); + window.addEventListener("message", async (e: any) => { + if (e.origin === "http://localhost:1050" && e.data.message === "annotation created") { + console.log("DASH RECEIVED MESSAGE:", e.data.message); + const response = await Hypothesis.getPlaceholderId("melissaz", "placeholder"); // delete once eventListening between client & Dash works + const source = SelectionManager.SelectedDocuments()[0]; + response && runInAction(() => { + DocumentLinksButton.AnnotationId = response.id; + DocumentLinksButton.AnnotationUri = response.uri; + DocumentLinksButton.StartLink = source; + }); + } }); } @@ -174,7 +164,6 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp // if the link is to a Hypothes.is annotation if (DocumentLinksButton.AnnotationId && DocumentLinksButton.AnnotationUri) { const sourceUrl = DocumentLinksButton.AnnotationUri; // the URL of the annotation's source web page - console.log("sourceAnnotationId, url", DocumentLinksButton.AnnotationId, sourceUrl); Doc.GetProto(linkDoc as Doc).linksToAnnotation = true; Doc.GetProto(linkDoc as Doc).annotationUrl = Hypothesis.makeAnnotationUrl(DocumentLinksButton.AnnotationId, sourceUrl); // redirect web doc to this URL when following link Hypothesis.dispatchLinkRequest(StrCast(targetDoc.title), Utils.prepend("/doc/" + targetDoc[Id]), DocumentLinksButton.AnnotationId); // update and link placeholder annotation diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index f766c3867..2f19eb266 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -774,15 +774,6 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu const cm = ContextMenu.Instance; if (!cm) return; - cm.addItem({ - description: "pretend we made an annotation", event: () => { - document.dispatchEvent(new CustomEvent("fakeAnnotationCreated", { - 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" })); |