Skip to content

Commit 2d6545f

Browse files
authored
Backport PR jupyterlab#11420 on branch 3.2.x (Makes ILabShell optional in toc extension) (jupyterlab#11421)
* Runs prettier manually * Moves labShell parameter below translator per @jtpio, makes optional * Makes ILabShell optional in toc extension * Removes references to showPanel command * Runs Prettier
1 parent 2600047 commit 2d6545f

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

packages/toc-extension/src/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ async function activateTOC(
5959
app: JupyterFrontEnd,
6060
docmanager: IDocumentManager,
6161
editorTracker: IEditorTracker,
62-
labShell: ILabShell,
6362
restorer: ILayoutRestorer,
6463
markdownViewerTracker: IMarkdownViewerTracker,
6564
notebookTracker: INotebookTracker,
6665
rendermime: IRenderMimeRegistry,
6766
translator: ITranslator,
67+
labShell?: ILabShell,
6868
settingRegistry?: ISettingRegistry
6969
): Promise<ITableOfContentsRegistry> {
7070
const trans = translator.load('jupyterlab');
@@ -85,7 +85,7 @@ async function activateTOC(
8585
toc.node.setAttribute('role', 'region');
8686
toc.node.setAttribute('aria-label', trans.__('Table of Contents section'));
8787

88-
labShell.add(toc, 'left', { rank: 400 });
88+
app.shell.add(toc, 'left', { rank: 400 });
8989

9090
app.commands.addCommand(CommandIDs.runCells, {
9191
execute: args => {
@@ -121,11 +121,6 @@ async function activateTOC(
121121
label: trans.__('Run Cell(s)')
122122
});
123123

124-
app.contextMenu.addItem({
125-
selector: '.jp-tocItem',
126-
command: CommandIDs.runCells
127-
});
128-
129124
// Add the ToC widget to the application restorer:
130125
restorer.add(toc, '@jupyterlab/toc:plugin');
131126

@@ -180,7 +175,9 @@ async function activateTOC(
180175
registry.add(pythonGenerator);
181176

182177
// Update the ToC when the active widget changes:
183-
labShell.currentChanged.connect(onConnect);
178+
if (labShell) {
179+
labShell.currentChanged.connect(onConnect);
180+
}
184181

185182
return registry;
186183

@@ -219,14 +216,13 @@ const extension: JupyterFrontEndPlugin<ITableOfContentsRegistry> = {
219216
requires: [
220217
IDocumentManager,
221218
IEditorTracker,
222-
ILabShell,
223219
ILayoutRestorer,
224220
IMarkdownViewerTracker,
225221
INotebookTracker,
226222
IRenderMimeRegistry,
227223
ITranslator
228224
],
229-
optional: [ISettingRegistry],
225+
optional: [ILabShell, ISettingRegistry],
230226
activate: activateTOC
231227
};
232228

0 commit comments

Comments
 (0)