File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1081,6 +1081,29 @@ export class NavigationController {
10811081 ShortcutRegistry . registry . addKeyMapping ( ctrlShiftI , shortcut . name ) ;
10821082 }
10831083
1084+ /**
1085+ * Register a shortcut to clean up the workspace.
1086+ */
1087+ registerCleanup ( ) {
1088+ const cleanupShortcut : Blockly . ShortcutRegistry . KeyboardShortcut = {
1089+ name : 'Clean up workspace' ,
1090+ preconditionFn : ( workspace ) => {
1091+ return workspace . getTopBlocks ( false ) . length > 0 ;
1092+ } ,
1093+ callback : ( workspace ) => {
1094+ workspace . cleanUp ( ) ;
1095+ this . announcer . setText ( 'clean up' ) ;
1096+ return true ;
1097+ } ,
1098+ } ;
1099+
1100+ ShortcutRegistry . registry . register ( cleanupShortcut ) ;
1101+ ShortcutRegistry . registry . addKeyMapping (
1102+ BlocklyUtils . KeyCodes . C ,
1103+ cleanupShortcut . name ,
1104+ ) ;
1105+ }
1106+
10841107 /**
10851108 * Registers all default keyboard shortcut items for keyboard navigation. This
10861109 * should be called once per instance of KeyboardShortcutRegistry.
@@ -1115,6 +1138,8 @@ export class NavigationController {
11151138 this . registerListShortcuts ( ) ;
11161139 this . registerContextIn ( ) ;
11171140 this . registerContextOut ( ) ;
1141+
1142+ this . registerCleanup ( ) ;
11181143 }
11191144
11201145 /**
You can’t perform that action at this time.
0 commit comments