From 2a72e041ed8e7eebf0cb6a4916780f9dce9edaea Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Wed, 26 Feb 2025 18:31:26 +1100 Subject: [PATCH] select a single linear el --- packages/excalidraw/lasso/index.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/excalidraw/lasso/index.ts b/packages/excalidraw/lasso/index.ts index 72a55bd1a..9e165a9c5 100644 --- a/packages/excalidraw/lasso/index.ts +++ b/packages/excalidraw/lasso/index.ts @@ -2,8 +2,13 @@ import { GlobalPoint, pointFrom } from "../../math"; import { AnimatedTrail } from "../animated-trail"; import { AnimationFrameHandler } from "../animation-frame-handler"; import App from "../components/App"; -import { isFrameLikeElement } from "../element/typeChecks"; -import { ExcalidrawElement } from "../element/types"; +import { LinearElementEditor } from "../element/linearElementEditor"; +import { isFrameLikeElement, isLinearElement } from "../element/typeChecks"; +import { + ExcalidrawElement, + ExcalidrawLinearElement, + NonDeleted, +} from "../element/types"; import { getFrameChildren } from "../frame"; import { selectGroupsForSelectedElements } from "../groups"; import { easeOut } from "../utils"; @@ -77,9 +82,24 @@ export class LassoTrail extends AnimatedTrail { this.app, ); + const selectedIds = [...Object.keys(nextSelection.selectedElementIds)]; + const selectedGroupIds = [ + ...Object.keys(nextSelection.selectedGroupIds), + ]; + return { selectedElementIds: nextSelection.selectedElementIds, selectedGroupIds: nextSelection.selectedGroupIds, + selectedLinearElement: + selectedIds.length === 1 && + !selectedGroupIds.length && + isLinearElement(this.app.scene.getNonDeletedElement(selectedIds[0])) + ? new LinearElementEditor( + this.app.scene.getNonDeletedElement( + selectedIds[0], + ) as NonDeleted, + ) + : null, }; }); };