diff options
author | bobzel <zzzman@gmail.com> | 2024-12-17 15:03:07 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-12-17 15:03:07 -0500 |
commit | d5c4751b1522535ad323bb5eb254b7a1a7b4a63f (patch) | |
tree | c354287b7e7aae07bc8559506fa877c6dc9db5ac /src/client/views/nodes/ImageBox.tsx | |
parent | 337fbd9c4ce14a548e8b897c2cbb23d5de2a892f (diff) |
added updateIcon to imageBoxes to allow capturing of strokes for use with generative apis
Diffstat (limited to 'src/client/views/nodes/ImageBox.tsx')
-rw-r--r-- | src/client/views/nodes/ImageBox.tsx | 26 |
1 files changed, 24 insertions, 2 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 ''; |