Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 54a123e7c0 | |||
| fed4af4381 | |||
| e97c3704eb |
@@ -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(
|
||||||
@@ -499,10 +503,7 @@ function shiftElementsAccountingForFrames(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const frameAwareContiguousElementsToMove: {
|
const regularElements: ExcalidrawElement[] = [];
|
||||||
regularElements: ExcalidrawElement[];
|
|
||||||
frameChildren: Map<ExcalidrawFrameLikeElement["id"], ExcalidrawElement[]>;
|
|
||||||
} = { regularElements: [], frameChildren: new Map() };
|
|
||||||
|
|
||||||
const fullySelectedFrames = new Set<ExcalidrawFrameLikeElement["id"]>();
|
const fullySelectedFrames = new Set<ExcalidrawFrameLikeElement["id"]>();
|
||||||
|
|
||||||
@@ -512,51 +513,33 @@ 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 (
|
||||||
isFrameLikeElement(element) ||
|
isFrameLikeElement(element) ||
|
||||||
(element.frameId && fullySelectedFrames.has(element.frameId))
|
(element.frameId && fullySelectedFrames.has(element.frameId))
|
||||||
) {
|
) {
|
||||||
frameAwareContiguousElementsToMove.regularElements.push(element);
|
regularElements.push(element);
|
||||||
} else if (!element.frameId) {
|
} else if (!element.frameId) {
|
||||||
frameAwareContiguousElementsToMove.regularElements.push(element);
|
regularElements.push(element);
|
||||||
} else {
|
} else if (!selectedFrameIds.has(element.frameId)) {
|
||||||
const frameChildren =
|
selectedFrameIds.add(element.frameId);
|
||||||
frameAwareContiguousElementsToMove.frameChildren.get(
|
regularElements.push(element);
|
||||||
element.frameId,
|
|
||||||
) || [];
|
|
||||||
frameChildren.push(element);
|
|
||||||
frameAwareContiguousElementsToMove.frameChildren.set(
|
|
||||||
element.frameId,
|
|
||||||
frameChildren,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let nextElements = allElements;
|
const containingFrame =
|
||||||
|
selectedFrameIds.size > 0 ? [...selectedFrameIds][0] : null;
|
||||||
const frameChildrenSets = Array.from(
|
|
||||||
frameAwareContiguousElementsToMove.frameChildren.entries(),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const [frameId, children] of frameChildrenSets) {
|
|
||||||
nextElements = shiftFunction(
|
|
||||||
allElements,
|
|
||||||
appState,
|
|
||||||
direction,
|
|
||||||
frameId,
|
|
||||||
children,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return shiftFunction(
|
return shiftFunction(
|
||||||
nextElements,
|
allElements,
|
||||||
appState,
|
appState,
|
||||||
direction,
|
direction,
|
||||||
null,
|
containingFrame,
|
||||||
frameAwareContiguousElementsToMove.regularElements,
|
regularElements,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user