Commit bf00d910 authored by Mark Ghiorso's avatar Mark Ghiorso

Show skcd panel on command

parent 8ef57e5f
......@@ -2,6 +2,14 @@ import {
JupyterLabPlugin
} from '@jupyterlab/application';
import {
ICommandPalette
} from '@jupyterlab/apputils';
import {
Widget
} from '@phosphor/widgets';
import '../style/index.css';
......@@ -11,8 +19,32 @@ import '../style/index.css';
const extension: JupyterLabPlugin<void> = {
id: 'jupyterlab_gitlab',
autoStart: true,
activate: (app) => {
requires: [ICommandPalette],
activate: (app, palette: ICommandPalette) => {
console.log('JupyterLab extension jupyterlab_gitlab is activated!');
// Create a single widget
let widget: Widget = new Widget();
widget.id = 'xkcd-jupyterlab';
widget.title.label = 'xkcd.com';
widget.title.closable = true;
// Add an application command
const command: string = 'xkcd:open';
app.commands.addCommand(command, {
label: 'Random xkcd comic',
execute: () => {
if (!widget.isAttached) {
// Attach the widget to the main area if it's not there
app.shell.addToMainArea(widget);
}
// Activate the widget
app.shell.activateById(widget.id);
}
});
// Add the command to the palette.
palette.addItem({command, category: 'Tutorial'});
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment