diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/collectionFreeForm/MarqueeView.tsx | 118 |
1 files changed, 1 insertions, 117 deletions
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 05d4cd81d..b8d203cf6 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -22,7 +22,6 @@ import { ObservableReactComponent } from '../../ObservableReactComponent'; import { MarqueeViewBounds } from '../../PinFuncs'; import { PreviewCursor } from '../../PreviewCursor'; import { DocumentView } from '../../nodes/DocumentView'; -import { OverlayDisposer } from '../../OverlayView'; import { OpenWhere } from '../../nodes/OpenWhere'; import { pasteImageBitmap } from '../../nodes/WebBoxRenderer'; import { FormattedTextBox } from '../../nodes/formattedText/FormattedTextBox'; @@ -91,8 +90,6 @@ export class MarqueeView extends ObservableReactComponent<SubCollectionViewProps @observable pickerX = 0; // popup x coordinate @observable pickerY = 0; // popup y coordinate @observable pickerVisible = false; // show/hide ScrapbookPicker - // This will hold the “disposer” function returned by addWindow() - private _overlayDisposer: OverlayDisposer | null = null; @@ -295,7 +292,7 @@ export class MarqueeView extends ObservableReactComponent<SubCollectionViewProps MarqueeOptionsMenu.Instance.createCollection = this.collection; MarqueeOptionsMenu.Instance.delete = this.delete; MarqueeOptionsMenu.Instance.summarize = this.summary; - MarqueeOptionsMenu.Instance.generateScrapbook = this.generateAiScrapbooks; + MarqueeOptionsMenu.Instance.generateScrapbook = this.generateScrapbook; MarqueeOptionsMenu.Instance.showMarquee = this.showMarquee; MarqueeOptionsMenu.Instance.hideMarquee = this.hideMarquee; MarqueeOptionsMenu.Instance.jumpTo(e.clientX, e.clientY); @@ -632,100 +629,6 @@ export class MarqueeView extends ObservableReactComponent<SubCollectionViewProps }); - - - /** Called when the user clicks one of the N thumbnails */ - @action - onScrapbookChoice(idx: number) { - const chosenDoc = this.aiChoices[idx]; - if (!chosenDoc) return; - - // 1) Move chosenDoc from off‐screen to the marquee area - const bounds = this.Bounds; - chosenDoc.x = bounds.left; - chosenDoc.y = bounds.top; - chosenDoc._width = NumCast(bounds.width || chosenDoc._width); - chosenDoc._height = NumCast(bounds.height || chosenDoc._height); - chosenDoc.$title = 'AI‐chosen scrapbook'; - - // 2) Remove the other temp docs - this.aiChoices.forEach((doc, i) => { - if (i !== idx) { - this.props.removeDocument?.(doc); - } - }); - - // 3) Clear state and close the popup - this.aiChoices = []; - this.pickerVisible = false; - } - - /** Called when user clicks outside or the “×” in ScrapbookPicker */ - @action - cancelScrapbookChoice() { - // 1) Remove all temp scrapbooks - this.aiChoices.forEach((doc) => { - this.props.removeDocument?.(doc); - }); - - // 2) Clear array and hide popup - this.aiChoices = []; - this.pickerVisible = false; - } - @action - generateAiScrapbooks = async () => { - const n = 3; // Number of AI scrapbook presets - const descriptors = this.getAiPresetsDescriptors(); - if (descriptors.length === 0) { - alert('No documents selected to generate a scrapbook from!'); - return; - } - - // 1) Start N parallel requests for JSON configs - const calls: Promise<ScrapbookItemConfig[]>[] = []; - for (let i = 0; i < n; i++) { - calls.push(requestAiGeneratedPreset(descriptors)); - } - - // 2) Optionally show a “spinner” overlay in‐line here if you like… - // (But for brevity, let’s omit that.) - - try { - const allConfigsArrays = await Promise.all(calls); - - runInAction(() => { - // 3) For each returned config array, build placeholders and create _hidden_ Scrapbook doc - this.aiChoices = allConfigsArrays.map((cfgArr, i) => { - const placeholders = buildPlaceholdersFromConfigs(cfgArr); - // Off‐screen ScrapbookDocument: - const tempSb: Doc = Docs.Create.ScrapbookDocument(placeholders, { - title: `AI Preset (temp ${i + 1})`, - x: -10000, // far off screen - y: -10000, - _width: 600, - _height: 600, - backgroundColor: 'transparent', - _layout_showFlash: false, // keep it hidden until chosen - }); - this.props.addDocument?.(tempSb); - tempSb.$tags_chat = new List<string>(['@ai_preset']); - return tempSb; - }); - - // 4) Compute where to show the popup in screen coords - const bounds = this.Bounds; - const screenTopLeft = this._props - .getContainerTransform() - .transformPoint(bounds.left, bounds.top); - this.pickerX = screenTopLeft[0] + 20; - this.pickerY = screenTopLeft[1] + 20; - this.pickerVisible = true; - }); - } catch (err) { - console.error('Error generating AI scrapbooks:', err); - alert('Failed to generate presets. Please try again.'); - } - }; @action @@ -914,25 +817,6 @@ export class MarqueeView extends ObservableReactComponent<SubCollectionViewProps {this._visible ? this.marqueeDiv : null} {this.props.children} </div> - {this.pickerVisible && ( - <div - className="marqueeView-scrapbook-overlay" - style={{ - position: 'absolute', - top: this.pickerY, - left: this.pickerX, - zIndex: 2000, // just ensure it floats above - }} - > - <ScrapbookPicker - choices={this.aiChoices} - x={this.pickerX} - y={this.pickerY} - onSelect={(i) => this.onScrapbookChoice(i)} - onCancel={() => this.cancelScrapbookChoice()} - /> - </div> -)} </> ); |