Group/ungroup (#1648)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Pete Hunt
2020-05-26 13:07:46 -07:00
committed by GitHub
parent 5252726307
commit 61e5b66dac
23 changed files with 964 additions and 86 deletions

View File

@ -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]);