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.

reset-bounds.ts 850B

12345678910111213141516171819202122232425262728293031
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data } from 'types'
  4. import { getPage, getSelectedShapes } from 'utils/utils'
  5. import { current } from 'immer'
  6. import { getShapeUtils } from 'lib/shape-utils'
  7. export default function resetBoundsCommand(data: Data) {
  8. const initialShapes = Object.fromEntries(
  9. getSelectedShapes(current(data)).map((shape) => [shape.id, shape])
  10. )
  11. history.execute(
  12. data,
  13. new Command({
  14. name: 'reset_bounds',
  15. category: 'canvas',
  16. do(data) {
  17. getSelectedShapes(data).forEach((shape) => {
  18. getShapeUtils(shape).onBoundsReset(shape)
  19. })
  20. },
  21. undo(data) {
  22. const page = getPage(data)
  23. getSelectedShapes(data).forEach((shape) => {
  24. page.shapes[shape.id] = initialShapes[shape.id]
  25. })
  26. },
  27. })
  28. )
  29. }