aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-06-10 14:07:36 -0400
committeryipstanley <stanley_yip@brown.edu>2019-06-10 14:07:36 -0400
commit2ecd0c3486ec37d1061468cda12aa64e38d0d3d5 (patch)
tree0d54e533df467a163ef74d388b59e0f86abe0401 /src/client/views/pdf
parentbcd6960fe91008bf31d364c48b5c8765eec28701 (diff)
annotation improvements
Diffstat (limited to 'src/client/views/pdf')
-rw-r--r--src/client/views/pdf/Page.tsx17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/client/views/pdf/Page.tsx b/src/client/views/pdf/Page.tsx
index 7125c820c..5269f448b 100644
--- a/src/client/views/pdf/Page.tsx
+++ b/src/client/views/pdf/Page.tsx
@@ -7,10 +7,10 @@ import "./PDFViewer.scss";
import "pdfjs-dist/web/pdf_viewer.css";
import { PDFBox } from "../nodes/PDFBox";
import { DragManager } from "../../util/DragManager";
-import { Docs } from "../../documents/Documents";
+import { Docs, DocUtils } from "../../documents/Documents";
import { List } from "../../../new_fields/List";
import { emptyFunction } from "../../../Utils";
-import { Cast, NumCast } from "../../../new_fields/Types";
+import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
import { listSpec } from "../../../new_fields/Schema";
import { menuBar } from "prosemirror-menu";
@@ -66,6 +66,7 @@ export default class Page extends React.Component<IPageProps> {
() => {
let annotations = DocListCast(this.props.parent.Document.annotations);
if (annotations && annotations.length) {
+ annotations = annotations.filter(anno => NumCast(anno.page) === this.props.page);
this.renderAnnotations(annotations, true);
}
},
@@ -163,8 +164,10 @@ export default class Page extends React.Component<IPageProps> {
annoDoc.y = anno.offsetTop;
annoDoc.height = anno.offsetHeight;
annoDoc.width = anno.offsetWidth;
+ annoDoc.page = this.props.page;
annoDoc.target = targetDoc;
annoDocs.push(annoDoc);
+ DocUtils.MakeLink(annoDoc, targetDoc, `Annotation from ${StrCast(this.props.parent.Document.title)}`, "", StrCast(this.props.parent.Document.title));
anno.remove();
}
this._currentAnnotations = [];
@@ -190,13 +193,14 @@ export default class Page extends React.Component<IPageProps> {
targetDoc.targetPage = this.props.page;
// creates annotation documents for current highlights
let annotationDocs = this.makeAnnotationDocuments(targetDoc);
- let targetAnnotations = Cast(targetDoc.annotations, listSpec(Doc));
+ console.log(annotationDocs);
+ let targetAnnotations = DocListCast(this.props.parent.Document.annotations);
if (targetAnnotations) {
targetAnnotations.push(...annotationDocs);
- targetDoc.annotations = targetAnnotations;
+ this.props.parent.Document.annotations = new List<Doc>(targetAnnotations);
}
else {
- targetDoc.annotations = new List<Doc>(annotationDocs);
+ this.props.parent.Document.annotations = new List<Doc>(annotationDocs);
}
// create dragData and star tdrag
let dragData = new DragManager.AnnotationDragData(thisDoc, annotationDocs, targetDoc);
@@ -422,10 +426,11 @@ interface IAnnotation {
width: number;
height: number;
}
+
class RegionAnnotation extends React.Component<IAnnotation> {
render() {
return (
- <div className="pdfViewer-annotationBox" style={{ top: this.props.x, left: this.props.y, width: this.props.width, height: this.props.height }}></div>
+ <div className="pdfViewer-annotationBox" style={{ top: this.props.y, left: this.props.x, width: this.props.width, height: this.props.height }}></div>
);
}
} \ No newline at end of file