Implement logic to determine path point insertion anchor ID

This commit is contained in:
2026-05-13 05:07:34 +02:00
parent 6e7caef931
commit 5a8882dfcb

View File

@@ -1399,6 +1399,45 @@ function getSelectedPathPointState(
}; };
} }
function getPathPointInsertionAnchorId(
selection: EditorSelection,
path: ScenePath | null,
activeSelectionId: string | null
): string | null {
if (path === null) {
return null;
}
if (selection.kind === "pathPoint" && selection.pathId === path.id) {
return selection.pointId;
}
if (selection.kind !== "pathPoints" || selection.pathId !== path.id) {
return null;
}
if (
activeSelectionId !== null &&
selection.pointIds.includes(activeSelectionId)
) {
return activeSelectionId;
}
let anchorId: string | null = null;
let anchorIndex = -1;
for (const pointId of selection.pointIds) {
const pointIndex = getScenePathPointIndex(path, pointId);
if (pointIndex > anchorIndex) {
anchorIndex = pointIndex;
anchorId = pointId;
}
}
return anchorId;
}
function isModelAsset(asset: ProjectAssetRecord): asset is ModelAssetRecord { function isModelAsset(asset: ProjectAssetRecord): asset is ModelAssetRecord {
return asset.kind === "model"; return asset.kind === "model";
} }