@ -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 } ) = > (
< ToolButton
hidden = { ! alignActionsPredicate ( elements, appState, null , app ) }
hidden = { ! alignActionsPredicate ( appState, app ) }
type = "button"
icon = { AlignTopIcon }
onClick = { ( ) = > updateData ( null ) }
@ -98,7 +97,8 @@ export const actionAlignBottom = register({
label : "labels.alignBottom" ,
icon : AlignBottomIcon ,
trackEvent : { category : "element" } ,
predicate : alignActionsPredicate ,
predicate : ( elements , appState , appProps , app ) = >
alignActionsPredicate ( appState , app ) ,
perform : ( elements , appState , _ , app ) = > {
return {
appState ,
@ -113,7 +113,7 @@ export const actionAlignBottom = register({
event [ KEYS . CTRL_OR_CMD ] && event . shiftKey && event . key === KEYS . ARROW_DOWN ,
PanelComponent : ( { elements , appState , updateData , app } ) = > (
< ToolButton
hidden = { ! alignActionsPredicate ( elements, appState, null , app ) }
hidden = { ! alignActionsPredicate ( appState, app ) }
type = "button"
icon = { AlignBottomIcon }
onClick = { ( ) = > updateData ( null ) }
@ -131,7 +131,8 @@ export const actionAlignLeft = register({
label : "labels.alignLeft" ,
icon : AlignLeftIcon ,
trackEvent : { category : "element" } ,
predicate : alignActionsPredicate ,
predicate : ( elements , appState , appProps , app ) = >
alignActionsPredicate ( appState , app ) ,
perform : ( elements , appState , _ , app ) = > {
return {
appState ,
@ -146,7 +147,7 @@ export const actionAlignLeft = register({
event [ KEYS . CTRL_OR_CMD ] && event . shiftKey && event . key === KEYS . ARROW_LEFT ,
PanelComponent : ( { elements , appState , updateData , app } ) = > (
< ToolButton
hidden = { ! alignActionsPredicate ( elements, appState, null , app ) }
hidden = { ! alignActionsPredicate ( appState, app ) }
type = "button"
icon = { AlignLeftIcon }
onClick = { ( ) = > updateData ( null ) }
@ -164,7 +165,8 @@ export const actionAlignRight = register({
label : "labels.alignRight" ,
icon : AlignRightIcon ,
trackEvent : { category : "element" } ,
predicate : alignActionsPredicate ,
predicate : ( elements , appState , appProps , app ) = >
alignActionsPredicate ( appState , app ) ,
perform : ( elements , appState , _ , app ) = > {
return {
appState ,
@ -179,7 +181,7 @@ export const actionAlignRight = register({
event [ KEYS . CTRL_OR_CMD ] && event . shiftKey && event . key === KEYS . ARROW_RIGHT ,
PanelComponent : ( { elements , appState , updateData , app } ) = > (
< ToolButton
hidden = { ! alignActionsPredicate ( elements, appState, null , app ) }
hidden = { ! alignActionsPredicate ( appState, app ) }
type = "button"
icon = { AlignRightIcon }
onClick = { ( ) = > updateData ( null ) }
@ -197,7 +199,8 @@ export const actionAlignVerticallyCentered = register({
label : "labels.centerVertically" ,
icon : CenterVerticallyIcon ,
trackEvent : { category : "element" } ,
predicate : alignActionsPredicate ,
predicate : ( elements , appState , appProps , app ) = >
alignActionsPredicate ( appState , app ) ,
perform : ( elements , appState , _ , app ) = > {
return {
appState ,
@ -210,7 +213,7 @@ export const actionAlignVerticallyCentered = register({
} ,
PanelComponent : ( { elements , appState , updateData , app } ) = > (
< ToolButton
hidden = { ! alignActionsPredicate ( elements, appState, null , app ) }
hidden = { ! alignActionsPredicate ( appState, app ) }
type = "button"
icon = { CenterVerticallyIcon }
onClick = { ( ) = > updateData ( null ) }
@ -226,7 +229,8 @@ export const actionAlignHorizontallyCentered = register({
label : "labels.centerHorizontally" ,
icon : CenterHorizontallyIcon ,
trackEvent : { category : "element" } ,
predicate : alignActionsPredicate ,
predicate : ( elements , appState , appProps , app ) = >
alignActionsPredicate ( appState , app ) ,
perform : ( elements , appState , _ , app ) = > {
return {
appState ,
@ -239,7 +243,7 @@ export const actionAlignHorizontallyCentered = register({
} ,
PanelComponent : ( { elements , appState , updateData , app } ) = > (
< ToolButton
hidden = { ! alignActionsPredicate ( elements, appState, null , app ) }
hidden = { ! alignActionsPredicate ( appState, app ) }
type = "button"
icon = { CenterHorizontallyIcon }
onClick = { ( ) = > updateData ( null ) }