2021-06-15 11:58:51 +00:00
|
|
|
import Command from './command'
|
|
|
|
import history from '../history'
|
|
|
|
import { Data } from 'types'
|
2021-06-29 12:00:59 +00:00
|
|
|
import tld from 'utils/tld'
|
2021-06-15 11:58:51 +00:00
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export default function resetBoundsCommand(data: Data): void {
|
2021-06-29 12:00:59 +00:00
|
|
|
const initialShapes = tld.getSelectedShapeSnapshot(data)
|
2021-06-15 11:58:51 +00:00
|
|
|
|
|
|
|
history.execute(
|
|
|
|
data,
|
|
|
|
new Command({
|
|
|
|
name: 'reset_bounds',
|
|
|
|
category: 'canvas',
|
|
|
|
do(data) {
|
2021-06-29 12:00:59 +00:00
|
|
|
tld.mutateShapes(
|
|
|
|
data,
|
|
|
|
initialShapes.map((shape) => shape.id),
|
|
|
|
(shape, utils) => void utils.onBoundsReset(shape)
|
|
|
|
)
|
2021-06-15 11:58:51 +00:00
|
|
|
},
|
|
|
|
undo(data) {
|
2021-06-29 12:00:59 +00:00
|
|
|
tld.mutateShapes(
|
|
|
|
data,
|
|
|
|
initialShapes.map((shape) => shape.id),
|
|
|
|
(_, __, i) => initialShapes[i]
|
|
|
|
)
|
2021-06-15 11:58:51 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|