diff options
| author | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-06-20 15:44:53 -0400 |
|---|---|---|
| committer | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-06-20 15:44:53 -0400 |
| commit | 3ae9af9228a050fbe7f48c800701ae4399850f35 (patch) | |
| tree | 350c2314de77d9b44ffbc0042cc524d83e6e0b1e /src/client/views/pdf/PDFViewer.tsx | |
| parent | c02b622fc3fa5a897549b483acef06d54858624b (diff) | |
Chatcards with images
Diffstat (limited to 'src/client/views/pdf/PDFViewer.tsx')
| -rw-r--r-- | src/client/views/pdf/PDFViewer.tsx | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index befbee48b..27a523465 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -413,45 +413,19 @@ export class PDFViewer extends ObservableReactComponent<IViewerProps> { const queryText = this._selectionText; this._loading = true; try { + if (this._selectionText === '') { + } const res = await gptAPICall(queryText, GPTCallType.FLASHCARD); + console.log(res); - // GPTPopup.Instance.setText(res || 'Something went wrong.'); AnchorMenu.Instance.transferToFlashcard(res || 'Something went wrong'); - // this.transferToFlashcard(res || 'Something went wrong'); + this._selectionText = ''; } catch (err) { console.error(err); } this._loading = false; - // GPTPopup.Instance.setLoading(false); }; - // transferToFlashcard = (text: string) => { - // // put each question generated by GPT on the front of the flashcard - // var senArr = text.trim().split('Question: '); - // var collectionArr: Doc[] = []; - // for (let i = 1; i < senArr.length; i++) { - // console.log('Arr ' + i + ': ' + senArr[i]); - // const newDoc = Docs.Create.ComparisonDocument(senArr[i], { _layout_isFlashcard: true, _width: 300, _height: 300 }); - // newDoc.text = senArr[i]; - // collectionArr.push(newDoc); - // } - // // create a new carousel collection of these flashcards - // const newCol = Docs.Create.CarouselDocument(collectionArr, { - // _width: 250, - // _height: 200, - // _layout_fitWidth: false, - // _layout_autoHeight: true, - // }); - - // newCol.x = this._props.layoutDoc['x']; - // newCol.y = this._props.layoutDoc['y']; - // newCol.zIndex = 100; - - // this._props.DocumentView?.()._props.addDocument?.(newCol); - // console.log('HERE'); - // this._loading = false; - // }; - @action finishMarquee = (/* x?: number, y?: number */) => { this._getAnchor = AnchorMenu.Instance?.GetAnchor; @@ -469,6 +443,7 @@ export class PDFViewer extends ObservableReactComponent<IViewerProps> { document.removeEventListener('pointerup', this.onSelectEnd); const sel = window.getSelection(); + if (sel) { AnchorMenu.Instance.setSelectedText(sel.toString()); AnchorMenu.Instance.setLocation(NumCast(this._props.layoutDoc['x']), NumCast(this._props.layoutDoc['y'])); |
