Revert "refactor(snapping): clarify linear point reference options"
This reverts commit 79beed3f5c.
This commit is contained in:
@@ -1913,9 +1913,8 @@ export class LinearElementEditor {
|
|||||||
event,
|
event,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
{
|
{
|
||||||
selfReferencePoints: {
|
includeSelfPoints: true,
|
||||||
excludedPointIndices: selectedPointsIndices,
|
selectedPointsIndices,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -654,20 +654,19 @@ export const getReferenceSnapPoints = (
|
|||||||
.flatMap((elementGroup) => getElementsCorners(elementGroup, elementsMap));
|
.flatMap((elementGroup) => getElementsCorners(elementGroup, elementsMap));
|
||||||
};
|
};
|
||||||
|
|
||||||
type LinearElementPointReferencePointsOptions = {
|
|
||||||
selfReferencePoints?: {
|
|
||||||
excludedPointIndices?: readonly number[];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getReferenceSnapPointsForLinearElementPoint = (
|
export const getReferenceSnapPointsForLinearElementPoint = (
|
||||||
elements: readonly NonDeletedExcalidrawElement[],
|
elements: readonly NonDeletedExcalidrawElement[],
|
||||||
editingElement: ExcalidrawLinearElement,
|
editingElement: ExcalidrawLinearElement,
|
||||||
editingPointIndex: number,
|
editingPointIndex: number,
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
elementsMap: ElementsMap,
|
elementsMap: ElementsMap,
|
||||||
options: LinearElementPointReferencePointsOptions = {},
|
options: {
|
||||||
|
includeSelfPoints?: boolean;
|
||||||
|
selectedPointsIndices?: readonly number[];
|
||||||
|
} = {},
|
||||||
) => {
|
) => {
|
||||||
|
const { includeSelfPoints = false } = options;
|
||||||
|
|
||||||
// Get all reference elements (excluding the one being edited)
|
// Get all reference elements (excluding the one being edited)
|
||||||
const referenceElements = getReferenceElements(
|
const referenceElements = getReferenceElements(
|
||||||
elements,
|
elements,
|
||||||
@@ -692,14 +691,12 @@ export const getReferenceSnapPointsForLinearElementPoint = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Include other points from the same linear element when creating new points or in editing mode
|
// Include other points from the same linear element when creating new points or in editing mode
|
||||||
if (options.selfReferencePoints) {
|
if (includeSelfPoints) {
|
||||||
const excludedPointIndices =
|
|
||||||
options.selfReferencePoints.excludedPointIndices ?? [editingPointIndex];
|
|
||||||
const elementPoints = LinearElementEditor.getPointsGlobalCoordinates(
|
const elementPoints = LinearElementEditor.getPointsGlobalCoordinates(
|
||||||
editingElement as NonDeleted<ExcalidrawLinearElement>,
|
editingElement as NonDeleted<ExcalidrawLinearElement>,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
{
|
{
|
||||||
excludePointsIndices: excludedPointIndices,
|
excludePointsIndices: options.selectedPointsIndices,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
allSnapPoints.push(...elementPoints);
|
allSnapPoints.push(...elementPoints);
|
||||||
@@ -716,7 +713,10 @@ export const snapLinearElementPoint = (
|
|||||||
app: AppClassProperties,
|
app: AppClassProperties,
|
||||||
event: KeyboardModifiersObject,
|
event: KeyboardModifiersObject,
|
||||||
elementsMap: ElementsMap,
|
elementsMap: ElementsMap,
|
||||||
options: LinearElementPointReferencePointsOptions = {},
|
options: {
|
||||||
|
includeSelfPoints?: boolean;
|
||||||
|
selectedPointsIndices?: readonly number[];
|
||||||
|
} = {},
|
||||||
) => {
|
) => {
|
||||||
if (
|
if (
|
||||||
!isSnappingEnabled({ app, event, selectedElements: [editingElement] }) ||
|
!isSnappingEnabled({ app, event, selectedElements: [editingElement] }) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user