Skip to content

Commit

Permalink
Use Toolbar registry for the notebok button and move it to the right (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet authored Jan 14, 2025
1 parent 5976c33 commit 49644b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
9 changes: 9 additions & 0 deletions js/jupyterlab-slideshow/schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
"description": "Configure Deck Settings",
"jupyter.lab.setting-icon": "deck:start",
"jupyter.lab.setting-icon-label": "Decks",
"jupyter.lab.toolbars": {
"Notebook": [
{
"name": "deck",
"command": "deck:toggle",
"rank": 900
}
]
},
"properties": {
"active": {
"title": "Activate Deck",
Expand Down
20 changes: 1 addition & 19 deletions js/jupyterlab-slideshow/src/notebook/extension.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
import { CommandToolbarButton } from '@jupyterlab/apputils';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
import { CommandRegistry } from '@lumino/commands';
import { IDisposable, DisposableDelegate } from '@lumino/disposable';

import { CommandIds } from '../tokens';

import { NotebookPresenter } from './presenter';

export class NotebookDeckExtension
implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel>
{
private _commands: CommandRegistry;
private _presenter: NotebookPresenter;

constructor(options: DeckExtension.IOptions) {
this._commands = options.commands;
this._presenter = options.presenter;
}

createNew(
panel: NotebookPanel,
context: DocumentRegistry.IContext<INotebookModel>,
): IDisposable {
const button = new CommandToolbarButton({
commands: this._commands,
label: '',
id: CommandIds.toggle,
});

panel.toolbar.insertItem(5, 'deck', button);

): void {
this._presenter.preparePanel(panel);

return new DisposableDelegate(() => button.dispose());
}
}

export namespace DeckExtension {
export interface IOptions {
commands: CommandRegistry;
presenter: NotebookPresenter;
}
}
2 changes: 1 addition & 1 deletion js/jupyterlab-slideshow/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const notebookPlugin: JupyterFrontEndPlugin<void> = {

app.docRegistry.addWidgetExtension(
NOTEBOOK_FACTORY,
new NotebookDeckExtension({ commands, presenter }),
new NotebookDeckExtension({ presenter }),
);
},
};
Expand Down

0 comments on commit 49644b8

Please sign in to comment.