Render focus point in debug mode

This commit is contained in:
Mark Tolmacs
2025-08-25 16:57:32 +02:00
parent 0c39ace058
commit d1688deda7
2 changed files with 46 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ import {
getNormalizedCanvasDimensions,
} from "@excalidraw/excalidraw/renderer/helpers";
import { type AppState } from "@excalidraw/excalidraw/types";
import { arrayToMap, invariant, throttleRAF } from "@excalidraw/common";
import { arrayToMap, throttleRAF } from "@excalidraw/common";
import { useCallback } from "react";
import {
@@ -181,12 +181,13 @@ const renderBindings = (
if (isArrowElement(element)) {
if (element.startBinding) {
invariant(
elementsMap
if (
!elementsMap
.get(element.startBinding.elementId)
?.boundElements?.find((e) => e.id === element.id),
"Missing record in boundElements for arrow",
);
?.boundElements?.find((e) => e.id === element.id)
) {
return;
}
_renderBinding(
context,
@@ -200,6 +201,13 @@ const renderBindings = (
}
if (element.endBinding) {
if (
!elementsMap
.get(element.endBinding.elementId)
?.boundElements?.find((e) => e.id === element.id)
) {
return;
}
_renderBinding(
context,
element.endBinding,

View File

@@ -1,8 +1,10 @@
import {
KEYS,
arrayToMap,
debugDrawPoint,
invariant,
isAlwaysInsideBinding,
isDevEnv,
tupleToCoors,
} from "@excalidraw/common";
@@ -588,7 +590,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
// Handle new arrow creation separately, as it is special
if (opts?.newArrow) {
return bindingStrategyForNewSimpleArrowEndpointDragging(
const { start, end } = bindingStrategyForNewSimpleArrowEndpointDragging(
arrow,
draggingPoints,
elementsMap,
@@ -600,6 +602,17 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
appState,
globalBindMode,
);
if (isDevEnv()) {
if (start?.focusPoint) {
debugDrawPoint(start.focusPoint);
}
if (end?.focusPoint) {
debugDrawPoint(end.focusPoint);
}
}
return { start, end };
}
// Only the start point is dragged
@@ -621,6 +634,15 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
{ appState },
);
if (isDevEnv()) {
if (current?.focusPoint) {
debugDrawPoint(current.focusPoint);
}
if (other?.focusPoint) {
debugDrawPoint(other.focusPoint);
}
}
return { start: current, end: other };
}
@@ -642,6 +664,15 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
{ appState },
);
if (isDevEnv()) {
if (current?.focusPoint) {
debugDrawPoint(current.focusPoint);
}
if (other?.focusPoint) {
debugDrawPoint(other.focusPoint);
}
}
return { start: other, end: current };
}