diff options
Diffstat (limited to 'src/client/views')
| -rw-r--r-- | src/client/views/linking/LinkMenuItem.tsx | 5 | ||||
| -rw-r--r-- | src/client/views/nodes/DocumentLinksButton.tsx | 7 | ||||
| -rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 17 |
3 files changed, 7 insertions, 22 deletions
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<LinkMenuItemProps> { 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<LinkMenuItemProps> { <div className="linkMenu-text"> <p className="linkMenu-destination-title" onPointerDown={this.followDefault}> - {StrCast(this.props.destinationDoc.title)}</p> + {(this.props.linkDoc.linksToAnnotation ? "Annotation in " : "") + StrCast(this.props.destinationDoc.title)}</p> {this.props.linkDoc.description !== "" ? <p className="linkMenu-description"> {StrCast(this.props.linkDoc.description)}</p> : null} </div> 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<DocumentLinksButtonProp // if the link's source is a Hypothes.is annotation if (DocumentLinksButton.AnnotationId) { const sourceUrl = StrCast(sourceDoc.data.url); // the URL of the annotation's source web page + 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 + Hypothesis.dispatchLinkRequest(StrCast(targetDoc.title), Utils.prepend("/doc/" + targetDoc[Id]), DocumentLinksButton.AnnotationId); // update and link placeholder annotation } LinkManager.currentLink = linkDoc; @@ -169,8 +171,9 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp if (DocumentLinksButton.AnnotationId) { const sourceUrl = StrCast(sourceDoc.data.url); // 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 + Hypothesis.dispatchLinkRequest(StrCast(targetDoc.title), Utils.prepend("/doc/" + targetDoc[Id]), DocumentLinksButton.AnnotationId); // update and link placeholder annotation } LinkManager.currentLink = linkDoc; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 41308b3a4..f766c3867 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -775,23 +775,6 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu 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", { detail: "fakefakefakeid", |
