@@ -27,6 +27,7 @@ import * as Constants from './constants';
2727import { Navigation } from './navigation' ;
2828import { Announcer } from './announcer' ;
2929import { LineCursor } from './line_cursor' ;
30+ import { ShortcutDialog } from './shortcut_dialog' ;
3031
3132const KeyCodes = BlocklyUtils . KeyCodes ;
3233const createSerializedKey = ShortcutRegistry . registry . createSerializedKey . bind (
@@ -44,6 +45,7 @@ export class NavigationController {
4445 copyWorkspace : WorkspaceSvg | null = null ;
4546 navigation : Navigation = new Navigation ( ) ;
4647 announcer : Announcer = new Announcer ( ) ;
48+ shortcutDialog : ShortcutDialog = new ShortcutDialog ( ) ;
4749
4850 isAutoNavigationEnabled : boolean = false ;
4951 hasNavigationFocus : boolean = false ;
@@ -220,7 +222,7 @@ export class NavigationController {
220222 [ name : string ] : ShortcutRegistry . KeyboardShortcut ;
221223 } = {
222224 /** Go to the previous location. */
223- previous : {
225+ previous : {
224226 name : Constants . SHORTCUT_NAMES . PREVIOUS ,
225227 preconditionFn : ( workspace ) => workspace . keyboardAccessibilityMode ,
226228 callback : ( workspace , _ , shortcut ) => {
@@ -367,7 +369,7 @@ export class NavigationController {
367369 insert : {
368370 name : Constants . SHORTCUT_NAMES . INSERT ,
369371 preconditionFn : ( workspace ) =>
370- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
372+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
371373 callback : ( workspace ) => {
372374 switch ( this . navigation . getState ( workspace ) ) {
373375 case Constants . STATE . WORKSPACE :
@@ -442,7 +444,7 @@ export class NavigationController {
442444 disconnect : {
443445 name : Constants . SHORTCUT_NAMES . DISCONNECT ,
444446 preconditionFn : ( workspace ) =>
445- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
447+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
446448 callback : ( workspace ) => {
447449 switch ( this . navigation . getState ( workspace ) ) {
448450 case Constants . STATE . WORKSPACE :
@@ -459,7 +461,7 @@ export class NavigationController {
459461 focusToolbox : {
460462 name : Constants . SHORTCUT_NAMES . TOOLBOX ,
461463 preconditionFn : ( workspace ) =>
462- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
464+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
463465 callback : ( workspace ) => {
464466 switch ( this . navigation . getState ( workspace ) ) {
465467 case Constants . STATE . WORKSPACE :
@@ -507,7 +509,7 @@ export class NavigationController {
507509 wsMoveLeft : {
508510 name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_LEFT ,
509511 preconditionFn : ( workspace ) =>
510- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
512+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
511513 callback : ( workspace ) => {
512514 return this . navigation . moveWSCursor ( workspace , - 1 , 0 ) ;
513515 } ,
@@ -518,7 +520,7 @@ export class NavigationController {
518520 wsMoveRight : {
519521 name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_RIGHT ,
520522 preconditionFn : ( workspace ) =>
521- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
523+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
522524 callback : ( workspace ) => {
523525 return this . navigation . moveWSCursor ( workspace , 1 , 0 ) ;
524526 } ,
@@ -529,7 +531,7 @@ export class NavigationController {
529531 wsMoveUp : {
530532 name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_UP ,
531533 preconditionFn : ( workspace ) =>
532- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
534+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
533535 callback : ( workspace ) => {
534536 return this . navigation . moveWSCursor ( workspace , 0 , - 1 ) ;
535537 } ,
@@ -540,7 +542,7 @@ export class NavigationController {
540542 wsMoveDown : {
541543 name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_DOWN ,
542544 preconditionFn : ( workspace ) =>
543- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
545+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
544546 callback : ( workspace ) => {
545547 return this . navigation . moveWSCursor ( workspace , 0 , 1 ) ;
546548 } ,
@@ -593,9 +595,9 @@ export class NavigationController {
593595 paste : {
594596 name : Constants . SHORTCUT_NAMES . PASTE ,
595597 preconditionFn : ( workspace ) =>
596- workspace . keyboardAccessibilityMode &&
597- ! workspace . options . readOnly &&
598- ! Blockly . Gesture . inProgress ( ) ,
598+ workspace . keyboardAccessibilityMode &&
599+ ! workspace . options . readOnly &&
600+ ! Blockly . Gesture . inProgress ( ) ,
599601 callback : ( ) => {
600602 if ( ! this . copyData || ! this . copyWorkspace ) return false ;
601603 return this . navigation . paste ( this . copyData , this . copyWorkspace ) ;
@@ -688,11 +690,11 @@ export class NavigationController {
688690 allowCollision : true ,
689691 } ,
690692
691- /** List all current shortcuts in the announcer area . */
693+ /** List all of the currently registered shortcuts . */
692694 announceShortcuts : {
693695 name : Constants . SHORTCUT_NAMES . LIST_SHORTCUTS ,
694696 callback : ( workspace ) => {
695- this . announcer . listShortcuts ( ) ;
697+ this . shortcutDialog . toggle ( ) ;
696698 return true ;
697699 } ,
698700 keyCodes : [ KeyCodes . SLASH ] ,
@@ -845,7 +847,7 @@ export class NavigationController {
845847 } ,
846848 keyCodes : [
847849 createSerializedKey ( KeyCodes . TAB , [ KeyCodes . SHIFT ] ) ,
848- KeyCodes . TAB
850+ KeyCodes . TAB ,
849851 ] ,
850852 } ,
851853 } ;
@@ -859,6 +861,11 @@ export class NavigationController {
859861 for ( const shortcut of Object . values ( this . shortcuts ) ) {
860862 ShortcutRegistry . registry . register ( shortcut ) ;
861863 }
864+
865+ // Initalise the shortcut modal with available shortcuts. Needs
866+ // to be done separately rather at construction, as many shortcuts
867+ // are not registered at that point.
868+ this . shortcutDialog . createModalContent ( ) ;
862869 }
863870
864871 /**
0 commit comments