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

direct.ts 930B

123456789101112131415161718192021222324252627282930313233343536
  1. import Command from "./command"
  2. import history from "../history"
  3. import { DirectionSnapshot } from "state/sessions/direction-session"
  4. import { Data, LineShape, RayShape } from "types"
  5. export default function directCommand(
  6. data: Data,
  7. before: DirectionSnapshot,
  8. after: DirectionSnapshot
  9. ) {
  10. history.execute(
  11. data,
  12. new Command({
  13. name: "set_direction",
  14. category: "canvas",
  15. do(data) {
  16. const { shapes } = data.document.pages[after.currentPageId]
  17. for (let { id, direction } of after.shapes) {
  18. const shape = shapes[id] as RayShape | LineShape
  19. shape.direction = direction
  20. }
  21. },
  22. undo(data) {
  23. const { shapes } = data.document.pages[before.currentPageId]
  24. for (let { id, direction } of after.shapes) {
  25. const shape = shapes[id] as RayShape | LineShape
  26. shape.direction = direction
  27. }
  28. },
  29. })
  30. )
  31. }