From fdd7420e651e0490b03c0290324ed02ec3745d53 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Wed, 26 Mar 2025 19:42:40 +0100 Subject: [PATCH] Type fixes --- packages/common/src/utils.ts | 8 +++++++- packages/element/src/binding.ts | 2 +- packages/excalidraw/actions/actionFinalize.tsx | 2 ++ packages/excalidraw/components/App.tsx | 6 +++++- packages/excalidraw/data/transform.test.ts | 2 ++ packages/excalidraw/tests/history.test.tsx | 3 +-- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index d6652077f8..8b2e28f7f5 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -1,4 +1,10 @@ -import { average } from "@excalidraw/math"; +import { + average, + type GlobalPoint, + type LocalPoint, + pointTranslate, + vector, +} from "@excalidraw/math"; import type { ExcalidrawBindableElement, diff --git a/packages/element/src/binding.ts b/packages/element/src/binding.ts index 331300b6f5..356db32026 100644 --- a/packages/element/src/binding.ts +++ b/packages/element/src/binding.ts @@ -26,7 +26,7 @@ import { PRECISION, } from "@excalidraw/math"; -import { isPointOnShape } from "@excalidraw/utils/collision"; +import { isPointInShape, isPointOnShape } from "@excalidraw/utils/collision"; import type { LocalPoint, Radians } from "@excalidraw/math"; diff --git a/packages/excalidraw/actions/actionFinalize.tsx b/packages/excalidraw/actions/actionFinalize.tsx index e0180ecd72..b29898e7c4 100644 --- a/packages/excalidraw/actions/actionFinalize.tsx +++ b/packages/excalidraw/actions/actionFinalize.tsx @@ -3,11 +3,13 @@ import { type GlobalPoint, pointFrom } from "@excalidraw/math"; import { maybeBindLinearElement, bindOrUnbindLinearElement, + getHoveredElementForBinding, } from "@excalidraw/element/binding"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; import { mutateElement } from "@excalidraw/element/mutateElement"; import { isBindingElement, + isElbowArrow, isLinearElement, } from "@excalidraw/element/typeChecks"; diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index cdf0757f3c..bec9e9665d 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -101,6 +101,7 @@ import { arrayToMap, type EXPORT_IMAGE_TYPES, randomInteger, + toLocalPoint, } from "@excalidraw/common"; import { @@ -119,6 +120,8 @@ import { shouldEnableBindingForPointerEvent, updateBoundElements, getSuggestedBindingsForArrows, + getOutlineAvoidingPoint, + FIXED_BINDING_DISTANCE, } from "@excalidraw/element/binding"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; @@ -230,6 +233,7 @@ import { hitElementBoundText, hitElementBoundingBoxOnly, hitElementItself, + intersectElementWithLineSegment, } from "@excalidraw/element/collision"; import { getVisibleSceneBounds } from "@excalidraw/element/bounds"; @@ -330,7 +334,7 @@ import type { ExcalidrawArrowElement, } from "@excalidraw/element/types"; -import type { ValueOf } from "@excalidraw/common/utility-types"; +import type { Mutable, ValueOf } from "@excalidraw/common/utility-types"; import { actionAddToLibrary, diff --git a/packages/excalidraw/data/transform.test.ts b/packages/excalidraw/data/transform.test.ts index 75c8b40643..46a86c6e63 100644 --- a/packages/excalidraw/data/transform.test.ts +++ b/packages/excalidraw/data/transform.test.ts @@ -1,6 +1,8 @@ import { pointFrom } from "@excalidraw/math"; import { vi } from "vitest"; +import { FIXED_BINDING_DISTANCE } from "@excalidraw/element/binding"; + import type { ExcalidrawArrowElement } from "@excalidraw/element/types"; import { convertToExcalidrawElements } from "./transform"; diff --git a/packages/excalidraw/tests/history.test.tsx b/packages/excalidraw/tests/history.test.tsx index f3ab4d9705..a97a082694 100644 --- a/packages/excalidraw/tests/history.test.tsx +++ b/packages/excalidraw/tests/history.test.tsx @@ -6,6 +6,7 @@ import { waitFor, } from "@testing-library/react"; import { vi } from "vitest"; +import { FIXED_BINDING_DISTANCE } from "@excalidraw/element/binding"; import { pointFrom } from "@excalidraw/math"; import { newElementWith } from "@excalidraw/element/mutateElement"; @@ -52,8 +53,6 @@ import * as StaticScene from "../renderer/staticScene"; import { Snapshot, CaptureUpdateAction } from "../store"; import { AppStateChange, ElementsChange } from "../change"; -import { FIXED_BINDING_DISTANCE } from "../element/binding.js"; - import { API } from "./helpers/api"; import { Keyboard, Pointer, UI } from "./helpers/ui"; import {