diff options
| author | Stanley Yip <33562077+yipstanley@users.noreply.github.com> | 2019-07-28 18:20:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-28 18:20:07 +0000 |
| commit | 6e9b633b822c9c56f48b5b0766d730a27b32f018 (patch) | |
| tree | 76b10100785b842244793df3ad174fd09a2f2381 /src/client/views/nodes/PDFBox.tsx | |
| parent | 5fd48d3d10e86cea834f0238ec5d648febb62c81 (diff) | |
| parent | 8add42e2bb0eb997a8b6eb0904381d11e9ed2905 (diff) | |
Merge pull request #220 from browngraphicslab/pdf_paste_backlink
Pdf paste backlink
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
| -rw-r--r-- | src/client/views/nodes/PDFBox.tsx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 5a5e6e6dd..f527c0595 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() { |
