mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-23 17:49:49 +08:00
fix(paste): paste component into the first slot instead of 'content' slot
This commit is contained in:
parent
267ab40b37
commit
63b3a04935
@ -29,6 +29,15 @@ export const KeyboardEventWrapper: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
function getComponentFirstSlot(componentId: string) {
|
||||||
|
const component = components.find(c => c.id === componentId);
|
||||||
|
if (component) {
|
||||||
|
const spec = registry.getComponentByType(component?.type);
|
||||||
|
return Object.keys(spec.spec.slots)[0] || '';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
switch (e.key) {
|
switch (e.key) {
|
||||||
case 'Delete':
|
case 'Delete':
|
||||||
@ -103,7 +112,7 @@ export const KeyboardEventWrapper: React.FC<Props> = ({
|
|||||||
'operation',
|
'operation',
|
||||||
genOperation(registry, 'pasteComponent', {
|
genOperation(registry, 'pasteComponent', {
|
||||||
parentId: selectedComponentId || RootId,
|
parentId: selectedComponentId || RootId,
|
||||||
slot: 'content',
|
slot: getComponentFirstSlot(selectedComponentId),
|
||||||
component: clonedComponent!,
|
component: clonedComponent!,
|
||||||
copyTimes: pasteManager.current.copyTimes,
|
copyTimes: pasteManager.current.copyTimes,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user