aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-06-14 17:44:44 -0400
committeryipstanley <stanley_yip@brown.edu>2019-06-14 17:44:44 -0400
commita639f8febb6bb834ef25f26dc488202177cdfb50 (patch)
treeed2519734b18131f408ac6eec888c1e006b26380 /src/client/views/pdf
parentb987e2edbf7befbe90fafbdee476ee3b6513cc50 (diff)
parentf6e8b7a0f8a13ddf059cf701e46b8cbb8d9228f7 (diff)
Merge branch 'pdf_impl' of https://github.com/browngraphicslab/Dash-Web into pdf_impl
Diffstat (limited to 'src/client/views/pdf')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx6
-rw-r--r--src/client/views/pdf/Page.tsx12
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 3bc3ac33c..455e1d831 100644
--- a/src/client/views/pdf/Page.tsx
+++ b/src/client/views/pdf/Page.tsx
@@ -133,16 +133,14 @@ export default class Page extends React.Component<IPageProps> {
}
@action
- 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;
}