You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

draw.ts 839B

123456789101112131415161718192021222324252627282930313233343536
  1. import Command from "./command"
  2. import history from "../history"
  3. import { Data } from "types"
  4. import { getPage } from "utils/utils"
  5. import { getShapeUtils } from "lib/shape-utils"
  6. import { current } from "immer"
  7. export default function drawCommand(
  8. data: Data,
  9. id: string,
  10. before: number[][],
  11. after: number[][]
  12. ) {
  13. const restoreShape = current(getPage(data).shapes[id])
  14. getShapeUtils(restoreShape).setPoints!(restoreShape, after)
  15. history.execute(
  16. data,
  17. new Command({
  18. name: "set_points",
  19. category: "canvas",
  20. manualSelection: true,
  21. do(data, initial) {
  22. if (!initial) {
  23. getPage(data).shapes[id] = restoreShape
  24. }
  25. data.selectedIds.clear()
  26. },
  27. undo(data) {
  28. delete getPage(data).shapes[id]
  29. data.selectedIds.clear()
  30. },
  31. })
  32. )
  33. }