tldraw/packages
David Sheldrick 25dcc29803
Cropping undo/redo UX (#3891)
This PR aims to improve the UX around undo/redo and cropping. Before the
PR if you do some cropping, then stop cropping, then hit `undo`, you
will end up back in the cropping state and it will undo each of your
resize/translate cropping operations individually. This is weird 🙅🏼 It
should just undo the whole sequence of changes that happened during
cropping.

To achieve that, this PR introduces a new history method called
`squashToMark`, which strips out all the marks between the current head
of the undo stack and the mark id you pass in.

This PR also makes the default history record mode of
`updateCurrentPageState` to `ignore` like it already was for
`updateInstanceState`. The fact that it was recording changes to the
`croppingShapeId` was the reason that hitting undo would put you back
into the cropping state.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [x] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [x] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know


### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Add a brief release note for your PR here.
2024-06-11 06:13:03 +00:00
..
assets Add heart geo shape (#3787) 2024-05-24 13:04:28 +00:00
dotcom-shared Force interface instead of type for better docs (#3815) 2024-05-22 15:55:49 +00:00
editor Cropping undo/redo UX (#3891) 2024-06-11 06:13:03 +00:00
namespaced-tldraw Don't check api.json files into git (#3565) 2024-04-24 15:58:26 +00:00
state make sure everything marked @public gets documented (#3892) 2024-06-10 13:50:03 +00:00
store make sure everything marked @public gets documented (#3892) 2024-06-10 13:50:03 +00:00
tldraw Cropping undo/redo UX (#3891) 2024-06-11 06:13:03 +00:00
tlschema make sure everything marked @public gets documented (#3892) 2024-06-10 13:50:03 +00:00
tlsync [DX] sensible defaults for createTLStore (#3886) 2024-06-05 14:29:54 +00:00
utils make sure everything marked @public gets documented (#3892) 2024-06-10 13:50:03 +00:00
validate make sure everything marked @public gets documented (#3892) 2024-06-10 13:50:03 +00:00