Define `O` as the keyboard shortcut to toggle cell outputs (#7709)

* Define keyboard shortcut to toggle cell outputs

* Add UI test
dependabot/npm_and_yarn/ui-tests/mermaid-11.10.1
Jeremy Tuloup 6 months ago committed by GitHub
parent a8a8111d59
commit 346e30dec4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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"
}

@ -1006,6 +1006,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.
*/
@ -1185,6 +1199,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
rendermime,
shell,
sidePanelVisibility,
shortcuts,
splash,
status,
tabTitle,

@ -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…
Cancel
Save