From 280c24f1216a532e9f2157e6db0bf8c8030a16f3 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 13 Mar 2021 11:45:52 -0500 Subject: fixed pdf boxes to handle marquee annotation scaling properly. allowed for docFilters to be specific to pdf sidebar. fixed issue with viewTransition remaining set after following link to doc that was in collection but needs to be created. --- src/client/util/DocumentManager.ts | 7 ++++++- src/client/views/nodes/DocumentView.tsx | 2 +- src/client/views/nodes/PDFBox.tsx | 35 +++++++++++++++++---------------- src/client/views/pdf/PDFViewer.tsx | 24 +++++++++++----------- src/fields/Doc.ts | 11 ++++++----- 5 files changed, 43 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 969eed701..d975461e8 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -181,7 +181,12 @@ export class DocumentManager { } else { // otherwise try to get a view of the context of the target if (targetDocContextView) { // we found a context view and aren't forced to create a new one ... focus on the context first.. targetDocContext._viewTransition = "transform 500ms"; - targetDocContextView.props.focus(targetDocContextView.rootDoc, { willZoom }); + targetDocContextView.props.focus(targetDocContextView.rootDoc, { + willZoom, afterFocus: async () => { + targetDocContext._viewTransition = undefined; + return ViewAdjustment.doNothing; + } + }); // now find the target document within the context if (targetDoc._timecodeToShow) { // if the target has a timecode, it should show up once the (presumed) video context scrubs to the display timecode; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 056f5e968..8dea34a15 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -621,7 +621,7 @@ export class DocumentViewInternal extends DocComponent { const portalLink = this.allLinks.find(d => d.anchor1 === this.props.Document); if (!portalLink) { - const portal = Docs.Create.FreeformDocument([], { _width: NumCast(this.layoutDoc._width) + 10, _height: NumCast(this.layoutDoc._height), title: StrCast(this.props.Document.title) + ".portal" }); + const portal = Docs.Create.FreeformDocument([], { _width: NumCast(this.layoutDoc._width) + 10, _height: NumCast(this.layoutDoc._height), _fitWidth: true, title: StrCast(this.props.Document.title) + ".portal" }); DocUtils.MakeLink({ doc: this.props.Document }, { doc: portal }, "portal to"); } this.Document.followLinkLocation = "inPlace"; diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 516959029..e1ac8f16d 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -3,33 +3,31 @@ import { action, computed, IReactionDisposer, observable, reaction, runInAction import { observer } from "mobx-react"; import * as Pdfjs from "pdfjs-dist"; import "pdfjs-dist/web/pdf_viewer.css"; -import { Doc, Opt, WidthSym, HeightSym, DocListCast, StrListCast } from "../../../fields/Doc"; +import { Doc, DocListCast, Opt, StrListCast, WidthSym } from "../../../fields/Doc"; import { documentSchema } from '../../../fields/documentSchemas'; +import { Id } from '../../../fields/FieldSymbols'; import { makeInterface } from "../../../fields/Schema"; import { Cast, NumCast, StrCast } from '../../../fields/Types'; import { PdfField } from "../../../fields/URLField"; import { TraceMobx } from '../../../fields/util'; -import { Utils, returnOne, OmitKeys, emptyFunction, returnZero, returnTrue } from '../../../Utils'; +import { emptyFunction, OmitKeys, returnOne, returnTrue, returnZero, Utils } from '../../../Utils'; +import { Docs, DocUtils } from '../../documents/Documents'; import { KeyCodes } from '../../util/KeyCodes'; import { undoBatch } from '../../util/UndoManager'; import { panZoomSchema } from '../collections/collectionFreeForm/CollectionFreeFormView'; +import { CollectionStackingView } from '../collections/CollectionStackingView'; import { CollectionViewType } from '../collections/CollectionView'; import { ContextMenu } from '../ContextMenu'; import { ContextMenuProps } from '../ContextMenuItem'; import { ViewBoxAnnotatableComponent } from "../DocComponent"; import { PDFViewer } from "../pdf/PDFViewer"; +import { SearchBox } from '../search/SearchBox'; +import { StyleProp } from '../StyleProvider'; import { FieldView, FieldViewProps } from './FieldView'; +import { FormattedTextBox } from './formattedText/FormattedTextBox'; import { pageSchema } from "./ImageBox"; import "./PDFBox.scss"; import React = require("react"); -import { DocAfterFocusFunc } from './DocumentView'; -import { Docs, DocUtils } from '../../documents/Documents'; -import { CollectionStackingView } from '../collections/CollectionStackingView'; -import { StyleProp } from '../StyleProvider'; -import { SearchBox } from '../search/SearchBox'; -import { CurrentUserUtils } from '../../util/CurrentUserUtils'; -import { Id } from '../../../fields/FieldSymbols'; -import { FormattedTextBox } from './formattedText/FormattedTextBox'; type PdfDocument = makeInterface<[typeof documentSchema, typeof panZoomSchema, typeof pageSchema]>; const PdfDocument = makeInterface(documentSchema, panZoomSchema, pageSchema); @@ -129,15 +127,16 @@ export class PDFBox extends ViewBoxAnnotatableComponent this.addDocument(doc, this.sidebarKey()); sidebarMoveDocument = (doc: Doc | Doc[], targetCollection: Doc | undefined, addDocument: (doc: Doc | Doc[]) => boolean) => this.moveDocument(doc, targetCollection, addDocument, this.sidebarKey()); sidebarRemDocument = (doc: Doc | Doc[]) => this.removeDocument(doc, this.sidebarKey()); + sidebarDocFilters = () => [...StrListCast(this.layoutDoc._docFilters), ...StrListCast(this.layoutDoc[this.sidebarKey() + "-docFilters"])]; @computed get allTags() { const keys = new Set(); DocListCast(this.rootDoc[this.sidebarKey()]).forEach(doc => SearchBox.documentKeys(doc).forEach(key => keys.add(key))); return Array.from(keys.keys()).filter(key => key[0]).filter(key => !key.startsWith("_") && (key[0] === "#" || key[0] === key[0].toUpperCase())).sort(); } renderTag = (tag: string) => { - const active = StrListCast(this.rootDoc.docFilters).includes(`${tag}:${tag}:check`); + const active = StrListCast(this.rootDoc[this.sidebarKey() + "-docFilters"]).includes(`${tag}:${tag}:check`); return
Doc.setDocFilter(this.rootDoc, tag, tag, "check", true)}> + onClick={e => Doc.setDocFilter(this.rootDoc, tag, tag, "check", true, this.sidebarKey())}> {tag}
; } @@ -149,9 +148,6 @@ export class PDFBox extends ViewBoxAnnotatableComponent -
- {this.allTags.map(tag => this.renderTag(tag))} -
+ /> + +
+ {this.allTags.map(tag => this.renderTag(tag))} +
; } @@ -269,7 +270,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent Utils.CopyText(pdfUrl.url.pathname), icon: "expand-arrows-alt" }); funcs.push({ description: "Toggle Fit Width " + (this.Document._fitWidth ? "Off" : "On"), event: () => this.Document._fitWidth = !this.Document._fitWidth, icon: "expand-arrows-alt" }); - !Doc.UserDoc().noviceMode && funcs.push({ description: "Toggle Sidebar mode ", event: () => this.Document._showSidebar = !this.Document._showSidebar, icon: "expand-arrows-alt" }); + funcs.push({ description: "Toggle Annotation View ", event: () => this.Document._showSidebar = !this.Document._showSidebar, icon: "expand-arrows-alt" }); ContextMenu.Instance.addItem({ description: "Options...", subitems: funcs, icon: "asterisk" }); } diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 1750b526e..c7359f74e 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -553,8 +553,8 @@ export class PDFViewer extends ViewBoxAnnotatableComponent this._zoomed; render() { TraceMobx(); - return
-
+
}
- {this.overlayInfo} - {this.standinViews} - {!this._marqueeing || !this._mainCont.current || !this._annotationLayer.current ? (null) : - }
; } } \ No newline at end of file diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index e64195b63..e26d771d3 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -1063,9 +1063,10 @@ export namespace Doc { // filters document in a container collection: // all documents with the specified value for the specified key are included/excluded // based on the modifiers :"check", "x", undefined - export function setDocFilter(target: Opt, key: string, value: any, modifiers: "remove" | "match" | "check" | "x", toggle?: boolean) { + export function setDocFilter(target: Opt, key: string, value: any, modifiers: "remove" | "match" | "check" | "x", toggle?: boolean, fieldSuffix?:string) { const container = target ?? CollectionDockingView.Instance.props.Document; - const docFilters = Cast(container._docFilters, listSpec("string"), []); + const filterField = "_"+(fieldSuffix ? fieldSuffix+"-":"")+"docFilters"; + const docFilters = Cast(container[filterField], listSpec("string"), []); runInAction(() => { for (let i = 0; i < docFilters.length; i++) { const fields = docFilters[i].split(":"); // split key:value:modifier @@ -1075,15 +1076,15 @@ export namespace Doc { else return; } docFilters.splice(i, 1); - container._docFilters = new List(docFilters); + container[filterField] = new List(docFilters); break; } } if (!docFilters.length && modifiers === "match" && value === undefined) { - container._docFilters = undefined; + container[filterField] = undefined; } else if (modifiers !== "remove") { docFilters.push(key + ":" + value + ":" + modifiers); - container._docFilters = new List(docFilters); + container[filterField] = new List(docFilters); } }); } -- cgit v1.2.3-70-g09d2