From ac7f34fa5ee67900714121b700768ebb18b874d1 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sat, 21 Sep 2024 23:26:52 -0400
Subject: added flashcard deck creator to foramtted text box.

---
 src/client/views/nodes/formattedText/FormattedTextBox.tsx | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')

diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index c8e020192..07a4d1093 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -213,9 +213,22 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
         return anchor;
     };
 
+    gptPDFFlashcards = async () => {
+        const queryText = window.getSelection()?.toString() ?? '';
+        try {
+            if (queryText) {
+                const res = await gptAPICall(queryText, GPTCallType.FLASHCARD);
+                AnchorMenu.Instance.transferToFlashcard(res || 'Something went wrong', NumCast(this.layoutDoc.x), NumCast(this.layoutDoc.y));
+            }
+        } catch (err) {
+            console.error(err);
+        }
+    };
+
     @action
     setupAnchorMenu = () => {
         AnchorMenu.Instance.Status = 'marquee';
+        AnchorMenu.Instance.gptFlashcards = this.gptPDFFlashcards;
         AnchorMenu.Instance.OnClick = () => {
             !this.layoutDoc.layout_showSidebar && this.toggleSidebar();
             setTimeout(() => this._sidebarRef.current?.anchorMenuClick(this.makeLinkAnchor(undefined, OpenWhere.addRight, undefined, 'Anchored Selection', true))); // give time for sidebarRef to be created
-- 
cgit v1.2.3-70-g09d2

