tldraw/state/commands/change-page.ts

25 lines
587 B
TypeScript
Raw Normal View History

2021-06-03 12:06:39 +00:00
import Command from './command'
import history from '../history'
import { Data } from 'types'
import { getPage, getSelectedShapes } from 'utils/utils'
import { getShapeUtils } from 'lib/shape-utils'
import * as vec from 'utils/vec'
2021-06-03 13:10:54 +00:00
export default function changePage(data: Data, pageId: string) {
2021-06-03 12:06:39 +00:00
const { currentPageId: prevPageId } = data
history.execute(
data,
new Command({
name: 'change_page',
category: 'canvas',
do(data) {
data.currentPageId = pageId
},
undo(data) {
data.currentPageId = prevPageId
},
})
)
}