tldraw / tldraw-v1

A tiny little drawing app. This is the original 2021-2022 version, released under MIT.
https://old.tldraw.com
MIT License
61 stars 36 forks source link

[feature] Clear history or reset internal state so that the tldraw canvas becomes blank #91

Closed juliusgb closed 1 year ago

juliusgb commented 1 year ago

Is there a way to clear the history and to do a reset so that the tldraw canvas becomes blank, just like in Excalidraw - https://codesandbox.io/s/excalidraw-ehlz3?

ExcalidrawReset

This looked promising but seems to require to go into the lower-levels to make changes -> https://github.com/tldraw/tldraw/blob/main/examples/core-example-advanced/src/state/api.ts#L36

I thought I'd somehow get Api, call Api.reset, and all's well. But how to get Api seems to require dependencies that I'd like to avoid touching 😅 like useStateDesigner, machine, etc -> https://github.com/tldraw/tldraw/blob/main/examples/core-example-advanced/src/App.tsx#L184

Reason I want to clear it is so that when i open another .tldr file on top another one, then the new file's content should be displayed.

Problematic part: open fileB, don't close it. Then open fileA. Expecting to see fileB, but still seing fileA.

If I can clear tldraw's state/history when fileA disappears, then I can load fileA again when its opened.

WithoutReset

juliusgb commented 1 year ago

Using app.resetDocument() brings me closer to the goal.

judicaelandria commented 1 year ago

seems like it works for you! so gonna close this for now