diff options
| author | bob <bcz@cs.brown.edu> | 2019-06-14 17:27:49 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-06-14 17:27:49 -0400 |
| commit | f6e8b7a0f8a13ddf059cf701e46b8cbb8d9228f7 (patch) | |
| tree | 9c9e64aac9836a3e842ecfccc69488198aa50ea0 /src/client/views/pdf | |
| parent | e9d07e9d84ff5b0419b36f73768c8b8583fd0607 (diff) | |
added page fwd/back/goto
Diffstat (limited to 'src/client/views/pdf')
| -rw-r--r-- | src/client/views/pdf/PDFViewer.tsx | 6 | ||||
| -rw-r--r-- | src/client/views/pdf/Page.tsx | 12 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 17f65c7a6..dee891ba6 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -23,7 +23,7 @@ import { Dictionary } from "typescript-collections"; interface IPDFViewerProps { url: string; - loaded: (nw: number, nh: number) => void; + loaded: (nw: number, nh: number, np: number) => void; scrollY: number; parent: PDFBox; } @@ -61,7 +61,7 @@ export class PDFViewer extends React.Component<IPDFViewerProps> { interface IViewerProps { pdf: Opt<Pdfjs.PDFDocumentProxy>; - loaded: (nw: number, nh: number) => void; + loaded: (nw: number, nh: number, np: number) => void; scrollY: number; parent: PDFBox; mainCont: React.RefObject<HTMLDivElement>; @@ -400,7 +400,7 @@ class Viewer extends React.Component<IViewerProps> { return; } let numPages = this.props.pdf ? this.props.pdf.numPages : 0; - this.props.loaded(page.width, page.height); + this.props.loaded(page.width, page.height, numPages); this._pageSizes[index - 1] = { width: page.width, height: page.height }; this._pagesLoaded++; if (this._pagesLoaded === numPages) { diff --git a/src/client/views/pdf/Page.tsx b/src/client/views/pdf/Page.tsx index 44c502a04..e3dbeaebe 100644 --- a/src/client/views/pdf/Page.tsx +++ b/src/client/views/pdf/Page.tsx @@ -132,16 +132,14 @@ export default class Page extends React.Component<IPageProps> { } } - highlight = (targetDoc: Doc | undefined) => { + highlight = (targetDoc?: Doc) => { // creates annotation documents for current highlights let annotationDoc = this.props.makeAnnotationDocuments(targetDoc); - let targetAnnotations = DocListCast(this.props.parent.Document.annotations); - if (targetAnnotations) { + let targetAnnotations = Cast(this.props.parent.Document.annotations, listSpec(Doc)); + if (targetAnnotations === undefined) { + Doc.GetProto(this.props.parent.Document).annotations = new List([annotationDoc]); + } else { targetAnnotations.push(annotationDoc); - this.props.parent.Document.annotations = new List<Doc>(targetAnnotations); - } - else { - this.props.parent.Document.annotations = new List<Doc>([annotationDoc]); } return annotationDoc; } |
