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.

draw.ts 727B

1234567891011121314151617181920212223242526272829
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data, DrawShape } from 'types'
  4. import { getPage, setSelectedIds } from 'utils/utils'
  5. import { current } from 'immer'
  6. export default function drawCommand(data: Data, id: string) {
  7. const restoreShape = getPage(current(data)).shapes[id] as DrawShape
  8. history.execute(
  9. data,
  10. new Command({
  11. name: 'create_draw_shape',
  12. category: 'canvas',
  13. manualSelection: true,
  14. do(data, initial) {
  15. if (!initial) {
  16. getPage(data).shapes[id] = restoreShape
  17. }
  18. setSelectedIds(data, [])
  19. },
  20. undo(data) {
  21. setSelectedIds(data, [])
  22. delete getPage(data).shapes[id]
  23. },
  24. })
  25. )
  26. }