tldraw/apps/examples/e2e/tests
Steve Ruiz 0b3e83be52
Add snapshot prop, examples (#1856)
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
2023-09-08 14:48:55 +00:00
..
export-snapshots.spec.ts-snapshots ShapeUtil.getGeometry, selection rewrite (#1751) 2023-07-25 16:10:15 +00:00
export-snapshots.spec.ts ShapeUtil.getGeometry, selection rewrite (#1751) 2023-07-25 16:10:15 +00:00
test-camera.spec.ts Add playwright tests (#1484) 2023-05-30 15:28:56 +01:00
test-canvas-events.spec.ts ShapeUtil.getGeometry, selection rewrite (#1751) 2023-07-25 16:10:15 +00:00
test-clipboard.spec.ts Rename shapes apis (#1787) 2023-08-02 18:12:25 +00:00
test-focus.spec.ts More cleanup, focus bug fixes (#1749) 2023-07-19 10:52:21 +00:00
test-kbds.spec.ts Fix e2e test (#1748) 2023-07-18 22:13:11 +00:00
test-routes.spec.ts Add snapshot prop, examples (#1856) 2023-09-08 14:48:55 +00:00
test-shapes.spec.ts Add cloud shape (#1708) 2023-07-07 15:32:08 +00:00
test-smoke.spec.ts rename app to editor (#1503) 2023-06-02 15:21:45 +00:00
test-text.spec.ts rename app to editor (#1503) 2023-06-02 15:21:45 +00:00