2021-05-13 06:44:52 +00:00
|
|
|
import Command from "./command"
|
2021-05-13 08:34:56 +00:00
|
|
|
import history from "../history"
|
2021-05-13 06:44:52 +00:00
|
|
|
import { TranslateSnapshot } from "state/sessions/translate-session"
|
|
|
|
import { Data } from "types"
|
|
|
|
|
|
|
|
export default function translateCommand(
|
|
|
|
data: Data,
|
|
|
|
before: TranslateSnapshot,
|
|
|
|
after: TranslateSnapshot
|
|
|
|
) {
|
|
|
|
history.execute(
|
|
|
|
data,
|
|
|
|
new Command({
|
|
|
|
name: "translate_shapes",
|
|
|
|
category: "canvas",
|
|
|
|
do(data) {
|
|
|
|
const { shapes } = data.document.pages[after.currentPageId]
|
|
|
|
|
|
|
|
for (let { id, point } of after.shapes) {
|
|
|
|
shapes[id].point = point
|
|
|
|
}
|
|
|
|
},
|
|
|
|
undo(data) {
|
|
|
|
const { shapes } = data.document.pages[before.currentPageId]
|
|
|
|
|
|
|
|
for (let { id, point } of before.shapes) {
|
|
|
|
shapes[id].point = point
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|