Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

transform.ts 987B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data } from 'types'
  4. import { TransformSnapshot } from 'state/sessions/transform-session'
  5. import { getPage, updateParents } from 'utils/utils'
  6. export default function transformCommand(
  7. data: Data,
  8. before: TransformSnapshot,
  9. after: TransformSnapshot
  10. ): void {
  11. history.execute(
  12. data,
  13. new Command({
  14. name: 'transform_shapes',
  15. category: 'canvas',
  16. do(data) {
  17. const { shapeBounds } = after
  18. const { shapes } = getPage(data)
  19. for (const id in shapeBounds) {
  20. shapes[id] = shapeBounds[id].initialShape
  21. }
  22. updateParents(data, Object.keys(shapeBounds))
  23. },
  24. undo(data) {
  25. const { shapeBounds } = before
  26. const { shapes } = getPage(data)
  27. for (const id in shapeBounds) {
  28. shapes[id] = shapeBounds[id].initialShape
  29. }
  30. updateParents(data, Object.keys(shapeBounds))
  31. },
  32. })
  33. )
  34. }