From d5c4751b1522535ad323bb5eb254b7a1a7b4a63f Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 17 Dec 2024 15:03:07 -0500 Subject: added updateIcon to imageBoxes to allow capturing of strokes for use with generative apis --- src/client/views/nodes/ImageBox.tsx | 26 ++++++++++++++++++++++++-- src/server/ApiManagers/FireflyManager.ts | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 03d417e4e..25e7b566f 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -7,7 +7,7 @@ import { observer } from 'mobx-react'; import { extname } from 'path'; import * as React from 'react'; import ReactLoading from 'react-loading'; -import { ClientUtils, DashColor, returnEmptyString, returnFalse, returnOne, returnZero, setupMoveUpEvents } from '../../../ClientUtils'; +import { ClientUtils, DashColor, returnEmptyString, returnFalse, returnOne, returnZero, setupMoveUpEvents, UpdateIcon } from '../../../ClientUtils'; import { Doc, DocListCast, Opt } from '../../../fields/Doc'; import { DocData } from '../../../fields/DocSymbols'; import { Id } from '../../../fields/FieldSymbols'; @@ -360,7 +360,29 @@ export class ImageBox extends ViewBoxAnnotatableComponent() { } }; - updateIcon = () => new Promise(res => res()); + // updateIcon = () => new Promise(res => res()); + updateIcon = (usePanelDimensions?: boolean) => { + const contentDiv = this._mainCont.current; + return !contentDiv + ? new Promise(res => res()) + : UpdateIcon( + this.layoutDoc[Id] + '_icon_' + new Date().getTime(), + contentDiv, + usePanelDimensions ? this._props.PanelWidth() : NumCast(this.layoutDoc._width), + usePanelDimensions ? this._props.PanelHeight() : NumCast(this.layoutDoc._height), + this._props.PanelWidth(), + this._props.PanelHeight(), + 0, + 1, + false, + '', + (iconFile, nativeWidth, nativeHeight) => { + this.dataDoc.icon = new ImageField(iconFile); + this.dataDoc.icon_nativeWidth = nativeWidth; + this.dataDoc.icon_nativeHeight = nativeHeight; + } + ); + }; choosePath = (url: URL) => { if (!url?.href) return ''; diff --git a/src/server/ApiManagers/FireflyManager.ts b/src/server/ApiManagers/FireflyManager.ts index c84e9e8fa..e73795e41 100644 --- a/src/server/ApiManagers/FireflyManager.ts +++ b/src/server/ApiManagers/FireflyManager.ts @@ -239,7 +239,7 @@ export default class FireflyManager extends ApiManager { subscription: '/queryFireflyImageText', // eslint-disable-next-line @typescript-eslint/no-unused-vars secureHandler: ({ req, res }) => - fetch('http://localhost:1050/files/images/testshot.png').then(json => + fetch(req.body.file).then(json => json.blob().then(file => this.getImageText(file).then(text => { _success(res, text); -- cgit v1.2.3-70-g09d2