aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ImageBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/ImageBox.tsx')
-rw-r--r--src/client/views/nodes/ImageBox.tsx56
1 files changed, 16 insertions, 40 deletions
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index a794e213e..fde9fe582 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -354,63 +354,39 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
};
- static imageUrlToBase64 = async (imageUrl: string): Promise<string> => {
- try {
- const response = await fetch(imageUrl);
- const blob = await response.blob();
-
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.readAsDataURL(blob);
- reader.onloadend = () => resolve(reader.result as string);
- reader.onerror = error => reject(error);
- });
- } catch (error) {
- console.error('Error:', error);
- throw error;
- }
- };
+ // static imageUrlToBase64 = async (imageUrl: string): Promise<string> => {
+ // try {
+ // const response = await fetch(imageUrl);
+ // const blob = await response.blob();
+
+ // return new Promise((resolve, reject) => {
+ // const reader = new FileReader();
+ // reader.readAsDataURL(blob);
+ // reader.onloadend = () => resolve(reader.result as string);
+ // reader.onerror = error => reject(error);
+ // });
+ // } catch (error) {
+ // console.error('Error:', error);
+ // throw error;
+ // }
+ // };
getImageDesc = async () => {
- // if (StrCast(this.dataDoc.description)) return StrCast(this.dataDoc.description); // Return existing description
- const { href } = (this.dataDoc.data as URLField).url;
- const hrefParts = href.split('.');
- const hrefComplete = `${hrefParts[0]}_o.${hrefParts[1]}`;
this._loading = true;
try {
- // const hrefBase64 = await ImageBox.imageUrlToBase64(hrefComplete);
const hrefBase64 = await this.createCanvas();
- //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: ');
console.log(response);
AnchorMenu.Instance.transferToFlashcard(response);
- // this.Document[DocData].description = response.trim();
- // return response; // Return the response
} catch (error) {
console.log('Error');
}
this._loading = false;
- // return '';
};
@action
setRef = (iref: HTMLImageElement | null) => {
this._imageRef = iref;
- // if (iref) {
- // this._videoRef!.ontimeupdate = this.updateTimecode;
- // // @ts-ignore
- // // vref.onfullscreenchange = action((e) => this._fullScreen = vref.webkitDisplayingFullscreen);
- // this._disposers.reactionDisposer?.();
- // this._disposers.reactionDisposer = reaction(
- // () => NumCast(this.layoutDoc._layout_currentTimecode),
- // time => {
- // !this._playing && (vref.currentTime = time);
- // },
- // { fireImmediately: true }
- // );
-
- // (!this.dataDoc[this.fieldKey + '_thumbnails'] || StrListCast(this.dataDoc[this.fieldKey + '_thumbnails']).length !== VideoThumbnails.DENSE) && this.getVideoThumbnails();
- // }
};
specificContextMenu = (): void => {