mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix unknown original element for drag
This commit is contained in:
parent
b994753329
commit
d1b0aa63c4
2 changed files with 24 additions and 13 deletions
|
@ -8441,11 +8441,16 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
selectedElements.map((el) => [el.id, el]),
|
selectedElements.map((el) => [el.id, el]),
|
||||||
),
|
),
|
||||||
overrides: (el) => {
|
overrides: (el) => {
|
||||||
const origEl = pointerDownState.originalElements.get(el.id)!;
|
const origEl = pointerDownState.originalElements.get(el.id);
|
||||||
return {
|
|
||||||
x: origEl.x,
|
if (origEl) {
|
||||||
y: origEl.y,
|
return {
|
||||||
};
|
x: origEl.x,
|
||||||
|
y: origEl.y,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
},
|
},
|
||||||
reverseOrder: true,
|
reverseOrder: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -183,7 +183,7 @@ export const duplicateElements = (
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper to position cloned elements in the Z-order the product needs it
|
// Helper to position cloned elements in the Z-order the product needs it
|
||||||
const insertAfterIndex = (
|
const insertBeforeOrAfterIndex = (
|
||||||
index: number,
|
index: number,
|
||||||
elements: ExcalidrawElement | null | ExcalidrawElement[],
|
elements: ExcalidrawElement | null | ExcalidrawElement[],
|
||||||
) => {
|
) => {
|
||||||
|
@ -249,7 +249,7 @@ export const duplicateElements = (
|
||||||
return el.groupIds?.includes(groupId);
|
return el.groupIds?.includes(groupId);
|
||||||
});
|
});
|
||||||
|
|
||||||
insertAfterIndex(targetIndex, copyElements(groupElements));
|
insertBeforeOrAfterIndex(targetIndex, copyElements(groupElements));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,10 @@ export const duplicateElements = (
|
||||||
return el.frameId === frameId || el.id === frameId;
|
return el.frameId === frameId || el.id === frameId;
|
||||||
});
|
});
|
||||||
|
|
||||||
insertAfterIndex(targetIndex, copyElements([...frameChildren, element]));
|
insertBeforeOrAfterIndex(
|
||||||
|
targetIndex,
|
||||||
|
copyElements([...frameChildren, element]),
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,12 +290,12 @@ export const duplicateElements = (
|
||||||
});
|
});
|
||||||
|
|
||||||
if (boundTextElement) {
|
if (boundTextElement) {
|
||||||
insertAfterIndex(
|
insertBeforeOrAfterIndex(
|
||||||
targetIndex + (!!opts?.reverseOrder ? -1 : 0),
|
targetIndex + (!!opts?.reverseOrder ? -1 : 0),
|
||||||
copyElements([element, boundTextElement]),
|
copyElements([element, boundTextElement]),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
insertAfterIndex(targetIndex, copyElements(element));
|
insertBeforeOrAfterIndex(targetIndex, copyElements(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -306,9 +309,12 @@ export const duplicateElements = (
|
||||||
});
|
});
|
||||||
|
|
||||||
if (container) {
|
if (container) {
|
||||||
insertAfterIndex(targetIndex, copyElements([container, element]));
|
insertBeforeOrAfterIndex(
|
||||||
|
targetIndex,
|
||||||
|
copyElements([container, element]),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
insertAfterIndex(targetIndex, copyElements(element));
|
insertBeforeOrAfterIndex(targetIndex, copyElements(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -317,7 +323,7 @@ export const duplicateElements = (
|
||||||
// default duplication (regular elements)
|
// default duplication (regular elements)
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
insertAfterIndex(
|
insertBeforeOrAfterIndex(
|
||||||
findLastIndex(elementsWithClones, (el) => el.id === element.id),
|
findLastIndex(elementsWithClones, (el) => el.id === element.id),
|
||||||
copyElements(element),
|
copyElements(element),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue