Repository navigation
feat(canvas): implement core element locking with eraser immunity - #38
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces core canvas element locking capabilities to protect elements from accidental modifications or deletions. It includes robust hit-testing exclusions for locked elements (making them immune to eraser and selection dragging unless specifically overridden), visual overlays with a lock badge and dashed selection bounds, keybinding support for toggling locks (
Cmd/Ctrl + Shift + L), and history undo/redo compatibility.Closes: #29
Key Changes
lockedproperty to canvas element types, implementedSetElementsLockCommandin the history stack, and registered theselection.toggle_lockcommand.hitTestPointandhitTestMarqueeto ignore locked elements by default unless specified via options (e.g., holdingShiftduring marquee selection allows selecting locked elements).SelectionOverlayto hide resize handles, display a dashed stroke, and render a lock HUD badge when locked elements are selected.<D-S-l>) and Visual Mode action definitions for toggling locks.ClearCanvasCommandso that locked elements are preserved when clearing the canvas.Verification & Testing
HitTester.test.tsverifying marquee and point hit-testing behaviors withignoreLockedandincludeLockedoptions.PointerRouter.test.tsfor eraser tool immunity, selecting locked elements without drag mobility, and Shift-marquee multi-selection.SelectionOverlay.test.tsxandCommandRegistry.test.tsfor lock badges and command execution/history undo/redo.npm testor the workspace test runner to verify all canvas interaction and state unit tests pass successfully.