aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/smartdraw/AnnotationPalette.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/smartdraw/AnnotationPalette.tsx')
-rw-r--r--src/client/views/smartdraw/AnnotationPalette.tsx44
1 files changed, 7 insertions, 37 deletions
diff --git a/src/client/views/smartdraw/AnnotationPalette.tsx b/src/client/views/smartdraw/AnnotationPalette.tsx
index ec4279e3e..7e4d46204 100644
--- a/src/client/views/smartdraw/AnnotationPalette.tsx
+++ b/src/client/views/smartdraw/AnnotationPalette.tsx
@@ -64,7 +64,7 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
@action
handleKeyPress = async (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
- await this.generateDrawing();
+ await this.generateDrawings();
}
};
@@ -130,15 +130,14 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
}
@undoBatch
- generateDrawing = action(async () => {
+ generateDrawings = action(async () => {
this._isLoading = true;
this._props.Document[DocData].data = undefined;
for (var i = 0; i < 3; i++) {
try {
- SmartDrawHandler.Instance._addFunc = this.createDrawing;
+ SmartDrawHandler.Instance.AddDrawing = this.addDrawing;
this._canInteract = false;
if (this._showRegenerate) {
- SmartDrawHandler.Instance._deleteFunc = unimplementedFunction;
await SmartDrawHandler.Instance.regenerate(this._opts, this._gptRes[i], this._userInput);
} else {
await SmartDrawHandler.Instance.drawWithGPT({ X: 0, Y: 0 }, this._userInput, this._opts.complexity, this._opts.size, this._opts.autoColor);
@@ -154,39 +153,10 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
});
@action
- createDrawing = (strokeList: [InkData, string, string][], opts: DrawingOptions, gptRes: string) => {
- this._opts = opts;
+ addDrawing = (drawing: Doc, opts: DrawingOptions, gptRes: string) => {
this._gptRes.push(gptRes);
- const drawing: Doc[] = [];
-
- strokeList.forEach((stroke: [InkData, string, string]) => {
- const bounds = InkField.getBounds(stroke[0]);
- const inkWidth = Math.min(5, ActiveInkWidth());
- const inkDoc = Docs.Create.InkDocument(
- stroke[0],
- { title: 'stroke',
- x: bounds.left - inkWidth / 2,
- y: bounds.top - inkWidth / 2,
- _width: bounds.width + inkWidth,
- _height: bounds.height + inkWidth,
- stroke_showLabel: BoolCast(Doc.UserDoc().activeInkHideTextLabels)}, // prettier-ignore
- inkWidth,
- opts.autoColor ? stroke[1] : ActiveInkColor(),
- ActiveInkBezierApprox(),
- stroke[2] === 'none' ? ActiveFillColor() : stroke[2],
- ActiveArrowStart(),
- ActiveArrowEnd(),
- ActiveDash(),
- ActiveIsInkMask()
- );
- drawing.push(inkDoc);
- });
-
- const collection = MarqueeView.getCollection(drawing, undefined, true, { left: 1, top: 1, width: 1, height: 1 });
- if (collection) {
- collection[DocData].freeform_fitContentsToBox = true;
- Doc.AddDocToList(this._props.Document, 'data', collection);
- }
+ drawing[DocData].freeform_fitContentsToBox = true;
+ Doc.AddDocToList(this._props.Document, 'data', drawing);
};
saveDrawing = async () => {
@@ -262,7 +232,7 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
icon={this._isLoading ? <ReactLoading type="spin" color={SettingsManager.userVariantColor} width={16} height={20} /> : this._showRegenerate ? <FontAwesomeIcon icon={'rotate'} /> : <AiOutlineSend />}
iconPlacement="right"
color={SettingsManager.userColor}
- onClick={this.generateDrawing}
+ onClick={this.generateDrawings}
/>
</div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', width: '170px', marginTop: '5px' }}>