aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm
diff options
context:
space:
mode:
authorJoanne <zehan_ding@brown.edu>2025-05-12 21:00:38 -0400
committerJoanne <zehan_ding@brown.edu>2025-05-12 21:00:38 -0400
commit430db63077868fa54829721d6530a810aa4d4588 (patch)
tree4b1ac30d8f5d90ba4b9d5e45414e6222d3af0e09 /src/client/views/collections/collectionFreeForm
parentcd93c88b8fee83a99342eac4dc60f7b4373fa843 (diff)
parent0c3f86d57225a2991920adef3a337bc13e408ac0 (diff)
Merge branch 'master' of https://github.com/brown-dash/Dash-Web into joanne-tutorialagent
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx60
1 files changed, 8 insertions, 52 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 93314e383..5bbe93a90 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -258,8 +258,8 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
override contentBounds = () => {
const { x, y, r, b } = aggregateBounds(
this._layoutElements.filter(e => e.bounds?.width && !e.bounds.z).map(e => e.bounds!),
- NumCast(this.layoutDoc._xPadding, NumCast(this.layoutDoc._xMargin, this._props.xPadding ?? 0)),
- NumCast(this.layoutDoc._yPadding, NumCast(this.layoutDoc._yMargin, this._props.yPadding ?? 0))
+ NumCast(this.layoutDoc._xMargin, this._props.xMargin ?? 0),
+ NumCast(this.layoutDoc._yMargin, this._props.yMargin ?? 0)
);
const [width, height] = [r - x, b - y];
return {
@@ -1261,15 +1261,8 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
/**
* Adds the created drawing to the freeform canvas and sets the metadata.
*/
- addDrawing = (doc: Doc, opts: DrawingOptions, gptRes: string, x?: number, y?: number) => {
- doc.$title = opts.text;
- doc.$width = opts.size;
- doc.$ai_drawing_input = opts.text;
- doc.$ai_drawing_complexity = opts.complexity;
- doc.$ai_drawing_colored = opts.autoColor;
- doc.$ai_drawing_size = opts.size;
- doc.$ai_drawing_data = gptRes;
- doc.$ai = 'gpt';
+ addDrawing = (doc: Doc, opts: DrawingOptions, x?: number, y?: number) => {
+ doc.$ai_prompt = opts.text;
this._drawingContainer = doc;
if (x !== undefined && y !== undefined) {
[doc.x, doc.y] = this.screenToFreeformContentsXf.transformPoint(x, y);
@@ -1815,7 +1808,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
() => {
if (this.Document.isGroup && this.childDocs.length === this.childDocList?.length) {
const clist = this.childDocs.map(cd => ({ x: NumCast(cd.x), y: NumCast(cd.y), width: NumCast(cd._width), height: NumCast(cd._height) }));
- return aggregateBounds(clist, NumCast(this.layoutDoc._xPadding), NumCast(this.layoutDoc._yPadding));
+ return aggregateBounds(clist, NumCast(this.layoutDoc._xMargin), NumCast(this.layoutDoc._yMargin));
}
return undefined;
},
@@ -2017,7 +2010,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
event: action(() => {
SmartDrawHandler.Instance.AddDrawing = this.addDrawing;
SmartDrawHandler.Instance.RemoveDrawing = this.removeDrawing;
- !SmartDrawHandler.Instance.ShowRegenerate ? SmartDrawHandler.Instance.displayRegenerate(this._downX, this._downY - 10) : SmartDrawHandler.Instance.hideRegenerate();
+ !SmartDrawHandler.Instance.ShowRegenerate ? SmartDrawHandler.Instance.displayRegenerate(this._downX, this._downY - 10, NumCast(this.layoutDoc[this.scaleFieldKey])) : SmartDrawHandler.Instance.hideRegenerate();
}),
icon: 'pen-to-square',
});
@@ -2222,9 +2215,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
placeholder={this._drawingFillInput || StrCast(this.Document.title) || 'Describe image'}
type="text"
value={this._drawingFillInput}
- onChange={action(e => {
- this._drawingFillInput = e.target.value;
- })}
+ onChange={action(e => (this._drawingFillInput = e.target.value))}
/>
<div className="collectionFreeFormView-aiView-strength">
<span className="collectionFreeFormView-aiView-similarity">Similarity</span>
@@ -2253,11 +2244,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
onClick={undoable(
action(() => {
this._drawingFillLoading = true;
- DrawingFillHandler.drawingToImage(this.props.Document, this._fireflyRefStrength, this._drawingFillInput || StrCast(this.Document.title))?.then(
- action(() => {
- this._drawingFillLoading = false;
- })
- );
+ DrawingFillHandler.drawingToImage(this.props.Document, this._fireflyRefStrength, this._drawingFillInput || StrCast(this.Document.title))?.then(action(() => (this._drawingFillLoading = false)));
}),
'create image'
)}
@@ -2265,37 +2252,6 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
</div>
</div>
</div>
- <div className="collectionfreeformview-aiView-regenerate-container">
- <span className="collectionfreeformview-aiView-subtitle">Regenerate</span>
- <div className="collectionfreeformview-aiView-regenerate">
- <input
- className="collectionfreeformview-aiView-input"
- aria-label="Edit instructions input"
- type="text"
- value={this._regenInput}
- onChange={action(e => {
- this._regenInput = e.target.value;
- })}
- placeholder="..under development.."
- />
- <div className="collectionFreeFormView-aiView-regenBtn">
- <Button
- text="Regenerate"
- type={Type.SEC}
- icon={this._regenLoading ? <ReactLoading type="spin" color={SettingsManager.userVariantColor} width={16} height={20} /> : <AiOutlineSend />}
- iconPlacement="right"
- // onClick={action(async () => {
- // this._regenLoading = true;
- // SmartDrawHandler.Instance.CreateDrawingDoc = this.createDrawingDoc;
- // SmartDrawHandler.Instance.AddDrawing = this.addDrawing;
- // SmartDrawHandler.Instance.RemoveDrawing = this.removeDrawing;
- // await SmartDrawHandler.Instance.regenerate([this.Document], undefined, undefined, this._regenInput, true);
- // this._regenLoading = false;
- // })}
- />
- </div>
- </div>
- </div>
</div>
);
};