如何将NotebookPanel类的默认布局修改为扩展?

时间:2019-06-18 08:40:22

标签: javascript typescript jupyter-notebook jupyter-lab phosphorjs

当前,我创建了一个CustomNotebookPanel类,该类扩展了NotebookPanel并将默认布局更改为StackedPanel。 我希望Jupyterlab使用此类而不是默认的Notebook类。

我尝试使用此类创建扩展,但无法正常工作。

CustomNotebookPanel类:

  constructor(options: DocumentWidget.IOptions<Notebook, INotebookModel>) {
    super(options);
    super.layout = new StackedLayout();
  }
}

使用CustomNotebookPanel的扩展程序:

export
class SearchExtension implements DocumentRegistry.IWidgetExtension<CustomNotebookPanel, INotebookModel> {
  createNew(panel: CustomNotebookPanel, context: DocumentRegistry.IContext<INotebookModel>) : IDisposable {
    let commands = new CommandRegistry();
    let palette = new CommandPalette({ commands: commands });
    let stackedLayout = panel.layout as StackedLayout;
    stackedLayout.addWidget(palette);
    SetupCommands(commands, palette, panel);
    return new DisposableDelegate(() => {
      palette.dispose();
    });
  }
}
function activate(app: JupyterLab) {
  app.docRegistry.addWidgetExtension('Notebook', new SearchExtension());
};
export default extension;

成功安装此扩展并在JupyterLab中打开笔记本时,我看不到NotebookPanel和CommandPalette。

0 个答案:

没有答案