mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Add Eraser 🎉 (#4887)
* feat: Add Eraser 🎉
* Eraser working
* remove unused state
* fix
* toggle eraser
* Support deselect with Alt/Option
* rename actionDelete -> actionErase
* Add util isEraserActive
* show eraser in mobile
* render eraser conditionally in mobile
* use selection if eraser in local storage state
* Add sampling to erase accurately
* use pointerDownState
* set eraser to false in AllowedExcalidrawElementTypes
* rename/reword fixes
* don't use updateScene
* handle bound text when erasing
* fix hover state in mobile
* consider all hitElements instead of a single
* code improvements
* revert to select if eraser active and elements selected
* show eraser in zenmode
* erase element when clicked on element while eraser active
* set groupIds to empty when eraser active
* fix test
* remove dragged distance
This commit is contained in:
parent
5c0eff50a0
commit
7daf1a7944
18 changed files with 233 additions and 32 deletions
|
@ -8,7 +8,7 @@ import { NonDeletedExcalidrawElement } from "../element/types";
|
|||
import { FixedSideContainer } from "./FixedSideContainer";
|
||||
import { Island } from "./Island";
|
||||
import { HintViewer } from "./HintViewer";
|
||||
import { calculateScrollCenter } from "../scene";
|
||||
import { calculateScrollCenter, getSelectedElements } from "../scene";
|
||||
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
||||
import { Section } from "./Section";
|
||||
import CollabButton from "./CollabButton";
|
||||
|
@ -113,6 +113,12 @@ export const MobileMenu = ({
|
|||
};
|
||||
|
||||
const renderAppToolbar = () => {
|
||||
// Render eraser conditionally in mobile
|
||||
const showEraser =
|
||||
!appState.viewModeEnabled &&
|
||||
!appState.editingElement &&
|
||||
getSelectedElements(elements, appState).length === 0;
|
||||
|
||||
if (viewModeEnabled) {
|
||||
return (
|
||||
<div className="App-toolbar-content">
|
||||
|
@ -120,12 +126,16 @@ export const MobileMenu = ({
|
|||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="App-toolbar-content">
|
||||
{actionManager.renderAction("toggleCanvasMenu")}
|
||||
{actionManager.renderAction("toggleEditMenu")}
|
||||
|
||||
{actionManager.renderAction("undo")}
|
||||
{actionManager.renderAction("redo")}
|
||||
{showEraser && actionManager.renderAction("eraser")}
|
||||
|
||||
{actionManager.renderAction(
|
||||
appState.multiElement ? "finalize" : "duplicateSelection",
|
||||
)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue