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 846B

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