I'm currently working on developing a plugin to introduce a fresh menu into the existing menu structure within Jupyterlabs interface.... next to file
, edit
, ... Settings
, and Help
The basic xkcd example
is functioning correctly, and I've been thoroughly examining the code in packages/mainmenu
in an attempt to utilize the tab
menu as a guide (possibly incorporating contextual options later on...)
This is my current progress:
import { PageConfig } from '@jupyterlab/coreutils';
import { JupyterLab, JupyterLabPlugin } from '@jupyterlab/application';
import { IMainMenu, IJupyterLabMenu, JupyterLabMenu } from '@jupyterlab/mainmenu';
import { Menu } from '@phosphor/widgets';
interface INoteableMenu extends IJupyterLabMenu {}
class NoteableMenu extends JupyterLabMenu implements INoteableMenu {
constructor(options: Menu.IOptions) {
super(options);
this.menu.title.label = 'Noteable';
}
}
const extension: JupyterLabPlugin<void> = {
id: 'noteable-menu',
autoStart: true,
activate: (app: JupyterLab) => {
console.log('JupyterLab extension noteable is activated!');
let mainMenu: IMainMenu; //app.contextMenu??
//let noteableMenu = new NoteableMenu({ commands: {} });
mainMenu.addMenu(NoteableMenu.menu, { rank: 2000 });
}
};
export default extension;
export namespace CommandIDs {
export const returnToHome = 'noteablemenu:home';
export const switchToClassic = 'noteablemenu:classic';
}
export function createNoteableMenu(
menu: NoteableMenu,
): void {
const commands = menu.menu.commands;
commands.addCommand(CommandIDs.returnToHome, {
label: 'Jump to example page',
execute: () => {
location.assign(location.origin + '/example');
}
});
commands.addCommand(CommandIDs.switchToClassic, {
label: 'Switch to Classic Notebook',
execute: () => {
location.assign(PageConfig.getBaseUrl() + 'tree');
}
});
}
Unfortunately, I encountered a build failure (using
jupyter labextension install . --no-build
resulting in the error
src/index.ts:26:35 - error TS2339: Property 'menu' does not exist on type 'typeof NoteableMenu'.
26 mainMenu.addMenu(NoteableMenu.menu, { rank: 2000 });
~~~~
I am struggling to identify the practical differences between my code and the provided examples.
Any tips, hints, or direct solutions would be greatly appreciated...
(for reference: nodejs: v8.10.0
, jupyterlab: 0.35.5
)