aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-12-17 15:03:07 -0500
committerbobzel <zzzman@gmail.com>2024-12-17 15:03:07 -0500
commitd5c4751b1522535ad323bb5eb254b7a1a7b4a63f (patch)
treec354287b7e7aae07bc8559506fa877c6dc9db5ac
parent337fbd9c4ce14a548e8b897c2cbb23d5de2a892f (diff)
added updateIcon to imageBoxes to allow capturing of strokes for use with generative apis
-rw-r--r--src/client/views/nodes/ImageBox.tsx26
-rw-r--r--src/server/ApiManagers/FireflyManager.ts2
2 files changed, 25 insertions, 3 deletions
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<FieldViewProps>() {
}
};
- updateIcon = () => new Promise<void>(res => res());
+ // updateIcon = () => new Promise<void>(res => res());
+ updateIcon = (usePanelDimensions?: boolean) => {
+ const contentDiv = this._mainCont.current;
+ return !contentDiv
+ ? new Promise<void>(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);