aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm
diff options
context:
space:
mode:
authoreleanor-park <eleanor_park@brown.edu>2024-07-11 11:50:01 -0400
committereleanor-park <eleanor_park@brown.edu>2024-07-11 11:50:01 -0400
commit49b3c7cbe01f830a2b1d2c02452901fe360348d3 (patch)
treead4efc73fac5e2dfa20b1911399821614f42fa8c /src/client/views/collections/collectionFreeForm
parentf33e6c9e191092e6050f980892b4404ff0d0a1f2 (diff)
updates
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx18
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeOptionsMenu.tsx3
2 files changed, 13 insertions, 8 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 0bdcc8450..779d16a9c 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1269,8 +1269,11 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
};
_drawing: Doc[] = [];
+ _drawingContainer: Doc | undefined = undefined;
@undoBatch
- createDrawing = (e: React.PointerEvent<Element>, strokeData: [InkData, string, string][], opts: DrawingOptions, gptRes: string, containerDoc?: Doc) => {
+ createDrawing = (strokeData: [InkData, string, string][], opts: DrawingOptions, gptRes: string, containerDoc?: Doc) => {
+ this._drawing = [];
+ this._drawingContainer = undefined;
strokeData.forEach((stroke: [InkData, string, string]) => {
const bounds = InkField.getBounds(stroke[0]);
const B = this.screenToFreeformContentsXf.transformBounds(bounds.left, bounds.top, bounds.width, bounds.height);
@@ -1294,12 +1297,13 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
const collection = this._marqueeViewRef.current?.collection(undefined, true, this._drawing);
if (collection) {
const docData = collection[DocData];
- docData.title = opts.text;
+ docData.title = opts.text.match(/^(.*?)~~~.*$/)?.[0] || opts.text;
docData.drawingInput = opts.text;
docData.drawingComplexity = opts.complexity;
docData.drawingColored = opts.autoColor;
docData.drawingSize = opts.size;
docData.drawingData = gptRes;
+ this._drawingContainer = collection;
}
this._batch?.end();
};
@@ -1307,14 +1311,14 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
removeDrawing = (doc?: Doc) => {
this._batch = UndoManager.StartBatch('regenerateDrawing');
if (doc) {
- const docData: Doc = doc[DocData];
- const children = docData.data as unknown as Doc[];
- this._props.removeDocument?.(doc);
+ const docData = DocCast(doc[DocData]);
+ const children = DocListCast(docData.data);
this._props.removeDocument?.(children);
+ this._props.removeDocument?.(doc);
} else {
this._props.removeDocument?.(this._drawing);
+ if (this._drawingContainer) this._props.removeDocument?.(this._drawingContainer);
}
- this._drawing = [];
};
@action
@@ -2021,7 +2025,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
icon: 'eye',
});
optionItems.push({
- description: (this._showDrawingEditor ? 'Close' : 'Show') + ' Drawing Editor',
+ description: 'Show Drawing Editor',
event: action(() => {
this._showDrawingEditor = !this._showDrawingEditor;
this._showDrawingEditor ? SmartDrawHandler.Instance.displayRegenerate(this._downX, this._downY - 10, this.createDrawing, this.removeDrawing) : SmartDrawHandler.Instance.hideRegenerate();
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeOptionsMenu.tsx b/src/client/views/collections/collectionFreeForm/MarqueeOptionsMenu.tsx
index f02cd9d45..b3fdd9379 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeOptionsMenu.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeOptionsMenu.tsx
@@ -3,6 +3,7 @@ import { IconButton } from 'browndash-components';
import { computed, makeObservable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
+import { Doc } from '../../../../fields/Doc';
import { unimplementedFunction } from '../../../../Utils';
import { SettingsManager } from '../../../util/SettingsManager';
import { AntimodeMenu, AntimodeMenuProps } from '../../AntimodeMenu';
@@ -12,7 +13,7 @@ export class MarqueeOptionsMenu extends AntimodeMenu<AntimodeMenuProps> {
// eslint-disable-next-line no-use-before-define
static Instance: MarqueeOptionsMenu;
- public createCollection: (e: KeyboardEvent | React.PointerEvent | undefined, group?: boolean) => void = unimplementedFunction;
+ public createCollection: (e: KeyboardEvent | React.PointerEvent | undefined, group?: boolean, selection?: Doc[]) => Doc | void = unimplementedFunction;
public delete: (e: KeyboardEvent | React.PointerEvent | undefined) => void = unimplementedFunction;
public summarize: (e: KeyboardEvent | React.PointerEvent | undefined) => void = unimplementedFunction;
public showMarquee: () => void = unimplementedFunction;