|
|
@ -125,29 +125,24 @@ |
|
|
// loading is supported |
|
|
// loading is supported |
|
|
loading = false |
|
|
loading = false |
|
|
} else if (type === "move-component") { |
|
|
} else if (type === "move-component") { |
|
|
// Copy |
|
|
const { componentId, destinationComponentId } = data |
|
|
const sourceComponent = findComponent( |
|
|
const rootComponent = get(currentAsset).props |
|
|
get(currentAsset).props, |
|
|
|
|
|
data.componentId |
|
|
// Get source and destination components |
|
|
) |
|
|
const source = findComponent(rootComponent, componentId) |
|
|
const destinationComponent = findComponent( |
|
|
const destination = findComponent(rootComponent, destinationComponentId) |
|
|
get(currentAsset).props, |
|
|
|
|
|
data.destinationComponentId |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Stop if the target is a child of source |
|
|
// Stop if the target is a child of source |
|
|
const path = findComponentPath( |
|
|
const path = findComponentPath(source, destinationComponentId) |
|
|
sourceComponent, |
|
|
|
|
|
data.destinationComponentId |
|
|
|
|
|
) |
|
|
|
|
|
const ids = path.map(component => component._id) |
|
|
const ids = path.map(component => component._id) |
|
|
if (ids.includes(data.destinationComponentId)) { |
|
|
if (ids.includes(data.destinationComponentId)) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (sourceComponent && destinationComponent) { |
|
|
// Cut and paste the component to the new destination |
|
|
store.actions.components.copy(sourceComponent, true) |
|
|
if (source && destination) { |
|
|
store.actions.components.paste(destinationComponent, data.mode) |
|
|
store.actions.components.copy(source, true) |
|
|
|
|
|
store.actions.components.paste(destination, data.mode) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
console.warning(`Client sent unknown event type: ${type}`) |
|
|
console.warning(`Client sent unknown event type: ${type}`) |
|
|
|