From a5744b79733654cdaa4ed732b48e2d86f570e31d Mon Sep 17 00:00:00 2001 From: sharkiecodes Date: Mon, 12 May 2025 00:43:44 -0400 Subject: scrapbooks with tags --- src/client/views/nodes/scrapbook/ScrapbookBox.tsx | 66 +++++++++++++++++++++-- 1 file changed, 61 insertions(+), 5 deletions(-) (limited to 'src/client/views/nodes/scrapbook') diff --git a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx index ad3bfa7ad..9ffc13e6e 100644 --- a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx +++ b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx @@ -23,6 +23,8 @@ import { IReactionDisposer } from 'mobx'; import { observer } from 'mobx-react'; import { ImageField } from '../../../../fields/URLField'; import { runInAction } from 'mobx'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faRedoAlt } from '@fortawesome/free-solid-svg-icons'; enum ScrapbookPresetType { Classic = 'Classic', @@ -429,10 +431,12 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent() } - async generateAiImageCorrect() { + async generateAiImageCorrect(prompt? : string) { this.loading = true; - - const prompt = 'A serene mountain landscape at sunrise, ultra-wide, pastel sky, abstract, scrapbook background'; + + if(!prompt){ + prompt = 'A serene mountain landscape at sunrise, ultra-wide, pastel sky, abstract, scrapbook background'; + } const dimensions = FireflyImageDimensions.Square; SmartDrawHandler.CreateWithFirefly(prompt, dimensions) @@ -538,8 +542,31 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent() return false; }; + render() { + /*const internalTags = DocListCast(this.dataDoc[this.fieldKey]) + .flatMap(ph => StrListCast(ph.$tags_chat)) + .join(' ');*/ + const slots = DocListCast(this.dataDoc[this.fieldKey]); + + // 2) recursive unwrap: + const unwrap = (items: Doc[]): Doc[] => + items.flatMap(d => + d.$type === DocumentType.COL + ? unwrap(DocListCast(d[Doc.LayoutDataKey(d)])) + : [d] + ); + + // 3) produce a flat list of every doc, unwrapping any number of nested COLs + const allDocs: Doc[] = unwrap(slots); + const internalTags = '' + + const regenPrompt = internalTags + ? `Create a new background using these tags: ${internalTags}` + : 'A serene mountain landscape at sunrise, ultra-wide, pastel sky, abstract, scrapbook background'; + + return (
@@ -564,8 +591,37 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent() {...this._props} Document={this.imgDoc} fieldKey="data" - /> - )} )} + + {this._props.isContentActive() && ( +
e.stopPropagation()} + > + +
+ )} + +