All files / src/notebook extension.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                  34x 34x             56x           56x   56x   56x                    
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);
 
    this._presenter.preparePanel(panel);
 
    return new DisposableDelegate(() => button.dispose());
  }
}
 
export namespace DeckExtension {
  export interface IOptions {
    commands: CommandRegistry;
    presenter: NotebookPresenter;
  }
}