From fbc7a328016af60052dd3f33c2d906e6c6447a5f Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Mon, 6 Jul 2020 23:41:34 -0700 Subject: set up linking for hypothesis annotations --- src/client/views/collections/CollectionLinearView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/views/collections/CollectionLinearView.tsx') diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx index 7cbe5c19d..fd8eb506a 100644 --- a/src/client/views/collections/CollectionLinearView.tsx +++ b/src/client/views/collections/CollectionLinearView.tsx @@ -154,7 +154,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) { }} onPointerDown={e => e.stopPropagation()} > - Creating link from: {DocumentLinksButton.StartLink.title} + Creating link from: {(DocumentLinksButton.AnnotationId ? "Annotation in " : "")} {DocumentLinksButton.StartLink.title} Exit -- cgit v1.2.3-70-g09d2 From 638879c606302f809ba4fcdc431a289a8bc01c2e Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Tue, 7 Jul 2020 10:24:22 -0700 Subject: merge with master --- package.json | 2 +- src/client/views/collections/CollectionLinearView.tsx | 4 ---- src/client/views/nodes/DocumentView.tsx | 3 --- 3 files changed, 1 insertion(+), 8 deletions(-) (limited to 'src/client/views/collections/CollectionLinearView.tsx') diff --git a/package.json b/package.json index 89af3b0b5..48e535fe4 100644 --- a/package.json +++ b/package.json @@ -248,4 +248,4 @@ "xoauth2": "^1.2.0", "xregexp": "^4.3.0" } -} \ No newline at end of file +} diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx index f44c3db68..c370415be 100644 --- a/src/client/views/collections/CollectionLinearView.tsx +++ b/src/client/views/collections/CollectionLinearView.tsx @@ -170,14 +170,10 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) { }} onPointerDown={e => e.stopPropagation()} > -<<<<<<< HEAD - Creating link from: {(DocumentLinksButton.AnnotationId ? "Annotation in " : "")} {DocumentLinksButton.StartLink.title} -======= Creating link from: {DocumentLinksButton.StartLink.title} Labels: {LinkDescriptionPopup.showDescriptions ? LinkDescriptionPopup.showDescriptions : "ON"} ->>>>>>> 3f704ee2941fef77dd0eafebeb0a6ffb0a946a8b Exit diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 9ad08a692..c67267860 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -43,12 +43,9 @@ import React = require("react"); import { DocumentLinksButton } from './DocumentLinksButton'; import { MobileInterface } from '../../../mobile/MobileInterface'; import { LinkCreatedBox } from './LinkCreatedBox'; -<<<<<<< HEAD import { Hypothesis } from '../../apis/hypothesis/HypothesisApiUtils'; -======= import { LinkDescriptionPopup } from './LinkDescriptionPopup'; import { LinkManager } from '../../util/LinkManager'; ->>>>>>> 3f704ee2941fef77dd0eafebeb0a6ffb0a946a8b 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, -- cgit v1.2.3-70-g09d2 From 901610007e7b33b1c3db3c93aa6e96dacd414256 Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Tue, 7 Jul 2020 17:57:11 -0700 Subject: Follow link directly to annotations --- src/client/documents/Documents.ts | 6 +++--- src/client/views/collections/CollectionLinearView.tsx | 2 +- src/client/views/linking/LinkMenuItem.tsx | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/client/views/collections/CollectionLinearView.tsx') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 8c3abada6..763321a85 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -934,9 +934,9 @@ export namespace DocUtils { linkDoc.layout_linkView = Cast(Cast(Doc.UserDoc()["template-button-link"], Doc, null).dragFactory, Doc, null); Doc.GetProto(linkDoc).title = ComputedField.MakeFunction('self.anchor1?.title +" (" + (self.linkRelationship||"to") +") " + self.anchor2?.title'); - console.log("sourceAnnotationId, should be url?", sourceAnnotationId, StrCast(source.doc.data)); - Doc.GetProto(linkDoc).sourceRedirectUrl = Hypothesis.makeAnnotationUrl(sourceAnnotationId, StrCast(source.doc.data)); - // Doc.GetProto(linkDoc).targetRedirectUrl = undefined; + const sourceUrl = StrCast(source.doc.data.url); // The URL of the annotation's source web page + console.log("sourceAnnotationId, url", sourceAnnotationId, sourceUrl); + Doc.GetProto(linkDoc).annotationUrl = Hypothesis.makeAnnotationUrl(sourceAnnotationId, sourceUrl); Doc.GetProto(source.doc).links = ComputedField.MakeFunction("links(self)"); Doc.GetProto(target.doc).links = ComputedField.MakeFunction("links(self)"); diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx index c370415be..0bbe97ec9 100644 --- a/src/client/views/collections/CollectionLinearView.tsx +++ b/src/client/views/collections/CollectionLinearView.tsx @@ -170,7 +170,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) { }} onPointerDown={e => e.stopPropagation()} > - Creating link from: {DocumentLinksButton.StartLink.title} + Creating link from: {DocumentLinksButton.AnnotationId ? "Annotation in" : ""} {DocumentLinksButton.StartLink.title} Labels: {LinkDescriptionPopup.showDescriptions ? LinkDescriptionPopup.showDescriptions : "ON"} diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 6af474513..76f802c0c 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -15,6 +15,7 @@ import { setupMoveUpEvents, emptyFunction } from '../../../Utils'; import { DocumentView } from '../nodes/DocumentView'; import { DocumentLinksButton } from '../nodes/DocumentLinksButton'; import { LinkDocPreview } from '../nodes/LinkDocPreview'; +import { WebField } from '../../../fields/URLField'; library.add(faEye, faEdit, faTimes, faArrowRight, faChevronDown, faChevronUp, faPencilAlt); @@ -151,6 +152,10 @@ export class LinkMenuItem extends React.Component { DocumentLinksButton.EditLink = undefined; LinkDocPreview.LinkInfo = undefined; + const redirectUrl = StrCast(this.props.linkDoc.annotationUrl, null); + redirectUrl && (this.props.destinationDoc.data = new WebField(redirectUrl)); // If the link is to an annotation, go to annotation + console.log(redirectUrl, "redirectUrl"); + if (this.props.linkDoc.follow) { if (this.props.linkDoc.follow === "Default") { DocumentManager.Instance.FollowLink(this.props.linkDoc, this.props.sourceDoc, doc => this.props.addDocTab(doc, "onRight"), false); -- cgit v1.2.3-70-g09d2 From 8c9e41ce30e37e55265a4ea8c52cd0567af227e4 Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Wed, 5 Aug 2020 15:50:13 -0700 Subject: small bug fixes --- src/client/views/collections/CollectionLinearView.tsx | 2 +- src/client/views/collections/CollectionSubView.tsx | 8 +++++++- src/client/views/nodes/DocumentLinksButton.tsx | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/client/views/collections/CollectionLinearView.tsx') diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx index 19d1ffa7b..3cf46dbed 100644 --- a/src/client/views/collections/CollectionLinearView.tsx +++ b/src/client/views/collections/CollectionLinearView.tsx @@ -176,7 +176,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) { }} onPointerDown={e => e.stopPropagation()} > - Creating link from: {DocumentLinksButton.AnnotationId ? "Annotation in" : ""} {DocumentLinksButton.StartLink.title} + Creating link from: {DocumentLinksButton.AnnotationId ? "Annotation in " : " "} {StrCast(DocumentLinksButton.StartLink.title).length < 51 ? DocumentLinksButton.StartLink.title : StrCast(DocumentLinksButton.StartLink.title).slice(0, 50) + '...'}
{LinkDescriptionPopup.showDescriptions ? "Turn off description pop-up" : diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index 2c382fe88..ce3654cf2 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -349,7 +349,13 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T, moreProps?: const existingWebDoc = await Hypothesis.findWebDoc(uriList); if (existingWebDoc) { - this.addDocument(Doc.MakeAlias(existingWebDoc)); + const alias = Doc.MakeAlias(existingWebDoc); + alias.x = options.x; + alias.y = options.y; + alias._nativeWidth = 850; + alias._nativeHeight = 962; + alias._width = 400; + this.addDocument(alias); } else { const cleanedUri = uriList.split("#annotations:")[0]; // clean hypothes.is URLs that reference a specific annotation (eg. https://en.wikipedia.org/wiki/Cartoon#annotations:t7qAeNbCEeqfG5972KR2Ig) this.addDocument(Docs.Create.WebDocument(uriList, { diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index dcdaa3199..3057d87e8 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -92,6 +92,8 @@ export class DocumentLinksButton extends React.Component { if (this.props.InMenu && this.props.StartLink) { + DocumentLinksButton.AnnotationId = undefined; + DocumentLinksButton.AnnotationUri = undefined; if (DocumentLinksButton.StartLink === this.props.View.props.Document) { DocumentLinksButton.StartLink = undefined; } else { @@ -152,6 +154,7 @@ export class DocumentLinksButton extends React.Component