From 1e988c7c6d927630059645ebee05261619aba7b4 Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Wed, 8 Jul 2020 23:13:11 -0700 Subject: added multiple links capability, linking bug fixes --- src/client/views/linking/LinkMenuItem.tsx | 5 ++--- src/client/views/nodes/DocumentLinksButton.tsx | 7 +++++-- src/client/views/nodes/DocumentView.tsx | 17 ----------------- 3 files changed, 7 insertions(+), 22 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 9c21bca35..ad3c12122 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -152,8 +152,7 @@ export class LinkMenuItem extends React.Component { DocumentLinksButton.EditLink = undefined; LinkDocPreview.LinkInfo = undefined; - const redirectUrl = StrCast(this.props.linkDoc.annotationUrl, null); - redirectUrl && (Doc.GetProto(this.props.destinationDoc).data = new WebField(redirectUrl)); // if destination is a Hypothes.is annotation, redirect website to the annotation's URL to scroll to the annotation + this.props.linkDoc.linksToAnnotation && (Doc.GetProto(this.props.destinationDoc).data = new WebField(StrCast(this.props.linkDoc.annotationUrl))); // if destination is a Hypothes.is annotation, redirect website to the annotation's URL to scroll to the annotation if (this.props.linkDoc.follow) { if (this.props.linkDoc.follow === "Default") { @@ -196,7 +195,7 @@ export class LinkMenuItem extends React.Component {

- {StrCast(this.props.destinationDoc.title)}

+ {(this.props.linkDoc.linksToAnnotation ? "Annotation in " : "") + StrCast(this.props.destinationDoc.title)}

{this.props.linkDoc.description !== "" ?

{StrCast(this.props.linkDoc.description)}

: null}
diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index 839f83f78..32c344304 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -18,6 +18,7 @@ import { StrCast } from "../../../fields/Types"; import { LinkDescriptionPopup } from "./LinkDescriptionPopup"; import { LinkManager } from "../../util/LinkManager"; import { Hypothesis } from "../../apis/hypothesis/HypothesisApiUtils"; +import { Id } from "../../../fields/FieldSymbols"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -128,8 +129,9 @@ export class DocumentLinksButton extends React.Component(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("fakeAnnotationCreated", { -- cgit v1.2.3-70-g09d2