diff --git a/src/actions/actionAddToLibrary.ts b/src/actions/actionAddToLibrary.ts index a4fca560..ef69a60d 100644 --- a/src/actions/actionAddToLibrary.ts +++ b/src/actions/actionAddToLibrary.ts @@ -12,7 +12,10 @@ export const actionAddToLibrary = register({ const selectedElements = getSelectedElements( getNonDeletedElements(elements), appState, - true, + { + includeBoundTextElement: true, + includeElementsInFrames: true, + }, ); if (selectedElements.some((element) => element.type === "image")) { return { diff --git a/src/actions/actionAlign.tsx b/src/actions/actionAlign.tsx index eceb4217..d917f803 100644 --- a/src/actions/actionAlign.tsx +++ b/src/actions/actionAlign.tsx @@ -10,6 +10,7 @@ import { import { ToolButton } from "../components/ToolButton"; import { getNonDeletedElements } from "../element"; import { ExcalidrawElement } from "../element/types"; +import { updateFrameMembershipOfSelectedElements } from "../frame"; import { t } from "../i18n"; import { KEYS } from "../keys"; import { getSelectedElements, isSomeElementSelected } from "../scene"; @@ -17,10 +18,20 @@ import { AppState } from "../types"; import { arrayToMap, getShortcutKey } from "../utils"; import { register } from "./register"; -const enableActionGroup = ( +const alignActionsPredicate = ( elements: readonly ExcalidrawElement[], appState: AppState, -) => getSelectedElements(getNonDeletedElements(elements), appState).length > 1; +) => { + const selectedElements = getSelectedElements( + getNonDeletedElements(elements), + appState, + ); + return ( + selectedElements.length > 1 && + // TODO enable aligning frames when implemented properly + !selectedElements.some((el) => el.type === "frame") + ); +}; const alignSelectedElements = ( elements: readonly ExcalidrawElement[], @@ -36,14 +47,16 @@ const alignSelectedElements = ( const updatedElementsMap = arrayToMap(updatedElements); - return elements.map( - (element) => updatedElementsMap.get(element.id) || element, + return updateFrameMembershipOfSelectedElements( + elements.map((element) => updatedElementsMap.get(element.id) || element), + appState, ); }; export const actionAlignTop = register({ name: "alignTop", trackEvent: { category: "element" }, + predicate: alignActionsPredicate, perform: (elements, appState) => { return { appState, @@ -58,7 +71,7 @@ export const actionAlignTop = register({ event[KEYS.CTRL_OR_CMD] && event.shiftKey && event.key === KEYS.ARROW_UP, PanelComponent: ({ elements, appState, updateData }) => (