diff options
author | sharkiecodes <lanyi_stroud@brown.edu> | 2025-06-09 12:08:48 -0400 |
---|---|---|
committer | sharkiecodes <lanyi_stroud@brown.edu> | 2025-06-09 12:08:48 -0400 |
commit | 5493911505ddca32e32b7ca2dfb9545766b84a9b (patch) | |
tree | 6537fd92973abee0fab42ea0abbc161f3d8d06fe /src | |
parent | 6807ed433befd3f90f2dfc4ca359cd9ee8a68e32 (diff) |
scrapbooks commit
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/scrapbook/ScrapbookBox.tsx | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx index e910f2fa7..d1d357d4c 100644 --- a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx +++ b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx @@ -11,11 +11,11 @@ import { AspectRatioLimits } from '../../smartdraw/FireflyConstants'; import { DocumentView } from '../DocumentView'; import { FieldView, FieldViewProps } from '../FieldView'; import { DragManager } from '../../../util/DragManager'; -import { RTFCast, StrCast, toList } from '../../../../fields/Types'; +import { toList } from '../../../../fields/Types'; import { undoable } from '../../../util/UndoManager'; import ReactLoading from 'react-loading'; import { NumCast } from '../../../../fields/Types'; -import { ScrapbookItemConfig, ScrapbookPreset } from './ScrapbookPreset'; +import { ScrapbookItemConfig } from './ScrapbookPreset'; import { ImageBox } from '../ImageBox'; import { FireflyImageDimensions } from '../../smartdraw/FireflyConstants'; import { SmartDrawHandler } from '../../smartdraw/SmartDrawHandler'; @@ -104,7 +104,6 @@ export function slotRealDocIntoPlaceholders( RTFCast(d[Doc.LayoutDataKey(d)])?.Text.includes(StrCast(docs[0].$type)))*/ placeholders.forEach(ph => { - // 1) Enforce that placeholder.accepts_docType === realDoc.$type if (ph.accepts_docType !== realDoc.$type) { // Skip this placeholder entirely if types do not match. return; @@ -146,7 +145,6 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() private _disposers: { [name: string]: IReactionDisposer } = {}; private imageBoxRef = React.createRef<ImageBox>(); - // @observable configs : ScrapbookItemConfig[] constructor(props: FieldViewProps) { super(props); @@ -167,15 +165,13 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() // We still want `createdDate` set so that the UI title bar can show it if needed. this.createdDate = this.getFormattedDate(); } - //this.configs = - //ScrapbookPreset.createPreset(presetType); + // ensure we always have a List<Doc> in dataDoc['items'] if (!this.dataDoc[this.fieldKey]) { this.dataDoc[this.fieldKey] = new List<Doc>(); } - //this.initScrapbook(ScrapbookPresetType.Default); - //this.setLayout(ScrapbookPreset.Spotlight); + } public static LayoutString(fieldStr: string) { @@ -217,7 +213,7 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() if (!this.dataDoc[this.fieldKey]){ const image = Docs.Create.TextDocument('[placeholder] person image'); image.accepts_docType = DocumentType.IMG; - image.accepts_tagType = 'PERSON' //should i be writing fields on this doc? clarify diff between this and proto, original + image.accepts_tagType = 'PERSON' const placeholder = new Doc(); placeholder.proto = image; placeholder.original = image; @@ -225,23 +221,22 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() placeholder._height = 200; placeholder.x = 0; placeholder.y = -100; - //placeholder.overrideFields = new List<string>(['x', 'y']); // shouldn't need to do this for layout fields since the placeholder already overrides its protos + const summary = Docs.Create.TextDocument('[placeholder] long summary'); summary.accepts_docType = DocumentType.RTF; summary.accepts_tagType = 'lengthy description'; - //summary.$tags_chat = new List<string>(['lengthy description']); //we need to go back and set this const placeholder2 = new Doc(); placeholder2.proto = summary; placeholder2.original = summary; placeholder2.x = 0; placeholder2.y = 200; placeholder2._width = 250; - //placeholder2.overrideFields = new List<string>(['x', 'y', '_width']); // shouldn't need to do this for layout fields since the placeholder already overrides its protos + const sidebar = Docs.Create.TextDocument('[placeholder] brief sidebar'); sidebar.accepts_docType = DocumentType.RTF; - sidebar.accepts_tagType = 'title'; //accepts_textType = 'lengthy description' + sidebar.accepts_tagType = 'title'; const placeholder3 = new Doc(); placeholder3.proto = sidebar; placeholder3.original = sidebar; @@ -254,7 +249,7 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() const internalImg = Docs.Create.TextDocument('[placeholder] landscape internal'); internalImg.accepts_docType = DocumentType.IMG; - internalImg.accepts_tagType = 'LANDSCAPE' //should i be writing fields on this doc? clarify diff between this and proto, original + internalImg.accepts_tagType = 'LANDSCAPE' const placeholder5 = new Doc(); placeholder5.proto = internalImg; placeholder5.original = internalImg; @@ -282,23 +277,19 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() Should we consider that there are more collections than just COL type collections? when spreading*/ - - /*note-to-self difference between passing a new List<Doc> versus just the raw array? */ this.dataDoc[this.fieldKey] = new List<Doc>([placeholder, placeholder2, placeholder3, placeholder4]); } - //this.dataDoc[this.fieldKey] = this.dataDoc[this.fieldKey] ?? new List<Doc>([placeholder, placeholder2, placeholder3, placeholder4]); } } componentDidMount() { - //this.initScrapbook(ScrapbookPresetType.Default); this.setTitle(); - this.generateAiImageCorrect(); + this.generateAiImage(); this._disposers.propagateResize = reaction( () => ({ w: this.layoutDoc._width, h: this.layoutDoc._height }), @@ -330,7 +321,7 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() @action - async generateAiImageCorrect(prompt?: string) { + async generateAiImage(prompt?: string) { this.loading = true; try { // 1) Default to regenPrompt if none provided @@ -475,7 +466,7 @@ export class ScrapbookBox extends ViewBoxAnnotatableComponent<FieldViewProps>() <button type="button" title="Regenerate Background" - onClick={() => this.generateAiImageCorrect(this.regenPrompt)} + onClick={() => this.generateAiImage(this.regenPrompt)} className="scrapbook-box-ui-button" > <FontAwesomeIcon icon={faRedoAlt} /> |