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.

create-shape.ts 778B

123456789101112131415161718192021222324252627282930313233
  1. import Command from "./command"
  2. import history from "../history"
  3. import { Data, Shape } from "types"
  4. import { getPage } from "utils/utils"
  5. export default function registerShapeUtilsCommand(data: Data, shape: Shape) {
  6. const { currentPageId } = data
  7. history.execute(
  8. data,
  9. new Command({
  10. name: "translate_shapes",
  11. category: "canvas",
  12. do(data) {
  13. const page = getPage(data)
  14. page.shapes[shape.id] = shape
  15. data.selectedIds.clear()
  16. data.pointedId = undefined
  17. data.hoveredId = undefined
  18. },
  19. undo(data) {
  20. const page = getPage(data)
  21. delete page.shapes[shape.id]
  22. data.selectedIds.clear()
  23. data.pointedId = undefined
  24. data.hoveredId = undefined
  25. },
  26. })
  27. )
  28. }