Closed juliusgb closed 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?
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
Api
Api.reset
useStateDesigner
machine
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.
.tldr
fileA
fileB
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.
Using app.resetDocument() brings me closer to the goal.
app.resetDocument()
seems like it works for you! so gonna close this for now
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?
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
, callApi.reset
, and all's well. But how to get Api seems to require dependencies that I'd like to avoid touching 😅 likeuseStateDesigner
,machine
, etc -> https://github.com/tldraw/tldraw/blob/main/examples/core-example-advanced/src/App.tsx#L184Reason 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.fileA
- has some drawings (state) & clost it.fileB
- has no drawings & close it.Problematic part: open
fileB
, don't close it. Then openfileA
. Expecting to seefileB
, but still seingfileA
.If I can clear tldraw's state/history when
fileA
disappears, then I can loadfileA
again when its opened.