From 52eaf645919361c05d5ff75bd32d0e0e3a54e7e1 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Wed, 29 Jan 2025 08:10:16 +1100 Subject: [PATCH] feat: box select frame & children to allow resizing at the same time (#9031) * box select frame & children * avoid selecting children twice to avoid double their moving * do not show ele stats if frame and children selected together * do not update frame membership if selected together * do not group frame and its children * comment and refactor code * hide align altogether * include frame children when selecting all * simplify --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com> --- packages/excalidraw/actions/actionAlign.tsx | 34 +++++++------ packages/excalidraw/actions/actionFrame.ts | 1 + packages/excalidraw/actions/actionGroup.tsx | 17 +++++-- .../excalidraw/actions/actionSelectAll.ts | 15 +++--- packages/excalidraw/components/Actions.tsx | 8 ++- packages/excalidraw/components/App.tsx | 24 +++++++-- packages/excalidraw/components/LayerUI.tsx | 1 + packages/excalidraw/components/MobileMenu.tsx | 1 + .../excalidraw/components/Stats/index.tsx | 7 ++- packages/excalidraw/frame.ts | 49 ++++++++++++++++--- packages/excalidraw/scene/selection.ts | 7 ++- .../tests/__snapshots__/move.test.tsx.snap | 2 +- 12 files changed, 122 insertions(+), 44 deletions(-) diff --git a/packages/excalidraw/actions/actionAlign.tsx b/packages/excalidraw/actions/actionAlign.tsx index ed078e9d54..2acc12bfe5 100644 --- a/packages/excalidraw/actions/actionAlign.tsx +++ b/packages/excalidraw/actions/actionAlign.tsx @@ -21,10 +21,8 @@ import type { AppClassProperties, AppState, UIAppState } from "../types"; import { arrayToMap, getShortcutKey } from "../utils"; import { register } from "./register"; -const alignActionsPredicate = ( - elements: readonly ExcalidrawElement[], +export const alignActionsPredicate = ( appState: UIAppState, - _: unknown, app: AppClassProperties, ) => { const selectedElements = app.scene.getSelectedElements(appState); @@ -65,7 +63,8 @@ export const actionAlignTop = register({ label: "labels.alignTop", icon: AlignTopIcon, trackEvent: { category: "element" }, - predicate: alignActionsPredicate, + predicate: (elements, appState, appProps, app) => + alignActionsPredicate(appState, app), perform: (elements, appState, _, app) => { return { appState, @@ -80,7 +79,7 @@ export const actionAlignTop = register({ event[KEYS.CTRL_OR_CMD] && event.shiftKey && event.key === KEYS.ARROW_UP, PanelComponent: ({ elements, appState, updateData, app }) => (