From 1763ff090ea734ca275c3c28edc6c303c935b801 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 25 Jan 2023 12:59:50 -0500 Subject: added a linkFollow o[ption to choose between opening target, or highest level collection containing target. fixed adding marker annotations to pdf/web/etc. fixed following link to wikipedia pages to not create a new document each time. made searchBox's search function static so that it can be called programmatically. Fixed LinkDocPreview to not flicker when doing a nopreview link follow. changed PlayTrail to restore state of all freeform collections containing source anchor. --- src/client/util/DocumentManager.ts | 9 ++- src/client/util/LinkFollower.ts | 23 ++---- src/client/views/MainView.tsx | 6 +- src/client/views/PropertiesView.tsx | 12 ++- .../views/collections/CollectionDockingView.tsx | 9 ++- src/client/views/nodes/LinkDocPreview.tsx | 72 ++++++++++------- src/client/views/nodes/trails/PresBox.tsx | 16 ++-- src/client/views/pdf/AnchorMenu.tsx | 4 +- src/client/views/search/SearchBox.tsx | 27 ++++--- src/fields/Types.ts | 90 ++++++++++++---------- 10 files changed, 152 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index aa09fb005..7c867d710 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -194,11 +194,16 @@ export class DocumentManager { return toReturn; } - static GetContextPath(doc: Opt) { + static GetContextPath(doc: Opt, includeExistingViews?: boolean) { if (!doc) return []; const srcContext = Cast(doc.context, Doc, null) ?? Cast(Cast(doc.annotationOn, Doc, null)?.context, Doc, null); var containerDocContext = srcContext ? [srcContext] : []; - while (containerDocContext.length && containerDocContext[0]?.context && DocCast(containerDocContext[0].context)?.viewType !== CollectionViewType.Docking && !DocumentManager.Instance.getDocumentView(containerDocContext[0])) { + while ( + containerDocContext.length && + containerDocContext[0]?.context && + DocCast(containerDocContext[0].context)?.viewType !== CollectionViewType.Docking && + (includeExistingViews || !DocumentManager.Instance.getDocumentView(containerDocContext[0])) + ) { containerDocContext = [Cast(containerDocContext[0].context, Doc, null), ...containerDocContext]; } return containerDocContext; diff --git a/src/client/util/LinkFollower.ts b/src/client/util/LinkFollower.ts index 5bdfca54a..57618b53c 100644 --- a/src/client/util/LinkFollower.ts +++ b/src/client/util/LinkFollower.ts @@ -100,7 +100,7 @@ export class LinkFollower { : linkDoc.anchor1 ) as Doc; if (target) { - const doFollow = async (canToggle?: boolean) => { + const doFollow = (canToggle?: boolean) => { const options: DocFocusOptions = { playAudio: BoolCast(sourceDoc.followLinkAudio), toggleTarget: canToggle && BoolCast(sourceDoc.followLinkToggle), @@ -114,27 +114,14 @@ export class LinkFollower { zoomTextSelections: BoolCast(sourceDoc.followLinkZoomText), }; if (target.type === DocumentType.PRES) { - const containerAnnoDoc = Cast(sourceDoc, Doc, null); - const containerDoc = containerAnnoDoc || sourceDoc; - var containerDocContext = containerDoc?.context ? [Cast(await containerDoc?.context, Doc, null)] : ([] as Doc[]); - while (containerDocContext.length && containerDocContext[0]?.context && DocCast(containerDocContext[0].context)?.viewType !== CollectionViewType.Docking) { - containerDocContext = [Cast(await containerDocContext[0].context, Doc, null), ...containerDocContext]; - } - if (!DocumentManager.Instance.getDocumentView(containerDocContext[0])) { - CollectionDockingView.AddSplit(containerDocContext[0], OpenWhereMod.right); - } + const containerDocContext = DocumentManager.GetContextPath(sourceDoc, true); // gather all views that affect layout of sourceDoc so we can revert them after playing the rail SelectionManager.DeselectAll(); - DocumentManager.Instance.AddViewRenderedCb(target, dv => containerDocContext.length && (dv.ComponentView as PresBox).PlayTrail(containerDocContext[0])); + DocumentManager.Instance.AddViewRenderedCb(target, dv => containerDocContext.length && (dv.ComponentView as PresBox).PlayTrail(containerDocContext)); PresBox.OpenPresMinimized(target, [0, 0]); finished?.(); } else { - const containerAnnoDoc = Cast(target.annotationOn, Doc, null); - const containerDoc = containerAnnoDoc || target; - var containerDocContext = containerDoc?.context ? [Cast(await containerDoc?.context, Doc, null)] : ([] as Doc[]); - while (containerDocContext.length && containerDocContext[0]?.context && !DocumentManager.Instance.getDocumentView(containerDocContext[0]) && DocCast(containerDocContext[0].context)?.viewType !== CollectionViewType.Docking) { - containerDocContext = [Cast(await containerDocContext[0].context, Doc, null), ...containerDocContext]; - } - const targetContexts = LightboxView.LightboxDoc ? [containerAnnoDoc || containerDocContext[0]].filter(a => a) : containerDocContext; + const containerDocContext = DocumentManager.GetContextPath(target); + const targetContexts = !sourceDoc.followLinkToOuterContext && containerDocContext.length ? [containerDocContext.lastElement()] : containerDocContext; DocumentManager.Instance.jumpToDocument(target, options, (doc, finished) => createViewFunc(doc, StrCast(linkDoc.followLinkLocation, OpenWhere.inPlace), finished), targetContexts, allFinished); } }; diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 839db5795..895ed9bda 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -948,6 +948,10 @@ export class MainView extends React.Component { ); } + @computed get linkDocPreview() { + return LinkDocPreview.LinkInfo ? : null; + } + render() { return (
} {LinkDescriptionPopup.descriptionPopup ? : null} {DocumentLinksButton.LinkEditorDocView ? (DocumentLinksButton.LinkEditorDocView = undefined))} docView={DocumentLinksButton.LinkEditorDocView} /> : null} - {LinkDocPreview.LinkInfo ? : null} + {this.linkDocPreview} {((page: string) => { // prettier-ignore diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index af50478b0..411f51d84 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -1,6 +1,6 @@ import React = require('react'); import { IconLookup } from '@fortawesome/fontawesome-svg-core'; -import { faAnchor, faArrowRight } from '@fortawesome/free-solid-svg-icons'; +import { faAnchor, faArrowRight, faWindowMaximize } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Checkbox, Tooltip } from '@material-ui/core'; import { intersection } from 'lodash'; @@ -1689,6 +1689,16 @@ export class PropertiesView extends React.Component {
+
+

Toggle Follow to Outer Context

+ +

Toggle Target (Show/Hide)