From 324449b715942a2dcc02f959fd89016812671d26 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Fri, 14 Nov 2025 14:36:56 -0800 Subject: [PATCH] chore: remove erasing --- client-src/views/draw/state/state.ts | 97 +--------------------------- client-src/views/draw/state/types.ts | 4 +- 2 files changed, 3 insertions(+), 98 deletions(-) diff --git a/client-src/views/draw/state/state.ts b/client-src/views/draw/state/state.ts index 8e1b995..d49a825 100644 --- a/client-src/views/draw/state/state.ts +++ b/client-src/views/draw/state/state.ts @@ -90,16 +90,6 @@ export class AppState extends StateManager { this.createDrawingShape(info.point); break; } - case "erasing": { - this.setSnapshot(); - this.patchState({ - appState: { - status: "erasing", - }, - }); - this.erase(info.point); - break; - } } }; @@ -124,12 +114,6 @@ export class AppState extends StateManager { } break; } - case "erasing": { - if (status === "erasing") { - this.erase(info.point); - } - break; - } } }; @@ -140,20 +124,6 @@ export class AppState extends StateManager { this.completeDrawingShape(); break; } - case "erasing": { - this.setState({ - before: this.snapshot, - after: { - appState: { - status: "idle", - }, - page: { - shapes: this.state.page.shapes, - }, - }, - }); - break; - } } }; @@ -247,7 +217,7 @@ export class AppState extends StateManager { completeDrawingShape = () => { const { state } = this; const { shapes } = state.page; - if (!state.appState.editingId) return this; // Don't erase while drawing + if (!state.appState.editingId) return this; let shape = shapes[state.appState.editingId]; @@ -299,8 +269,6 @@ export class AppState extends StateManager { }; replayShape = (points: number[][]) => { - this.eraseAll(); - const newShape = draw.create({ id: Utils.uniqueId(), parentId: "page", @@ -369,62 +337,7 @@ export class AppState extends StateManager { return newShape; }; - erase = (point: number[]) => { - const { state } = this; - const camera = state.pageState.camera; - const pt = Vec.sub(point, camera.point); - const { getBounds } = shapeUtils.draw; - - return this.patchState({ - page: { - shapes: { - ...Object.fromEntries( - Object.entries(state.page.shapes).map(([id, shape]) => { - const bounds = getBounds(shape); - - if (Vec.dist(pt, shape.point) < 10) { - return [id, undefined]; - } - - if (Utils.pointInBounds(pt, bounds)) { - const points = draw.strokeCache.get(shape); - - if ( - (points && - pointInPolygon(Vec.sub(pt, shape.point), points)) || - Vec.dist(pt, shape.point) < 10 - ) { - return [id, undefined]; - } - } - - return [id, shape]; - }), - ), - }, - }, - }); - }; - - eraseAll = () => { - const { state } = this; - const { shapes } = state.page; - - if (state.appState.editingId) return this; // Don't erase while drawing - return this.setState({ - before: { - page: { - shapes, - }, - }, - after: { - page: { - shapes: {}, - }, - }, - }); - }; startStyleUpdate = () => { return this.setSnapshot(); @@ -704,14 +617,6 @@ export class AppState extends StateManager { }, }); }; - - selectErasingTool = () => { - this.patchState({ - appState: { - tool: "erasing", - }, - }); - }; } export const app = new AppState( diff --git a/client-src/views/draw/state/types.ts b/client-src/views/draw/state/types.ts index ab2322a..79858a8 100644 --- a/client-src/views/draw/state/types.ts +++ b/client-src/views/draw/state/types.ts @@ -34,8 +34,8 @@ export interface Doc { export interface State extends Doc { appState: { - status: "idle" | "drawing" | "erasing"; - tool: "drawing" | "erasing"; + status: "idle" | "drawing"; + tool: "drawing"; editingId?: string; style: DrawStyles; isPanelOpen: boolean; -- 2.51.2