Repository navigation
Real eraser: erasing splits or removes what it touches - #66
Merged
Merged
Conversation
…ring an eraser stroke - On pen-up an eraser stroke becomes edits (src/lib/eraserEdits.ts): pen, highlighter, spray, straight lines and shape-brush strokes are split into what's left; fully covered ink, notes and stamps are removed; no eraser element is stored. Rectangles and circles it only partly covers keep a trimmed piece of eraser over just them. - New elements-replace event applies the edits in place (src/lib/elementGroups.ts), so stacking order never changes and one undo restores everything exactly. - Tests: tests/eraserEdits.test.ts (geometry, order, undo, server sync and permissions) and e2e/eraser.spec.ts (shape brush split, second screen, undo, full erase). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"N drawn" in the sidebar is only the viewer's own count, so the second student's screen always read "0 drawn" for Alex's ink. Join the second browser as the teacher and read Alex's live item count on the Class tab, the same way classroom.spec.ts checks ink sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Before: the eraser saved a white "eraser stroke" that only hid ink at render time. Each swipe made a board heavier. Erased notes and strokes still existed, still showed up in lasso selection, and still counted in "N drawn".
After: when the pen lifts, the eraser stroke becomes real edits and no eraser stroke is stored.
How:
src/lib/eraserEdits.tsworks out the edits. It only touches the eraser's own author's ink drawn before the eraser, the same rule as before.elements-replaceevent (src/lib/elementGroups.ts). Each group removes ids and inserts the new elements where the first of them was, so stacking order never changes.groupshistory step. A fully removed element is put back right after the element that preceded it.Tests:
tests/eraserEdits.test.tscovers splitting, long segments, full removal, other people's ink, shape-brush pieces, notes and stamps, the partial rectangle, and an exact undo/redo round trip. It also covers the server: sync to a second screen, a late joiner's view, undo, and refusing to remove other people's ink.e2e/eraser.spec.tscovers a shape-brush stroke split, a second screen, undo and full erase. It couldn't run in my environment (no browser), so CI is its first run.Closes the TODO.md item "A real eraser".
Generated by Claude Code