File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 102102 "devDependencies" : {
103103 "@blockly/block-test" : " ^7.0.2" ,
104104 "@blockly/dev-tools" : " ^9.0.2" ,
105+ "@blockly/keyboard-navigation" : " ^3.0.1" ,
105106 "@blockly/theme-modern" : " ^7.0.1" ,
106107 "@hyperjump/browser" : " ^1.1.4" ,
107108 "@hyperjump/json-schema" : " ^1.5.0" ,
Original file line number Diff line number Diff line change 1818 await loadScript (
1919 '../../node_modules/@blockly/theme-modern/dist/index.js' ,
2020 ) ;
21+ await loadScript (
22+ '../../node_modules/@blockly/keyboard-navigation/dist/index.js' ,
23+ ) ;
24+
25+ let kbNavigation ;
2126
2227 function start ( ) {
2328 setBackgroundColour ( ) ;
4752 // Refresh theme.
4853 ws . setTheme ( ws . getTheme ( ) ) ;
4954 } ) ;
55+
56+ // Keyboard navigation options.
57+ const kbOptions = {
58+ 'Enable keyboard navigation' : false ,
59+ } ;
60+ gui . remember ( kbOptions ) ;
61+ gui . add ( kbOptions , 'Enable keyboard navigation' ) . onChange ( ( enabled ) => {
62+ setupKeyboardNav ( enabled , playground ) ;
63+ } ) ;
64+
65+ // Set up keyboard navigation on page load
66+ setupKeyboardNav ( kbOptions [ 'Enable keyboard navigation' ] , playground ) ;
67+ }
68+
69+ function setupKeyboardNav ( enabled , playground ) {
70+ if ( enabled ) {
71+ kbNavigation = new KeyboardNavigation ( playground . getWorkspace ( ) ) ;
72+ } else {
73+ if ( kbNavigation ) {
74+ kbNavigation . dispose ( ) ;
75+ }
76+ }
5077 }
5178
5279 function initPlayground ( ) {
101128 } ;
102129
103130 Blockly . ContextMenuItems . registerCommentOptions ( ) ;
131+ KeyboardNavigation . registerKeyboardNavigationStyles ( ) ;
132+ // TODO: register the navigation-deferring toolbox.
104133
105134 createPlayground (
106135 document . getElementById ( 'root' ) ,
153182 </ style >
154183 </ head >
155184 < body >
185+ < div id ="shortcuts "> </ div >
156186 < div id ="root "> </ div >
157187 </ body >
158188</ html >
You can’t perform that action at this time.
0 commit comments