aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PDFBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
-rw-r--r--src/client/views/nodes/PDFBox.tsx44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index d15f2b82c..12a5bc492 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -26,11 +26,12 @@ const PdfDocument = makeInterface(documentSchema, panZoomSchema, pageSchema);
@observer
export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocument) {
public static LayoutString() { return FieldView.LayoutString(PDFBox); }
- private _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
private _reactionDisposer?: IReactionDisposer;
private _keyValue: string = "";
private _valueValue: string = "";
private _scriptValue: string = "";
+ @observable private _searching: boolean = false;
+ private _pdfViewer: PDFViewer | undefined;
private _keyRef: React.RefObject<HTMLInputElement> = React.createRef();
private _valueRef: React.RefObject<HTMLInputElement> = React.createRef();
private _scriptRef: React.RefObject<HTMLInputElement> = React.createRef();
@@ -58,37 +59,45 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
this._reactionDisposer && this._reactionDisposer();
}
+ public search(string: string) {
+ this._pdfViewer && this._pdfViewer.search(string);
+ }
+
+ setPdfViewer = (pdfViewer: PDFViewer) => {
+ this._pdfViewer = pdfViewer;
+ }
+
public GetPage() {
- return 1;//Math.floor((this.Document.panY || 0) / (this.Document.nativeHeight || 0)) + 1;
+ return Math.floor((this.Document.panY || 0) / (this.Document.nativeHeight || 0)) + 1;
}
@action
public BackPage() {
- // let cp = Math.ceil((this.Document.panY || 0) / (this.Document.nativeHeight || 0)) + 1;
- // cp = cp - 1;
- // if (cp > 0) {
- // this.Document.panY = (cp - 1) * (this.Document.nativeHeight || 0);
- // }
+ let cp = Math.ceil((this.Document.panY || 0) / (this.Document.nativeHeight || 0)) + 1;
+ cp = cp - 1;
+ if (cp > 0) {
+ this.Document.panY = (cp - 1) * (this.Document.nativeHeight || 0);
+ }
}
@action
public GotoPage = (p: number) => {
- // if (p > 0 && p <= NumCast(this.dataDoc.numPages)) {
- // this.Document.panY = (p - 1) * (this.Document.nativeHeight || 0);
- // }
+ if (p > 0 && p <= NumCast(this.dataDoc.numPages)) {
+ this.Document.panY = (p - 1) * (this.Document.nativeHeight || 0);
+ }
}
@action
public ForwardPage() {
- // let cp = this.GetPage() + 1;
- // if (cp <= NumCast(this.dataDoc.numPages)) {
- // this.Document.panY = (cp - 1) * (this.Document.nativeHeight || 0);
- // }
+ let cp = this.GetPage() + 1;
+ if (cp <= NumCast(this.dataDoc.numPages)) {
+ this.Document.panY = (cp - 1) * (this.Document.nativeHeight || 0);
+ }
}
@action
setPanY = (y: number) => {
- //this.Document.panY = y;
+ this.Document.panY = y;
}
@action
@@ -99,7 +108,7 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
}
scrollTo = (y: number) => {
- this._mainCont.current && this._mainCont.current.scrollTo({ top: Math.max(y - (this._mainCont.current.offsetHeight / 2), 0), behavior: "auto" });
+
}
private resetFilters = () => {
@@ -172,13 +181,14 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
let classname = "pdfBox-cont" + (this.props.active() && !InkingControl.Instance.selectedTool && !this._alt ? "-interactive" : "");
return (!(pdfUrl instanceof PdfField) || !this._pdf ?
<div>{`pdf, ${this.dataDoc[this.props.fieldKey]}, not found`}</div> :
- <div className={classname} ref={this._mainCont} onWheel={(e: React.WheelEvent) => e.stopPropagation()} onPointerDown={(e: React.PointerEvent) => {
+ <div className={classname} onWheel={(e: React.WheelEvent) => e.stopPropagation()} onPointerDown={(e: React.PointerEvent) => {
let hit = document.elementFromPoint(e.clientX, e.clientY);
if (hit && hit.localName === "span") {
e.button === 0 && e.stopPropagation();
}
}}>
<PDFViewer pdf={this._pdf} url={pdfUrl.url.pathname} active={this.props.active} scrollTo={this.scrollTo} loaded={this.loaded}
+ setPdfViewer={this.setPdfViewer}
Document={this.props.Document} DataDoc={this.dataDoc}
addDocTab={this.props.addDocTab} GoToPage={this.GotoPage}
pinToPres={this.props.pinToPres} addDocument={this.props.addDocument}