aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/Documents.ts2
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx6
-rw-r--r--src/client/views/nodes/PDFBox.scss5
-rw-r--r--src/client/views/nodes/PDFBox.tsx3
-rw-r--r--src/client/views/pdf/PDFViewer.scss9
-rw-r--r--src/client/views/pdf/PDFViewer.tsx84
6 files changed, 82 insertions, 27 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 4ae770e25..ea7a3a8b6 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -144,7 +144,7 @@ export namespace Docs {
options: { height: 32 }
}],
[DocumentType.PDF, {
- layout: { view: PDFBox, collectionView: [CollectionPDFView, data, anno] as CollectionViewType },
+ layout: { view: PDFBox },
options: { nativeWidth: 1200, curPage: 1 }
}],
[DocumentType.ICON, {
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index af84a1d73..45c021c5f 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -286,7 +286,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
@action
onPointerMove = (e: PointerEvent): void => {
- if (!e.cancelBubble) {
+ if (!e.cancelBubble && this.props.layoutKey) {
if (this._hitCluster && this.tryDragCluster(e)) {
e.stopPropagation(); // doesn't actually stop propagation since all our listeners are listening to events on 'document' however it does mark the event as cancelBubble=true which we test for in the move event handlers
e.preventDefault();
@@ -339,7 +339,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
@action
onPointerWheel = (e: React.WheelEvent): void => {
- if (this.props.Document.lockedPosition) return;
+ if (this.props.Document.lockedPosition || this.isAnnotationOverlay) return;
if (!e.ctrlKey && this.props.Document.scrollHeight !== undefined) { // things that can scroll vertically should do that instead of zooming
e.stopPropagation();
}
@@ -699,7 +699,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
// otherwise, they are stored in fieldKey. All annotations to this document are stored in the extension document
Doc.UpdateDocumentExtensionForField(this.props.DataDoc || this.props.Document, this.props.fieldKey);
return (
- <div className={"collectionfreeformview-container"} ref={this.createDropTarget} onWheel={this.onPointerWheel}
+ <div className={"collectionfreeformview-container"} style={{ height: this.props.layoutKey ? "100%" : this.props.PanelHeight() }} ref={this.createDropTarget} onWheel={this.onPointerWheel}
onPointerDown={this.onPointerDown} onPointerMove={this.onCursorMove} onDrop={this.onDrop.bind(this)} onContextMenu={this.onContextMenu}>
<MarqueeView container={this} activeDocuments={this.getActiveDocuments} selectDocuments={this.selectDocuments} isSelected={this.props.isSelected}
addDocument={this.addDocument} removeDocument={this.props.removeDocument} addLiveTextDocument={this.addLiveTextBox}
diff --git a/src/client/views/nodes/PDFBox.scss b/src/client/views/nodes/PDFBox.scss
index 3fd01c2c1..b7ff84d4a 100644
--- a/src/client/views/nodes/PDFBox.scss
+++ b/src/client/views/nodes/PDFBox.scss
@@ -3,8 +3,9 @@
display: flex;
flex-direction: row;
height: 100%;
- overflow-y: scroll;
- overflow-x: hidden;
+ width:100%;
+ overflow: hidden;
+ position:absolute;
}
.pdfBox-cont {
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index e27bc0ca0..e00635408 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -220,11 +220,12 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
e.button === 0 && e.stopPropagation();
}
}}>
- <PDFViewer pdf={this._pdf} url={pdfUrl.url.pathname} active={this.props.active} scrollTo={this.scrollTo} loaded={this.loaded}
+ <PDFViewer {...this.props} pdf={this._pdf} url={pdfUrl.url.pathname} active={this.props.active} scrollTo={this.scrollTo} loaded={this.loaded}
setPdfViewer={this.setPdfViewer}
Document={this.props.Document} DataDoc={this.dataDoc}
addDocTab={this.props.addDocTab} GoToPage={this.GotoPage}
pinToPres={this.props.pinToPres} addDocument={this.props.addDocument}
+ ScreenToLocalTransform={this.props.ScreenToLocalTransform}
fieldKey={this.props.fieldKey} fieldExtensionDoc={this.extensionDoc} />
{this.settingsPanel()}
</div>);
diff --git a/src/client/views/pdf/PDFViewer.scss b/src/client/views/pdf/PDFViewer.scss
index 456eea7a1..a561be94d 100644
--- a/src/client/views/pdf/PDFViewer.scss
+++ b/src/client/views/pdf/PDFViewer.scss
@@ -6,6 +6,15 @@
overflow-y: scroll;
overflow-x: hidden;
+ // .canvasWrapper {
+ // transform: scale(0.75);
+ // transform-origin: top left;
+ // }
+ // .textLayer {
+ // transform: scale(0.75);
+ // transform-origin: top left;
+ // }
+
.page {
position: relative;
}
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index bbd40d970..ea5e00d73 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -20,6 +20,10 @@ import PDFMenu from "./PDFMenu";
import "./PDFViewer.scss";
import React = require("react");
import requestPromise = require("request-promise");
+import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
+import { CollectionView } from "../collections/CollectionView";
+import { listSpec } from "../../../new_fields/Schema";
+import { Transform } from "../../util/Transform";
const PDFJSViewer = require("pdfjs-dist/web/pdf_viewer");
interface IViewerProps {
@@ -37,6 +41,8 @@ interface IViewerProps {
pinToPres: (document: Doc) => void;
addDocument?: (doc: Doc, allowDuplicates?: boolean) => boolean;
setPdfViewer: (view: PDFViewer) => void;
+ ScreenToLocalTransform: () => Transform;
+
}
/**
@@ -438,22 +444,22 @@ export class PDFViewer extends React.Component<IViewerProps> {
this._marqueeHeight = this._marqueeWidth = 0;
}
- else {
- let sel = window.getSelection();
- if (sel && sel.type === "Range") {
- let selRange = sel.getRangeAt(0);
- this.createTextAnnotation(sel, selRange);
- PDFMenu.Instance.jumpTo(e.clientX, e.clientY);
- }
- }
-
- if (PDFMenu.Instance.Highlighting) {
- this.highlight(undefined, "goldenrod");
- }
- else {
- PDFMenu.Instance.StartDrag = this.startDrag;
- PDFMenu.Instance.Highlight = this.highlight;
- }
+ // else {
+ // let sel = window.getSelection();
+ // if (sel && sel.type === "Range") {
+ // let selRange = sel.getRangeAt(0);
+ // this.createTextAnnotation(sel, selRange);
+ // PDFMenu.Instance.jumpTo(e.clientX, e.clientY);
+ // }
+ // }
+
+ // if (PDFMenu.Instance.Highlighting) {
+ // this.highlight(undefined, "goldenrod");
+ // }
+ // else {
+ // PDFMenu.Instance.StartDrag = this.startDrag;
+ // PDFMenu.Instance.Highlight = this.highlight;
+ // }
document.removeEventListener("pointermove", this.onSelectStart);
document.removeEventListener("pointerup", this.onSelectEnd);
}
@@ -506,11 +512,36 @@ export class PDFViewer extends React.Component<IViewerProps> {
DragManager.StartDocumentDrag([], new DragManager.DocumentDragData([view]), 0, 0);
}
+ // this is called with the document that was dragged and the collection to move it into.
+ // if the target collection is the same as this collection, then the move will be allowed.
+ // otherwise, the document being moved must be able to be removed from its container before
+ // moving it into the target.
+ @action.bound
+ moveDocument(doc: Doc, targetCollection: Doc, addDocument: (doc: Doc) => boolean): boolean {
+ if (Doc.AreProtosEqual(this.props.Document, targetCollection)) {
+ return true;
+ }
+ return this.removeDocument(doc) ? addDocument(doc) : false;
+ }
+
+
+ @action.bound
+ removeDocument(doc: Doc): boolean {
+ //TODO This won't create the field if it doesn't already exist
+ let targetDataDoc = this.props.fieldExtensionDoc;
+ let targetField = "annotations";
+ let value = Cast(targetDataDoc[targetField], listSpec(Doc), []);
+ let index = value.reduce((p, v, i) => (v instanceof Doc && v === doc) ? i : p, -1);
+ index = index !== -1 ? index : value.reduce((p, v, i) => (v instanceof Doc && Doc.AreProtosEqual(v, doc)) ? i : p, -1);
+ index !== -1 && value.splice(index, 1);
+ return true;
+ }
+ scrollXf = () => {
+ return this._mainCont.current ? this.props.ScreenToLocalTransform().translate(0, this._mainCont.current.scrollTop) : this.props.ScreenToLocalTransform();
+ }
render() {
- return (<div className="pdfViewer-viewer" onPointerDown={this.onPointerDown} ref={this._mainCont}>
- <div className="pdfViewer-text">
- <div key="viewerReal" ref={this._viewer} />
- </div>
+ return (<div className="pdfViewer-viewer" onPointerDown={this.onPointerDown} onWheel={(e) => e.stopPropagation()} ref={this._mainCont}>
+ <div className="pdfViewer-text" ref={this._viewer} />
<div className="pdfViewer-dragAnnotationBox" ref={this._marquee}
style={{
left: `${this._marqueeX}px`, top: `${this._marqueeY}px`,
@@ -522,6 +553,19 @@ export class PDFViewer extends React.Component<IViewerProps> {
{this.nonDocAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y)).map((anno, index) =>
<Annotation {...this.props} anno={anno} key={`${anno[Id]}-annotation`} />)}
</div>
+ <CollectionFreeFormView {...this.props}
+ fieldExt="annotations"
+ PanelHeight={() => this._pageSizes.length && this._pageSizes[0] ? this.props.pdf.numPages * this._pageSizes[0].height : 300}
+ removeDocument={this.removeDocument}
+ moveDocument={this.moveDocument}
+ addDocument={(doc: Doc, allow: boolean | undefined) => { Doc.AddDocToList(this.props.fieldExtensionDoc, "annotations", doc); return true; }}
+ CollectionView={this.props.ContainingCollectionView}
+ ScreenToLocalTransform={this.scrollXf}
+ ruleProvider={this.props.ruleProvider}
+ chromeCollapsed={true}
+ layoutKey={undefined}
+ backgroundLayout={undefined} >
+ </CollectionFreeFormView>
</div >);
}
}