| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import Command from './command'
- import history from '../history'
- import { Data, Shape } from 'types'
- import { getShapeUtils } from 'lib/shape-utils'
- import { getPage, updateParents } from 'utils/utils'
-
- // Used when changing the properties of one or more shapes,
- // without changing selection or deleting any shapes.
-
- export default function mutateShapesCommand(
- data: Data,
- before: Shape[],
- after: Shape[],
- name = 'mutate_shapes'
- ) {
- history.execute(
- data,
- new Command({
- name,
- category: 'canvas',
- do(data) {
- const { shapes } = getPage(data)
-
- after.forEach((shape) => {
- shapes[shape.id] = shape
- getShapeUtils(shape).onSessionComplete(shape)
- })
-
- // updateParents(
- // data,
- // after.map((shape) => shape.id)
- // )
- },
- undo(data) {
- const { shapes } = getPage(data)
-
- before.forEach((shape) => {
- shapes[shape.id] = shape
- getShapeUtils(shape).onSessionComplete(shape)
- })
-
- updateParents(
- data,
- before.map((shape) => shape.id)
- )
- },
- })
- )
- }
|