fix: move elementCenterPoint from common/src/utils.ts to element/src/bounds.ts (#9647)

move elementCenterPoint from utils to bounds.ts
This commit is contained in:
zsviczian
2025-06-14 12:49:22 +02:00
committed by GitHub
parent 60512f13d5
commit 320af405e9
8 changed files with 26 additions and 27 deletions

View File

@ -1,12 +1,9 @@
import { average, pointFrom, type GlobalPoint } from "@excalidraw/math";
import { getCenterForBounds, getElementBounds } from "@excalidraw/element";
import { average } from "@excalidraw/math";
import type {
ExcalidrawBindableElement,
FontFamilyValues,
FontString,
ExcalidrawElement,
ElementsMap,
} from "@excalidraw/element/types";
import type {
@ -1239,17 +1236,6 @@ export const escapeDoubleQuotes = (str: string) => {
export const castArray = <T>(value: T | T[]): T[] =>
Array.isArray(value) ? value : [value];
export const elementCenterPoint = (
element: ExcalidrawElement,
elementsMap: ElementsMap,
xOffset: number = 0,
yOffset: number = 0,
) => {
const [x, y] = getCenterForBounds(getElementBounds(element, elementsMap));
return pointFrom<GlobalPoint>(x + xOffset, y + yOffset);
};
/** hack for Array.isArray type guard not working with readonly value[] */
export const isReadonlyArray = (value?: any): value is readonly any[] => {
return Array.isArray(value);