diff options
| author | vkalev <victor_kalev@brown.edu> | 2021-11-09 16:08:01 -0500 |
|---|---|---|
| committer | vkalev <victor_kalev@brown.edu> | 2021-11-09 16:08:01 -0500 |
| commit | f450c8760c0563cdadd414f169902faeace585ec (patch) | |
| tree | 463c363ef36df3051bb4d1648ee23161b1578555 /src/client/views/collections | |
| parent | b2b95106d21f03a0b2b46f972a36bbf00068ab20 (diff) | |
working on undo/redo
Diffstat (limited to 'src/client/views/collections')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index f60af6355..018f4f79a 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -29,7 +29,7 @@ import { SearchUtil } from "../../../util/SearchUtil"; import { SelectionManager } from "../../../util/SelectionManager"; import { SnappingManager } from "../../../util/SnappingManager"; import { Transform } from "../../../util/Transform"; -import { undoBatch } from "../../../util/UndoManager"; +import { undoBatch, UndoManager } from "../../../util/UndoManager"; import { COLLECTION_BORDER_WIDTH } from "../../../views/global/globalCssVariables.scss"; import { Timeline } from "../../animationtimeline/Timeline"; import { ContextMenu } from "../../ContextMenu"; @@ -99,6 +99,7 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P private _layoutSizeData = observable.map<string, { width?: number, height?: number }>(); private _cachedPool: Map<string, PoolData> = new Map(); private _lastTap = 0; + private _batch: UndoManager.Batch | undefined = undefined; private get isAnnotationOverlay() { return this.props.isAnnotationOverlay; } private get scaleFieldKey() { return this.props.scaleField || "_viewScale"; } @@ -449,6 +450,7 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P document.addEventListener("pointerup", this.onPointerUp); // if not using a pen and in no ink mode if (CurrentUserUtils.SelectedTool === InkTool.None) { + this._batch = UndoManager.StartBatch("collectionErase"); this._downX = this._lastX = e.pageX; this._downY = this._lastY = e.pageY; } @@ -598,6 +600,8 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P } } + // @undoBatch + @action onPointerUp = (e: PointerEvent): void => { if (!InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) { document.removeEventListener("pointermove", this.onPointerMove); @@ -607,11 +611,13 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P if (CurrentUserUtils.SelectedTool !== InkTool.None) { if (this._deleteList.length > 0) { this._deleteList.forEach(ink => { + ink.Document.opacity = 1; ink.props.removeDocument?.(ink.props.Document); }); } this._prevPoint = this._currPoint = { X: -1, Y: -1 }; this._deleteList = []; + this._batch?.end(); } } } |
