aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/GPTPopup
diff options
context:
space:
mode:
authoralyssaf16 <alyssa_feinberg@brown.edu>2024-03-30 00:06:27 -0400
committeralyssaf16 <alyssa_feinberg@brown.edu>2024-03-30 00:06:27 -0400
commite95d25eb8159bb7c753fa27e74e9baa8d3bffea6 (patch)
tree570d27aff92be8b50b98f07687829fe0d0eb6432 /src/client/views/pdf/GPTPopup
parent416e00b5481e4835a674683c2e8213b536cab74c (diff)
working on making flashcards from pdf with ai
Diffstat (limited to 'src/client/views/pdf/GPTPopup')
-rw-r--r--src/client/views/pdf/GPTPopup/GPTPopup.tsx39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
index da8a88803..dbcdd4e3a 100644
--- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx
+++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
@@ -15,11 +15,14 @@ import { DocUtils, Docs } from '../../../documents/Documents';
import { ObservableReactComponent } from '../../ObservableReactComponent';
import { AnchorMenu } from '../AnchorMenu';
import './GPTPopup.scss';
+import { ComparisonBox } from '../../nodes/ComparisonBox';
+import { DashColor, emptyFunction, lightOrDark, returnFalse } from '../../../../Utils';
export enum GPTPopupMode {
SUMMARY,
EDIT,
IMAGE,
+ FLASHCARD,
}
interface GPTPopupProps {}
@@ -149,6 +152,22 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
}
};
+ transferToFlashcard = () => {
+ const senArr = this.text.split('.');
+ for (var i = 0; i < senArr.length; i += 2) {
+ console.log('SEN: ' + senArr[i]);
+ const newDoc = Docs.Create.ComparisonDocument(senArr[i], { _layout_isFlashcard: true, _width: 300, _height: 300 });
+ newDoc.text = senArr[i];
+ this.addDoc(newDoc, this.sidebarId);
+ const anchor = AnchorMenu.Instance?.GetAnchor(undefined, false);
+ if (anchor) {
+ DocUtils.MakeLink(newDoc, anchor, {
+ link_relationship: 'GPT Summary',
+ });
+ }
+ }
+ };
+
/**
* Transfers the image urls to actual image docs
*/
@@ -213,6 +232,23 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
);
};
+ flashcardBox = () => {
+ // const textArr = this.text.split(".");
+ // textArr.forEach(function(sentence) {
+ // console.log(sentence);
+
+ // });
+ // const newDoc = Docs.Create.ComparisonDocument();
+ // this.addToCollection?.(newDoc);
+ // // const newDoc = Docs.Create.ComparisonDocument();
+ // DocUtils.copyDragFactory(Doc.UserDoc().emptyFlashcard as Doc);
+ // // this.addToCollection?.(newDoc);
+ // // return newDoc;
+ // <ComparisonBox/>
+ const newDoc = Docs.Create.TextDocument('Hello there');
+ this.addDoc?.(newDoc);
+ };
+
data = () => {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
@@ -268,6 +304,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
<>
<IconButton tooltip="Generate Again" onClick={this.callSummaryApi} icon={<FontAwesomeIcon icon="redo-alt" size="lg" />} color={StrCast(Doc.UserDoc().userVariantColor)} />
<Button tooltip="Transfer to text" text="Transfer To Text" onClick={this.transferToText} color={StrCast(Doc.UserDoc().userVariantColor)} type={Type.TERT} />
+ {/* <Button tooltip="Transfer to flashcard" text="flashcard" onClick={this.transferToFlashcard} color={StrCast(Doc.UserDoc().userVariantColor)} type={Type.TERT} /> */}
</>
) : (
<div className="summarizing">
@@ -308,7 +345,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
render() {
return (
<div className="summary-box" style={{ display: this.visible ? 'flex' : 'none' }}>
- {this.mode === GPTPopupMode.SUMMARY ? this.summaryBox() : this.mode === GPTPopupMode.IMAGE ? this.imageBox() : <></>}
+ {this.mode === GPTPopupMode.SUMMARY ? this.summaryBox() : this.mode === GPTPopupMode.IMAGE ? this.imageBox() : this.mode == GPTPopupMode.FLASHCARD ? this.summaryBox() : <></>}
</div>
);
}