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
14 lines
435 B
JSON
14 lines
435 B
JSON
{
|
|
"extends": "../../config/tsconfig.base.json",
|
|
"include": ["src", "e2e", "./vite.config.ts", "**/*.json"],
|
|
"exclude": ["node_modules", "dist", "**/*.css", ".tsbuild*", "./scripts/legacy-translations"],
|
|
"compilerOptions": {
|
|
"outDir": "./.tsbuild"
|
|
},
|
|
"references": [
|
|
{ "path": "../../packages/tldraw" },
|
|
{ "path": "../../packages/utils" },
|
|
{ "path": "../../packages/assets" },
|
|
{ "path": "../../packages/validate" }
|
|
]
|
|
}
|