aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/smartdraw/StickerPalette.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-24 16:29:32 -0400
committerbobzel <zzzman@gmail.com>2025-03-24 16:29:32 -0400
commit858f5d2f1621695a703b0e3f8297521c3ebe692d (patch)
tree3180f91ee18bf8accef98cbbb6db6688666e8340 /src/client/views/smartdraw/StickerPalette.tsx
parent9c5d14fdd562dc1bcc8aa0f73ce7ad189c9fbf23 (diff)
parentb6cf21b5a52184f89909898d292a79c57c043d7e (diff)
Merge branch 'fieldSyntaxUpdate' into aarav_edit
Diffstat (limited to 'src/client/views/smartdraw/StickerPalette.tsx')
-rw-r--r--src/client/views/smartdraw/StickerPalette.tsx40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/client/views/smartdraw/StickerPalette.tsx b/src/client/views/smartdraw/StickerPalette.tsx
index d5307974f..2260d1f73 100644
--- a/src/client/views/smartdraw/StickerPalette.tsx
+++ b/src/client/views/smartdraw/StickerPalette.tsx
@@ -9,7 +9,6 @@ import ReactLoading from 'react-loading';
import { returnEmptyFilter, returnFalse, returnTrue } from '../../../ClientUtils';
import { emptyFunction, numberRange } from '../../../Utils';
import { Doc, DocListCast, returnEmptyDoclist } from '../../../fields/Doc';
-import { DocData } from '../../../fields/DocSymbols';
import { ImageCast, NumCast } from '../../../fields/Types';
import { ImageField } from '../../../fields/URLField';
import { DocumentType } from '../../documents/DocumentTypes';
@@ -26,7 +25,7 @@ import { DrawingOptions, SmartDrawHandler } from './SmartDrawHandler';
import './StickerPalette.scss';
interface StickerPaletteProps {
- Document: Doc;
+ Doc: Doc;
}
enum StickerPaletteMode {
@@ -133,7 +132,7 @@ export class StickerPalette extends ObservableReactComponent<StickerPaletteProps
this._canInteract = true;
this._opts = { text: '', complexity: 5, size: 200, autoColor: true, x: 0, y: 0 };
this._gptRes = [];
- this._props.Document[DocData].data = undefined;
+ this._props.Doc.$data = undefined;
});
/**
@@ -143,15 +142,15 @@ export class StickerPalette extends ObservableReactComponent<StickerPaletteProps
@undoBatch
generateDrawings = action(() => {
this._isLoading = true;
- const prevDrawings = DocListCast(this._props.Document[DocData].data);
- this._props.Document[DocData].data = undefined;
+ const prevDrawings = DocListCast(this._props.Doc.$data);
+ this._props.Doc.$data = undefined;
SmartDrawHandler.Instance.AddDrawing = this.addDrawing;
this._canInteract = false;
Promise.all(
numberRange(3).map(i => {
return this._showRegenerate
? SmartDrawHandler.Instance.regenerate(prevDrawings, this._opts, this._gptRes[i], this._userInput)
- : SmartDrawHandler.Instance.drawWithGPT({ X: 0, Y: 0 }, this._userInput, this._opts.complexity, this._opts.size, this._opts.autoColor);
+ : SmartDrawHandler.Instance.drawWithGPT({ X: 0, Y: 0 }, this._userInput, this._opts.complexity || 0, this._opts.size || 0, !!this._opts.autoColor);
})
).then(() => {
this._opts.text !== '' ? (this._opts.text = `${this._opts.text} ~~~ ${this._userInput}`) : (this._opts.text = this._userInput);
@@ -164,8 +163,8 @@ export class StickerPalette extends ObservableReactComponent<StickerPaletteProps
@action
addDrawing = (drawing: Doc, opts: DrawingOptions, gptRes: string) => {
this._gptRes.push(gptRes);
- drawing[DocData].freeform_fitContentsToBox = true;
- Doc.AddDocToList(this._props.Document, 'data', drawing);
+ drawing.$freeform_fitContentsToBox = true;
+ Doc.AddDocToList(this._props.Doc, 'data', drawing);
};
/**
@@ -174,19 +173,18 @@ export class StickerPalette extends ObservableReactComponent<StickerPaletteProps
* presses the "save drawing" button.
*/
saveDrawing = () => {
- const cIndex = NumCast(this._props.Document.carousel_index);
- const focusedDrawing = DocListCast(this._props.Document.data)[cIndex];
- const docData = focusedDrawing[DocData];
- docData.title = this._opts.text.match(/^(.*?)~~~.*$/)?.[1] || this._opts.text;
- docData.ai_drawing_input = this._opts.text;
- docData.ai_drawing_complexity = this._opts.complexity;
- docData.ai_drawing_colored = this._opts.autoColor;
- docData.ai_drawing_size = this._opts.size;
- docData.ai_drawing_data = this._gptRes[cIndex];
- docData.ai = 'gpt';
+ const cIndex = NumCast(this._props.Doc.carousel_index);
+ const focusedDrawing = DocListCast(this._props.Doc.data)[cIndex];
+ focusedDrawing.$title = this._opts.text?.match(/^(.*?)~~~.*$/)?.[1] || this._opts.text;
+ focusedDrawing.$ai_drawing_input = this._opts.text;
+ focusedDrawing.$ai_drawing_complexity = this._opts.complexity;
+ focusedDrawing.$ai_drawing_colored = this._opts.autoColor;
+ focusedDrawing.$ai_drawing_size = this._opts.size;
+ focusedDrawing.$ai_drawing_data = this._gptRes[cIndex];
+ focusedDrawing.$ai = 'gpt';
focusedDrawing.width = this._opts.size;
- docData.x = this._opts.x;
- docData.y = this._opts.y;
+ focusedDrawing.x = this._opts.x;
+ focusedDrawing.y = this._opts.y;
StickerPalette.addToPalette(focusedDrawing).then(() => this.resetPalette(true));
};
@@ -315,7 +313,7 @@ export class StickerPalette extends ObservableReactComponent<StickerPaletteProps
<>
{this.renderCreateInput()}
{this.renderCreateOptions()}
- {this.renderDoc(this._props.Document, (r: DocumentView) => {
+ {this.renderDoc(this._props.Doc, (r: DocumentView) => {
this._docCarouselView = r;
})}
<div className="palette-buttons">