From cc89a0c16246afde8bb3d891a4ede492b6644b1f Mon Sep 17 00:00:00 2001 From: geireann Date: Wed, 18 Aug 2021 11:01:57 -0400 Subject: added search linking --- src/Utils.ts | 1 + src/client/views/MarqueeAnnotator.tsx | 2 ++ src/client/views/linking/LinkPopup.tsx | 5 ++++- src/client/views/nodes/formattedText/FormattedTextBox.tsx | 1 + src/client/views/pdf/AnchorMenu.tsx | 12 +++++------- src/client/views/search/SearchBox.tsx | 14 +++++++++++--- src/client/views/topbar/TopBar.scss | 1 + 7 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Utils.ts b/src/Utils.ts index 194c38a6f..f9ca8646f 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -439,6 +439,7 @@ export function emptyFunction() { } export function unimplementedFunction() { throw new Error("This function is not implemented, but should be."); } + export type Without = Pick>; export type Predicate = (entry: [K, V]) => boolean; diff --git a/src/client/views/MarqueeAnnotator.tsx b/src/client/views/MarqueeAnnotator.tsx index a3a3bce56..fa1a4cfea 100644 --- a/src/client/views/MarqueeAnnotator.tsx +++ b/src/client/views/MarqueeAnnotator.tsx @@ -68,6 +68,8 @@ export class MarqueeAnnotator extends React.Component { AnchorMenu.Instance.OnClick = (e: PointerEvent) => this.props.anchorMenuClick?.()?.(this.highlight("rgba(173, 216, 230, 0.75)", true)); AnchorMenu.Instance.Highlight = this.highlight; AnchorMenu.Instance.GetAnchor = (savedAnnotations?: ObservableMap) => this.highlight("rgba(173, 216, 230, 0.75)", true, savedAnnotations); + AnchorMenu.Instance.onMakeAnchor = AnchorMenu.Instance.GetAnchor; + /** * This function is used by the AnchorMenu to create an anchor highlight and a new linked text annotation. * It also initiates a Drag/Drop interaction to place the text annotation. diff --git a/src/client/views/linking/LinkPopup.tsx b/src/client/views/linking/LinkPopup.tsx index 85fd91d9f..c8be9069c 100644 --- a/src/client/views/linking/LinkPopup.tsx +++ b/src/client/views/linking/LinkPopup.tsx @@ -11,9 +11,11 @@ import { SearchBox } from '../search/SearchBox'; import { DefaultStyleProvider } from '../StyleProvider'; import './LinkPopup.scss'; import React = require("react"); +import { Doc, Opt } from '../../../fields/Doc'; interface LinkPopupProps { showPopup: boolean; + linkFrom?: () => Doc | undefined; // groupType: string; // linkDoc: Doc; // docView: DocumentView; @@ -48,6 +50,7 @@ export class LinkPopup extends React.Component { render() { const popupVisibility = this.props.showPopup ? "block" : "none"; + const linkDoc = this.props.linkFrom ? this.props.linkFrom : undefined; return (
{/*
@@ -67,7 +70,7 @@ export class LinkPopup extends React.Component { { @observable public Highlighting: boolean = false; @observable public Status: "marquee" | "annotation" | "" = ""; + public onMakeAnchor: () => Opt = () => undefined; // Method to get anchor from text search + public OnClick: (e: PointerEvent) => void = unimplementedFunction; - public OnLink: (e: PointerEvent) => void = unimplementedFunction; public StartDrag: (e: PointerEvent, ele: HTMLElement) => void = unimplementedFunction; public Highlight: (color: string, isPushpin: boolean) => Opt = (color: string, isPushpin: boolean) => undefined; public GetAnchor: (savedAnnotations?: ObservableMap) => Opt = () => undefined; @@ -67,15 +68,12 @@ export class AnchorMenu extends AntimodeMenu { componentDidMount() { this._disposer = reaction(() => SelectionManager.Views(), selected => { - AnchorMenu.Instance.fadeOut(true) this._showLinkPopup = false; + console.log("unmount"); + AnchorMenu.Instance.fadeOut(true) }); } - componentWillUnmount() { - console.log("unmount"); - } - pointerDown = (e: React.PointerEvent) => { setupMoveUpEvents(this, e, (e: PointerEvent) => { this.StartDrag(e, this._commentCont.current!); @@ -159,7 +157,7 @@ export class AnchorMenu extends AntimodeMenu { , - + ] : [ {"Remove Link Anchor"}
}>