aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PDFBox.tsx
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-07-29 11:27:58 -0400
committerFawn <fangrui_tong@brown.edu>2019-07-29 11:27:58 -0400
commit7ea25f83dfcb3fb31bf6fce1f4112c8bded294e2 (patch)
tree1d3cfa0d5f8e3424423c1ed5fdfc06c027c2df48 /src/client/views/nodes/PDFBox.tsx
parent7098f381f3f93e77880f3589427c81e61a5ee25a (diff)
parente7ea2028f54787d6c92fb22b789f17b7268d3793 (diff)
fixed sub collections having wrong children
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
-rw-r--r--src/client/views/nodes/PDFBox.tsx18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 5a5e6e6dd..4973340df 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -24,6 +24,8 @@ import { Flyout, anchorPoints } from '../DocumentDecorations';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ScriptField } from '../../../new_fields/ScriptField';
import { KeyCodes } from '../../northstar/utils/KeyCodes';
+import { Utils } from '../../../Utils';
+import { Id } from '../../../new_fields/FieldSymbols';
type PdfDocument = makeInterface<[typeof positionSchema, typeof pageSchema]>;
const PdfDocument = makeInterface(positionSchema, pageSchema);
@@ -67,10 +69,24 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
componentDidMount() {
if (this.props.setPdfBox) this.props.setPdfBox(this);
+
+ document.removeEventListener("copy", this.copy);
+ document.addEventListener("copy", this.copy);
}
componentWillUnmount() {
this._reactionDisposer && this._reactionDisposer();
+ document.removeEventListener("copy", this.copy);
+ }
+
+ private copy = (e: ClipboardEvent) => {
+ if (this.props.active()) {
+ if (e.clipboardData) {
+ e.clipboardData.setData("text/plain", text);
+ e.clipboardData.setData("dash/pdfOrigin", this.props.Document[Id]);
+ e.preventDefault();
+ }
+ }
}
public GetPage() {
@@ -151,7 +167,7 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
scrollTo(y: number) {
if (this._mainCont.current) {
- this._mainCont.current.scrollTo({ top: y, behavior: "auto" });
+ this._mainCont.current.scrollTo({ top: Math.max(y - (this._mainCont.current!.offsetHeight / 2), 0), behavior: "auto" });
}
}