Images now always bind inside

This commit is contained in:
Mark Tolmacs 2025-07-28 14:19:54 +02:00
parent fc350cf9f5
commit 4b3eef6099
No known key found for this signature in database
2 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,11 @@
import { average } from "@excalidraw/math";
import { isImageElement } from "@excalidraw/element";
import type { FontFamilyValues, FontString } from "@excalidraw/element/types";
import type {
ExcalidrawBindableElement,
FontFamilyValues,
FontString,
} from "@excalidraw/element/types";
import type {
ActiveTool,
@ -562,6 +567,9 @@ export const isTransparent = (color: string) => {
);
};
export const isAlwaysInsideBinding = (element: ExcalidrawBindableElement) =>
isImageElement(element);
export type ResolvablePromise<T> = Promise<T> & {
resolve: [T] extends [undefined]
? (value?: MaybePromise<Awaited<T>>) => void

View File

@ -1,4 +1,10 @@
import { KEYS, arrayToMap, invariant, tupleToCoors } from "@excalidraw/common";
import {
KEYS,
arrayToMap,
invariant,
isAlwaysInsideBinding,
tupleToCoors,
} from "@excalidraw/common";
import {
lineSegment,
@ -318,7 +324,10 @@ const bindingStrategyForEndpointDragging = (
// If the global bind mode is in free binding mode, just bind
// where the pointer is and keep the other end intact
if (globalBindMode === "inside") {
if (
globalBindMode === "inside" ||
(hovered && isAlwaysInsideBinding(hovered))
) {
current = hovered
? {
element: hovered,
@ -393,7 +402,6 @@ const bindingStrategyForEndpointDragging = (
}
// The dragged point is inside the hovered bindable element
else {
console.log(oppositeBinding);
// The opposite binding is on the same element
// eslint-disable-next-line no-lonely-if
if (oppositeBinding) {