From 971237c0df48f8281cec6c6ab2b0c6d142489bfa Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Tue, 28 Apr 2026 16:22:49 +1000 Subject: [PATCH] Revert "refactor(snapping): clarify linear point reference options" This reverts commit 79beed3f5c75fb9faa92f420468ff5679a1bad60. --- packages/element/src/linearElementEditor.ts | 5 ++--- packages/element/src/snapping.ts | 24 ++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/element/src/linearElementEditor.ts b/packages/element/src/linearElementEditor.ts index 7045736e2f..92fef508cc 100644 --- a/packages/element/src/linearElementEditor.ts +++ b/packages/element/src/linearElementEditor.ts @@ -1913,9 +1913,8 @@ export class LinearElementEditor { event, elementsMap, { - selfReferencePoints: { - excludedPointIndices: selectedPointsIndices, - }, + includeSelfPoints: true, + selectedPointsIndices, }, ); diff --git a/packages/element/src/snapping.ts b/packages/element/src/snapping.ts index c734519527..09610c379e 100644 --- a/packages/element/src/snapping.ts +++ b/packages/element/src/snapping.ts @@ -654,20 +654,19 @@ export const getReferenceSnapPoints = ( .flatMap((elementGroup) => getElementsCorners(elementGroup, elementsMap)); }; -type LinearElementPointReferencePointsOptions = { - selfReferencePoints?: { - excludedPointIndices?: readonly number[]; - }; -}; - export const getReferenceSnapPointsForLinearElementPoint = ( elements: readonly NonDeletedExcalidrawElement[], editingElement: ExcalidrawLinearElement, editingPointIndex: number, appState: AppState, elementsMap: ElementsMap, - options: LinearElementPointReferencePointsOptions = {}, + options: { + includeSelfPoints?: boolean; + selectedPointsIndices?: readonly number[]; + } = {}, ) => { + const { includeSelfPoints = false } = options; + // Get all reference elements (excluding the one being edited) const referenceElements = getReferenceElements( elements, @@ -692,14 +691,12 @@ export const getReferenceSnapPointsForLinearElementPoint = ( } // Include other points from the same linear element when creating new points or in editing mode - if (options.selfReferencePoints) { - const excludedPointIndices = - options.selfReferencePoints.excludedPointIndices ?? [editingPointIndex]; + if (includeSelfPoints) { const elementPoints = LinearElementEditor.getPointsGlobalCoordinates( editingElement as NonDeleted, elementsMap, { - excludePointsIndices: excludedPointIndices, + excludePointsIndices: options.selectedPointsIndices, }, ); allSnapPoints.push(...elementPoints); @@ -716,7 +713,10 @@ export const snapLinearElementPoint = ( app: AppClassProperties, event: KeyboardModifiersObject, elementsMap: ElementsMap, - options: LinearElementPointReferencePointsOptions = {}, + options: { + includeSelfPoints?: boolean; + selectedPointsIndices?: readonly number[]; + } = {}, ) => { if ( !isSnappingEnabled({ app, event, selectedElements: [editingElement] }) ||