From 2fa69ddc329c327458d50ce6efde65d4e247b175 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 29 Mar 2022 17:10:19 +0530 Subject: [PATCH] refactor: move elementLocked to activeTool.locked (#4983) * refactor: move elementLocked to activeTool.locked * fix * fix snap * update docs * Update src/packages/excalidraw/CHANGELOG.md * revert * make lastActiveToolBeforeEraser required and nullable * fix snap --- src/actions/actionCanvas.tsx | 6 +- src/actions/actionDeleteSelected.tsx | 2 +- src/actions/actionFinalize.tsx | 15 +- src/appState.ts | 8 +- src/components/Actions.tsx | 2 +- src/components/App.tsx | 51 +++--- src/components/LayerUI.tsx | 2 +- src/components/MobileMenu.tsx | 2 +- src/data/restore.ts | 5 +- src/packages/excalidraw/CHANGELOG.md | 8 +- .../__snapshots__/contextmenu.test.tsx.snap | 48 ++++-- .../regressionTests.test.tsx.snap | 156 ++++++++++++------ .../packages/__snapshots__/utils.test.ts.snap | 3 +- src/types.ts | 4 +- 14 files changed, 199 insertions(+), 113 deletions(-) diff --git a/src/actions/actionCanvas.tsx b/src/actions/actionCanvas.tsx index b83bf679..dd88c73c 100644 --- a/src/actions/actionCanvas.tsx +++ b/src/actions/actionCanvas.tsx @@ -62,7 +62,6 @@ export const actionClearCanvas = register({ ...getDefaultAppState(), files: {}, theme: appState.theme, - elementLocked: appState.elementLocked, penMode: appState.penMode, penDetected: appState.penDetected, exportBackground: appState.exportBackground, @@ -72,7 +71,7 @@ export const actionClearCanvas = register({ pasteDialog: appState.pasteDialog, activeTool: appState.activeTool.type === "image" - ? { type: "selection" } + ? { ...appState.activeTool, type: "selection" } : appState.activeTool, }, commitToHistory: true, @@ -311,12 +310,13 @@ export const actionErase = register({ selectedElementIds: {}, selectedGroupIds: {}, activeTool: { + ...appState.activeTool, type: isEraserActive(appState) ? appState.activeTool.lastActiveToolBeforeEraser ?? "selection" : "eraser", lastActiveToolBeforeEraser: appState.activeTool.type === "eraser" //node throws incorrect type error when using isEraserActive() - ? undefined + ? null : appState.activeTool.type, }, }, diff --git a/src/actions/actionDeleteSelected.tsx b/src/actions/actionDeleteSelected.tsx index 7079936e..d7836314 100644 --- a/src/actions/actionDeleteSelected.tsx +++ b/src/actions/actionDeleteSelected.tsx @@ -134,7 +134,7 @@ export const actionDeleteSelected = register({ elements: nextElements, appState: { ...nextAppState, - activeTool: { type: "selection" }, + activeTool: { ...appState.activeTool, type: "selection" }, multiElement: null, }, commitToHistory: isSomeElementSelected( diff --git a/src/actions/actionFinalize.tsx b/src/actions/actionFinalize.tsx index e129a93e..25d528bf 100644 --- a/src/actions/actionFinalize.tsx +++ b/src/actions/actionFinalize.tsx @@ -121,13 +121,17 @@ export const actionFinalize = register({ ); } - if (!appState.elementLocked && appState.activeTool.type !== "freedraw") { + if ( + !appState.activeTool.locked && + appState.activeTool.type !== "freedraw" + ) { appState.selectedElementIds[multiPointElement.id] = true; } } if ( - (!appState.elementLocked && appState.activeTool.type !== "freedraw") || + (!appState.activeTool.locked && + appState.activeTool.type !== "freedraw") || !multiPointElement ) { resetCursor(canvas); @@ -138,10 +142,11 @@ export const actionFinalize = register({ appState: { ...appState, activeTool: - (appState.elementLocked || appState.activeTool.type === "freedraw") && + (appState.activeTool.locked || + appState.activeTool.type === "freedraw") && multiPointElement ? appState.activeTool - : { type: "selection" }, + : { ...appState.activeTool, type: "selection" }, draggingElement: null, multiElement: null, editingElement: null, @@ -149,7 +154,7 @@ export const actionFinalize = register({ suggestedBindings: [], selectedElementIds: multiPointElement && - !appState.elementLocked && + !appState.activeTool.locked && appState.activeTool.type !== "freedraw" ? { ...appState.selectedElementIds, diff --git a/src/appState.ts b/src/appState.ts index 550eaabf..f906f527 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -41,8 +41,11 @@ export const getDefaultAppState = (): Omit< editingElement: null, editingGroupId: null, editingLinearElement: null, - elementLocked: false, - activeTool: { type: "selection" }, + activeTool: { + type: "selection", + locked: false, + lastActiveToolBeforeEraser: null, + }, penMode: false, penDetected: false, errorMessage: null, @@ -130,7 +133,6 @@ const APP_STATE_STORAGE_CONF = (< editingElement: { browser: false, export: false, server: false }, editingGroupId: { browser: true, export: false, server: false }, editingLinearElement: { browser: false, export: false, server: false }, - elementLocked: { browser: true, export: false, server: false }, activeTool: { browser: true, export: false, server: false }, penMode: { browser: true, export: false, server: false }, penDetected: { browser: true, export: false, server: false }, diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx index a7cc92bf..347e3453 100644 --- a/src/components/Actions.tsx +++ b/src/components/Actions.tsx @@ -220,7 +220,7 @@ export const ShapesSwitcher = ({ }); } setAppState({ - activeTool: { type: activeToolType }, + activeTool: { ...activeTool, type: activeToolType }, multiElement: null, selectedElementIds: {}, }); diff --git a/src/components/App.tsx b/src/components/App.tsx index 1d9bc12e..9e287d27 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -807,12 +807,11 @@ class App extends React.Component { } const scene = restore(initialData, null, null); - scene.appState = { ...scene.appState, activeTool: scene.appState.activeTool.type === "image" - ? { type: "selection" } + ? { ...scene.appState.activeTool, type: "selection" } : scene.appState.activeTool, isLoading: false, }; @@ -1067,7 +1066,9 @@ class App extends React.Component { Object.keys(this.state.selectedElementIds).length && isEraserActive(this.state) ) { - this.setState({ activeTool: { type: "selection" } }); + this.setState({ + activeTool: { ...this.state.activeTool, type: "selection" }, + }); } if (prevState.theme !== this.state.theme) { setEraserCursor(this.canvas, this.state.theme); @@ -1431,7 +1432,7 @@ class App extends React.Component { } else if (data.text) { this.addTextFromPaste(data.text); } - this.setActiveTool({ type: "selection" }); + this.setActiveTool({ ...this.state.activeTool, type: "selection" }); event?.preventDefault(); }, ); @@ -1519,7 +1520,7 @@ class App extends React.Component { } }, ); - this.setActiveTool({ type: "selection" }); + this.setActiveTool({ ...this.state.activeTool, type: "selection" }); }; private addTextFromPaste(text: any) { @@ -1569,7 +1570,7 @@ class App extends React.Component { }; toggleLock = (source: "keyboard" | "ui" = "ui") => { - if (!this.state.elementLocked) { + if (!this.state.activeTool.locked) { trackEvent( "toolbar", "toggleLock", @@ -1578,10 +1579,13 @@ class App extends React.Component { } this.setState((prevState) => { return { - elementLocked: !prevState.elementLocked, - activeTool: prevState.elementLocked - ? { type: "selection" } - : prevState.activeTool, + activeTool: { + ...prevState.activeTool, + locked: !prevState.activeTool.locked, + type: prevState.activeTool.locked + ? "selection" + : prevState.activeTool.type, + }, }; }); }; @@ -1860,7 +1864,7 @@ class App extends React.Component { `keyboard (${this.deviceType.isMobile ? "mobile" : "desktop"})`, ); } - this.setActiveTool({ type: shape }); + this.setActiveTool({ ...this.state.activeTool, type: shape }); } else if (event.key === KEYS.Q) { this.toggleLock("keyboard"); } @@ -2073,7 +2077,7 @@ class App extends React.Component { draggingElement: null, editingElement: null, }); - if (this.state.elementLocked) { + if (this.state.activeTool.locked) { setCursorForShape(this.canvas, this.state); } @@ -3556,7 +3560,7 @@ class App extends React.Component { ): void => { // if we're currently still editing text, clicking outside // should only finalize it, not create another (irrespective - // of state.elementLocked) + // of state.activeTool.locked) if (isTextElement(this.state.editingElement)) { return; } @@ -3580,9 +3584,9 @@ class App extends React.Component { }); resetCursor(this.canvas); - if (!this.state.elementLocked) { + if (!this.state.activeTool.locked) { this.setState({ - activeTool: { type: "selection" }, + activeTool: { ...this.state.activeTool, type: "selection" }, }); } }; @@ -4227,7 +4231,6 @@ class App extends React.Component { resizingElement, multiElement, activeTool, - elementLocked, isResizing, isRotating, } = this.state; @@ -4391,11 +4394,11 @@ class App extends React.Component { ); } this.setState({ suggestedBindings: [], startBoundElement: null }); - if (!elementLocked) { + if (!activeTool.locked) { resetCursor(this.canvas); this.setState((prevState) => ({ draggingElement: null, - activeTool: { type: "selection" }, + activeTool: { ...prevState.activeTool, type: "selection" }, selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, @@ -4584,7 +4587,11 @@ class App extends React.Component { return; } - if (!elementLocked && activeTool.type !== "freedraw" && draggingElement) { + if ( + !activeTool.locked && + activeTool.type !== "freedraw" && + draggingElement + ) { this.setState((prevState) => ({ selectedElementIds: { ...prevState.selectedElementIds, @@ -4608,12 +4615,12 @@ class App extends React.Component { ); } - if (!elementLocked && activeTool.type !== "freedraw") { + if (!activeTool.locked && activeTool.type !== "freedraw") { resetCursor(this.canvas); this.setState({ draggingElement: null, suggestedBindings: [], - activeTool: { type: "selection" }, + activeTool: { ...activeTool, type: "selection" }, }); } else { this.setState({ @@ -4919,7 +4926,7 @@ class App extends React.Component { { pendingImageElement: null, editingElement: null, - activeTool: { type: "selection" }, + activeTool: { ...this.state.activeTool, type: "selection" }, }, () => { this.actionManager.executeAction(actionFinalize); diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index 9792f38e..fbe416dc 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -327,7 +327,7 @@ const LayerUI = ({ /> onLockToggle()} title={t("toolBar.lock")} /> diff --git a/src/components/MobileMenu.tsx b/src/components/MobileMenu.tsx index 7a928fb4..9b40a437 100644 --- a/src/components/MobileMenu.tsx +++ b/src/components/MobileMenu.tsx @@ -86,7 +86,7 @@ export const MobileMenu = ({ {renderTopRightUI && renderTopRightUI(true, appState)} | null | undefined, ): RestoredAppState => { appState = appState || {}; - const defaultAppState = getDefaultAppState(); const nextAppState = {} as typeof defaultAppState; - for (const [key, defaultValue] of Object.entries(defaultAppState) as [ keyof typeof defaultAppState, any, @@ -252,12 +250,11 @@ export const restoreAppState = ( ? localValue : defaultValue; } - return { ...nextAppState, activeTool: AllowedExcalidrawActiveTools[nextAppState.activeTool.type] ? nextAppState.activeTool - : { type: "selection" }, + : { ...nextAppState.activeTool, type: "selection" }, // Migrates from previous version where appState.zoom was a number zoom: typeof appState.zoom === "number" diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.md index bacc7606..23badc8e 100644 --- a/src/packages/excalidraw/CHANGELOG.md +++ b/src/packages/excalidraw/CHANGELOG.md @@ -17,7 +17,13 @@ Please add the latest change on the top under the correct section. #### Refactor -- Rename `appState.elementType` to [`appState.activeTool`](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L80) which is now an object. +- Rename `appState.elementLocked` to `appState.activeTool.locked` [#4983](https://github.com/excalidraw/excalidraw/pull/4983). + +##### BREAKING CHANGE + +You will need to pass `activeTool.locked` instead of `elementType` from now onwards in `appState`. + +- Rename `appState.elementType` to [`appState.activeTool`](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L80) which is now an object [#4698](https://github.com/excalidraw/excalidraw/pull/4968). ##### BREAKING CHANGE diff --git a/src/tests/__snapshots__/contextmenu.test.tsx.snap b/src/tests/__snapshots__/contextmenu.test.tsx.snap index 1f9b7f00..7d5029a9 100644 --- a/src/tests/__snapshots__/contextmenu.test.tsx.snap +++ b/src/tests/__snapshots__/contextmenu.test.tsx.snap @@ -3,6 +3,8 @@ exports[`contextMenu element selecting 'Add to library' in context menu adds element to library: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -26,7 +28,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -176,6 +177,8 @@ exports[`contextMenu element selecting 'Add to library' in context menu adds ele exports[`contextMenu element selecting 'Bring forward' in context menu brings element forward: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -199,7 +202,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -505,6 +507,8 @@ exports[`contextMenu element selecting 'Bring forward' in context menu brings el exports[`contextMenu element selecting 'Bring to front' in context menu brings element to front: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -528,7 +532,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -834,6 +837,8 @@ exports[`contextMenu element selecting 'Bring to front' in context menu brings e exports[`contextMenu element selecting 'Copy styles' in context menu copies styles: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -857,7 +862,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -1007,6 +1011,8 @@ exports[`contextMenu element selecting 'Copy styles' in context menu copies styl exports[`contextMenu element selecting 'Delete' in context menu deletes element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -1030,7 +1036,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -1215,6 +1220,8 @@ exports[`contextMenu element selecting 'Delete' in context menu deletes element: exports[`contextMenu element selecting 'Duplicate' in context menu duplicates element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -1238,7 +1245,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -1480,6 +1486,8 @@ exports[`contextMenu element selecting 'Duplicate' in context menu duplicates el exports[`contextMenu element selecting 'Group selection' in context menu groups selected elements: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -1503,7 +1511,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -1827,6 +1834,8 @@ exports[`contextMenu element selecting 'Group selection' in context menu groups exports[`contextMenu element selecting 'Paste styles' in context menu pastes styles: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -1850,7 +1859,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -2604,6 +2612,8 @@ exports[`contextMenu element selecting 'Paste styles' in context menu pastes sty exports[`contextMenu element selecting 'Send backward' in context menu sends element backward: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -2627,7 +2637,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -2933,6 +2942,8 @@ exports[`contextMenu element selecting 'Send backward' in context menu sends ele exports[`contextMenu element selecting 'Send to back' in context menu sends element to back: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -2956,7 +2967,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -3262,6 +3272,8 @@ exports[`contextMenu element selecting 'Send to back' in context menu sends elem exports[`contextMenu element selecting 'Ungroup selection' in context menu ungroups selected group: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3285,7 +3297,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -3669,6 +3680,8 @@ exports[`contextMenu element selecting 'Ungroup selection' in context menu ungro exports[`contextMenu element shows 'Group selection' in context menu for multiple selected elements: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3692,7 +3705,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -3940,6 +3952,8 @@ exports[`contextMenu element shows 'Group selection' in context menu for multipl exports[`contextMenu element shows 'Ungroup selection' in context menu for group inside selected elements: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3963,7 +3977,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -4290,6 +4303,8 @@ exports[`contextMenu element shows 'Ungroup selection' in context menu for group exports[`contextMenu element shows context menu for canvas: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -4313,7 +4328,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -4394,6 +4408,8 @@ exports[`contextMenu element shows context menu for canvas: [end of test] number exports[`contextMenu element shows context menu for element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -4417,7 +4433,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -4476,6 +4491,8 @@ Object { exports[`contextMenu element shows context menu for element: [end of test] appState 2`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -4499,7 +4516,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, diff --git a/src/tests/__snapshots__/regressionTests.test.tsx.snap b/src/tests/__snapshots__/regressionTests.test.tsx.snap index d3bf0703..e6ef53c1 100644 --- a/src/tests/__snapshots__/regressionTests.test.tsx.snap +++ b/src/tests/__snapshots__/regressionTests.test.tsx.snap @@ -3,6 +3,8 @@ exports[`given element A and group of elements B and given both are selected when user clicks on B, on pointer up only elements from B should be selected: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -26,7 +28,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -498,6 +499,8 @@ exports[`given element A and group of elements B and given both are selected whe exports[`given element A and group of elements B and given both are selected when user shift-clicks on B, on pointer up only element A should be selected: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -521,7 +524,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -999,6 +1001,8 @@ exports[`given element A and group of elements B and given both are selected whe exports[`regression tests Cmd/Ctrl-click exclusively select element under pointer: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -1022,7 +1026,6 @@ Object { "editingElement": null, "editingGroupId": "id10", "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -1835,6 +1838,8 @@ exports[`regression tests Cmd/Ctrl-click exclusively select element under pointe exports[`regression tests Drags selected element when hitting only bounding box and keeps element selected: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -1858,7 +1863,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -2051,6 +2055,8 @@ exports[`regression tests Drags selected element when hitting only bounding box exports[`regression tests adjusts z order when grouping: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -2074,7 +2080,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -2543,6 +2548,8 @@ exports[`regression tests adjusts z order when grouping: [end of test] number of exports[`regression tests alt-drag duplicates an element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -2566,7 +2573,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -2812,6 +2818,8 @@ exports[`regression tests alt-drag duplicates an element: [end of test] number o exports[`regression tests arrow keys: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -2835,7 +2843,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -2985,6 +2992,8 @@ exports[`regression tests arrow keys: [end of test] number of renders 1`] = `20` exports[`regression tests can drag element that covers another element, while another elem is selected: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3008,7 +3017,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -3460,6 +3468,8 @@ exports[`regression tests can drag element that covers another element, while an exports[`regression tests change the properties of a shape: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3483,7 +3493,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -3711,6 +3720,8 @@ exports[`regression tests change the properties of a shape: [end of test] number exports[`regression tests click on an element and drag it: [dragged] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3734,7 +3745,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -3927,6 +3937,8 @@ exports[`regression tests click on an element and drag it: [dragged] number of r exports[`regression tests click on an element and drag it: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -3950,7 +3962,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -4186,6 +4197,8 @@ exports[`regression tests click on an element and drag it: [end of test] number exports[`regression tests click to select a shape: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -4209,7 +4222,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -4454,6 +4466,8 @@ exports[`regression tests click to select a shape: [end of test] number of rende exports[`regression tests click-drag to select a group: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -4477,7 +4491,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -4840,6 +4853,8 @@ exports[`regression tests click-drag to select a group: [end of test] number of exports[`regression tests deselects group of selected elements on pointer down when pointer doesn't hit any element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -4887,7 +4902,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -5155,6 +5169,8 @@ exports[`regression tests deselects group of selected elements on pointer down w exports[`regression tests deselects group of selected elements on pointer up when pointer hits common bounding box without hitting any element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -5202,7 +5218,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -5446,6 +5461,8 @@ exports[`regression tests deselects group of selected elements on pointer up whe exports[`regression tests deselects selected element on pointer down when pointer doesn't hit any element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -5493,7 +5510,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -5667,6 +5683,8 @@ exports[`regression tests deselects selected element on pointer down when pointe exports[`regression tests deselects selected element, on pointer up, when click hits element bounding box but doesn't hit the element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -5714,7 +5732,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -5864,6 +5881,8 @@ exports[`regression tests deselects selected element, on pointer up, when click exports[`regression tests double click to edit a group: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -5887,7 +5906,6 @@ Object { "editingElement": null, "editingGroupId": "id3", "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -6351,6 +6369,8 @@ exports[`regression tests double click to edit a group: [end of test] number of exports[`regression tests drags selected elements from point inside common bounding box that doesn't hit any element and keeps elements selected after dragging: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -6374,7 +6394,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -6690,6 +6709,8 @@ exports[`regression tests drags selected elements from point inside common bound exports[`regression tests draw every type of shape: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "freedraw", }, "collaborators": Map {}, @@ -6713,7 +6734,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -8870,6 +8890,8 @@ exports[`regression tests draw every type of shape: [end of test] number of rend exports[`regression tests given a group of selected elements with an element that is not selected inside the group common bounding box when element that is not selected is clicked should switch selection to not selected element on pointer up: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -8893,7 +8915,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -9257,6 +9278,8 @@ exports[`regression tests given a group of selected elements with an element tha exports[`regression tests given a selected element A and a not selected element B with higher z-index than A and given B partially overlaps A when there's a shift-click on the overlapped section B is added to the selection: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -9280,7 +9303,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -9526,6 +9548,8 @@ exports[`regression tests given a selected element A and a not selected element exports[`regression tests given selected element A with lower z-index than unselected element B and given B is partially over A when clicking intersection between A and B B should be selected on pointer up: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -9549,7 +9573,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -9757,6 +9780,8 @@ exports[`regression tests given selected element A with lower z-index than unsel exports[`regression tests given selected element A with lower z-index than unselected element B and given B is partially over A when dragging on intersection between A and B A should be dragged and keep being selected: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -9780,7 +9805,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -10055,6 +10079,8 @@ exports[`regression tests given selected element A with lower z-index than unsel exports[`regression tests key 2 selects rectangle tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -10078,7 +10104,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -10228,6 +10253,8 @@ exports[`regression tests key 2 selects rectangle tool: [end of test] number of exports[`regression tests key 3 selects diamond tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -10251,7 +10278,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -10401,6 +10427,8 @@ exports[`regression tests key 3 selects diamond tool: [end of test] number of re exports[`regression tests key 4 selects ellipse tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -10424,7 +10452,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -10574,6 +10601,8 @@ exports[`regression tests key 4 selects ellipse tool: [end of test] number of re exports[`regression tests key 5 selects arrow tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -10597,7 +10626,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -10777,6 +10805,8 @@ exports[`regression tests key 5 selects arrow tool: [end of test] number of rend exports[`regression tests key 6 selects line tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -10800,7 +10830,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -10980,6 +11009,8 @@ exports[`regression tests key 6 selects line tool: [end of test] number of rende exports[`regression tests key 7 selects freedraw tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "freedraw", }, "collaborators": Map {}, @@ -11003,7 +11034,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -11201,6 +11231,8 @@ exports[`regression tests key 7 selects freedraw tool: [end of test] number of r exports[`regression tests key a selects arrow tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -11224,7 +11256,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -11404,6 +11435,8 @@ exports[`regression tests key a selects arrow tool: [end of test] number of rend exports[`regression tests key d selects diamond tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -11427,7 +11460,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -11577,6 +11609,8 @@ exports[`regression tests key d selects diamond tool: [end of test] number of re exports[`regression tests key l selects line tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -11600,7 +11634,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -11780,6 +11813,8 @@ exports[`regression tests key l selects line tool: [end of test] number of rende exports[`regression tests key o selects ellipse tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -11803,7 +11838,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -11953,6 +11987,8 @@ exports[`regression tests key o selects ellipse tool: [end of test] number of re exports[`regression tests key r selects rectangle tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -11976,7 +12012,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -12126,6 +12161,8 @@ exports[`regression tests key r selects rectangle tool: [end of test] number of exports[`regression tests key x selects freedraw tool: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "freedraw", }, "collaborators": Map {}, @@ -12149,7 +12186,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -12347,6 +12383,8 @@ exports[`regression tests key x selects freedraw tool: [end of test] number of r exports[`regression tests make a group and duplicate it: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -12370,7 +12408,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -13118,6 +13155,8 @@ exports[`regression tests make a group and duplicate it: [end of test] number of exports[`regression tests noop interaction after undo shouldn't create history entry: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -13141,7 +13180,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -13387,6 +13425,8 @@ exports[`regression tests noop interaction after undo shouldn't create history e exports[`regression tests pinch-to-zoom works: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -13410,7 +13450,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -13493,6 +13532,8 @@ exports[`regression tests pinch-to-zoom works: [end of test] number of renders 1 exports[`regression tests rerenders UI on language change: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "rectangle", }, "collaborators": Map {}, @@ -13516,7 +13557,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -13597,6 +13637,8 @@ exports[`regression tests rerenders UI on language change: [end of test] number exports[`regression tests shift click on selected element should deselect it on pointer up: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -13620,7 +13662,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -13773,6 +13814,8 @@ exports[`regression tests shift click on selected element should deselect it on exports[`regression tests shift-click to multiselect, then drag: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -13796,7 +13839,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -14115,6 +14157,8 @@ exports[`regression tests shift-click to multiselect, then drag: [end of test] n exports[`regression tests should show fill icons when element has non transparent background: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -14138,7 +14182,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -14327,6 +14370,8 @@ exports[`regression tests should show fill icons when element has non transparen exports[`regression tests single-clicking on a subgroup of a selected group should not alter selection: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -14350,7 +14395,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -15213,6 +15257,8 @@ exports[`regression tests single-clicking on a subgroup of a selected group shou exports[`regression tests spacebar + drag scrolls the canvas: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -15236,7 +15282,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -15317,6 +15362,8 @@ exports[`regression tests spacebar + drag scrolls the canvas: [end of test] numb exports[`regression tests supports nested groups: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -15340,7 +15387,6 @@ Object { "editingElement": null, "editingGroupId": "id3", "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -16108,6 +16154,8 @@ exports[`regression tests supports nested groups: [end of test] number of render exports[`regression tests switches from group of selected elements to another element on pointer down: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -16155,7 +16203,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -16542,6 +16589,8 @@ exports[`regression tests switches from group of selected elements to another el exports[`regression tests switches selected element on pointer down: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -16589,7 +16638,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -16857,6 +16905,8 @@ exports[`regression tests switches selected element on pointer down: [end of tes exports[`regression tests two-finger scroll works: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -16880,7 +16930,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -16963,6 +17012,8 @@ exports[`regression tests two-finger scroll works: [end of test] number of rende exports[`regression tests undo/redo drawing an element: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -16986,7 +17037,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -17493,6 +17543,8 @@ exports[`regression tests undo/redo drawing an element: [end of test] number of exports[`regression tests updates fontSize & fontFamily appState: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "text", }, "collaborators": Map {}, @@ -17516,7 +17568,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, @@ -17597,6 +17648,8 @@ exports[`regression tests updates fontSize & fontFamily appState: [end of test] exports[`regression tests zoom hotkeys: [end of test] appState 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -17620,7 +17673,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, diff --git a/src/tests/packages/__snapshots__/utils.test.ts.snap b/src/tests/packages/__snapshots__/utils.test.ts.snap index d195ca7c..3c04b7b7 100644 --- a/src/tests/packages/__snapshots__/utils.test.ts.snap +++ b/src/tests/packages/__snapshots__/utils.test.ts.snap @@ -3,6 +3,8 @@ exports[`exportToSvg with default arguments 1`] = ` Object { "activeTool": Object { + "lastActiveToolBeforeEraser": null, + "locked": false, "type": "selection", }, "collaborators": Map {}, @@ -26,7 +28,6 @@ Object { "editingElement": null, "editingGroupId": null, "editingLinearElement": null, - "elementLocked": false, "errorMessage": null, "exportBackground": true, "exportEmbedScene": false, diff --git a/src/types.ts b/src/types.ts index 2b130caf..43f9212e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -79,9 +79,9 @@ export type AppState = { editingLinearElement: LinearElementEditor | null; activeTool: { type: typeof SHAPES[number]["value"] | "eraser"; - lastActiveToolBeforeEraser?: typeof SHAPES[number]["value"]; + lastActiveToolBeforeEraser: typeof SHAPES[number]["value"] | null; + locked: boolean; }; - elementLocked: boolean; penMode: boolean; penDetected: boolean; exportBackground: boolean;