aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/smartdraw/AnnotationPalette.tsx
diff options
context:
space:
mode:
authoreleanor-park <eleanor_park@brown.edu>2024-10-01 18:45:03 -0400
committereleanor-park <eleanor_park@brown.edu>2024-10-01 18:45:03 -0400
commit5d859cab5fa714860723fa252498c407d5909cdc (patch)
treea8366cbcacdbb18fb24204e8b89187db49a26785 /src/client/views/smartdraw/AnnotationPalette.tsx
parent06ab521c759e44a26be58fdf7ffc8d790e551236 (diff)
parent39dc004c0f8e4bcc21ca0c2ecb0b665037f3d1ad (diff)
Merge branch 'eleanor-gptdraw' of https://github.com/brown-dash/Dash-Web into eleanor-gptdraw
Diffstat (limited to 'src/client/views/smartdraw/AnnotationPalette.tsx')
-rw-r--r--src/client/views/smartdraw/AnnotationPalette.tsx12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/client/views/smartdraw/AnnotationPalette.tsx b/src/client/views/smartdraw/AnnotationPalette.tsx
index 0c8dbf12d..f1e2e4f41 100644
--- a/src/client/views/smartdraw/AnnotationPalette.tsx
+++ b/src/client/views/smartdraw/AnnotationPalette.tsx
@@ -10,10 +10,11 @@ import { returnEmptyFilter, returnFalse, returnTrue } from '../../../ClientUtils
import { emptyFunction } from '../../../Utils';
import { Doc, DocListCast, returnEmptyDoclist } from '../../../fields/Doc';
import { DocData } from '../../../fields/DocSymbols';
-import { ImageCast } from '../../../fields/Types';
+import { ImageCast, NumCast } from '../../../fields/Types';
+import { ImageField } from '../../../fields/URLField';
import { DocumentType } from '../../documents/DocumentTypes';
import { Docs } from '../../documents/Documents';
-import { makeUserTemplateImage } from '../../util/DropConverter';
+import { makeUserTemplateButtonOrImage } from '../../util/DropConverter';
import { SettingsManager } from '../../util/SettingsManager';
import { Transform } from '../../util/Transform';
import { undoBatch } from '../../util/UndoManager';
@@ -23,8 +24,6 @@ import { DocumentView, DocumentViewInternal } from '../nodes/DocumentView';
import { FieldView } from '../nodes/FieldView';
import './AnnotationPalette.scss';
import { DrawingOptions, SmartDrawHandler } from './SmartDrawHandler';
-import { ImageField } from '../../../fields/URLField';
-import { Copy } from '../../../fields/FieldSymbols';
interface AnnotationPaletteProps {
Document: Doc;
@@ -123,7 +122,7 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
const { clone } = await Doc.MakeClone(doc);
clone.title = doc.title;
const image = ImageCast(doc.icon, ImageCast(clone[Doc.LayoutFieldKey(clone)]))?.url?.href;
- Doc.AddDocToList(Doc.MyAnnos, 'data', makeUserTemplateImage(clone, image));
+ Doc.AddDocToList(Doc.MyAnnos, 'data', makeUserTemplateButtonOrImage(clone, image));
doc.savedAsAnno = true;
}
};
@@ -158,7 +157,6 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
console.log('Error generating drawing', e);
}
}
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
this._opts.text !== '' ? (this._opts.text = `${this._opts.text} ~~~ ${this._userInput}`) : (this._opts.text = this._userInput);
this._userInput = '';
this._isLoading = false;
@@ -178,7 +176,7 @@ export class AnnotationPalette extends ObservableReactComponent<AnnotationPalett
* presses the "save drawing" button.
*/
saveDrawing = async () => {
- const cIndex: number = this._props.Document.carousel_index as number;
+ 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;