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> = {
10061006 } ,
10071007} ;
10081008
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+
10091023/**
10101024 * The default tree route resolver plugin.
10111025 */
@@ -1185,6 +1199,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
11851199 rendermime ,
11861200 shell ,
11871201 sidePanelVisibility ,
1202+ shortcuts ,
11881203 splash ,
11891204 status ,
11901205 tabTitle ,
Original file line number Diff line number Diff line change @@ -223,4 +223,31 @@ test.describe('Notebook', () => {
223223
224224 await expect ( page . locator ( '.jp-LogConsole' ) ) . toBeVisible ( ) ;
225225 } ) ;
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+ } ) ;
226253} ) ;
You can’t perform that action at this time.
0 commit comments