You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

change-page.ts 659B

1234567891011121314151617181920212223242526
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data } from 'types'
  4. import storage from 'state/storage'
  5. export default function changePage(data: Data, pageId: string) {
  6. const { currentPageId: prevPageId } = data
  7. history.execute(
  8. data,
  9. new Command({
  10. name: 'change_page',
  11. category: 'canvas',
  12. manualSelection: true,
  13. do(data) {
  14. storage.savePage(data, data.currentPageId)
  15. data.currentPageId = pageId
  16. storage.loadPage(data, data.currentPageId)
  17. },
  18. undo(data) {
  19. data.currentPageId = prevPageId
  20. storage.loadPage(data, prevPageId)
  21. },
  22. })
  23. )
  24. }