aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/Page.tsx
diff options
context:
space:
mode:
authorandrewdkim <adkim414@gmail.com>2019-08-06 12:30:09 -0400
committerandrewdkim <adkim414@gmail.com>2019-08-06 12:30:09 -0400
commitb6990a61befdea70abd99f125a2488ce5a6f04a6 (patch)
tree833c13a0ddabb325cc2e39dbb199f111cced22d2 /src/client/views/pdf/Page.tsx
parent2c86a6958186c020ce7fbe99555f07ffe9f9f821 (diff)
parent298d1c9b29d6ce2171fd9ac8274b64583b73f6f5 (diff)
merge from master
Diffstat (limited to 'src/client/views/pdf/Page.tsx')
-rw-r--r--src/client/views/pdf/Page.tsx13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/client/views/pdf/Page.tsx b/src/client/views/pdf/Page.tsx
index c205617b4..dea4e0da1 100644
--- a/src/client/views/pdf/Page.tsx
+++ b/src/client/views/pdf/Page.tsx
@@ -5,7 +5,7 @@ import "pdfjs-dist/web/pdf_viewer.css";
import { Doc, DocListCastAsync, Opt, WidthSym } from "../../../new_fields/Doc";
import { List } from "../../../new_fields/List";
import { listSpec } from "../../../new_fields/Schema";
-import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
+import { Cast, NumCast, StrCast, BoolCast } from "../../../new_fields/Types";
import { Docs, DocUtils } from "../../documents/Documents";
import { DragManager } from "../../util/DragManager";
import { PDFBox } from "../nodes/PDFBox";
@@ -159,6 +159,7 @@ export default class Page extends React.Component<IPageProps> {
let targetDoc = Docs.Create.TextDocument({ width: 200, height: 200, title: "New Annotation" });
targetDoc.targetPage = this.props.page;
let annotationDoc = this.highlight(undefined, "red");
+ Doc.GetProto(annotationDoc).annotationOn = thisDoc;
annotationDoc.linkedToDoc = false;
// create dragData and star tdrag
let dragData = new DragManager.AnnotationDragData(thisDoc, annotationDoc, targetDoc);
@@ -166,16 +167,12 @@ export default class Page extends React.Component<IPageProps> {
DragManager.StartAnnotationDrag([ele], dragData, e.pageX, e.pageY, {
handlers: {
dragComplete: async () => {
- if (!(await annotationDoc.linkedToDoc)) {
+ if (!BoolCast(annotationDoc.linkedToDoc)) {
let annotations = await DocListCastAsync(annotationDoc.annotations);
- if (annotations) {
- annotations.forEach(anno => {
- anno.target = targetDoc;
- });
- }
+ annotations && annotations.forEach(anno => anno.target = targetDoc);
let pdfDoc = await Cast(annotationDoc.pdfDoc, Doc);
if (pdfDoc) {
- DocUtils.MakeLink(annotationDoc, targetDoc, undefined, `Annotation from ${StrCast(pdfDoc.title)}`, "", StrCast(pdfDoc.title));
+ DocUtils.MakeLink(annotationDoc, targetDoc, dragData.targetContext, `Annotation from ${StrCast(pdfDoc.title)}`, "", StrCast(pdfDoc.title));
}
}
}