2021-06-22 21:06:51 +00:00
|
|
|
import Command from './command'
|
|
|
|
import history from '../history'
|
|
|
|
import { Data, PointerInfo } from 'types'
|
|
|
|
import { getShapeUtils } from 'state/shape-utils'
|
2021-06-29 12:00:59 +00:00
|
|
|
import { deepClone } from 'utils'
|
|
|
|
import tld from 'utils/tld'
|
2021-06-22 21:06:51 +00:00
|
|
|
|
|
|
|
export default function doublePointHandleCommand(
|
|
|
|
data: Data,
|
|
|
|
id: string,
|
|
|
|
payload: PointerInfo
|
|
|
|
): void {
|
2021-06-29 12:00:59 +00:00
|
|
|
const initialShape = deepClone(tld.getShape(data, id))
|
2021-06-22 21:06:51 +00:00
|
|
|
|
|
|
|
history.execute(
|
|
|
|
data,
|
|
|
|
new Command({
|
|
|
|
name: 'double_point_handle',
|
|
|
|
category: 'canvas',
|
|
|
|
do(data) {
|
2021-06-29 12:00:59 +00:00
|
|
|
const { shapes } = tld.getPage(data)
|
2021-06-22 21:06:51 +00:00
|
|
|
|
|
|
|
const shape = shapes[id]
|
|
|
|
getShapeUtils(shape).onDoublePointHandle(shape, payload.target, payload)
|
2021-06-29 12:00:59 +00:00
|
|
|
tld.updateParents(data, [id])
|
2021-06-22 21:06:51 +00:00
|
|
|
},
|
|
|
|
undo(data) {
|
2021-06-29 12:00:59 +00:00
|
|
|
const { shapes } = tld.getPage(data)
|
2021-06-22 21:06:51 +00:00
|
|
|
shapes[id] = initialShape
|
2021-06-29 12:00:59 +00:00
|
|
|
tld.updateParents(data, [id])
|
2021-06-22 21:06:51 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|