From 0e7ae057264445ece675e4b5d2380893ea124112 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 28 Feb 2025 15:40:51 -0500 Subject: fixed gptpopup disappearing in overlayView. added creation of images based on selection image in gptpopup. --- src/client/views/pdf/GPTPopup/GPTPopup.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/client/views/pdf') diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index 96c7f37a3..79f5121ed 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -28,6 +28,8 @@ import './GPTPopup.scss'; import { FireflyImageDimensions } from '../../smartdraw/FireflyConstants'; import { Upload } from '../../../../server/SharedMediaTypes'; import { OpenWhere } from '../../nodes/OpenWhere'; +import { DrawingFillHandler } from '../../smartdraw/DrawingFillHandler'; +import { ImageField } from '../../../../fields/URLField'; export enum GPTPopupMode { SUMMARY, // summary of seleted document text @@ -204,13 +206,18 @@ export class GPTPopup extends ObservableReactComponent { )) // prettier-ignore generateFireflyImage = (imgDesc: string) => { - // if (this._fireflyRefStrength) { - // DrawingFillHandler.drawingToImage(this.props.Document, this._fireflyRefStrength, this._regenInput || StrCast(this.Document.title), this.Document)?.then( - // action(() => { - // this._regenerateLoading = false; - // }) - // ); - // } else∂ + const selView = DocumentView.Selected().lastElement(); + const selDoc = selView?.Document; + if (selDoc && (selView._props.renderDepth > 1 || selDoc[Doc.LayoutFieldKey(selDoc)] instanceof ImageField)) { + const oldPrompt = StrCast(selDoc.ai_firefly_prompt, StrCast(selDoc.title)); + const newPrompt = oldPrompt ? `${oldPrompt} ~~~ ${imgDesc}` : imgDesc; + return DrawingFillHandler.drawingToImage(selDoc, 100, newPrompt, selDoc) + .then(action(() => (this._userPrompt = ''))) + .catch(e => { + alert(e); + return undefined; + }); + } return SmartDrawHandler.CreateWithFirefly(imgDesc, FireflyImageDimensions.Square, 0) .then( action(doc => { -- cgit v1.2.3-70-g09d2