您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

handle.ts 962B

123456789101112131415161718192021222324252627282930313233343536
  1. import Command from './command'
  2. import history from '../history'
  3. import { Data } from 'types'
  4. import { getPage } from 'utils/utils'
  5. import { HandleSnapshot } from 'state/sessions/handle-session'
  6. import { getShapeUtils } from 'state/shape-utils'
  7. export default function handleCommand(
  8. data: Data,
  9. before: HandleSnapshot,
  10. after: HandleSnapshot
  11. ): void {
  12. history.execute(
  13. data,
  14. new Command({
  15. name: 'moved_handle',
  16. category: 'canvas',
  17. do(data) {
  18. const { initialShape, currentPageId } = after
  19. const page = getPage(data, currentPageId)
  20. const shape = page.shapes[initialShape.id]
  21. getShapeUtils(shape)
  22. .onHandleChange(shape, initialShape.handles)
  23. .onSessionComplete(shape)
  24. },
  25. undo(data) {
  26. const { initialShape, currentPageId } = before
  27. const page = getPage(data, currentPageId)
  28. page.shapes[initialShape.id] = initialShape
  29. },
  30. })
  31. )
  32. }