@@ -27,6 +27,7 @@ import * as Constants from './constants';
27
27
import { Navigation } from './navigation' ;
28
28
import { Announcer } from './announcer' ;
29
29
import { LineCursor } from './line_cursor' ;
30
+ import { ShortcutDialog } from './shortcut_dialog' ;
30
31
31
32
const KeyCodes = BlocklyUtils . KeyCodes ;
32
33
const createSerializedKey = ShortcutRegistry . registry . createSerializedKey . bind (
@@ -44,6 +45,7 @@ export class NavigationController {
44
45
copyWorkspace : WorkspaceSvg | null = null ;
45
46
navigation : Navigation = new Navigation ( ) ;
46
47
announcer : Announcer = new Announcer ( ) ;
48
+ shortcutDialog : ShortcutDialog = new ShortcutDialog ( ) ;
47
49
48
50
isAutoNavigationEnabled : boolean = false ;
49
51
hasNavigationFocus : boolean = false ;
@@ -220,7 +222,7 @@ export class NavigationController {
220
222
[ name : string ] : ShortcutRegistry . KeyboardShortcut ;
221
223
} = {
222
224
/** Go to the previous location. */
223
- previous : {
225
+ previous : {
224
226
name : Constants . SHORTCUT_NAMES . PREVIOUS ,
225
227
preconditionFn : ( workspace ) => workspace . keyboardAccessibilityMode ,
226
228
callback : ( workspace , _ , shortcut ) => {
@@ -367,7 +369,7 @@ export class NavigationController {
367
369
insert : {
368
370
name : Constants . SHORTCUT_NAMES . INSERT ,
369
371
preconditionFn : ( workspace ) =>
370
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
372
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
371
373
callback : ( workspace ) => {
372
374
switch ( this . navigation . getState ( workspace ) ) {
373
375
case Constants . STATE . WORKSPACE :
@@ -442,7 +444,7 @@ export class NavigationController {
442
444
disconnect : {
443
445
name : Constants . SHORTCUT_NAMES . DISCONNECT ,
444
446
preconditionFn : ( workspace ) =>
445
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
447
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
446
448
callback : ( workspace ) => {
447
449
switch ( this . navigation . getState ( workspace ) ) {
448
450
case Constants . STATE . WORKSPACE :
@@ -459,7 +461,7 @@ export class NavigationController {
459
461
focusToolbox : {
460
462
name : Constants . SHORTCUT_NAMES . TOOLBOX ,
461
463
preconditionFn : ( workspace ) =>
462
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
464
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
463
465
callback : ( workspace ) => {
464
466
switch ( this . navigation . getState ( workspace ) ) {
465
467
case Constants . STATE . WORKSPACE :
@@ -507,7 +509,7 @@ export class NavigationController {
507
509
wsMoveLeft : {
508
510
name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_LEFT ,
509
511
preconditionFn : ( workspace ) =>
510
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
512
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
511
513
callback : ( workspace ) => {
512
514
return this . navigation . moveWSCursor ( workspace , - 1 , 0 ) ;
513
515
} ,
@@ -518,7 +520,7 @@ export class NavigationController {
518
520
wsMoveRight : {
519
521
name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_RIGHT ,
520
522
preconditionFn : ( workspace ) =>
521
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
523
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
522
524
callback : ( workspace ) => {
523
525
return this . navigation . moveWSCursor ( workspace , 1 , 0 ) ;
524
526
} ,
@@ -529,7 +531,7 @@ export class NavigationController {
529
531
wsMoveUp : {
530
532
name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_UP ,
531
533
preconditionFn : ( workspace ) =>
532
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
534
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
533
535
callback : ( workspace ) => {
534
536
return this . navigation . moveWSCursor ( workspace , 0 , - 1 ) ;
535
537
} ,
@@ -540,7 +542,7 @@ export class NavigationController {
540
542
wsMoveDown : {
541
543
name : Constants . SHORTCUT_NAMES . MOVE_WS_CURSOR_DOWN ,
542
544
preconditionFn : ( workspace ) =>
543
- workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
545
+ workspace . keyboardAccessibilityMode && ! workspace . options . readOnly ,
544
546
callback : ( workspace ) => {
545
547
return this . navigation . moveWSCursor ( workspace , 0 , 1 ) ;
546
548
} ,
@@ -593,9 +595,9 @@ export class NavigationController {
593
595
paste : {
594
596
name : Constants . SHORTCUT_NAMES . PASTE ,
595
597
preconditionFn : ( workspace ) =>
596
- workspace . keyboardAccessibilityMode &&
597
- ! workspace . options . readOnly &&
598
- ! Blockly . Gesture . inProgress ( ) ,
598
+ workspace . keyboardAccessibilityMode &&
599
+ ! workspace . options . readOnly &&
600
+ ! Blockly . Gesture . inProgress ( ) ,
599
601
callback : ( ) => {
600
602
if ( ! this . copyData || ! this . copyWorkspace ) return false ;
601
603
return this . navigation . paste ( this . copyData , this . copyWorkspace ) ;
@@ -688,11 +690,11 @@ export class NavigationController {
688
690
allowCollision : true ,
689
691
} ,
690
692
691
- /** List all current shortcuts in the announcer area . */
693
+ /** List all of the currently registered shortcuts . */
692
694
announceShortcuts : {
693
695
name : Constants . SHORTCUT_NAMES . LIST_SHORTCUTS ,
694
696
callback : ( workspace ) => {
695
- this . announcer . listShortcuts ( ) ;
697
+ this . shortcutDialog . toggle ( ) ;
696
698
return true ;
697
699
} ,
698
700
keyCodes : [ KeyCodes . SLASH ] ,
@@ -845,7 +847,7 @@ export class NavigationController {
845
847
} ,
846
848
keyCodes : [
847
849
createSerializedKey ( KeyCodes . TAB , [ KeyCodes . SHIFT ] ) ,
848
- KeyCodes . TAB
850
+ KeyCodes . TAB ,
849
851
] ,
850
852
} ,
851
853
} ;
@@ -859,6 +861,11 @@ export class NavigationController {
859
861
for ( const shortcut of Object . values ( this . shortcuts ) ) {
860
862
ShortcutRegistry . registry . register ( shortcut ) ;
861
863
}
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 ( ) ;
862
869
}
863
870
864
871
/**
0 commit comments