From 3ae9af9228a050fbe7f48c800701ae4399850f35 Mon Sep 17 00:00:00 2001
From: alyssaf16 <alyssa_feinberg@brown.edu>
Date: Thu, 20 Jun 2024 15:44:53 -0400
Subject: Chatcards with images

---
 .../views/nodes/formattedText/FormattedTextBox.tsx     | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

(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 aee885688..2091ee89a 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -1001,12 +1001,16 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
         !help && cm.addItem({ description: 'Help...', subitems: helpItems, icon: 'eye' });
     };
 
-    findImageTags = () => {
+    findImageTags = async () => {
         const c = this.ProseRef?.getElementsByTagName('img');
         if (c) {
             for (let i of c) {
-                this.getImageDesc(i.src);
                 console.log(i);
+
+                // console.log(canvas.toDataURL());
+                // canvas.style.zIndex = '2000000';
+                // document.body.appendChild(canvas);
+                if (i.className !== 'ProseMirror-separator') this.getImageDesc(i.src);
             }
         }
         // console.log('HI' + this.ProseRef?.getElementsByTagName('img'));
@@ -1031,13 +1035,13 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
 
     getImageDesc = async (u: string) => {
         // if (StrCast(this.dataDoc.description)) return StrCast(this.dataDoc.description); // Return existing description
-        const { href } = (u as URLField).url;
-        const hrefParts = href.split('.');
+        // const { href } = (u as URLField).url;
+        const hrefParts = u.split('.');
         const hrefComplete = `${hrefParts[0]}_o.${hrefParts[1]}`;
         try {
-            const hrefBase64 = await FormattedTextBox.imageUrlToBase64(hrefComplete);
-            //const response = await gptImageLabel(hrefBase64, 'Tell me what words you see on this image.');
-            const response = await gptImageLabel(hrefBase64, 'Make flashcards out of this text with each question and answer labeled as question and answer. Do not label each flashcard and do not include asterisks: ');
+            const hrefBase64 = await FormattedTextBox.imageUrlToBase64(u);
+            const response = await gptImageLabel(hrefBase64, 'Tell me what you see in this image');
+            //const response = await gptImageLabel(u, 'Make flashcards out of this text with each question and answer labeled as question and answer. Do not label each flashcard and do not include asterisks: ');
             console.log(response);
             // AnchorMenu.Instance.transferToFlashcard(response);
             // this.Document[DocData].description = response.trim();
-- 
cgit v1.2.3-70-g09d2

