@ -12,15 +12,21 @@ import { getShortcutKey } from "../utils";
|
||||
export const actionDuplicateSelection = register({
|
||||
name: "duplicateSelection",
|
||||
perform: (elements, appState) => {
|
||||
const groupIdMap = new Map();
|
||||
return {
|
||||
appState,
|
||||
elements: elements.reduce(
|
||||
(acc: Array<ExcalidrawElement>, element: ExcalidrawElement) => {
|
||||
if (appState.selectedElementIds[element.id]) {
|
||||
const newElement = duplicateElement(element, {
|
||||
x: element.x + 10,
|
||||
y: element.y + 10,
|
||||
});
|
||||
const newElement = duplicateElement(
|
||||
appState.editingGroupId,
|
||||
groupIdMap,
|
||||
element,
|
||||
{
|
||||
x: element.x + 10,
|
||||
y: element.y + 10,
|
||||
},
|
||||
);
|
||||
appState.selectedElementIds[newElement.id] = true;
|
||||
delete appState.selectedElementIds[element.id];
|
||||
return acc.concat([element, newElement]);
|
||||
|
Reference in New Issue
Block a user