refactor: export everything from @excalidraw/element, don't import from subpaths (#9466)

* Don't import from subpaths

* Fix tests, move related tests to element
This commit is contained in:
Marcel Mraz
2025-05-09 23:01:33 +02:00
committed by GitHub
parent a8ebe514da
commit 7e41026812
129 changed files with 517 additions and 541 deletions
@@ -1,18 +1,18 @@
import { degreesToRadians, radiansToDegrees } from "@excalidraw/math";
import { getBoundTextElement } from "@excalidraw/element/textElement";
import { isArrowElement, isElbowArrow } from "@excalidraw/element/typeChecks";
import { getBoundTextElement } from "@excalidraw/element";
import { isArrowElement, isElbowArrow } from "@excalidraw/element";
import { updateBindings } from "@excalidraw/element";
import type { Degrees } from "@excalidraw/math";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import { angleIcon } from "../icons";
import { updateBindings } from "../../../element/src/binding";
import DragInput from "./DragInput";
import { getStepSizedValue, isPropertyEditable } from "./utils";
@@ -1,4 +1,4 @@
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import { getNormalizedGridStep } from "../../scene";
@@ -4,13 +4,13 @@ import { MIN_WIDTH_OR_HEIGHT } from "@excalidraw/common";
import {
MINIMAL_CROP_SIZE,
getUncroppedWidthAndHeight,
} from "@excalidraw/element/cropElement";
import { resizeSingleElement } from "@excalidraw/element/resizeElements";
import { isImageElement } from "@excalidraw/element/typeChecks";
} from "@excalidraw/element";
import { resizeSingleElement } from "@excalidraw/element";
import { isImageElement } from "@excalidraw/element";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import DragInput from "./DragInput";
import { getStepSizedValue, isPropertyEditable } from "./utils";
@@ -3,13 +3,13 @@ import { useEffect, useRef, useState } from "react";
import { EVENT, KEYS, cloneJSON } from "@excalidraw/common";
import { deepCopyElement } from "@excalidraw/element/duplicate";
import { deepCopyElement } from "@excalidraw/element";
import { CaptureUpdateAction } from "@excalidraw/element/store";
import { CaptureUpdateAction } from "@excalidraw/element";
import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import { useApp } from "../App";
import { InlineIcon } from "../InlineIcon";
@@ -1,18 +1,15 @@
import {
getBoundTextElement,
redrawTextBoundingBox,
} from "@excalidraw/element/textElement";
import {
hasBoundTextElement,
isTextElement,
} from "@excalidraw/element/typeChecks";
} from "@excalidraw/element";
import { hasBoundTextElement, isTextElement } from "@excalidraw/element";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
} from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import { fontSizeIcon } from "../icons";
@@ -1,15 +1,15 @@
import { degreesToRadians, radiansToDegrees } from "@excalidraw/math";
import { getBoundTextElement } from "@excalidraw/element/textElement";
import { isArrowElement } from "@excalidraw/element/typeChecks";
import { getBoundTextElement } from "@excalidraw/element";
import { isArrowElement } from "@excalidraw/element";
import { isInGroup } from "@excalidraw/element/groups";
import { isInGroup } from "@excalidraw/element";
import type { Degrees } from "@excalidraw/math";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import { angleIcon } from "../icons";
@@ -2,17 +2,14 @@ import { pointFrom, type GlobalPoint } from "@excalidraw/math";
import { useMemo } from "react";
import { MIN_WIDTH_OR_HEIGHT } from "@excalidraw/common";
import { updateBoundElements } from "@excalidraw/element/binding";
import { updateBoundElements } from "@excalidraw/element";
import {
rescalePointsInElement,
resizeSingleElement,
} from "@excalidraw/element/resizeElements";
import {
getBoundTextElement,
handleBindTextResize,
} from "@excalidraw/element/textElement";
} from "@excalidraw/element";
import { getBoundTextElement, handleBindTextResize } from "@excalidraw/element";
import { isTextElement } from "@excalidraw/element/typeChecks";
import { isTextElement } from "@excalidraw/element";
import { getCommonBounds } from "@excalidraw/utils";
@@ -22,7 +19,7 @@ import type {
NonDeletedSceneElementsMap,
} from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import DragInput from "./DragInput";
import { getAtomicUnits, getStepSizedValue, isPropertyEditable } from "./utils";
@@ -1,13 +1,10 @@
import {
getBoundTextElement,
redrawTextBoundingBox,
} from "@excalidraw/element/textElement";
import {
hasBoundTextElement,
isTextElement,
} from "@excalidraw/element/typeChecks";
} from "@excalidraw/element";
import { hasBoundTextElement, isTextElement } from "@excalidraw/element";
import { isInGroup } from "@excalidraw/element/groups";
import { isInGroup } from "@excalidraw/element";
import type {
ExcalidrawElement,
@@ -15,7 +12,7 @@ import type {
NonDeletedSceneElementsMap,
} from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import { fontSizeIcon } from "../icons";
@@ -1,13 +1,13 @@
import { pointFrom, pointRotateRads } from "@excalidraw/math";
import { useMemo } from "react";
import { isTextElement } from "@excalidraw/element/typeChecks";
import { isTextElement } from "@excalidraw/element";
import { getCommonBounds } from "@excalidraw/element/bounds";
import { getCommonBounds } from "@excalidraw/element";
import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import StatsDragInput from "./DragInput";
import {
@@ -3,12 +3,12 @@ import { clamp, pointFrom, pointRotateRads, round } from "@excalidraw/math";
import {
getFlipAdjustedCropPosition,
getUncroppedWidthAndHeight,
} from "@excalidraw/element/cropElement";
import { isImageElement } from "@excalidraw/element/typeChecks";
} from "@excalidraw/element";
import { isImageElement } from "@excalidraw/element";
import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import type { Scene } from "@excalidraw/element";
import StatsDragInput from "./DragInput";
import { getStepSizedValue, moveElement, STEP_SIZE } from "./utils";
@@ -4,13 +4,13 @@ import throttle from "lodash.throttle";
import { useEffect, useMemo, useState, memo } from "react";
import { STATS_PANELS } from "@excalidraw/common";
import { getCommonBounds } from "@excalidraw/element/bounds";
import { getUncroppedWidthAndHeight } from "@excalidraw/element/cropElement";
import { isElbowArrow, isImageElement } from "@excalidraw/element/typeChecks";
import { getCommonBounds } from "@excalidraw/element";
import { getUncroppedWidthAndHeight } from "@excalidraw/element";
import { isElbowArrow, isImageElement } from "@excalidraw/element";
import { frameAndChildrenSelectedTogether } from "@excalidraw/element/frame";
import { frameAndChildrenSelectedTogether } from "@excalidraw/element";
import { elementsAreInSameGroup } from "@excalidraw/element/groups";
import { elementsAreInSameGroup } from "@excalidraw/element";
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
@@ -5,9 +5,9 @@ import { vi } from "vitest";
import { setDateTimeForTests, reseed } from "@excalidraw/common";
import { isInGroup } from "@excalidraw/element/groups";
import { isInGroup } from "@excalidraw/element";
import { isTextElement } from "@excalidraw/element/typeChecks";
import { isTextElement } from "@excalidraw/element";
import type { Degrees } from "@excalidraw/math";
+7 -10
View File
@@ -1,18 +1,17 @@
import { pointFrom, pointRotateRads } from "@excalidraw/math";
import { getBoundTextElement } from "@excalidraw/element/textElement";
import {
isFrameLikeElement,
isTextElement,
} from "@excalidraw/element/typeChecks";
import { getBoundTextElement } from "@excalidraw/element";
import { isFrameLikeElement, isTextElement } from "@excalidraw/element";
import {
getSelectedGroupIds,
getElementsInGroup,
isInGroup,
} from "@excalidraw/element/groups";
} from "@excalidraw/element";
import { getFrameChildren } from "@excalidraw/element/frame";
import { getFrameChildren } from "@excalidraw/element";
import { updateBindings } from "@excalidraw/element";
import type { Radians } from "@excalidraw/math";
@@ -22,9 +21,7 @@ import type {
NonDeletedExcalidrawElement,
} from "@excalidraw/element/types";
import type Scene from "@excalidraw/element/Scene";
import { updateBindings } from "../../../element/src/binding";
import type { Scene } from "@excalidraw/element";
import type { AppState } from "../../types";