Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738
  1. import Command from "./command"
  2. import history from "../history"
  3. import { StretchType, Data } from "types"
  4. import { getPage } from "utils/utils"
  5. import { getShapeUtils } from "lib/shape-utils"
  6. export default function stretchCommand(data: Data, type: StretchType) {
  7. const { currentPageId } = data
  8. const initialPoints = Object.fromEntries(
  9. Object.entries(getPage(data).shapes).map(([id, shape]) => [id, shape.point])
  10. )
  11. history.execute(
  12. data,
  13. new Command({
  14. name: "distributed",
  15. category: "canvas",
  16. do(data) {
  17. const { shapes } = getPage(data, currentPageId)
  18. switch (type) {
  19. case StretchType.Horizontal: {
  20. }
  21. case StretchType.Vertical: {
  22. }
  23. }
  24. },
  25. undo(data) {
  26. const { shapes } = getPage(data, currentPageId)
  27. for (let id in initialPoints) {
  28. const shape = shapes[id]
  29. getShapeUtils(shape).translateTo(shape, initialPoints[id])
  30. }
  31. },
  32. })
  33. )
  34. }