File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
packages/application-extension Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "jupyter.lab.setting-icon" : " notebook-ui-components:jupyter" ,
3
+ "jupyter.lab.setting-icon-label" : " Jupyter Notebook shortcuts" ,
4
+ "title" : " Jupyter Notebook Shortcuts" ,
5
+ "description" : " Keyboard shortcuts for Jupyter Notebook" ,
6
+ "jupyter.lab.shortcuts" : [
7
+ {
8
+ "args" : {},
9
+ "command" : " notebook:toggle-cell-outputs" ,
10
+ "keys" : [" O" ],
11
+ "selector" : " .jp-Notebook.jp-mod-commandMode"
12
+ }
13
+ ],
14
+ "additionalProperties" : false ,
15
+ "type" : " object"
16
+ }
Original file line number Diff line number Diff line change @@ -1006,6 +1006,20 @@ const sidePanelVisibility: JupyterFrontEndPlugin<void> = {
1006
1006
} ,
1007
1007
} ;
1008
1008
1009
+ /**
1010
+ * A plugin for defining keyboard shortcuts specific to the notebook application.
1011
+ */
1012
+ const shortcuts : JupyterFrontEndPlugin < void > = {
1013
+ id : '@jupyter-notebook/application-extension:shortcuts' ,
1014
+ description :
1015
+ 'A plugin for defining keyboard shortcuts specific to the notebook application.' ,
1016
+ autoStart : true ,
1017
+ activate : ( app : JupyterFrontEnd ) => {
1018
+ // for now this plugin is mostly useful for defining keyboard shortcuts
1019
+ // specific to the notebook application
1020
+ } ,
1021
+ } ;
1022
+
1009
1023
/**
1010
1024
* The default tree route resolver plugin.
1011
1025
*/
@@ -1185,6 +1199,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
1185
1199
rendermime ,
1186
1200
shell ,
1187
1201
sidePanelVisibility ,
1202
+ shortcuts ,
1188
1203
splash ,
1189
1204
status ,
1190
1205
tabTitle ,
Original file line number Diff line number Diff line change @@ -223,4 +223,31 @@ test.describe('Notebook', () => {
223
223
224
224
await expect ( page . locator ( '.jp-LogConsole' ) ) . toBeVisible ( ) ;
225
225
} ) ;
226
+
227
+ test ( 'Toggle cell outputs with the O keyboard shortcut' , async ( {
228
+ page,
229
+ tmpPath,
230
+ } ) => {
231
+ const notebook = 'autoscroll.ipynb' ;
232
+ await page . contents . uploadFile (
233
+ path . resolve ( __dirname , `./notebooks/${ notebook } ` ) ,
234
+ `${ tmpPath } /${ notebook } `
235
+ ) ;
236
+ await page . goto ( `notebooks/${ tmpPath } /${ notebook } ` ) ;
237
+
238
+ await waitForKernelReady ( page ) ;
239
+
240
+ // run the two cells
241
+ await page . keyboard . press ( 'Shift+Enter' ) ;
242
+ await page . keyboard . press ( 'ControlOrMeta+Enter' ) ;
243
+
244
+ await page . keyboard . press ( 'Escape' ) ;
245
+ await page . keyboard . press ( 'O' ) ;
246
+
247
+ await page . waitForSelector ( '.jp-OutputPlaceholder' , { state : 'visible' } ) ;
248
+
249
+ await page . keyboard . press ( 'O' ) ;
250
+
251
+ await page . waitForSelector ( '.jp-OutputPlaceholder' , { state : 'hidden' } ) ;
252
+ } ) ;
226
253
} ) ;
You can’t perform that action at this time.
0 commit comments