Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/application-extension/schema/shortcuts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"jupyter.lab.setting-icon": "notebook-ui-components:jupyter",
"jupyter.lab.setting-icon-label": "Jupyter Notebook shortcuts",
"title": "Jupyter Notebook Shortcuts",
"description": "Keyboard shortcuts for Jupyter Notebook",
"jupyter.lab.shortcuts": [
{
"args": {},
"command": "notebook:toggle-cell-outputs",
"keys": ["O"],
"selector": ".jp-Notebook.jp-mod-commandMode"
}
],
"additionalProperties": false,
"type": "object"
}
15 changes: 15 additions & 0 deletions packages/application-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,20 @@ const sidePanelVisibility: JupyterFrontEndPlugin<void> = {
},
};

/**
* A plugin for defining keyboard shortcuts specific to the notebook application.
*/
const shortcuts: JupyterFrontEndPlugin<void> = {
id: '@jupyter-notebook/application-extension:shortcuts',
description:
'A plugin for defining keyboard shortcuts specific to the notebook application.',
autoStart: true,
activate: (app: JupyterFrontEnd) => {
// for now this plugin is mostly useful for defining keyboard shortcuts
// specific to the notebook application
},
};

/**
* The default tree route resolver plugin.
*/
Expand Down Expand Up @@ -1175,6 +1189,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
rendermime,
shell,
sidePanelVisibility,
shortcuts,
splash,
status,
tabTitle,
Expand Down
27 changes: 27 additions & 0 deletions ui-tests/test/notebook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,31 @@ test.describe('Notebook', () => {

await expect(page.locator('.jp-LogConsole')).toBeVisible();
});

test('Toggle cell outputs with the O keyboard shortcut', async ({
page,
tmpPath,
}) => {
const notebook = 'autoscroll.ipynb';
await page.contents.uploadFile(
path.resolve(__dirname, `./notebooks/${notebook}`),
`${tmpPath}/${notebook}`
);
await page.goto(`notebooks/${tmpPath}/${notebook}`);

await waitForKernelReady(page);

// run the two cells
await page.keyboard.press('Shift+Enter');
await page.keyboard.press('ControlOrMeta+Enter');

await page.keyboard.press('Escape');
await page.keyboard.press('O');

await page.waitForSelector('.jp-OutputPlaceholder', { state: 'visible' });

await page.keyboard.press('O');

await page.waitForSelector('.jp-OutputPlaceholder', { state: 'hidden' });
});
});
Loading