aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/PDFViewer.tsx
diff options
context:
space:
mode:
authorgeireann <geireann.lindfield@gmail.com>2023-03-02 11:44:04 -0500
committergeireann <geireann.lindfield@gmail.com>2023-03-02 11:44:04 -0500
commitc6425a0469727305f76d00e3f8c545e04aad61cc (patch)
treeff8eb7d202f9f8c1305adcf2d4d5933c8c8dca63 /src/client/views/pdf/PDFViewer.tsx
parent4a60851bd4d3495b2605863e3070c73129c9bc57 (diff)
parentd34d212ea550a3c1ca16747fadeb9e69c936cb5d (diff)
Merge branch 'pres-trail-sophie' of https://github.com/brown-dash/Dash-Web into pres-trail-sophie
Diffstat (limited to 'src/client/views/pdf/PDFViewer.tsx')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 324f31f23..88854debe 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -24,7 +24,7 @@ import { AnchorMenu } from './AnchorMenu';
import { Annotation } from './Annotation';
import './PDFViewer.scss';
import React = require('react');
-import { gptSummarize } from '../../apis/gpt/Summarization';
+import { GPTPopup } from './GPTPopup';
const PDFJSViewer = require('pdfjs-dist/web/pdf_viewer');
const pdfjsLib = require('pdfjs-dist');
const _global = (window /* browser */ || global) /* node */ as any;
@@ -41,6 +41,7 @@ interface IViewerProps extends FieldViewProps {
fieldKey: string;
pdf: Pdfjs.PDFDocumentProxy;
url: string;
+ sidebarAddDoc: (doc: Doc | Doc[], sidebarKey?: string | undefined) => boolean;
loaded?: (nw: number, nh: number, np: number) => void;
setPdfViewer: (view: PDFViewer) => void;
anchorMenuClick?: () => undefined | ((anchor: Doc, summarize?: boolean) => void);
@@ -83,19 +84,6 @@ export class PDFViewer extends React.Component<IViewerProps> {
return AnchorMenu.Instance?.GetAnchor;
}
- // Fields for using GPT to summarize selected text
- private _summaryText: string = '';
- setSummaryText = async () => {
- try {
- const summary = await gptSummarize(this.selectionText());
- this._summaryText = `Summary: ${summary}`;
- } catch (err) {
- console.log(err);
- this._summaryText = 'Failed to fetch summary.';
- }
- };
- summaryText = () => this._summaryText;
-
selectionText = () => this._selectionText;
selectionContent = () => this._selectionContent;
@@ -435,6 +423,10 @@ export class PDFViewer extends React.Component<IViewerProps> {
this.createTextAnnotation(sel, sel.getRangeAt(0));
AnchorMenu.Instance.jumpTo(e.clientX, e.clientY);
}
+
+ // Changing which document to add the annotation to (the currently selected PDF)
+ GPTPopup.Instance.setSidebarId('data-sidebar');
+ GPTPopup.Instance.addDoc = this.props.sidebarAddDoc;
};
@action
@@ -614,8 +606,6 @@ export class PDFViewer extends React.Component<IViewerProps> {
finishMarquee={this.finishMarquee}
savedAnnotations={this.savedAnnotations}
selectionText={this.selectionText}
- setSummaryText={this.setSummaryText}
- summaryText={this.summaryText}
annotationLayer={this._annotationLayer.current}
mainCont={this._mainCont.current}
anchorMenuCrop={this._textSelecting ? undefined : this.crop}