|
@@ -43,61 +43,8 @@ const plugin: JupyterLabPlugin<void> = {
|
|
|
requires: [ICommandPalette],
|
|
|
activate: (app: JupyterLab, palette: ICommandPalette) => {
|
|
|
app.settings.setDB(new StateDB({ namespace: 'jupyter.db.settings' }));
|
|
|
- app.settings.load(plugin.id).then(settings => {
|
|
|
- console.log(settings.plugin, settings);
|
|
|
- }).catch(reason => {
|
|
|
- console.warn('settings load failure', reason);
|
|
|
- });
|
|
|
-
|
|
|
- // Add the main application commands.
|
|
|
- const category = 'Main Area';
|
|
|
- let command = CommandIDs.activateNextTab;
|
|
|
- app.commands.addCommand(command, {
|
|
|
- label: 'Activate Next Tab',
|
|
|
- execute: () => { app.shell.activateNextTab(); }
|
|
|
- });
|
|
|
- palette.addItem({ command, category });
|
|
|
-
|
|
|
- command = CommandIDs.activatePreviousTab;
|
|
|
- app.commands.addCommand(command, {
|
|
|
- label: 'Activate Previous Tab',
|
|
|
- execute: () => { app.shell.activatePreviousTab(); }
|
|
|
- });
|
|
|
- palette.addItem({ command, category });
|
|
|
-
|
|
|
- command = CommandIDs.closeAll;
|
|
|
- app.commands.addCommand(command, {
|
|
|
- label: 'Close All Widgets',
|
|
|
- execute: () => { app.shell.closeAll(); }
|
|
|
- });
|
|
|
- palette.addItem({ command, category });
|
|
|
-
|
|
|
- command = CommandIDs.setMode;
|
|
|
- app.commands.addCommand(command, {
|
|
|
- isVisible: args => {
|
|
|
- const mode = args['mode'] as string;
|
|
|
- return mode === 'single-document' || mode === 'multiple-document';
|
|
|
- },
|
|
|
- execute: args => {
|
|
|
- const mode = args['mode'] as string;
|
|
|
- if (mode === 'single-document' || mode === 'multiple-document') {
|
|
|
- app.shell.mode = mode;
|
|
|
- return;
|
|
|
- }
|
|
|
- throw new Error(`Unsupported application shell mode: ${mode}`);
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- command = CommandIDs.toggleMode;
|
|
|
- app.commands.addCommand(command, {
|
|
|
- label: 'Toggle Single-Document Mode',
|
|
|
- execute: () => {
|
|
|
- const args = app.shell.mode === 'multiple-document' ?
|
|
|
- { mode: 'single-document' } : { mode: 'multiple-document' };
|
|
|
- return app.commands.execute(CommandIDs.setMode, args);
|
|
|
- }
|
|
|
- });
|
|
|
- palette.addItem({ command, category });
|
|
|
+ addCommands(app, palette);
|
|
|
|
|
|
// Temporary build message for manual rebuild.
|
|
|
let buildMessage = PageConfig.getOption('buildRequired');
|
|
@@ -131,6 +78,61 @@ const plugin: JupyterLabPlugin<void> = {
|
|
|
};
|
|
|
|
|
|
|
|
|
+/**
|
|
|
+ * Add the main application commands.
|
|
|
+ */
|
|
|
+function addCommands(app: JupyterLab, palette: ICommandPalette): void {
|
|
|
+ const category = 'Main Area';
|
|
|
+ let command = CommandIDs.activateNextTab;
|
|
|
+ app.commands.addCommand(command, {
|
|
|
+ label: 'Activate Next Tab',
|
|
|
+ execute: () => { app.shell.activateNextTab(); }
|
|
|
+ });
|
|
|
+ palette.addItem({ command, category });
|
|
|
+
|
|
|
+ command = CommandIDs.activatePreviousTab;
|
|
|
+ app.commands.addCommand(command, {
|
|
|
+ label: 'Activate Previous Tab',
|
|
|
+ execute: () => { app.shell.activatePreviousTab(); }
|
|
|
+ });
|
|
|
+ palette.addItem({ command, category });
|
|
|
+
|
|
|
+ command = CommandIDs.closeAll;
|
|
|
+ app.commands.addCommand(command, {
|
|
|
+ label: 'Close All Widgets',
|
|
|
+ execute: () => { app.shell.closeAll(); }
|
|
|
+ });
|
|
|
+ palette.addItem({ command, category });
|
|
|
+
|
|
|
+ command = CommandIDs.setMode;
|
|
|
+ app.commands.addCommand(command, {
|
|
|
+ isVisible: args => {
|
|
|
+ const mode = args['mode'] as string;
|
|
|
+ return mode === 'single-document' || mode === 'multiple-document';
|
|
|
+ },
|
|
|
+ execute: args => {
|
|
|
+ const mode = args['mode'] as string;
|
|
|
+ if (mode === 'single-document' || mode === 'multiple-document') {
|
|
|
+ app.shell.mode = mode;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ throw new Error(`Unsupported application shell mode: ${mode}`);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ command = CommandIDs.toggleMode;
|
|
|
+ app.commands.addCommand(command, {
|
|
|
+ label: 'Toggle Single-Document Mode',
|
|
|
+ execute: () => {
|
|
|
+ const args = app.shell.mode === 'multiple-document' ?
|
|
|
+ { mode: 'single-document' } : { mode: 'multiple-document' };
|
|
|
+ return app.commands.execute(CommandIDs.setMode, args);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ palette.addItem({ command, category });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Export the plugin as default.
|
|
|
*/
|