kopia lustrzana https://github.com/Tldraw/Tldraw
27 wiersze
653 B
TypeScript
27 wiersze
653 B
TypeScript
import { createShapePropsMigrationIds } from '@tldraw/tlschema/src/records/TLShape'
|
|
import { createShapePropsMigrationSequence } from 'tldraw'
|
|
|
|
const versions = createShapePropsMigrationIds(
|
|
// this must match the shape type in the shape definition
|
|
'card',
|
|
{
|
|
AddSomeProperty: 1,
|
|
}
|
|
)
|
|
|
|
// Migrations for the custom card shape (optional but very helpful)
|
|
export const cardShapeMigrations = createShapePropsMigrationSequence({
|
|
sequence: [
|
|
{
|
|
id: versions.AddSomeProperty,
|
|
up(props) {
|
|
// it is safe to mutate the props object here
|
|
props.someProperty = 'some value'
|
|
},
|
|
down(props) {
|
|
delete props.someProperty
|
|
},
|
|
},
|
|
],
|
|
})
|