Mark Tolmacs 5 mēneši atpakaļ
vecāks
revīzija
8d28b47989

+ 7 - 1
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,

+ 1 - 1
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";
 

+ 2 - 0
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";
 

+ 5 - 1
packages/excalidraw/components/App.tsx

@@ -100,6 +100,7 @@ import {
   isShallowEqual,
   arrayToMap,
   type EXPORT_IMAGE_TYPES,
+  toLocalPoint,
 } from "@excalidraw/common";
 
 import {
@@ -118,6 +119,8 @@ import {
   shouldEnableBindingForPointerEvent,
   updateBoundElements,
   getSuggestedBindingsForArrows,
+  getOutlineAvoidingPoint,
+  FIXED_BINDING_DISTANCE,
 } from "@excalidraw/element/binding";
 
 import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
@@ -229,6 +232,7 @@ import {
   hitElementBoundText,
   hitElementBoundingBoxOnly,
   hitElementItself,
+  intersectElementWithLineSegment,
 } from "@excalidraw/element/collision";
 
 import { getVisibleSceneBounds } from "@excalidraw/element/bounds";
@@ -329,7 +333,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,

+ 2 - 0
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";

+ 1 - 2
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 {