Add NotebookTools widget in right panel

This commit is contained in:
Nicolas Brichet 2022-08-04 22:46:38 +02:00 committed by foo
parent b02eb05750
commit 45deda1f6c
4 changed files with 29 additions and 2 deletions

View File

@ -91,6 +91,7 @@ async function main() {
'@jupyterlab/apputils-extension:toolbar-registry'
].includes(id)
),
require('@jupyterlab/celltags-extension'),
require('@jupyterlab/codemirror-extension').default.filter(({ id }) =>
[
'@jupyterlab/codemirror-extension:services',
@ -138,6 +139,7 @@ async function main() {
'@jupyterlab/notebook-extension:export',
'@jupyterlab/notebook-extension:factory',
'@jupyterlab/notebook-extension:toc',
'@jupyterlab/notebook-extension:tools',
'@jupyterlab/notebook-extension:tracker',
'@jupyterlab/notebook-extension:widget-factory'
].includes(id)

View File

@ -29,6 +29,7 @@
"@jupyterlab/cell-toolbar": "~4.0.0-alpha.14",
"@jupyterlab/cell-toolbar-extension": "~4.0.0-alpha.14",
"@jupyterlab/celltags": "~4.0.0-alpha.14",
"@jupyterlab/celltags-extension": "~4.0.0-alpha.14",
"@jupyterlab/codeeditor": "~4.0.0-alpha.14",
"@jupyterlab/codemirror-extension": "~4.0.0-alpha.14",
"@jupyterlab/collaboration": "~4.0.0-alpha.14",
@ -114,6 +115,7 @@
"@jupyterlab/apputils-extension": "^4.0.0-alpha.14",
"@jupyterlab/cell-toolbar-extension": "^4.0.0-alpha.14",
"@jupyterlab/celltags": "^4.0.0-alpha.14",
"@jupyterlab/celltags-extension": "^4.0.0-alpha.14",
"@jupyterlab/codemirror-extension": "^4.0.0-alpha.14",
"@jupyterlab/collaboration-extension": "^4.0.0-alpha.14",
"@jupyterlab/completer-extension": "^4.0.0-alpha.14",

View File

@ -28,6 +28,8 @@ import { DocumentWidget } from '@jupyterlab/docregistry';
import { IMainMenu } from '@jupyterlab/mainmenu';
import { INotebookTools } from '@jupyterlab/notebook';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { ITranslator } from '@jupyterlab/translation';
@ -595,13 +597,14 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
const sidebarVisibility: JupyterFrontEndPlugin<void> = {
id: '@jupyter-notebook/application-extension:sidebar',
requires: [INotebookShell, ITranslator],
optional: [IMainMenu, ISettingRegistry],
optional: [IMainMenu, ISettingRegistry, INotebookTools],
activate: (
app: JupyterFrontEnd<JupyterFrontEnd.IShell>,
notebookShell: INotebookShell,
translator: ITranslator,
menu: IMainMenu | null,
settingRegistry: ISettingRegistry | null
settingRegistry: ISettingRegistry | null,
notebookTools: INotebookTools | null
) => {
if (!sidePanelsEnabled()) {
return;
@ -688,6 +691,8 @@ const sidebarVisibility: JupyterFrontEndPlugin<void> = {
notebookShell.leftHandler.updateMenu();
notebookShell.rightHandler.updateMenu();
if (notebookTools) notebookShell.add(notebookTools, 'right');
}
});
},

View File

@ -124,4 +124,22 @@ test.describe('Notebook', () => {
)
).toHaveCount(3);
});
test('Open notebook tools right panel', async ({ page, tmpPath }) => {
const notebook = 'simple.ipynb';
const menuPath = 'View>Show Right Sidebar>Table Of Contents';
await page.contents.uploadFile(
path.resolve(__dirname, `./notebooks/${notebook}`),
`${tmpPath}/${notebook}`
);
await page.goto(`notebooks/${tmpPath}/${notebook}`);
await waitForKernelReady(page);
await page.menu.open(menuPath);
await page.isVisible('#notebook-tools.jp-NotebookTools');
await page.isVisible('#notebook-tools.jp-NotebookTools > #add-tag.tag');
});
});