refactor: decoupling global Scene state part-1 (#7577)

This commit is contained in:
David Luzar
2024-01-22 00:23:02 +01:00
committed by GitHub
parent 740a165452
commit 0415c616b1
31 changed files with 630 additions and 384 deletions

View File

@@ -3,6 +3,7 @@ import {
ExcalidrawElement,
NonDeleted,
NonDeletedExcalidrawElement,
ElementsMapOrArray,
} from "./element/types";
import {
AppClassProperties,
@@ -270,9 +271,17 @@ export const isElementInGroup = (element: ExcalidrawElement, groupId: string) =>
element.groupIds.includes(groupId);
export const getElementsInGroup = (
elements: readonly ExcalidrawElement[],
elements: ElementsMapOrArray,
groupId: string,
) => elements.filter((element) => isElementInGroup(element, groupId));
) => {
const elementsInGroup: ExcalidrawElement[] = [];
for (const element of elements.values()) {
if (isElementInGroup(element, groupId)) {
elementsInGroup.push(element);
}
}
return elementsInGroup;
};
export const getSelectedGroupIdForElement = (
element: ExcalidrawElement,