1
+ import { CommandType } from '../../../../../commandHandling/CommandType.js' ;
2
+ import { IContextMenuItem } from '../../../../helper/contextMenu/IContextMenuItem.js' ;
3
+ import { IDesignItem } from '../../../../item/IDesignItem.js' ;
4
+ import { NodeType } from '../../../../item/NodeType.js' ;
5
+ import { IDesignerCanvas } from '../../IDesignerCanvas.js' ;
6
+ import { ContextmenuInitiator , IContextMenuExtension } from './IContextMenuExtension.js' ;
7
+
8
+ export class AlignItemsContextMenu implements IContextMenuExtension {
9
+
10
+ public shouldProvideContextmenu ( event : MouseEvent , designerView : IDesignerCanvas , designItem : IDesignItem , initiator : ContextmenuInitiator ) {
11
+ return ! designItem ?. isRootItem && designItem ?. nodeType == NodeType . Element ;
12
+ }
13
+
14
+ public provideContextMenuItems ( event : MouseEvent , designerView : IDesignerCanvas , designItem : IDesignItem ) : IContextMenuItem [ ] {
15
+ return [
16
+ { title : 'align left' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/alignHorizontalLeft.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . arrangeLeft } ) ; } } ,
17
+ { title : 'align center' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/alignHorizontalCenter.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . arrangeCenter } ) ; } } ,
18
+ { title : 'align right' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/alignHorizontalRight.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . arrangeRight } ) ; } } ,
19
+ { title : 'distribute horizontal' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/horizontalDistribute.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . distributeHorizontal } ) ; } } ,
20
+ { title : 'align top' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/alignVerticalTop.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . arrangeTop } ) ; } } ,
21
+ { title : 'align middle' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/alignVerticalCenter.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . arrangeMiddle } ) ; } } ,
22
+ { title : 'align bottom' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/alignVerticalBottom.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . arrangeBottom } ) ; } } ,
23
+ { title : 'distribute vertical' , icon : `<img src="${ new URL ( '../../../../../../assets/icons/verticalDistribute.svg' , import . meta. url ) } ">` , action : ( ) => { designerView . executeCommand ( { type : CommandType . distributeVertical } ) ; } } ,
24
+ ]
25
+ }
26
+ }
0 commit comments