diff options
author | bobzel <zzzman@gmail.com> | 2020-12-13 14:25:33 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2020-12-13 14:25:33 -0500 |
commit | 898227ac1cecb3cd8d4be4ed00ab4190713f006a (patch) | |
tree | 4cd165cad87ea55c7022a06f2230d69b8770c7d0 /src | |
parent | 043fe3cb67003ddd0bc309b85e2b0dad353ed629 (diff) |
adding documentView as a fieldView prop to make contetnScaling available in PDFview
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/PDFBox.tsx | 5 | ||||
-rw-r--r-- | src/client/views/pdf/PDFViewer.tsx | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index f766976d0..6ca3ffbee 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -52,6 +52,7 @@ export interface DocumentViewSharedProps { renderDepth: number; Document: Doc; DataDoc?: Doc; + DocumentView?: DocumentView; ContainingCollectionView: Opt<CollectionView>; ContainingCollectionDoc: Opt<Doc>; CollectionFreeFormDocumentView?: () => CollectionFreeFormDocumentView; @@ -913,6 +914,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu }}> <DocumentContentsView key={1} renderDepth={this.props.renderDepth} + DocumentView={this} Document={this.props.Document} DataDoc={this.props.DataDoc} ContainingCollectionView={this.props.ContainingCollectionView} diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index b34c7966b..18ded4f3b 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -9,7 +9,7 @@ import { makeInterface } from "../../../fields/Schema"; import { Cast, NumCast } from "../../../fields/Types"; import { PdfField } from "../../../fields/URLField"; import { TraceMobx } from '../../../fields/util'; -import { Utils } from '../../../Utils'; +import { Utils, returnOne } from '../../../Utils'; import { KeyCodes } from '../../util/KeyCodes'; import { undoBatch } from '../../util/UndoManager'; import { panZoomSchema } from '../collections/collectionFreeForm/CollectionFreeFormView'; @@ -183,7 +183,6 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps, PdfDocum ContextMenu.Instance.addItem({ description: "Options...", subitems: funcs, icon: "asterisk" }); } - @computed get contentScaling() { return 1; } @computed get renderTitleBox() { const classname = "pdfBox" + (this.active() ? "-interactive" : ""); return <div className={classname} > @@ -193,6 +192,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps, PdfDocum </div>; } + contentScaling = () => this.props.DocumentView?.props.ContentScaling() || 1; isChildActive = (outsideReaction?: boolean) => this._isChildActive; @computed get renderPdfView() { TraceMobx(); @@ -209,6 +209,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps, PdfDocum whenActiveChanged={this.whenActiveChanged} isChildActive={this.isChildActive} startupLive={true} + ContentScaling={this.contentScaling} /> {this.settingsPanel()} </div>; diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index fc547c60f..7696167a7 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -60,6 +60,7 @@ interface IViewerProps extends FieldViewProps { loaded?: (nw: number, nh: number, np: number) => void; isChildActive: (outsideReaction?: boolean) => boolean; setPdfViewer: (view: PDFViewer) => void; + ContentScaling: () => number; } /** @@ -370,7 +371,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu @action scrollToAnnotation = (scrollToAnnotation: Doc) => { if (scrollToAnnotation) { - const offset = this.props.PanelHeight() / 2; + const offset = (this.props.PanelHeight() / this.props.ContentScaling()) / 2; this._mainCont.current && smoothScroll(500, this._mainCont.current, NumCast(scrollToAnnotation.y) - offset); Doc.linkFollowHighlight(scrollToAnnotation); } @@ -737,7 +738,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu @computed get pdfViewerDiv() { return <div className={"pdfViewerDash-text" + ((this.props.isSelected() || this.props.isChildActive()) ? "-selected" : "")} ref={this._viewer} />; } - @computed get contentScaling() { return 1; } + @computed get contentScaling() { return this.props.ContentScaling(); } @computed get standinViews() { return <> {this._showCover ? this.getCoverImage() : (null)} @@ -758,6 +759,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu overflowX: this._zoomed !== 1 ? "scroll" : undefined, width: !this.props.Document._fitWidth && (window.screen.width > 600) ? Doc.NativeWidth(this.props.Document) : `${100 / this.contentScaling}%`, height: !this.props.Document._fitWidth && (window.screen.width > 600) ? Doc.NativeHeight(this.props.Document) : `${100 / this.contentScaling}%`, + transform: `scale(${this.props.ContentScaling()})` }} > {this.pdfViewerDiv} {this.annotationLayer} |