From c2312afe4ee969043ba3ce4cb9c275a48b0f1ee0 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 10 Jan 2025 12:38:00 -0500 Subject: fixed scrolling when ai editor is open. rearranged items in ImageBox ai editor to be more compact. added error catch handler to queryFireflyImage --- src/client/views/nodes/DocumentView.tsx | 50 +++++++++++++++++-------- src/client/views/nodes/ImageBox.scss | 6 +-- src/client/views/nodes/ImageBox.tsx | 31 +++------------ src/client/views/smartdraw/SmartDrawHandler.tsx | 34 +++++++++-------- 4 files changed, 59 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index d656bcf50..640d27aa1 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -52,7 +52,6 @@ import { FormattedTextBox } from './formattedText/FormattedTextBox'; import { PresEffect, PresEffectDirection } from './trails/PresEnums'; import SpringAnimation from './trails/SlideEffect'; import { SpringType, springMappings } from './trails/SpringUtils'; -import { DrawingFillHandler } from '../smartdraw/DrawingFillHandler'; export interface DocumentViewProps extends FieldViewSharedProps { hideDecorations?: boolean; // whether to suppress all DocumentDecorations when doc is selected @@ -716,21 +715,21 @@ export class DocumentViewInternal extends DocComponent this._props.PanelWidth() / 2; - rph = () => this.panelHeight() / 2; + @observable _aiWinHeight = 100; + rpw = () => this._props.PanelWidth() - this._aiWinHeight; + rph = () => this.panelHeight() - this._aiWinHeight; @computed get viewBoxContents() { TraceMobx(); const isInk = this.layoutDoc._layout_isSvg && !this._props.LayoutTemplateString; const noBackground = this.Document.isGroup && !this._componentView?.isUnstyledView?.() && (!this.layoutDoc.backgroundColor || this.layoutDoc.backgroundColor === 'transparent'); return ( -
+ <>
- {this._showAIEditor && ( -
- {this._componentView?.componentAIViewHistory?.() ?? null} -
- )} - {this._showAIEditor && ( -
-
- {this._componentView?.componentAIView?.() ?? null} -
+ {!this._showAIEditor ? null : ( + <> +
{ + this.historyRef(this._oldAiWheel, (this._oldAiWheel = r)); + }} + style={{ height: this.rph(), width: (this._props.PanelWidth() - this.rpw()) * 0.95 }}> + {this._componentView?.componentAIViewHistory?.() ?? null} +
+
{ + this.historyRef(this._oldHistoryWheel, (this._oldHistoryWheel = r)); + }}> +
+ {this._componentView?.componentAIView?.() ?? null} +
+ )} -
+ ); } + _oldHistoryWheel: HTMLDivElement | null = null; + _oldAiWheel: HTMLDivElement | null = null; + onPassiveWheel = (e: WheelEvent) => { + e.stopPropagation(); + }; + + protected historyRef = (lastEle: HTMLDivElement | null, ele: HTMLDivElement | null) => { + lastEle?.removeEventListener('wheel', this.onPassiveWheel); + ele?.addEventListener('wheel', this.onPassiveWheel, { passive: false }); + }; captionStyleProvider = (doc: Opt, props: Opt, property: string) => this._props?.styleProvider?.(doc, props, property + ':caption'); fieldsDropdown = (placeholder: string) => ( diff --git a/src/client/views/nodes/ImageBox.scss b/src/client/views/nodes/ImageBox.scss index 9532f4ad3..1b6b3c85a 100644 --- a/src/client/views/nodes/ImageBox.scss +++ b/src/client/views/nodes/ImageBox.scss @@ -162,16 +162,14 @@ .imageBox-aiView-subtitle { position: relative; - left: 5px; - align-self: start; + align-content: center; } .imageBox-aiView-regenerate-container, .imageBox-aiView-options-container { font-weight: normal; - text-align: start; margin: 5px; - padding-left: 5px; + display: flex; } .imageBox-aiView-regenerate, diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index db8bb2c6e..9838af4d0 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -76,7 +76,6 @@ export class ImageBox extends ViewBoxAnnotatableComponent() { return FieldView.LayoutString(ImageBox, fieldKey); } _ffref = React.createRef(); - _oldWheel: HTMLElement | null = null; private _ignoreScroll = false; private _forcedScroll = false; private _dropDisposer?: DragManager.DragDropDisposer; @@ -536,24 +535,13 @@ export class ImageBox extends ViewBoxAnnotatableComponent() { ); } - onPassiveWheel = (e: WheelEvent) => e.stopPropagation(); - - protected createDashEventsTarget = (ele: HTMLDivElement | null) => { - // this._dropDisposer?.(); - this._oldWheel?.removeEventListener('wheel', this.onPassiveWheel); - this._oldWheel = ele; - // prevent wheel events from passively propagating up through containers and prevents containers from preventDefault which would block scrolling - ele?.addEventListener('wheel', this.onPassiveWheel, { passive: false }); - }; - componentAIViewHistory = () => { return ( -
+
)}
- {showRegenerate && More Image Options } + {showRegenerate && More Options: }