From 46b9a18bf278ab17845d1082a1152d16c07b1240 Mon Sep 17 00:00:00 2001 From: yipstanley Date: Tue, 11 Jun 2019 11:30:53 -0400 Subject: annotation navigationnn --- src/client/views/pdf/PDFViewer.tsx | 41 +++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 1152587a4..092765324 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -7,7 +7,11 @@ import "./PDFViewer.scss"; import "pdfjs-dist/web/pdf_viewer.css"; import { PDFBox } from "../nodes/PDFBox"; import Page from "./Page"; -import { NumCast } from "../../../new_fields/Types"; +import { NumCast, Cast, BoolCast } from "../../../new_fields/Types"; +import { Id } from "../../../new_fields/FieldSymbols"; +import { DocUtils } from "../../documents/Documents"; +import { DocumentManager } from "../../util/DocumentManager"; +import { SelectionManager } from "../../util/SelectionManager"; interface IPDFViewerProps { url: string; @@ -297,9 +301,9 @@ class Viewer extends React.Component {
{this._visibleElements}
-
+
- {this._annotations.map(anno => )} + {this._annotations.map(anno => )}
@@ -307,21 +311,44 @@ class Viewer extends React.Component { } } -interface IAnnotation { +interface IAnnotationProps { x: number; y: number; width: number; height: number; + document: Doc; } -class RegionAnnotation extends React.Component { +class RegionAnnotation extends React.Component { + @observable private _backgroundColor: string = "red"; + + // private _reactionDisposer?: IReactionDisposer; + + constructor(props: IAnnotationProps) { + super(props); + + // this._reactionDisposer = reaction( + // () => { BoolCast(this.props.document.selected); }, + // () => { this._backgroundColor = BoolCast(this.props.document.selected) ? "yellow" : "red"; }, + // { fireImmediately: true } + // ) + } + onPointerDown = (e: React.PointerEvent) => { - console.log("clicked!"); + let targetDoc = Cast(this.props.document.target, Doc, null); + if (targetDoc) { + DocumentManager.Instance.jumpToDocument(targetDoc); + // let annotations = DocListCast(targetDoc.proto!.linkedFromDocs); + // if (annotations && annotations.length) { + // annotations.forEach(anno => anno.selected = true); + // } + } } render() { return ( -
+
); } } \ No newline at end of file -- cgit v1.2.3-70-g09d2