From 2b3fb53a5e0ebe21eef2406992257ef5e86b3b2d Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Fri, 31 Jul 2020 16:03:03 -0700 Subject: modify link completing from annotations, fix web drag & drop --- src/client/views/nodes/DocumentLinksButton.tsx | 46 +++++++++++++++----------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'src/client/views/nodes/DocumentLinksButton.tsx') diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index 581d84eae..be7c3e135 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -11,13 +11,14 @@ import { DragManager } from "../../util/DragManager"; import { LinkManager } from "../../util/LinkManager"; import { undoBatch, UndoManager } from "../../util/UndoManager"; import { DocumentView } from "./DocumentView"; -import { StrCast } from "../../../fields/Types"; +import { StrCast, Cast } from "../../../fields/Types"; import { LinkDescriptionPopup } from "./LinkDescriptionPopup"; import { Hypothesis } from "../../apis/hypothesis/HypothesisUtils"; import { Id } from "../../../fields/FieldSymbols"; import { TaskCompletionBox } from "./TaskCompletedBox"; import React = require("react"); import './DocumentLinksButton.scss'; +import { WebField } from "../../../fields/URLField"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; @@ -40,27 +41,30 @@ export class DocumentLinksButton extends React.Component { - const annotationUri = e.detail.uri; - const sourceDoc = DocumentLinksButton.StartLink && await Hypothesis.getSourceWebDoc(annotationUri); - - this.props.View.props.Document.type === DocumentType.WEB && console.log(sourceDoc === this.props.View.props.Document, - sourceDoc, - this.props.View.props.Document, - sourceDoc!.title, - this.props.View.props.Document, - sourceDoc!.data, - this.props.View.props.Document.data); - - if (sourceDoc === this.props.View.props.Document && sourceDoc !== DocumentLinksButton.StartLink) { - this.finishLinkClick(20, 20); + const annotationId: string = e.detail.id; + const annotationUri: string = e.detail.uri; + const sourceDoc: Doc = e.detail.sourceDoc; + + // DocumentLinksButton.StartLink && this.props.View.props.Document.type === DocumentType.WEB && console.log( + // sourceDoc.title, + // this.props.View.props.Document.title, + // sourceDoc.data, + // this.props.View.props.Document.data, + // Doc.AreProtosEqual(sourceDoc, this.props.View.props.Document)); + + if (Doc.AreProtosEqual(sourceDoc, this.props.View.props.Document) && sourceDoc !== DocumentLinksButton.StartLink) { + DocumentLinksButton.AnnotationId = annotationId; + DocumentLinksButton.AnnotationUri = annotationUri; + this.finishLinkClick(500, 100); console.log("completed link from annotation"); } } @@ -122,7 +126,7 @@ export class DocumentLinksButton extends React.Component { setupMoveUpEvents(this, e, returnFalse, emptyFunction, action((e, doubleTap) => { - if (doubleTap && this.props.InMenu && !!!this.props.StartLink) { + if (doubleTap && !this.props.StartLink) { if (DocumentLinksButton.StartLink === this.props.View.props.Document) { DocumentLinksButton.StartLink = undefined; DocumentLinksButton.AnnotationId = undefined; @@ -169,7 +173,7 @@ export class DocumentLinksButton extends React.Component { -- cgit v1.2.3-70-g09d2