From 610ddaf1425018b4b00eb1fae83930f20777bad7 Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Tue, 14 Jul 2020 22:22:47 -0700 Subject: deleting a link in a document removes its corresponding hyperlink in annotation (with some regex bugs) --- src/client/views/linking/LinkMenuItem.tsx | 6 +++++- src/client/views/nodes/DocumentLinksButton.tsx | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index ad3c12122..509de2745 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -11,11 +11,13 @@ import { ContextMenu } from '../ContextMenu'; import './LinkMenuItem.scss'; import React = require("react"); import { DocumentManager } from '../../util/DocumentManager'; -import { setupMoveUpEvents, emptyFunction } from '../../../Utils'; +import { setupMoveUpEvents, emptyFunction, Utils } from '../../../Utils'; import { DocumentView } from '../nodes/DocumentView'; import { DocumentLinksButton } from '../nodes/DocumentLinksButton'; import { LinkDocPreview } from '../nodes/LinkDocPreview'; import { WebField } from '../../../fields/URLField'; +import { Hypothesis } from '../../apis/hypothesis/HypothesisApiUtils'; +import { Id } from '../../../fields/FieldSymbols'; library.add(faEye, faEdit, faTimes, faArrowRight, faChevronDown, faChevronUp, faPencilAlt); @@ -169,6 +171,8 @@ export class LinkMenuItem extends React.Component { @action deleteLink = (): void => { + this.props.linkDoc.linksToAnnotation && Hypothesis.deleteLink(StrCast(this.props.linkDoc.annotationId), Utils.prepend("/doc/" + this.props.sourceDoc[Id])); // delete hyperlink in annotation + this.props.linkDoc.linksToAnnotation && console.log("annotationId", this.props.linkDoc.annotationId); LinkManager.Instance.deleteLink(this.props.linkDoc); //this.props.showLinks(); LinkDocPreview.LinkInfo = undefined; diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index ab97e8531..6d439e379 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -40,7 +40,7 @@ export class DocumentLinksButton extends React.Component { if (e.origin === "http://localhost:1050" && e.data.message === "annotation created") { - console.log("DASH RECEIVED MESSAGE:", e.data.message); + console.log("DASH received message: annotation created"); const response = await Hypothesis.getPlaceholderId("placeholder"); // delete once eventListening between client & Dash works const source = SelectionManager.SelectedDocuments()[0]; response && runInAction(() => { @@ -110,7 +110,6 @@ export class DocumentLinksButton extends React.Component) => { // Doc.UnBrushDoc(this.props.View.Document); // }); @@ -124,8 +123,9 @@ export class DocumentLinksButton extends React.Component) => { // Doc.UnBrushDoc(this.props.View.Document); // }); @@ -165,8 +164,9 @@ export class DocumentLinksButton extends React.Component