36 lines
900 B
TypeScript
36 lines
900 B
TypeScript
import Command from './command'
|
|
import history from '../history'
|
|
import { Data } from 'types'
|
|
import tld from 'utils/tld'
|
|
import { HandleSnapshot } from 'state/sessions/handle-session'
|
|
import { getShapeUtils } from 'state/shape-utils'
|
|
|
|
export default function handleCommand(
|
|
data: Data,
|
|
before: HandleSnapshot,
|
|
after: HandleSnapshot
|
|
): void {
|
|
history.execute(
|
|
data,
|
|
new Command({
|
|
name: 'moved_handle',
|
|
category: 'canvas',
|
|
do(data) {
|
|
const { initialShape } = after
|
|
|
|
const page = tld.getPage(data)
|
|
const shape = page.shapes[initialShape.id]
|
|
|
|
getShapeUtils(shape)
|
|
.onHandleChange(shape, initialShape.handles)
|
|
.onSessionComplete(shape)
|
|
},
|
|
undo(data) {
|
|
const { initialShape } = before
|
|
|
|
const page = tld.getPage(data)
|
|
page.shapes[initialShape.id] = initialShape
|
|
},
|
|
})
|
|
)
|
|
}
|