fix: Move to top or bottom
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
@@ -409,8 +409,10 @@ const shiftElementsToEnd = (
|
|||||||
let trailingIndex: number;
|
let trailingIndex: number;
|
||||||
if (direction === "left") {
|
if (direction === "left") {
|
||||||
if (containingFrame) {
|
if (containingFrame) {
|
||||||
leadingIndex = findIndex(elements, (el) =>
|
leadingIndex = findIndex(
|
||||||
isOfTargetFrame(el, containingFrame),
|
elements,
|
||||||
|
(el) =>
|
||||||
|
el.id !== containingFrame && isOfTargetFrame(el, containingFrame),
|
||||||
);
|
);
|
||||||
} else if (appState.editingGroupId) {
|
} else if (appState.editingGroupId) {
|
||||||
const groupElements = getElementsInGroup(
|
const groupElements = getElementsInGroup(
|
||||||
@@ -428,8 +430,10 @@ const shiftElementsToEnd = (
|
|||||||
trailingIndex = indicesToMove[indicesToMove.length - 1];
|
trailingIndex = indicesToMove[indicesToMove.length - 1];
|
||||||
} else {
|
} else {
|
||||||
if (containingFrame) {
|
if (containingFrame) {
|
||||||
trailingIndex = findLastIndex(elements, (el) =>
|
trailingIndex = findLastIndex(
|
||||||
isOfTargetFrame(el, containingFrame),
|
elements,
|
||||||
|
(el) =>
|
||||||
|
el.id !== containingFrame && isOfTargetFrame(el, containingFrame),
|
||||||
);
|
);
|
||||||
} else if (appState.editingGroupId) {
|
} else if (appState.editingGroupId) {
|
||||||
const groupElements = getElementsInGroup(
|
const groupElements = getElementsInGroup(
|
||||||
@@ -509,6 +513,8 @@ function shiftElementsAccountingForFrames(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedFrameIds = new Set<ExcalidrawFrameLikeElement["id"]>();
|
||||||
|
|
||||||
for (const element of allElements) {
|
for (const element of allElements) {
|
||||||
if (elementsToMove.has(element.id)) {
|
if (elementsToMove.has(element.id)) {
|
||||||
if (
|
if (
|
||||||
@@ -518,11 +524,23 @@ function shiftElementsAccountingForFrames(
|
|||||||
regularElements.push(element);
|
regularElements.push(element);
|
||||||
} else if (!element.frameId) {
|
} else if (!element.frameId) {
|
||||||
regularElements.push(element);
|
regularElements.push(element);
|
||||||
|
} else if (!selectedFrameIds.has(element.frameId)) {
|
||||||
|
selectedFrameIds.add(element.frameId);
|
||||||
|
regularElements.push(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return shiftFunction(allElements, appState, direction, null, regularElements);
|
const containingFrame =
|
||||||
|
selectedFrameIds.size > 0 ? [...selectedFrameIds][0] : null;
|
||||||
|
|
||||||
|
return shiftFunction(
|
||||||
|
allElements,
|
||||||
|
appState,
|
||||||
|
direction,
|
||||||
|
containingFrame,
|
||||||
|
regularElements,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public API
|
// public API
|
||||||
|
|||||||
Reference in New Issue
Block a user