fix: exporting frame-overlapping elements belonging to other frames (#7584)

This commit is contained in:
David Luzar 2024-01-19 14:41:22 +01:00 committed by GitHub
parent 3b0593baa7
commit 46da032626
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 92 additions and 19 deletions

View file

@ -21,7 +21,10 @@ import { getElementsWithinSelection, getSelectedElements } from "./scene";
import { getElementsInGroup, selectGroupsFromGivenElements } from "./groups";
import Scene, { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
import { getElementLineSegments } from "./element/bounds";
import { doLineSegmentsIntersect } from "../utils/export";
import {
doLineSegmentsIntersect,
elementsOverlappingBBox,
} from "../utils/export";
import { isFrameElement, isFrameLikeElement } from "./element/typeChecks";
// --------------------------- Frame State ------------------------------------
@ -664,3 +667,19 @@ export const getFrameLikeTitle = (
// TODO name frames AI only is specific to AI frames
return isFrameElement(element) ? `Frame ${frameIdx}` : `AI Frame ${frameIdx}`;
};
export const getElementsOverlappingFrame = (
elements: readonly ExcalidrawElement[],
frame: ExcalidrawFrameLikeElement,
) => {
return (
elementsOverlappingBBox({
elements,
bounds: frame,
type: "overlap",
})
// removes elements who are overlapping, but are in a different frame,
// and thus invisible in target frame
.filter((el) => !el.frameId || el.frameId === frame.id)
);
};