mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Eraser toggle to switch back to the previous tool (#4981)
* add typeBeforeEraser * ESC to switch to lastActiveToolBeforeEraser
This commit is contained in:
parent
f242721f3b
commit
1331cffe93
3 changed files with 24 additions and 6 deletions
|
@ -310,12 +310,25 @@ export const actionErase = register({
|
|||
...appState,
|
||||
selectedElementIds: {},
|
||||
selectedGroupIds: {},
|
||||
activeTool: { type: isEraserActive(appState) ? "selection" : "eraser" },
|
||||
activeTool: {
|
||||
type: isEraserActive(appState)
|
||||
? appState.activeTool.lastActiveToolBeforeEraser ?? "selection"
|
||||
: "eraser",
|
||||
lastActiveToolBeforeEraser:
|
||||
appState.activeTool.type === "eraser" //node throws incorrect type error when using isEraserActive()
|
||||
? undefined
|
||||
: appState.activeTool.type,
|
||||
},
|
||||
},
|
||||
commitToHistory: true,
|
||||
};
|
||||
},
|
||||
keyTest: (event) => event.key === KEYS.E,
|
||||
keyTest: (event, appState) => {
|
||||
return (
|
||||
event.key === KEYS.E ||
|
||||
(event.key === KEYS.ESCAPE && isEraserActive(appState))
|
||||
);
|
||||
},
|
||||
PanelComponent: ({ elements, appState, updateData, data }) => (
|
||||
<ToolButton
|
||||
type="button"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue