فهرست منبع

Merge pull request #1554 from afshin/commands-ids

Command Refactor
Steven Silvester 8 سال پیش
والد
کامیت
6ab5916ca2

+ 5 - 4
src/about/index.ts

@@ -221,12 +221,13 @@ const NOTEBOOK_DESC = [
 
 
 /**
- * The map of command ids used by the about plugin.
+ * The command IDs used by the about plugin.
  */
 export
-const cmdIds = {
-  open: 'about-jupyterlab:open'
-};
+namespace CommandIDs {
+  export
+  const open = 'about-jupyterlab:open';
+}
 
 
 /**

+ 2 - 2
src/about/plugin.ts

@@ -18,7 +18,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  AboutModel, AboutWidget, cmdIds
+  AboutModel, AboutWidget, CommandIDs
 } from './';
 
 /**
@@ -41,7 +41,7 @@ export default plugin;
 function activate(app: JupyterLab, palette: ICommandPalette, restorer: IInstanceRestorer): void {
   const namespace = 'about-jupyterlab';
   const model = new AboutModel({ version: app.info.version });
-  const command = cmdIds.open;
+  const command = CommandIDs.open;
   const category = 'Help';
   const tracker = new InstanceTracker<AboutWidget>({ namespace });
 

+ 4 - 3
src/application/index.ts

@@ -26,11 +26,12 @@ export { ApplicationShell } from './shell';
 
 
 /**
- * The map of command ids used by the application plugin.
+ * The command IDs used by the application plugin.
  */
 export
-const cmdIds = {
-  closeAll: 'main-jupyterlab:close-all'
+namespace CommandIDs {
+  export
+  const closeAll = 'main-jupyterlab:close-all';
 };
 
 

+ 4 - 4
src/application/plugin.ts

@@ -2,7 +2,7 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  JupyterLab, JupyterLabPlugin, cmdIds
+  JupyterLab, JupyterLabPlugin, CommandIDs
 } from './';
 
 import {
@@ -17,13 +17,13 @@ const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.main',
   requires: [ICommandPalette],
   activate: (app: JupyterLab, palette: ICommandPalette) => {
-    let commandId = cmdIds.closeAll;
-    app.commands.addCommand(commandId, {
+    let command = CommandIDs.closeAll;
+    app.commands.addCommand(command, {
       label: 'Close All Widgets',
       execute: () => { app.shell.closeAll(); }
     });
 
-    palette.addItem({ command: commandId, category: 'Main Area' });
+    palette.addItem({ command, category: 'Main Area' });
 
     const message = 'Are you sure you want to exit JupyterLab?\n' +
                     'Any unsaved changes will be lost.';

+ 37 - 23
src/codemirror/plugin.ts

@@ -66,16 +66,30 @@ export default plugins;
 
 
 /**
- * The map of command ids used by the editor.
+ * The command IDs used by the editor plugin.
  */
-const cmdIds = {
-  lineNumbers: 'editor:line-numbers',
-  lineWrap: 'editor:line-wrap',
-  matchBrackets: 'editor:match-brackets',
-  vimMode: 'editor:vim-mode',
-  changeTheme: 'editor:change-theme',
-  createConsole: 'editor:create-console',
-  runCode: 'editor:run-code'
+export
+namespace CommandIDs {
+  export
+  const lineNumbers = 'editor:line-numbers';
+
+  export
+  const lineWrap = 'editor:line-wrap';
+
+  export
+  const matchBrackets = 'editor:match-brackets';
+
+  export
+  const vimMode = 'editor:vim-mode';
+
+  export
+  const changeTheme = 'editor:change-theme';
+
+  export
+  const createConsole = 'editor:create-console';
+
+  export
+  const runCode = 'editor:run-code';
 };
 
 
@@ -124,15 +138,15 @@ function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMe
     settings.title.label = 'Settings';
     theme.title.label = 'Theme';
 
-    settings.addItem({ command: cmdIds.lineNumbers });
-    settings.addItem({ command: cmdIds.lineWrap });
-    settings.addItem({ command: cmdIds.matchBrackets });
-    settings.addItem({ command: cmdIds.vimMode });
+    settings.addItem({ command: CommandIDs.lineNumbers });
+    settings.addItem({ command: CommandIDs.lineWrap });
+    settings.addItem({ command: CommandIDs.matchBrackets });
+    settings.addItem({ command: CommandIDs.vimMode });
 
-    commands.addCommand(cmdIds.changeTheme, {
+    commands.addCommand(CommandIDs.changeTheme, {
       label: args => args['theme'] as string,
       execute: args => {
-        let name: string = args['theme'] as string || CodeMirrorEditor.DEFAULT_THEME;
+        let name = args['theme'] as string || CodeMirrorEditor.DEFAULT_THEME;
         tracker.forEach(widget => {
           if (widget.editor instanceof CodeMirrorEditor) {
             let cm = widget.editor.editor;
@@ -160,23 +174,23 @@ function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMe
 
   mainMenu.addMenu(createMenu(), { rank: 30 });
 
-  commands.addCommand(cmdIds.matchBrackets, {
+  commands.addCommand(CommandIDs.matchBrackets, {
     execute: () => { toggleMatchBrackets(); },
     label: 'Toggle Match Brackets',
   });
 
-  commands.addCommand(cmdIds.vimMode, {
+  commands.addCommand(CommandIDs.vimMode, {
     execute: () => { toggleVim(); },
     label: 'Toggle Vim Mode'
   });
 
   [
-    cmdIds.lineNumbers,
-    cmdIds.lineWrap,
-    cmdIds.matchBrackets,
-    cmdIds.vimMode,
-    cmdIds.createConsole,
-    cmdIds.runCode,
+    CommandIDs.lineNumbers,
+    CommandIDs.lineWrap,
+    CommandIDs.matchBrackets,
+    CommandIDs.vimMode,
+    CommandIDs.createConsole,
+    CommandIDs.runCode
   ].forEach(command => palette.addItem({ command, category: 'Editor' }));
 
 }

+ 10 - 5
src/commandpalette/index.ts

@@ -17,13 +17,18 @@ import {
 
 
 /**
- * The map of command ids used by the commandpalette plugin.
+ * The command IDs used by the command palette plugin.
  */
 export
-const cmdIds = {
-  activate: 'command-palette:activate',
-  hide: 'command-palette:hide',
-  toggle: 'command-palette:toggle'
+namespace CommandIDs {
+  export
+  const activate = 'command-palette:activate';
+
+  export
+  const hide = 'command-palette:hide';
+
+  export
+  const toggle = 'command-palette:toggle';
 };
 
 

+ 18 - 35
src/commandpalette/plugin.ts

@@ -20,7 +20,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  ICommandPalette, IPaletteItem, cmdIds
+  CommandIDs, ICommandPalette, IPaletteItem
 } from './';
 
 
@@ -102,44 +102,27 @@ function activate(app: JupyterLab, restorer: IInstanceRestorer): ICommandPalette
   palette.id = 'command-palette';
   palette.title.label = 'Commands';
 
-  /**
-   * Activate the command palette within the app shell (used as a command).
-   */
-  function activatePalette(): void {
-    app.shell.activateLeft(palette.id);
-    palette.activate();
-  }
-
-  /**
-   * Hide the command palette within the app shell (used as a command).
-   */
-  function hidePalette(): void {
-    if (!palette.isHidden) {
-      app.shell.collapseLeft();
-    }
-  }
-
-  /**
-   * Toggle the command palette within the app shell (used as a command).
-   */
-  function togglePalette(): void {
-    if (palette.isHidden) {
-      activatePalette();
-    } else {
-      hidePalette();
-    }
-  }
-
-  app.commands.addCommand(cmdIds.activate, {
-    execute: activatePalette,
+  app.commands.addCommand(CommandIDs.activate, {
+    execute: () => { app.shell.activateLeft(palette.id); },
     label: 'Activate Command Palette'
   });
-  app.commands.addCommand(cmdIds.hide, {
-    execute: hidePalette,
+
+  app.commands.addCommand(CommandIDs.hide, {
+    execute: () => {
+      if (!palette.isHidden) {
+        app.shell.collapseLeft();
+      }
+    },
     label: 'Hide Command Palette'
   });
-  app.commands.addCommand(cmdIds.toggle, {
-    execute: togglePalette,
+
+  app.commands.addCommand(CommandIDs.toggle, {
+    execute: () => {
+      if (palette.isHidden) {
+        return app.commands.execute(CommandIDs.activate, void 0);
+      }
+      return app.commands.execute(CommandIDs.hide, void 0);
+    },
     label: 'Toggle Command Palette'
   });
 

+ 28 - 11
src/console/index.ts

@@ -15,19 +15,36 @@ export * from './widget';
 
 
 /**
- * The map of command ids used by the console plugin.
+ * The command IDs used by the console plugin.
  */
 export
-const cmdIds = {
-  create: 'console:create',
-  clear: 'console:clear',
-  run: 'console:run',
-  runForced: 'console:run-forced',
-  linebreak: 'console:linebreak',
-  interrupt: 'console:interrupt-kernel',
-  open: 'console:open',
-  inject: 'console:inject',
-  switchKernel: 'console:switch-kernel'
+namespace CommandIDs {
+  export
+  const create = 'console:create';
+
+  export
+  const clear = 'console:clear';
+
+  export
+  const run = 'console:run';
+
+  export
+  const runForced = 'console:run-forced';
+
+  export
+  const linebreak = 'console:linebreak';
+
+  export
+  const interrupt = 'console:interrupt-kernel';
+
+  export
+  const open = 'console:open';
+
+  export
+  const inject = 'console:inject';
+
+  export
+  const switchKernel = 'console:switch-kernel';
 };
 
 

+ 12 - 12
src/console/plugin.ts

@@ -62,7 +62,7 @@ import {
 } from '../services';
 
 import {
-  IConsoleTracker, ICreateConsoleArgs, ConsolePanel, cmdIds
+  IConsoleTracker, ICreateConsoleArgs, ConsolePanel, CommandIDs
 } from './index';
 
 
@@ -144,7 +144,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
 
   // Handle state restoration.
   restorer.restore(tracker, {
-    command: cmdIds.create,
+    command: CommandIDs.create,
     args: panel => ({ id: panel.console.session.id }),
     name: panel => panel.console.session && panel.console.session.id,
     when: manager.ready
@@ -160,7 +160,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   // Set the main menu title.
   menu.title.label = category;
 
-  command = cmdIds.create;
+  command = CommandIDs.create;
   commands.addCommand(command, {
     label: 'Start New Console',
     execute: (args?: ICreateConsoleArgs) => {
@@ -208,7 +208,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   palette.addItem({ command, category });
   menu.addItem({ command });
 
-  command = cmdIds.clear;
+  command = CommandIDs.clear;
   commands.addCommand(command, {
     label: 'Clear Cells',
     execute: () => {
@@ -221,7 +221,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   palette.addItem({ command, category });
   menu.addItem({ command });
 
-  command = cmdIds.run;
+  command = CommandIDs.run;
   commands.addCommand(command, {
     label: 'Run Cell',
     execute: () => {
@@ -235,7 +235,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   menu.addItem({ command });
 
 
-  command = cmdIds.runForced;
+  command = CommandIDs.runForced;
   commands.addCommand(command, {
     label: 'Run Cell (forced)',
     execute: () => {
@@ -248,7 +248,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   palette.addItem({ command, category });
   menu.addItem({ command });
 
-  command = cmdIds.linebreak;
+  command = CommandIDs.linebreak;
   commands.addCommand(command, {
     label: 'Insert Line Break',
     execute: () => {
@@ -261,7 +261,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   palette.addItem({ command, category });
   menu.addItem({ command });
 
-  command = cmdIds.interrupt;
+  command = CommandIDs.interrupt;
   commands.addCommand(command, {
     label: 'Interrupt Kernel',
     execute: () => {
@@ -277,7 +277,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
   palette.addItem({ command, category });
   menu.addItem({ command });
 
-  command = cmdIds.inject;
+  command = CommandIDs.inject;
   commands.addCommand(command, {
     execute: (args: JSONObject) => {
       let id = args['id'];
@@ -290,7 +290,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
     }
   });
 
-  command = cmdIds.open;
+  command = CommandIDs.open;
   commands.addCommand(command, {
     execute: (args: JSONObject) => {
       let id = args['id'];
@@ -302,7 +302,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
       if (widget) {
         app.shell.activateMain(widget.id);
       } else {
-        app.commands.execute(cmdIds.create, { id });
+        app.commands.execute(CommandIDs.create, { id });
       }
     }
   });
@@ -378,7 +378,7 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
     app.shell.activateMain(panel.id);
   }
 
-  command = cmdIds.switchKernel;
+  command = CommandIDs.switchKernel;
   commands.addCommand(command, {
     label: 'Switch Kernel',
     execute: () => {

+ 2 - 2
src/csvwidget/plugin.ts

@@ -14,7 +14,7 @@ import {
 } from '../docregistry';
 
 import {
-  cmdIds as fileBrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -62,7 +62,7 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: IInsta
 
   // Handle state restoration.
   restorer.restore(tracker, {
-    command: fileBrowserCmdIds.open,
+    command: FileBrowserCommandIDs.open,
     args: widget => ({ path: widget.context.path, factory: FACTORY }),
     name: widget => widget.context.path
   });

+ 13 - 6
src/editorwidget/index.ts

@@ -5,12 +5,19 @@ export * from './widget';
 
 
 /**
- * The map of command ids used by the editor plugin.
+ * The command IDs used by the editor plugin.
  */
 export
-const cmdIds = {
-  lineNumbers: 'editor:line-numbers',
-  lineWrap: 'editor:line-wrap',
-  createConsole: 'editor:create-console',
-  runCode: 'editor:run-code'
+namespace CommandIDs {
+  export
+  const lineNumbers = 'editor:line-numbers';
+
+  export
+  const lineWrap = 'editor:line-wrap';
+
+  export
+  const createConsole = 'editor:create-console';
+
+  export
+  const runCode = 'editor:run-code';
 };

+ 10 - 10
src/editorwidget/plugin.ts

@@ -18,7 +18,7 @@ import {
 } from '../common/instancetracker';
 
 import {
-  cmdIds as consoleCmdIds
+  CommandIDs as ConsoleCommandIDs
 } from '../console';
 
 import {
@@ -26,7 +26,7 @@ import {
 } from '../docregistry';
 
 import {
-  cmdIds as fileBrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -34,7 +34,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  IEditorTracker, EditorWidget, EditorWidgetFactory, cmdIds
+  IEditorTracker, EditorWidget, EditorWidgetFactory, CommandIDs
 } from './';
 
 
@@ -88,7 +88,7 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: IInsta
 
   // Handle state restoration.
   restorer.restore(tracker, {
-    command: fileBrowserCmdIds.open,
+    command: FileBrowserCommandIDs.open,
     args: widget => ({ path: widget.context.path, factory: FACTORY }),
     name: widget => widget.context.path
   });
@@ -130,17 +130,17 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: IInsta
 
   let commands = app.commands;
 
-  commands.addCommand(cmdIds.lineNumbers, {
+  commands.addCommand(CommandIDs.lineNumbers, {
     execute: () => { toggleLineNums(); },
     label: 'Toggle Line Numbers'
   });
 
-  commands.addCommand(cmdIds.lineWrap, {
+  commands.addCommand(CommandIDs.lineWrap, {
     execute: () => { toggleLineWrap(); },
     label: 'Toggle Line Wrap'
   });
 
-  commands.addCommand(cmdIds.createConsole, {
+  commands.addCommand(CommandIDs.createConsole, {
     execute: () => {
       let widget = tracker.currentWidget;
       if (!widget) {
@@ -150,13 +150,13 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: IInsta
         path: widget.context.path,
         preferredLanguage: widget.context.model.defaultKernelLanguage
       };
-      return commands.execute(consoleCmdIds.create, options)
+      return commands.execute(ConsoleCommandIDs.create, options)
         .then(id => { sessionIdProperty.set(widget, id); });
     },
     label: 'Create Console for Editor'
   });
 
-  commands.addCommand(cmdIds.runCode, {
+  commands.addCommand(CommandIDs.runCode, {
     execute: () => {
       let widget = tracker.currentWidget;
       if (!widget) {
@@ -173,7 +173,7 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: IInsta
       const start = editor.getOffsetAt(selection.start);
       const end = editor.getOffsetAt(selection.end);
       const code = editor.model.value.text.substring(start, end);
-      return commands.execute(consoleCmdIds.inject, { id, code });
+      return commands.execute(ConsoleCommandIDs.inject, { id, code });
     },
     label: 'Run Code'
   });

+ 4 - 3
src/faq/index.ts

@@ -5,9 +5,10 @@ export * from './widget';
 
 
 /**
- * The map of command ids used by the faq plugin.
+ * The command IDs used by the FAQ plugin.
  */
 export
-const cmdIds = {
-  open: 'faq-jupyterlab:open',
+namespace CommandIDs {
+  export
+  const open = 'faq-jupyterlab:open';
 };

+ 2 - 2
src/faq/plugin.ts

@@ -22,7 +22,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  FaqModel, FaqWidget, cmdIds
+  FaqModel, FaqWidget, CommandIDs
 } from './';
 
 
@@ -48,7 +48,7 @@ export default plugin;
  */
 function activate(app: JupyterLab, palette: ICommandPalette, linker: ICommandLinker, restorer: IInstanceRestorer): void {
   const category = 'Help';
-  const command = cmdIds.open;
+  const command = CommandIDs.open;
   const model = new FaqModel();
   const tracker = new InstanceTracker<FaqWidget>({ namespace: 'faq' });
 

+ 34 - 13
src/filebrowser/index.ts

@@ -10,19 +10,40 @@ export * from './tracker';
 
 
 /**
- * The map of command ids used by the filebrowser plugin.
+ * The command IDs used by the file browser plugin.
  */
 export
-const cmdIds = {
-  save: 'file-operations:save',
-  restoreCheckpoint: 'file-operations:restore-checkpoint',
-  saveAs: 'file-operations:save-as',
-  close: 'file-operations:close',
-  closeAllFiles: 'file-operations:close-all-files',
-  open: 'file-operations:open',
-  newTextFile: 'file-operations:new-text-file',
-  newNotebook: 'file-operations:new-notebook-file',
-  showBrowser: 'file-browser:activate',
-  hideBrowser: 'file-browser:hide',
-  toggleBrowser: 'file-browser:toggle'
+namespace CommandIDs {
+  export
+  const save = 'file-operations:save';
+
+  export
+  const restoreCheckpoint = 'file-operations:restore-checkpoint';
+
+  export
+  const saveAs = 'file-operations:save-as';
+
+  export
+  const close = 'file-operations:close';
+
+  export
+  const closeAllFiles = 'file-operations:close-all-files';
+
+  export
+  const open = 'file-operations:open';
+
+  export
+  const newTextFile = 'file-operations:new-text-file';
+
+  export
+  const newNotebook = 'file-operations:new-notebook-file';
+
+  export
+  const showBrowser = 'file-browser:activate';
+
+  export
+  const hideBrowser = 'file-browser:hide';
+
+  export
+  const toggleBrowser = 'file-browser:toggle';
 };

+ 27 - 23
src/filebrowser/plugin.ts

@@ -46,7 +46,7 @@ import {
 } from '../statedb';
 
 import {
-  FileBrowserModel, FileBrowser, IPathTracker, cmdIds
+  CommandIDs, FileBrowserModel, FileBrowser, IPathTracker
 } from './';
 
 
@@ -166,11 +166,11 @@ function activate(app: JupyterLab, manager: IServiceManager, documentManager: ID
   addCommands(app, fbWidget, documentManager);
 
   [
-    cmdIds.save,
-    cmdIds.restoreCheckpoint,
-    cmdIds.saveAs,
-    cmdIds.close,
-    cmdIds.closeAllFiles,
+    CommandIDs.save,
+    CommandIDs.restoreCheckpoint,
+    CommandIDs.saveAs,
+    CommandIDs.close,
+    CommandIDs.closeAllFiles
   ].forEach(command => { palette.addItem({ command, category }); });
 
   let menu = createMenu(app, Object.keys(creatorCmds));
@@ -183,7 +183,7 @@ function activate(app: JupyterLab, manager: IServiceManager, documentManager: ID
   // If the layout is a fresh session without saved data, open file browser.
   app.restored.then(layout => {
     if (layout.fresh) {
-      app.commands.execute(cmdIds.showBrowser, void 0);
+      app.commands.execute(CommandIDs.showBrowser, void 0);
     }
   });
 
@@ -217,7 +217,7 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     return !!(currentWidget && docManager.contextForWidget(currentWidget));
   };
 
-  commands.addCommand(cmdIds.save, {
+  commands.addCommand(CommandIDs.save, {
     label: 'Save',
     caption: 'Save and create checkpoint',
     isEnabled,
@@ -229,7 +229,7 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     }
   });
 
-  commands.addCommand(cmdIds.restoreCheckpoint, {
+  commands.addCommand(CommandIDs.restoreCheckpoint, {
     label: 'Revert to Checkpoint',
     caption: 'Revert contents to previous checkpoint',
     isEnabled,
@@ -241,7 +241,7 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     }
   });
 
-  commands.addCommand(cmdIds.saveAs, {
+  commands.addCommand(CommandIDs.saveAs, {
     label: 'Save As...',
     caption: 'Save with new path and create checkpoint',
     isEnabled,
@@ -255,7 +255,7 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     }
   });
 
-  commands.addCommand(cmdIds.open, {
+  commands.addCommand(CommandIDs.open, {
     execute: args => {
       let path = args['path'] as string;
       let factory = args['factory'] as string || void 0;
@@ -264,7 +264,7 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     }
   });
 
-  commands.addCommand(cmdIds.close, {
+  commands.addCommand(CommandIDs.close, {
     label: 'Close',
     execute: () => {
       if (app.shell.currentWidget) {
@@ -273,16 +273,16 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     }
   });
 
-  commands.addCommand(cmdIds.closeAllFiles, {
+  commands.addCommand(CommandIDs.closeAllFiles, {
     label: 'Close All',
     execute: () => { app.shell.closeAll(); }
   });
 
-  commands.addCommand(cmdIds.showBrowser, {
+  commands.addCommand(CommandIDs.showBrowser, {
     execute: () => { app.shell.activateLeft(fbWidget.id); }
   });
 
-  commands.addCommand(cmdIds.hideBrowser, {
+  commands.addCommand(CommandIDs.hideBrowser, {
     execute: () => {
       if (!fbWidget.isHidden) {
         app.shell.collapseLeft();
@@ -290,12 +290,12 @@ function addCommands(app: JupyterLab, fbWidget: FileBrowser, docManager: IDocume
     }
   });
 
-  commands.addCommand(cmdIds.toggleBrowser, {
+  commands.addCommand(CommandIDs.toggleBrowser, {
     execute: () => {
       if (fbWidget.isHidden) {
-        return commands.execute(cmdIds.showBrowser, void 0);
+        return commands.execute(CommandIDs.showBrowser, void 0);
       } else {
-        return commands.execute(cmdIds.hideBrowser, void 0);
+        return commands.execute(CommandIDs.hideBrowser, void 0);
       }
     }
   });
@@ -313,11 +313,11 @@ function createMenu(app: JupyterLab, creatorCmds: string[]): Menu {
     menu.addItem({ command: Private.commandForName(name) });
   });
   [
-    cmdIds.save,
-    cmdIds.restoreCheckpoint,
-    cmdIds.saveAs,
-    cmdIds.close,
-    cmdIds.closeAllFiles,
+    CommandIDs.save,
+    CommandIDs.restoreCheckpoint,
+    CommandIDs.saveAs,
+    CommandIDs.close,
+    CommandIDs.closeAllFiles
   ].forEach(command => { menu.addItem({ command }); });
 
   return menu;
@@ -326,6 +326,10 @@ function createMenu(app: JupyterLab, creatorCmds: string[]): Menu {
 
 /**
  * Create a context menu for the file browser listing.
+ *
+ * #### Notes
+ * This function generates temporary commands with an incremented name. These
+ * commands are disposed when the menu itself is disposed.
  */
 function createContextMenu(fbWidget: FileBrowser, openWith: Menu):  Menu {
   let { commands, keymap } = fbWidget;

+ 19 - 8
src/help/index.ts

@@ -3,14 +3,25 @@
 
 
 /**
- * The map of command ids used by the help plugin.
+ * The command IDs used by the help plugin.
  */
 export
-const cmdIds = {
-  open: 'help-jupyterlab:open',
-  activate: 'help-jupyterlab:activate',
-  show: 'help-jupyterlab:show',
-  hide: 'help-jupyterlab:hide',
-  toggle: 'help-jupyterlab:toggle',
-  launchClassic: 'classic-notebook:launchClassic'
+namespace CommandIDs {
+  export
+  const open = 'help-jupyterlab:open';
+
+  export
+  const activate = 'help-jupyterlab:activate';
+
+  export
+  const show = 'help-jupyterlab:show';
+
+  export
+  const hide = 'help-jupyterlab:hide';
+
+  export
+  const toggle = 'help-jupyterlab:toggle';
+
+  export
+  const launchClassic = 'classic-notebook:launchClassic';
 };

+ 15 - 15
src/help/plugin.ts

@@ -18,7 +18,7 @@ import {
 } from 'phosphor/lib/ui/widget';
 
 import {
-  cmdIds as aboutCmdIds
+  CommandIDs as AboutCommandIDs
 } from '../about';
 
 import {
@@ -38,7 +38,7 @@ import {
 } from '../commandpalette';
 
 import {
-  cmdIds as faqCmdIds
+  CommandIDs as FAQCommandIDs
 } from '../faq';
 
 import {
@@ -50,11 +50,11 @@ import {
 } from '../mainmenu';
 
 import {
-  cmdIds as statedbCmdIds
+  CommandIDs as StateDBCommandIDs
 } from '../statedb';
 
 import {
-  cmdIds
+  CommandIDs
 } from './';
 
 
@@ -150,7 +150,7 @@ function activate(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette
   let iframe: IFrame = null;
   const category = 'Help';
   const namespace = 'help-doc';
-  const command = cmdIds.open;
+  const command = CommandIDs.open;
   const menu = createMenu();
   const tracker = new InstanceTracker<IFrame>({ namespace });
 
@@ -197,13 +197,13 @@ function activate(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette
     let menu = new Menu({ commands, keymap });
     menu.title.label = category;
 
-    menu.addItem({ command: aboutCmdIds.open });
-    menu.addItem({ command: faqCmdIds.open });
-    menu.addItem({ command: cmdIds.launchClassic });
+    menu.addItem({ command: AboutCommandIDs.open });
+    menu.addItem({ command: FAQCommandIDs.open });
+    menu.addItem({ command: CommandIDs.launchClassic });
     menu.addItem({ type: 'separator' });
     RESOURCES.forEach(args => { menu.addItem({ args, command }); });
     menu.addItem({ type: 'separator' });
-    menu.addItem({ command: statedbCmdIds.clear });
+    menu.addItem({ command: StateDBCommandIDs.clear });
 
     return menu;
   }
@@ -271,24 +271,24 @@ function activate(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette
     }
   });
 
-  app.commands.addCommand(cmdIds.show, {
+  app.commands.addCommand(CommandIDs.show, {
     execute: () => { showHelp(); }
   });
-  app.commands.addCommand(cmdIds.hide, {
+  app.commands.addCommand(CommandIDs.hide, {
     execute: () => { hideHelp(); }
   });
-  app.commands.addCommand(cmdIds.toggle, {
+  app.commands.addCommand(CommandIDs.toggle, {
     execute: () => { toggleHelp(); }
   });
 
   RESOURCES.forEach(args => { palette.addItem({ args, command, category }); });
 
-  palette.addItem({ command: statedbCmdIds.clear, category });
+  palette.addItem({ command: StateDBCommandIDs.clear, category });
 
-  app.commands.addCommand(cmdIds.launchClassic, {
+  app.commands.addCommand(CommandIDs.launchClassic, {
     label: 'Launch Classic Notebook',
     execute: () => { window.open(utils.getBaseUrl() + 'tree'); }
   });
-  palette.addItem({ command: cmdIds.launchClassic, category });
+  palette.addItem({ command: CommandIDs.launchClassic, category });
   mainMenu.addMenu(menu, {});
 }

+ 10 - 5
src/imagewidget/index.ts

@@ -5,11 +5,16 @@ export * from './widget';
 
 
 /**
- * The map of command ids used by the imagewidget plugin.
+ * The command IDs used by the image widget plugin.
  */
 export
-const cmdIds = {
-  zoomIn: 'imagewidget:zoom-in',
-  zoomOut: 'imagewidget:zoom-out',
-  resetZoom: 'imagewidget:reset-zoom'
+namespace CommandIDs {
+  export
+  const zoomIn = 'imagewidget:zoom-in';
+
+  export
+  const zoomOut = 'imagewidget:zoom-out';
+
+  export
+  const resetZoom = 'imagewidget:reset-zoom';
 };

+ 7 - 7
src/imagewidget/plugin.ts

@@ -18,7 +18,7 @@ import {
 } from '../docregistry';
 
 import {
-  cmdIds as filebrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -26,7 +26,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  ImageWidget, ImageWidgetFactory, cmdIds
+  CommandIDs, ImageWidget, ImageWidgetFactory
 } from './';
 
 
@@ -73,7 +73,7 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, palette: IComman
 
   // Handle state restoration.
   restorer.restore(tracker, {
-    command: filebrowserCmdIds.open,
+    command: FileBrowserCommandIDs.open,
     args: widget => ({ path: widget.context.path, factory: FACTORY }),
     name: widget => widget.context.path
   });
@@ -86,24 +86,24 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, palette: IComman
     tracker.add(widget);
   });
 
-  app.commands.addCommand(cmdIds.zoomIn, {
+  app.commands.addCommand(CommandIDs.zoomIn, {
     execute: zoomIn,
     label: 'Zoom In'
   });
 
-  app.commands.addCommand(cmdIds.zoomOut, {
+  app.commands.addCommand(CommandIDs.zoomOut, {
     execute: zoomOut,
     label: 'Zoom Out'
   });
 
-  app.commands.addCommand(cmdIds.resetZoom, {
+  app.commands.addCommand(CommandIDs.resetZoom, {
     execute: resetZoom,
     label: 'Reset Zoom'
   });
 
   let category = 'Image Widget';
 
-  [cmdIds.zoomIn, cmdIds.zoomOut, cmdIds.resetZoom]
+  [CommandIDs.zoomIn, CommandIDs.zoomOut, CommandIDs.resetZoom]
     .forEach(command => palette.addItem({ command, category }));
 
   function zoomIn(): void {

+ 4 - 3
src/inspector/index.ts

@@ -6,9 +6,10 @@ export * from './inspector';
 
 
 /**
- * The map of command ids used by the inspector plugin.
+ * The command IDs used by the inspector plugin.
  */
 export
-const cmdIds = {
-  open: 'inspector:open'
+namespace CommandIDs {
+  export
+  const open = 'inspector:open';
 };

+ 2 - 2
src/inspector/plugin.ts

@@ -19,7 +19,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  IInspector, Inspector, cmdIds
+  CommandIDs, IInspector, Inspector
 } from './';
 
 
@@ -98,7 +98,7 @@ class InspectorManager implements IInspector {
  */
 function activate(app: JupyterLab, palette: ICommandPalette, restorer: IInstanceRestorer): IInspector {
   const category = 'Inspector';
-  const command = cmdIds.open;
+  const command = CommandIDs.open;
   const label = 'Open Inspector';
   const manager = new InspectorManager();
   const tracker = new InstanceTracker<Inspector>({ namespace: 'inspector' });

+ 4 - 3
src/landing/index.ts

@@ -5,9 +5,10 @@ export * from './widget';
 
 
 /**
- * The map of command ids used by the landing plugin.
+ * The command IDs used by the landing plugin.
  */
 export
-const cmdIds = {
-  open: 'landing-jupyterlab:open',
+namespace CommandIDs {
+  export
+  const open = 'landing-jupyterlab:open';
 };

+ 2 - 2
src/landing/plugin.ts

@@ -26,7 +26,7 @@ import {
 } from '../services';
 
 import {
-  LandingModel, LandingWidget, cmdIds
+  CommandIDs, LandingModel, LandingWidget
 } from './';
 
 /**
@@ -56,7 +56,7 @@ export default plugin;
  */
 function activate(app: JupyterLab, pathTracker: IPathTracker, palette: ICommandPalette, services: IServiceManager, restorer: IInstanceRestorer): void {
   const category = 'Help';
-  const command = cmdIds.open;
+  const command = CommandIDs.open;
   const model = new LandingModel(services.terminals.isAvailable());
   const tracker = new InstanceTracker<LandingWidget>({ namespace: 'landing' });
 

+ 4 - 3
src/launcher/index.ts

@@ -36,11 +36,12 @@ import {
 
 
 /**
- * The map of command ids used by the landing plugin.
+ * The command IDs used by the launcher plugin.
  */
 export
-const cmdIds = {
-  show: 'launcher-jupyterlab:show',
+namespace CommandIDs {
+  export
+  const show = 'launcher-jupyterlab:show';
 };
 
 

+ 17 - 11
src/launcher/plugin.ts

@@ -14,11 +14,11 @@ import {
 } from '../commandpalette';
 
 import {
-  cmdIds as consoleCmdIds
+  CommandIDs as ConsoleCommandIDs
 } from '../console';
 
 import {
-  cmdIds as filebrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -34,11 +34,11 @@ import {
 } from '../services';
 
 import {
-  cmdIds as terminalCmdIds
+  CommandIDs as TerminalCommandIDs
 } from '../terminal';
 
 import {
-  ILauncher, ILauncherItem, LauncherModel, LauncherWidget, cmdIds
+  CommandIDs, ILauncher, ILauncherItem, LauncherModel, LauncherWidget
 } from './';
 
 
@@ -48,7 +48,13 @@ import {
 const plugin: JupyterLabPlugin<ILauncher> = {
   activate,
   id: 'jupyter.services.launcher',
-  requires: [IServiceManager, IPathTracker, ICommandPalette, ICommandLinker, IInstanceRestorer],
+  requires: [
+    IServiceManager,
+    IPathTracker,
+    ICommandPalette,
+    ICommandLinker,
+    IInstanceRestorer
+  ],
   provides: ILauncher,
   autoStart: true
 };
@@ -85,22 +91,22 @@ function activate(app: JupyterLab, services: IServiceManager, pathTracker: IPath
   let defaults: ILauncherItem[] = [
     {
       name: 'Notebook',
-      command: filebrowserCmdIds.newNotebook
+      command: FileBrowserCommandIDs.newNotebook
     },
     {
       name: 'Code Console',
-      command: consoleCmdIds.create
+      command: ConsoleCommandIDs.create
     },
     {
       name: 'Text Editor',
-      command: filebrowserCmdIds.newTextFile
+      command: FileBrowserCommandIDs.newTextFile
     }
   ];
 
   if (services.terminals.isAvailable()) {
     defaults.push({
       name: 'Terminal',
-      command: terminalCmdIds.createNew
+      command: TerminalCommandIDs.createNew
     });
   }
 
@@ -108,7 +114,7 @@ function activate(app: JupyterLab, services: IServiceManager, pathTracker: IPath
   // means we have to way of removing them after the fact.
   defaults.forEach(options => { model.add(options); });
 
-  app.commands.addCommand(cmdIds.show, {
+  app.commands.addCommand(CommandIDs.show, {
     label: 'Show Launcher',
     execute: () => {
       if (!widget.isAttached) {
@@ -117,7 +123,7 @@ function activate(app: JupyterLab, services: IServiceManager, pathTracker: IPath
       app.shell.activateLeft(widget.id);
     }
   });
-  palette.addItem({ command: cmdIds.show, category: 'Help' });
+  palette.addItem({ command: CommandIDs.show, category: 'Help' });
 
   app.shell.addToLeftArea(widget);
 

+ 12 - 7
src/markdownwidget/plugin.ts

@@ -14,7 +14,7 @@ import {
 } from '../docregistry';
 
 import {
-  cmdIds as filebrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -50,9 +50,17 @@ const FACTORY = 'Rendered Markdown';
  * The markdown handler extension.
  */
 const plugin: JupyterLabPlugin<void> = {
+  activate,
   id: 'jupyter.extensions.rendered-markdown',
   requires: [IDocumentRegistry, IRenderMime, IInstanceRestorer],
-  activate: (app: JupyterLab, registry: IDocumentRegistry, rendermime: IRenderMime, restorer: IInstanceRestorer) => {
+  autoStart: true
+};
+
+
+/**
+ * Activate the markdown plugin.
+ */
+function activate(app: JupyterLab, registry: IDocumentRegistry, rendermime: IRenderMime, restorer: IInstanceRestorer) {
     const factory = new MarkdownWidgetFactory({
       name: FACTORY,
       fileExtensions: ['.md'],
@@ -64,7 +72,7 @@ const plugin: JupyterLabPlugin<void> = {
 
     // Handle state restoration.
     restorer.restore(tracker, {
-      command: filebrowserCmdIds.open,
+      command: FileBrowserCommandIDs.open,
       args: widget => ({ path: widget.context.path, factory: FACTORY }),
       name: widget => widget.context.path
     });
@@ -77,13 +85,10 @@ const plugin: JupyterLabPlugin<void> = {
     });
 
     registry.addWidgetFactory(factory);
-  },
-  autoStart: true
-};
+  }
 
 
 /**
  * Export the plugin as default.
  */
 export default plugin;
-

+ 127 - 44
src/notebook/index.ts

@@ -13,50 +13,133 @@ export * from './widgetfactory';
 
 
 /**
- * The map of command ids used by the notebook plugin.
+ * The command IDs used by the notebook plugin.
  */
 export
-const cmdIds = {
-  interrupt: 'notebook:interrupt-kernel',
-  restart: 'notebook:restart-kernel',
-  restartClear: 'notebook:restart-clear',
-  restartRunAll: 'notebook:restart-runAll',
-  switchKernel: 'notebook:switch-kernel',
-  clearAllOutputs: 'notebook:clear-outputs',
-  closeAndHalt: 'notebook:close-and-halt',
-  trust: 'notebook:trust',
-  run: 'notebook-cells:run',
-  runAndAdvance: 'notebook-cells:run-and-advance',
-  runAndInsert: 'notebook-cells:run-and-insert',
-  runAll: 'notebook:run-all',
-  toCode: 'notebook-cells:to-code',
-  toMarkdown: 'notebook-cells:to-markdown',
-  toRaw: 'notebook-cells:to-raw',
-  cut: 'notebook-cells:cut',
-  copy: 'notebook-cells:copy',
-  paste: 'notebook-cells:paste',
-  moveUp: 'notebook-cells:move-up',
-  moveDown: 'notebook-cells:move-down',
-  clearOutputs: 'notebook-cells:clear-output',
-  deleteCell: 'notebook-cells:delete',
-  insertAbove: 'notebook-cells:insert-above',
-  insertBelow: 'notebook-cells:insert-below',
-  selectAbove: 'notebook-cells:select-above',
-  selectBelow: 'notebook-cells:select-below',
-  extendAbove: 'notebook-cells:extend-above',
-  extendBelow: 'notebook-cells:extend-below',
-  editMode: 'notebook:edit-mode',
-  merge: 'notebook-cells:merge',
-  split: 'notebook-cells:split',
-  commandMode: 'notebook:command-mode',
-  toggleLines: 'notebook-cells:toggle-line-numbers',
-  toggleAllLines: 'notebook-cells:toggle-all-line-numbers',
-  undo: 'notebook-cells:undo',
-  redo: 'notebook-cells:redo',
-  markdown1: 'notebook-cells:markdown-header1',
-  markdown2: 'notebook-cells:markdown-header2',
-  markdown3: 'notebook-cells:markdown-header3',
-  markdown4: 'notebook-cells:markdown-header4',
-  markdown5: 'notebook-cells:markdown-header5',
-  markdown6: 'notebook-cells:markdown-header6',
+namespace CommandIDs {
+  export
+  const interrupt = 'notebook:interrupt-kernel';
+
+  export
+  const restart = 'notebook:restart-kernel';
+
+  export
+  const restartClear = 'notebook:restart-clear';
+
+  export
+  const restartRunAll = 'notebook:restart-runAll';
+
+  export
+  const switchKernel = 'notebook:switch-kernel';
+
+  export
+  const clearAllOutputs = 'notebook:clear-outputs';
+
+  export
+  const closeAndHalt = 'notebook:close-and-halt';
+
+  export
+  const trust = 'notebook:trust';
+
+  export
+  const run = 'notebook-cells:run';
+
+  export
+  const runAndAdvance = 'notebook-cells:run-and-advance';
+
+  export
+  const runAndInsert = 'notebook-cells:run-and-insert';
+
+  export
+  const runAll = 'notebook:run-all';
+
+  export
+  const toCode = 'notebook-cells:to-code';
+
+  export
+  const toMarkdown = 'notebook-cells:to-markdown';
+
+  export
+  const toRaw = 'notebook-cells:to-raw';
+
+  export
+  const cut = 'notebook-cells:cut';
+
+  export
+  const copy = 'notebook-cells:copy';
+
+  export
+  const paste = 'notebook-cells:paste';
+
+  export
+  const moveUp = 'notebook-cells:move-up';
+
+  export
+  const moveDown = 'notebook-cells:move-down';
+
+  export
+  const clearOutputs = 'notebook-cells:clear-output';
+
+  export
+  const deleteCell = 'notebook-cells:delete';
+
+  export
+  const insertAbove = 'notebook-cells:insert-above';
+
+  export
+  const insertBelow = 'notebook-cells:insert-below';
+
+  export
+  const selectAbove = 'notebook-cells:select-above';
+
+  export
+  const selectBelow = 'notebook-cells:select-below';
+
+  export
+  const extendAbove = 'notebook-cells:extend-above';
+
+  export
+  const extendBelow = 'notebook-cells:extend-below';
+
+  export
+  const editMode = 'notebook:edit-mode';
+
+  export
+  const merge = 'notebook-cells:merge';
+
+  export
+  const split = 'notebook-cells:split';
+
+  export
+  const commandMode = 'notebook:command-mode';
+
+  export
+  const toggleLines = 'notebook-cells:toggle-line-numbers';
+
+  export
+  const toggleAllLines = 'notebook-cells:toggle-all-line-numbers';
+
+  export
+  const undo = 'notebook-cells:undo';
+
+  export
+  const redo = 'notebook-cells:redo';
+
+  export
+  const markdown1 = 'notebook-cells:markdown-header1';
+
+  export
+  const markdown2 = 'notebook-cells:markdown-header2';
+
+  export
+  const markdown3 = 'notebook-cells:markdown-header3';
+
+  export
+  const markdown4 = 'notebook-cells:markdown-header4';
+
+  export
+  const markdown5 = 'notebook-cells:markdown-header5';
+
+  export
+  const markdown6 = 'notebook-cells:markdown-header6';
 };

+ 101 - 102
src/notebook/plugin.ts

@@ -26,12 +26,11 @@ import {
 } from '../mainmenu';
 
 import {
-  IDocumentRegistry,
-  restartKernel, selectKernelForContext
+  IDocumentRegistry, restartKernel, selectKernelForContext
 } from '../docregistry';
 
 import {
-  cmdIds as filebrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -51,8 +50,8 @@ import {
 } from '../services';
 
 import {
-  INotebookTracker, NotebookModelFactory, NotebookPanel, NotebookTracker,
-  NotebookWidgetFactory, NotebookActions, cmdIds, trustNotebook
+  CommandIDs, INotebookTracker, NotebookActions, NotebookModelFactory,
+  NotebookPanel, NotebookTracker, NotebookWidgetFactory, trustNotebook
 } from './';
 
 
@@ -141,7 +140,7 @@ function activateNotebookHandler(app: JupyterLab, registry: IDocumentRegistry, s
 
   // Handle state restoration.
   restorer.restore(tracker, {
-    command: filebrowserCmdIds.open,
+    command: FileBrowserCommandIDs.open,
     args: panel => ({ path: panel.context.path, factory: FACTORY }),
     name: panel => panel.context.path,
     when: services.ready
@@ -197,7 +196,7 @@ function activateNotebookHandler(app: JupyterLab, registry: IDocumentRegistry, s
 function addCommands(app: JupyterLab, services: IServiceManager, tracker: NotebookTracker): void {
   let commands = app.commands;
 
-  commands.addCommand(cmdIds.runAndAdvance, {
+  commands.addCommand(CommandIDs.runAndAdvance, {
     label: 'Run Cell(s) and Advance',
     execute: () => {
       let current = tracker.currentWidget;
@@ -207,7 +206,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.run, {
+  commands.addCommand(CommandIDs.run, {
     label: 'Run Cell(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -216,7 +215,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.runAndInsert, {
+  commands.addCommand(CommandIDs.runAndInsert, {
     label: 'Run Cell(s) and Insert',
     execute: () => {
       let current = tracker.currentWidget;
@@ -225,7 +224,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.runAll, {
+  commands.addCommand(CommandIDs.runAll, {
     label: 'Run All Cells',
     execute: () => {
       let current = tracker.currentWidget;
@@ -234,7 +233,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.restart, {
+  commands.addCommand(CommandIDs.restart, {
     label: 'Restart Kernel',
     execute: () => {
       let current = tracker.currentWidget;
@@ -245,7 +244,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.closeAndHalt, {
+  commands.addCommand(CommandIDs.closeAndHalt, {
     label: 'Close and Halt',
     execute: () => {
       let current = tracker.currentWidget;
@@ -254,7 +253,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.trust, {
+  commands.addCommand(CommandIDs.trust, {
     label: 'Trust Notebook',
     execute: () => {
       let current = tracker.currentWidget;
@@ -265,7 +264,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.restartClear, {
+  commands.addCommand(CommandIDs.restartClear, {
     label: 'Restart Kernel & Clear Outputs',
     execute: () => {
       let current = tracker.currentWidget;
@@ -280,7 +279,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.restartRunAll, {
+  commands.addCommand(CommandIDs.restartRunAll, {
     label: 'Restart Kernel & Run All',
     execute: () => {
       let current = tracker.currentWidget;
@@ -293,7 +292,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.clearAllOutputs, {
+  commands.addCommand(CommandIDs.clearAllOutputs, {
     label: 'Clear All Outputs',
     execute: () => {
       let current = tracker.currentWidget;
@@ -302,7 +301,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.clearOutputs, {
+  commands.addCommand(CommandIDs.clearOutputs, {
     label: 'Clear Output(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -311,7 +310,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.interrupt, {
+  commands.addCommand(CommandIDs.interrupt, {
     label: 'Interrupt Kernel',
     execute: () => {
       let current = tracker.currentWidget;
@@ -323,7 +322,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.toCode, {
+  commands.addCommand(CommandIDs.toCode, {
     label: 'Convert to Code',
     execute: () => {
       let current = tracker.currentWidget;
@@ -332,7 +331,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.toMarkdown, {
+  commands.addCommand(CommandIDs.toMarkdown, {
     label: 'Convert to Markdown',
     execute: () => {
       let current = tracker.currentWidget;
@@ -341,7 +340,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.toRaw, {
+  commands.addCommand(CommandIDs.toRaw, {
     label: 'Convert to Raw',
     execute: () => {
       let current = tracker.currentWidget;
@@ -350,7 +349,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.cut, {
+  commands.addCommand(CommandIDs.cut, {
     label: 'Cut Cell(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -359,7 +358,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.copy, {
+  commands.addCommand(CommandIDs.copy, {
     label: 'Copy Cell(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -368,7 +367,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.paste, {
+  commands.addCommand(CommandIDs.paste, {
     label: 'Paste Cell(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -377,7 +376,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.deleteCell, {
+  commands.addCommand(CommandIDs.deleteCell, {
     label: 'Delete Cell(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -386,7 +385,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.split, {
+  commands.addCommand(CommandIDs.split, {
     label: 'Split Cell',
     execute: () => {
       let current = tracker.currentWidget;
@@ -395,7 +394,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.merge, {
+  commands.addCommand(CommandIDs.merge, {
     label: 'Merge Selected Cell(s)',
     execute: () => {
       let current = tracker.currentWidget;
@@ -404,7 +403,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.insertAbove, {
+  commands.addCommand(CommandIDs.insertAbove, {
     label: 'Insert Cell Above',
     execute: () => {
       let current = tracker.currentWidget;
@@ -413,7 +412,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.insertBelow, {
+  commands.addCommand(CommandIDs.insertBelow, {
     label: 'Insert Cell Below',
     execute: () => {
       let current = tracker.currentWidget;
@@ -422,7 +421,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.selectAbove, {
+  commands.addCommand(CommandIDs.selectAbove, {
     label: 'Select Cell Above',
     execute: () => {
       let current = tracker.currentWidget;
@@ -431,7 +430,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.selectBelow, {
+  commands.addCommand(CommandIDs.selectBelow, {
     label: 'Select Cell Below',
     execute: () => {
       let current = tracker.currentWidget;
@@ -440,7 +439,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.extendAbove, {
+  commands.addCommand(CommandIDs.extendAbove, {
     label: 'Extend Selection Above',
     execute: () => {
       let current = tracker.currentWidget;
@@ -449,7 +448,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.extendBelow, {
+  commands.addCommand(CommandIDs.extendBelow, {
     label: 'Extend Selection Below',
     execute: () => {
       let current = tracker.currentWidget;
@@ -458,7 +457,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.moveUp, {
+  commands.addCommand(CommandIDs.moveUp, {
     label: 'Move Cell(s) Up',
     execute: () => {
       let current = tracker.currentWidget;
@@ -467,7 +466,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.moveDown, {
+  commands.addCommand(CommandIDs.moveDown, {
     label: 'Move Cell(s) Down',
     execute: () => {
       let current = tracker.currentWidget;
@@ -476,7 +475,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.toggleLines, {
+  commands.addCommand(CommandIDs.toggleLines, {
     label: 'Toggle Line Numbers',
     execute: () => {
       let current = tracker.currentWidget;
@@ -485,7 +484,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.toggleAllLines, {
+  commands.addCommand(CommandIDs.toggleAllLines, {
     label: 'Toggle All Line Numbers',
     execute: () => {
       let current = tracker.currentWidget;
@@ -494,7 +493,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.commandMode, {
+  commands.addCommand(CommandIDs.commandMode, {
     label: 'To Command Mode',
     execute: () => {
       let current = tracker.currentWidget;
@@ -503,7 +502,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.editMode, {
+  commands.addCommand(CommandIDs.editMode, {
     label: 'To Edit Mode',
     execute: () => {
       let current = tracker.currentWidget;
@@ -512,7 +511,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.undo, {
+  commands.addCommand(CommandIDs.undo, {
     label: 'Undo Cell Operation',
     execute: () => {
       let current = tracker.currentWidget;
@@ -521,7 +520,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.redo, {
+  commands.addCommand(CommandIDs.redo, {
     label: 'Redo Cell Operation',
     execute: () => {
       let current = tracker.currentWidget;
@@ -530,7 +529,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.switchKernel, {
+  commands.addCommand(CommandIDs.switchKernel, {
     label: 'Switch Kernel',
     execute: () => {
       let current = tracker.currentWidget;
@@ -543,7 +542,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.markdown1, {
+  commands.addCommand(CommandIDs.markdown1, {
     label: 'Markdown Header 1',
     execute: () => {
       let current = tracker.currentWidget;
@@ -552,7 +551,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.markdown2, {
+  commands.addCommand(CommandIDs.markdown2, {
     label: 'Markdown Header 2',
     execute: () => {
       let current = tracker.currentWidget;
@@ -561,7 +560,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.markdown3, {
+  commands.addCommand(CommandIDs.markdown3, {
     label: 'Markdown Header 3',
     execute: () => {
       let current = tracker.currentWidget;
@@ -570,7 +569,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.markdown4, {
+  commands.addCommand(CommandIDs.markdown4, {
     label: 'Markdown Header 4',
     execute: () => {
       let current = tracker.currentWidget;
@@ -579,7 +578,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.markdown5, {
+  commands.addCommand(CommandIDs.markdown5, {
     label: 'Markdown Header 5',
     execute: () => {
       let current = tracker.currentWidget;
@@ -588,7 +587,7 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
       }
     }
   });
-  commands.addCommand(cmdIds.markdown6, {
+  commands.addCommand(CommandIDs.markdown6, {
     label: 'Markdown Header 6',
     execute: () => {
       let current = tracker.currentWidget;
@@ -605,52 +604,52 @@ function addCommands(app: JupyterLab, services: IServiceManager, tracker: Notebo
 function populatePalette(palette: ICommandPalette): void {
   let category = 'Notebook Operations';
   [
-    cmdIds.interrupt,
-    cmdIds.restart,
-    cmdIds.restartClear,
-    cmdIds.restartRunAll,
-    cmdIds.runAll,
-    cmdIds.clearAllOutputs,
-    cmdIds.toggleAllLines,
-    cmdIds.editMode,
-    cmdIds.commandMode,
-    cmdIds.switchKernel,
-    cmdIds.closeAndHalt,
-    cmdIds.trust
+    CommandIDs.interrupt,
+    CommandIDs.restart,
+    CommandIDs.restartClear,
+    CommandIDs.restartRunAll,
+    CommandIDs.runAll,
+    CommandIDs.clearAllOutputs,
+    CommandIDs.toggleAllLines,
+    CommandIDs.editMode,
+    CommandIDs.commandMode,
+    CommandIDs.switchKernel,
+    CommandIDs.closeAndHalt,
+    CommandIDs.trust
   ].forEach(command => { palette.addItem({ command, category }); });
 
   category = 'Notebook Cell Operations';
   [
-    cmdIds.run,
-    cmdIds.runAndAdvance,
-    cmdIds.runAndInsert,
-    cmdIds.clearOutputs,
-    cmdIds.toCode,
-    cmdIds.toMarkdown,
-    cmdIds.toRaw,
-    cmdIds.cut,
-    cmdIds.copy,
-    cmdIds.paste,
-    cmdIds.deleteCell,
-    cmdIds.split,
-    cmdIds.merge,
-    cmdIds.insertAbove,
-    cmdIds.insertBelow,
-    cmdIds.selectAbove,
-    cmdIds.selectBelow,
-    cmdIds.extendAbove,
-    cmdIds.extendBelow,
-    cmdIds.moveDown,
-    cmdIds.moveUp,
-    cmdIds.toggleLines,
-    cmdIds.undo,
-    cmdIds.redo,
-    cmdIds.markdown1,
-    cmdIds.markdown2,
-    cmdIds.markdown3,
-    cmdIds.markdown4,
-    cmdIds.markdown5,
-    cmdIds.markdown6
+    CommandIDs.run,
+    CommandIDs.runAndAdvance,
+    CommandIDs.runAndInsert,
+    CommandIDs.clearOutputs,
+    CommandIDs.toCode,
+    CommandIDs.toMarkdown,
+    CommandIDs.toRaw,
+    CommandIDs.cut,
+    CommandIDs.copy,
+    CommandIDs.paste,
+    CommandIDs.deleteCell,
+    CommandIDs.split,
+    CommandIDs.merge,
+    CommandIDs.insertAbove,
+    CommandIDs.insertBelow,
+    CommandIDs.selectAbove,
+    CommandIDs.selectBelow,
+    CommandIDs.extendAbove,
+    CommandIDs.extendBelow,
+    CommandIDs.moveDown,
+    CommandIDs.moveUp,
+    CommandIDs.toggleLines,
+    CommandIDs.undo,
+    CommandIDs.redo,
+    CommandIDs.markdown1,
+    CommandIDs.markdown2,
+    CommandIDs.markdown3,
+    CommandIDs.markdown4,
+    CommandIDs.markdown5,
+    CommandIDs.markdown6
   ].forEach(command => { palette.addItem({ command, category }); });
 }
 
@@ -664,18 +663,18 @@ function createMenu(app: JupyterLab): Menu {
 
   menu.title.label = 'Notebook';
   settings.title.label = 'Settings';
-  settings.addItem({ command: cmdIds.toggleAllLines });
-
-  menu.addItem({ command: cmdIds.undo });
-  menu.addItem({ command: cmdIds.redo });
-  menu.addItem({ command: cmdIds.split });
-  menu.addItem({ command: cmdIds.deleteCell });
-  menu.addItem({ command: cmdIds.clearAllOutputs });
-  menu.addItem({ command: cmdIds.runAll });
-  menu.addItem({ command: cmdIds.restart });
-  menu.addItem({ command: cmdIds.switchKernel });
-  menu.addItem({ command: cmdIds.closeAndHalt });
-  menu.addItem({ command: cmdIds.trust });
+  settings.addItem({ command: CommandIDs.toggleAllLines });
+
+  menu.addItem({ command: CommandIDs.undo });
+  menu.addItem({ command: CommandIDs.redo });
+  menu.addItem({ command: CommandIDs.split });
+  menu.addItem({ command: CommandIDs.deleteCell });
+  menu.addItem({ command: CommandIDs.clearAllOutputs });
+  menu.addItem({ command: CommandIDs.runAll });
+  menu.addItem({ command: CommandIDs.restart });
+  menu.addItem({ command: CommandIDs.switchKernel });
+  menu.addItem({ command: CommandIDs.closeAndHalt });
+  menu.addItem({ command: CommandIDs.trust });
   menu.addItem({ type: 'separator' });
   menu.addItem({ type: 'submenu', menu: settings });
 

+ 8 - 6
src/running/plugin.ts

@@ -6,7 +6,7 @@ import {
 } from '../application';
 
 import {
-  cmdIds as consoleCmdIds
+  CommandIDs as ConsoleCommandIDs
 } from '../console';
 
 import {
@@ -14,7 +14,7 @@ import {
 } from '../instancerestorer';
 
 import {
-  cmdIds as filebrowserCmdIds
+  CommandIDs as FileBrowserCommandIDs
 } from '../filebrowser';
 
 import {
@@ -22,7 +22,7 @@ import {
 } from '../services';
 
 import {
-  cmdIds as terminalCmdIds
+  CommandIDs as TerminalCommandIDs
 } from '../terminal';
 
 import {
@@ -64,15 +64,17 @@ function activate(app: JupyterLab, services: IServiceManager, restorer: IInstanc
     let path = model.notebook.path;
     let name = path.split('/').pop();
     if (CONSOLE_REGEX.test(name)) {
-      app.commands.execute(consoleCmdIds.open, { id: model.id });
+      app.commands.execute(ConsoleCommandIDs.open, { id: model.id });
     } else {
-      app.commands.execute(filebrowserCmdIds.open, { path });
+      app.commands.execute(FileBrowserCommandIDs.open, { path });
     }
 
   });
+
   running.terminalOpenRequested.connect((sender, model) => {
-    app.commands.execute(terminalCmdIds.open, { name: model.name });
+    app.commands.execute(TerminalCommandIDs.open, { name: model.name });
   });
+
   // Rank has been chosen somewhat arbitrarily to give priority to the running
   // sessions widget in the sidebar.
   app.shell.addToLeftArea(running, { rank: 50 });

+ 120 - 84
src/shortcuts/plugin.ts

@@ -5,6 +5,42 @@ import {
   JupyterLab, JupyterLabPlugin
 } from '../application';
 
+import {
+  CommandIDs as CommandPaletteCommandIDs
+} from '../commandpalette';
+
+import {
+  CommandIDs as ConsoleCommandIDs
+} from '../console';
+
+import {
+  CommandIDs as EditorWidgetCommandIDs
+} from '../editorwidget';
+
+import {
+  CommandIDs as FileBrowserCommandIDs
+} from '../filebrowser';
+
+import {
+  CommandIDs as HelpCommandIDs
+} from '../help';
+
+import {
+  CommandIDs as ImageWidgetCommandIDs
+} from '../imagewidget';
+
+import {
+  CommandIDs as InspectorCommandIDs
+} from '../inspector';
+
+import {
+  CommandIDs as NotebookCommandIDs
+} from '../notebook';
+
+import {
+  CommandIDs as TooltipCommandIDs
+} from '../tooltip';
+
 
 /**
  * The list of default application shortcuts.
@@ -31,284 +67,284 @@ import {
  */
 const SHORTCUTS = [
   {
-    command: 'command-palette:activate',
+    command: CommandPaletteCommandIDs.activate,
     selector: 'body',
     keys: ['Accel Shift P']
   },
   {
-    command: 'editor:run-code',
+    command: ConsoleCommandIDs.run,
+    selector: '.jp-CodeConsole-prompt',
+    keys: ['Enter']
+  },
+  {
+    command: ConsoleCommandIDs.runForced,
+    selector: '.jp-CodeConsole-prompt',
+    keys: ['Shift Enter']
+  },
+  {
+    command: ConsoleCommandIDs.linebreak,
+    selector: '.jp-CodeConsole-prompt',
+    keys: ['Ctrl Enter']
+  },
+  {
+    command: EditorWidgetCommandIDs.runCode,
     selector: '.jp-EditorWidget',
     keys: ['Shift Enter']
   },
   {
-    command: 'file-browser:toggle',
+    command: FileBrowserCommandIDs.toggleBrowser,
     selector: 'body',
     keys: ['Accel Shift F']
   },
   {
-    command: 'file-operations:new-text-file',
+    command: FileBrowserCommandIDs.newTextFile,
     selector: 'body',
     keys: ['Ctrl O']
   },
   {
-    command: 'file-operations:new-notebook',
+    command: FileBrowserCommandIDs.newNotebook,
     selector: 'body',
     keys: ['Ctrl Shift N']
   },
   {
-    command: 'file-operations:save',
+    command: FileBrowserCommandIDs.save,
     selector: '.jp-Document',
     keys: ['Accel S']
   },
   {
-    command: 'file-operations:close',
+    command: FileBrowserCommandIDs.close,
     selector: '.jp-Document',
     keys: ['Ctrl Q']
   },
   {
-    command: 'file-operations:close-all',
+    command: FileBrowserCommandIDs.closeAllFiles,
     selector: '.jp-Document',
     keys: ['Ctrl Shift Q']
   },
   {
-    command: 'help-doc:toggle',
+    command: HelpCommandIDs.toggle,
     selector: 'body',
     keys: ['Accel Shift H']
   },
   {
-    command: 'notebook-cells:run-and-advance',
+    command: ImageWidgetCommandIDs.zoomIn,
+    selector: '.jp-ImageWidget',
+    keys: ['=']
+  },
+  {
+    command: ImageWidgetCommandIDs.zoomOut,
+    selector: '.jp-ImageWidget',
+    keys: ['-']
+  },
+  {
+    command: ImageWidgetCommandIDs.resetZoom,
+    selector: '.jp-ImageWidget',
+    keys: ['0']
+  },
+  {
+    command: InspectorCommandIDs.open,
+    selector: '.jp-CodeConsole-prompt',
+    keys: ['Accel I']
+  },
+  {
+    command: NotebookCommandIDs.runAndAdvance,
     selector: '.jp-Notebook',
     keys: ['Shift Enter']
   },
   {
-    command: 'notebook-cells:run-and-insert',
+    command: NotebookCommandIDs.runAndInsert,
     selector: '.jp-Notebook',
     keys: ['Alt Enter']
   },
   {
-    command: 'notebook-cells:run',
+    command: NotebookCommandIDs.run,
     selector: '.jp-Notebook',
     keys: ['Ctrl Enter']
   },
   {
-    command: 'notebook:interrupt-kernel',
+    command: NotebookCommandIDs.interrupt,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['I', 'I']
   },
   {
-    command: 'notebook:restart-kernel',
+    command: NotebookCommandIDs.restart,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['0', '0']
   },
   {
-    command: 'notebook-cells:to-code',
+    command: NotebookCommandIDs.toCode,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Y']
   },
   {
-    command: 'notebook-cells:to-markdown',
+    command: NotebookCommandIDs.toMarkdown,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['M']
   },
   {
-    command: 'notebook-cells:to-raw',
+    command: NotebookCommandIDs.toRaw,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['R']
   },
   {
-    command: 'notebook-cells:delete',
+    command: NotebookCommandIDs.deleteCell,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['D', 'D'],
   },
   {
-    command: 'notebook-cells:split',
+    command: NotebookCommandIDs.split,
     selector: '.jp-Notebook.jp-mod-editMode',
     keys: ['Ctrl Shift -'],
   },
   {
-    command: 'notebook-cells:merge',
+    command: NotebookCommandIDs.merge,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Shift M'],
   },
   {
-    command: 'notebook-cells:select-above',
+    command: NotebookCommandIDs.selectAbove,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['ArrowUp'],
   },
   {
-    command: 'notebook-cells:select-above',
+    command: NotebookCommandIDs.selectAbove,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['K'],
   },
   {
-    command: 'notebook-cells:select-below',
+    command: NotebookCommandIDs.selectBelow,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['ArrowDown'],
   },
   {
-    command: 'notebook-cells:select-below',
+    command: NotebookCommandIDs.selectBelow,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['J'],
   },
   {
-    command: 'notebook-cells:extend-above',
+    command: NotebookCommandIDs.extendAbove,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Shift ArrowUp'],
   },
   {
-    command: 'notebook-cells:extend-above',
+    command: NotebookCommandIDs.extendAbove,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Shift K'],
   },
   {
-    command: 'notebook-cells:extend-below',
+    command: NotebookCommandIDs.extendBelow,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Shift ArrowDown'],
   },
   {
-    command: 'notebook-cells:extend-below',
+    command: NotebookCommandIDs.extendBelow,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Shift J'],
   },
   {
-    command: 'notebook-cells:undo',
+    command: NotebookCommandIDs.undo,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Z'],
   },
   {
-    command: 'notebook-cells:redo',
+    command: NotebookCommandIDs.redo,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Shift Z'],
   },
   {
-    command: 'notebook-cells:cut',
+    command: NotebookCommandIDs.cut,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['X']
   },
   {
-    command: 'notebook-cells:copy',
+    command: NotebookCommandIDs.copy,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['C']
   },
   {
-    command: 'notebook-cells:paste',
+    command: NotebookCommandIDs.paste,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['V']
   },
   {
-    command: 'notebook-cells:insert-above',
+    command: NotebookCommandIDs.insertAbove,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['A']
   },
   {
-    command: 'notebook-cells:insert-below',
+    command: NotebookCommandIDs.insertBelow,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['B']
   },
   {
-    command: 'notebook-cells:toggle-line-numbers',
+    command: NotebookCommandIDs.toggleLines,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['L']
   },
   {
-    command: 'notebook-cells:markdown-header1',
+    command: NotebookCommandIDs.markdown1,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['1']
   },
   {
-    command: 'notebook-cells:markdown-header2',
+    command: NotebookCommandIDs.markdown2,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['2']
   },
   {
-    command: 'notebook-cells:markdown-header3',
+    command: NotebookCommandIDs.markdown3,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['3']
   },
   {
-    command: 'notebook-cells:markdown-header4',
+    command: NotebookCommandIDs.markdown4,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['4']
   },
   {
-    command: 'notebook-cells:markdown-header5',
+    command: NotebookCommandIDs.markdown5,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['5']
   },
   {
-    command: 'notebook-cells:markdown-header6',
+    command: NotebookCommandIDs.markdown6,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['6']
   },
   {
-    command: 'notebook:edit-mode',
+    command: NotebookCommandIDs.editMode,
     selector: '.jp-Notebook.jp-mod-commandMode',
     keys: ['Enter']
   },
   {
-    command: 'notebook:command-mode',
+    command: NotebookCommandIDs.commandMode,
     selector: '.jp-Notebook.jp-mod-editMode',
     keys: ['Escape']
   },
   {
-    command: 'notebook:command-mode',
+    command: NotebookCommandIDs.commandMode,
     selector: '.jp-Notebook.jp-mod-editMode',
     keys: ['Ctrl M']
   },
   {
-    command: 'console:run',
-    selector: '.jp-CodeConsole-prompt',
-    keys: ['Enter']
-  },
-  {
-    command: 'console:run-forced',
-    selector: '.jp-CodeConsole-prompt',
-    keys: ['Shift Enter']
-  },
-  {
-    command: 'console:linebreak',
-    selector: '.jp-CodeConsole-prompt',
-    keys: ['Ctrl Enter']
-  },
-  {
-    command: 'console:toggle-inspectors',
-    selector: '.jp-CodeConsole-promptt',
-    keys: ['Accel I']
-  },
-  {
-    command: 'image-widget:zoom-in',
-    selector: '.jp-ImageWidget',
-    keys: ['=']
-  },
-  {
-    command: 'image-widget:zoom-out',
-    selector: '.jp-ImageWidget',
-    keys: ['-']
-  },
-  {
-    command: 'image-widget:reset-zoom',
-    selector: '.jp-ImageWidget',
-    keys: ['0']
-  },
-  {
-    command: 'tooltip:launch',
+    command: TooltipCommandIDs.launch,
     selector: '.jp-Notebook',
     keys: ['Shift Tab'],
     args: { notebook: true }
   },
   {
-    command: 'tooltip:launch',
+    command: TooltipCommandIDs.launch,
     selector: '.jp-ConsolePanel',
     keys: ['Shift Tab'],
     args: { notebook: false }
   },
   {
-    command: 'tooltip:remove',
+    command: TooltipCommandIDs.remove,
     selector: '.jp-Notebook.jp-Tooltip-anchor',
     keys: ['Escape']
   },
   {
-    command: 'tooltip:remove',
+    command: TooltipCommandIDs.remove,
     selector: '.jp-CodeConsole.jp-Tooltip-anchor',
     keys: ['Escape']
   }

+ 4 - 3
src/statedb/index.ts

@@ -13,11 +13,12 @@ export * from './statedb';
 
 
 /**
- * The map of command ids used by the console plugin.
+ * The command IDs used by the state database plugin.
  */
 export
-const cmdIds = {
-  clear: 'statedb:clear'
+namespace CommandIDs {
+  export
+  const clear = 'statedb:clear';
 };
 
 

+ 2 - 2
src/statedb/plugin.ts

@@ -14,7 +14,7 @@ import {
 } from './index';
 
 import {
-  StateDB, cmdIds
+  CommandIDs, StateDB
 } from './';
 
 
@@ -41,7 +41,7 @@ export default plugin;
 function activate(app: JupyterLab): Promise<IStateDB> {
   let state = new StateDB({ namespace: app.info.namespace });
   let version = app.info.version;
-  let command = cmdIds.clear;
+  let command = CommandIDs.clear;
   let key = 'statedb:version';
   let fetch = state.fetch(key);
   let save = () => state.save(key, { version });

+ 16 - 7
src/terminal/index.ts

@@ -5,13 +5,22 @@ export * from './widget';
 
 
 /**
- * The map of command ids used by the terminal plugin.
+ * The command IDs used by the terminal plugin.
  */
 export
-const cmdIds = {
-  createNew: 'terminal:create-new',
-  open: 'terminal:open',
-  increaseFont: 'terminal:increase-font',
-  decreaseFont: 'terminal:decrease-font',
-  toggleTheme: 'terminal:toggle-theme'
+namespace CommandIDs {
+  export
+  const createNew = 'terminal:create-new';
+
+  export
+  const open = 'terminal:open';
+
+  export
+  const increaseFont = 'terminal:increase-font';
+
+  export
+  const decreaseFont = 'terminal:decrease-font';
+
+  export
+  const toggleTheme = 'terminal:toggle-theme';
 };

+ 13 - 10
src/terminal/plugin.ts

@@ -34,7 +34,7 @@ import {
 } from '../services';
 
 import {
-  TerminalWidget, cmdIds
+  CommandIDs, TerminalWidget
 } from './';
 
 
@@ -91,13 +91,13 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
 
   // Handle state restoration.
   restorer.restore(tracker, {
-    command: cmdIds.createNew,
+    command: CommandIDs.createNew,
     args: widget => ({ name: widget.session.name }),
     name: widget => widget.session && widget.session.name
   });
 
   // Add terminal commands.
-  commands.addCommand(cmdIds.createNew, {
+  commands.addCommand(CommandIDs.createNew, {
     label: 'New Terminal',
     caption: 'Start a new terminal session',
     execute: args => {
@@ -122,7 +122,7 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
     }
   });
 
-  commands.addCommand(cmdIds.increaseFont, {
+  commands.addCommand(CommandIDs.increaseFont, {
     label: 'Increase Terminal Font Size',
     execute: () => {
       if (options.fontSize < 72) {
@@ -132,7 +132,7 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
     }
   });
 
-  commands.addCommand(cmdIds.decreaseFont, {
+  commands.addCommand(CommandIDs.decreaseFont, {
     label: 'Decrease Terminal Font Size',
     execute: () => {
       if (options.fontSize > 9) {
@@ -142,7 +142,7 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
     }
   });
 
-  commands.addCommand(cmdIds.toggleTheme, {
+  commands.addCommand(CommandIDs.toggleTheme, {
     label: 'Toggle Terminal Theme',
     caption: 'Switch Terminal Background and Font Colors',
     execute: () => {
@@ -160,7 +160,7 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
     }
   });
 
-  commands.addCommand(cmdIds.open, {
+  commands.addCommand(CommandIDs.open, {
     execute: args => {
       let name = args['name'] as string;
       // Check for a running terminal with the given name.
@@ -169,7 +169,7 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
         app.shell.activateMain(widget.id);
       } else {
         // Otherwise, create a new terminal with a given name.
-        return commands.execute(cmdIds.createNew, { name });
+        return commands.execute(CommandIDs.createNew, { name });
       }
     }
   });
@@ -177,8 +177,11 @@ function activate(app: JupyterLab, services: IServiceManager, mainMenu: IMainMen
   // Add command palette and menu items.
   let menu = new Menu({ commands, keymap });
   menu.title.label = category;
-  [cmdIds.createNew, cmdIds.increaseFont, cmdIds.decreaseFont,
-   cmdIds.toggleTheme
+  [
+    CommandIDs.createNew,
+    CommandIDs.increaseFont,
+    CommandIDs.decreaseFont,
+    CommandIDs.toggleTheme
   ].forEach(command => {
     palette.addItem({ command, category });
     menu.addItem({ command });

+ 7 - 4
src/tooltip/index.ts

@@ -6,10 +6,13 @@ export * from './widget';
 
 
 /**
- * The command ids used by the tooltip plugin.
+ * The command IDs used by the tooltip plugin.
  */
 export
-const cmdIds = {
-  launch: 'tooltip:launch',
-  remove: 'tooltip:remove'
+namespace CommandIDs {
+  export
+  const launch = 'tooltip:launch';
+
+  export
+  const remove = 'tooltip:remove';
 };

+ 4 - 4
src/tooltip/plugin.ts

@@ -30,7 +30,7 @@ import {
 } from '../rendermime';
 
 import {
-  cmdIds, TooltipModel, TooltipWidget
+  CommandIDs, TooltipModel, TooltipWidget
 } from './';
 
 
@@ -59,11 +59,11 @@ function activate(app: JupyterLab, consoles: IConsoleTracker, notebooks: INotebo
   let tooltip: TooltipWidget = null;
 
   // Add tooltip launch command.
-  registry.addCommand(cmdIds.launch, {
+  registry.addCommand(CommandIDs.launch, {
     execute: args => {
       // If a tooltip is open, remove it and return.
       if (tooltip) {
-        return app.commands.execute(cmdIds.remove, void 0);
+        return app.commands.execute(CommandIDs.remove, void 0);
       }
 
       const notebook = args['notebook'] as boolean;
@@ -109,7 +109,7 @@ function activate(app: JupyterLab, consoles: IConsoleTracker, notebooks: INotebo
   });
 
   // Add tooltip remove command.
-  registry.addCommand(cmdIds.remove, {
+  registry.addCommand(CommandIDs.remove, {
     execute: () => {
       if (!tooltip) {
         return;