Skip to content

Commit 307f1e9

Browse files
feat: add option to sort block tunes
1 parent 1a6d8ec commit 307f1e9

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

src/components/block-tunes/block-tune-delete.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default class DeleteTune implements BlockTune {
4444
title: this.api.i18n.t('Click to delete'),
4545
onActivate: (): void => this.handleClick(),
4646
},
47+
sort: 302,
4748
};
4849
}
4950

src/components/block-tunes/block-tune-move-down.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default class MoveDownTune implements BlockTune {
5050
title: this.api.i18n.t('Move down'),
5151
onActivate: (): void => this.handleClick(),
5252
name: 'move-down',
53+
sort: 303,
5354
};
5455
}
5556

src/components/block-tunes/block-tune-move-up.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default class MoveUpTune implements BlockTune {
4848
title: this.api.i18n.t('Move up'),
4949
onActivate: (): void => this.handleClick(),
5050
name: 'move-up',
51+
sort: 301,
5152
};
5253
}
5354

src/components/modules/toolbar/blockSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
116116
*/
117117
const [tunesItems, customHtmlTunesContainer] = targetBlock.getTunes();
118118

119+
tunesItems.sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100))
120+
119121
/** Tell to subscribers that block settings is opened */
120122
this.eventsDispatcher.emit(this.events.opened);
121123
this.popover = new Popover({

types/configs/popover.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ export interface PopoverItemWithoutConfirmation extends PopoverItemBase {
7777
/**
7878
* Represents single popover item
7979
*/
80-
export type PopoverItem = PopoverItemWithConfirmation | PopoverItemWithoutConfirmation
80+
export type PopoverItem = (PopoverItemWithConfirmation | PopoverItemWithoutConfirmation) & {
81+
sort?: number;
82+
}
8183

0 commit comments

Comments
 (0)