0b3e83be52
This PR: - adds a `snapshot` prop to the <Tldraw> component. It does basically the same thing as calling `loadSnapshot` after creating the store, but happens before the editor actually loads. - adds a largeish example (including a JSON snapshot) to the examples We have some very complex ways of juggling serialized data between multiplayer, file formats, and the snapshot APIs. I'd like to see these simplified, or at least for our documentation to reflect a narrow subset of all the options available. The most common questions seem to be: Q: How do I serialize data? A: Via the `Editor.getSnapshot()` method Q: How do I restore serialized data? A: Via the `Editor.loadSnapshot()` method OR via the `<Tldraw>` component's `snapshot` prop The store has an `initialData` constructor prop, however this is quite complex as the store also requires a schema class instance with which to migrate the data. In our components (<Tldraw> and <TldrawEditor>) we were also accepting `initialData`, however we weren't accepting a schema, and either way I think it's unrealistic to also expect users to create schemas themselves and pass those in. AFAIK the `initialData` prop is only used in the file loading, which is a good example of how complex it looks like to create a schema and migrate data outside of the components. ### Change Type - [x] `minor` — New feature |
||
---|---|---|
.. | ||
export-snapshots.spec.ts-snapshots | ||
export-snapshots.spec.ts | ||
test-camera.spec.ts | ||
test-canvas-events.spec.ts | ||
test-clipboard.spec.ts | ||
test-focus.spec.ts | ||
test-kbds.spec.ts | ||
test-routes.spec.ts | ||
test-shapes.spec.ts | ||
test-smoke.spec.ts | ||
test-text.spec.ts |