diff --git a/packages/tldraw/src/state/migrate.ts b/packages/tldraw/src/state/migrate.ts index 1f661ed83..acbe9fd27 100644 --- a/packages/tldraw/src/state/migrate.ts +++ b/packages/tldraw/src/state/migrate.ts @@ -4,9 +4,11 @@ import { Decoration, TLDrawDocument, TLDrawShapeType } from '~types' export function migrate(document: TLDrawDocument, newVersion: number): TLDrawDocument { const { version = 0 } = document + console.log(`Migrating document from ${version} to ${newVersion}.`) + if (version === newVersion) return document - if (version <= 12) { + if (version <= 13) { Object.values(document.pages).forEach((page) => { Object.values(page.bindings).forEach((binding) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/tldraw/src/state/tlstate.ts b/packages/tldraw/src/state/tlstate.ts index ed9792ec0..01db60b45 100644 --- a/packages/tldraw/src/state/tlstate.ts +++ b/packages/tldraw/src/state/tlstate.ts @@ -100,10 +100,13 @@ export class TLDrawState extends StateManager { onChange?: (tlstate: TLDrawState, data: Data, reason: string) => void, onUserChange?: (tlstate: TLDrawState, user: TLDrawUser) => void ) { - super(TLDrawState.defaultState, id, TLDrawState.version, (prev, next) => { + super(TLDrawState.defaultState, id, TLDrawState.version, (prev, next, prevVersion) => { return { ...next, - document: migrate({ ...next.document, ...prev.document, version: 0 }, TLDrawState.version), + document: migrate( + { ...next.document, ...prev.document, version: prevVersion }, + TLDrawState.version + ), } }) @@ -2458,7 +2461,7 @@ export class TLDrawState extends StateManager { } } - static version = 12.6 + static version = 13 static defaultDocument: TLDrawDocument = { id: 'doc',