mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
parent
5252726307
commit
61e5b66dac
23 changed files with 964 additions and 86 deletions
|
@ -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]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue