Adds arrows, handles
This commit is contained in:
parent
facd9e9845
commit
bcffee6458
27 changed files with 1120 additions and 292 deletions
36
state/commands/handle.ts
Normal file
36
state/commands/handle.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import Command from './command'
|
||||
import history from '../history'
|
||||
import { Data } from 'types'
|
||||
import { getPage } from 'utils/utils'
|
||||
import { HandleSnapshot } from 'state/sessions/handle-session'
|
||||
import { getShapeUtils } from 'lib/shape-utils'
|
||||
|
||||
export default function handleCommand(
|
||||
data: Data,
|
||||
before: HandleSnapshot,
|
||||
after: HandleSnapshot
|
||||
) {
|
||||
history.execute(
|
||||
data,
|
||||
new Command({
|
||||
name: 'moved_handle',
|
||||
category: 'canvas',
|
||||
do(data, isInitial) {
|
||||
if (isInitial) return
|
||||
|
||||
const { initialShape, currentPageId } = after
|
||||
|
||||
const shape = getPage(data, currentPageId).shapes[initialShape.id]
|
||||
|
||||
getShapeUtils(shape).onHandleMove(shape, initialShape.handles)
|
||||
},
|
||||
undo(data) {
|
||||
const { initialShape, currentPageId } = before
|
||||
|
||||
const shape = getPage(data, currentPageId).shapes[initialShape.id]
|
||||
|
||||
getShapeUtils(shape).onHandleMove(shape, initialShape.handles)
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue