diff --git a/notebook/static/base/js/keyboard.js b/notebook/static/base/js/keyboard.js index 1ee374738..0e0e9d471 100644 --- a/notebook/static/base/js/keyboard.js +++ b/notebook/static/base/js/keyboard.js @@ -396,6 +396,11 @@ define([ * Remove the binding of shortcut `sortcut` with its action. * throw an error if trying to remove a non-exiting shortcut **/ + if(!shortcut){ + console.warn('trying to remove empty shortcut'); + return; + + } shortcut = normalize_shortcut(shortcut); if( typeof(shortcut) === 'string'){ shortcut = shortcut.split(','); @@ -404,14 +409,15 @@ define([ * The shortcut error should be explicit here, because it will be * seen by users. */ - try - { + var that = this; + try { this._remove_leaf(shortcut, this._shortcuts); if (!suppress_help_update) { // update the keyboard shortcuts notebook help this.events.trigger('rebuild.QuickHelp'); } } catch (ex) { + console.warn('shortbut', shortcut, '...',this._shortcuts); throw new Error('trying to remove a non-existent shortcut', shortcut); } }; diff --git a/notebook/static/deprecated-imports.js b/notebook/static/deprecated-imports.js index e7da5df80..0ae9af26d 100644 --- a/notebook/static/deprecated-imports.js +++ b/notebook/static/deprecated-imports.js @@ -76,4 +76,4 @@ "notebookApp['" + modulePath + "']});`"].join(' ')); return notebookApp[modulePath]; }); -}); \ No newline at end of file +}); diff --git a/notebook/static/notebook/js/celltoolbarpresets/attachments.js b/notebook/static/notebook/js/celltoolbarpresets/attachments.js index 5dd37c860..068d84d69 100644 --- a/notebook/static/notebook/js/celltoolbarpresets/attachments.js +++ b/notebook/static/notebook/js/celltoolbarpresets/attachments.js @@ -43,8 +43,7 @@ define([ attachments_preset.push('attachments.edit'); CellToolbar.register_preset('Attachments', attachments_preset, notebook); - console.log('Attachments editing toolbar loaded.'); }; - return {'register' : register} + return {'register' : register}; }); diff --git a/notebook/static/notebook/js/celltoolbarpresets/default.js b/notebook/static/notebook/js/celltoolbarpresets/default.js index a7a761786..41e8b4d1f 100644 --- a/notebook/static/notebook/js/celltoolbarpresets/default.js +++ b/notebook/static/notebook/js/celltoolbarpresets/default.js @@ -44,7 +44,6 @@ define([ example_preset.push('default.rawedit'); CellToolbar.register_preset('Edit Metadata', example_preset, notebook); - console.log('Default extension for cell metadata editing loaded.'); }; return {'register': register}; }); diff --git a/notebook/static/notebook/js/celltoolbarpresets/rawcell.js b/notebook/static/notebook/js/celltoolbarpresets/rawcell.js index d59a29420..3cfb858d3 100644 --- a/notebook/static/notebook/js/celltoolbarpresets/rawcell.js +++ b/notebook/static/notebook/js/celltoolbarpresets/rawcell.js @@ -78,7 +78,6 @@ define([ raw_cell_preset.push('raw_cell.select'); CellToolbar.register_preset('Raw Cell Format', raw_cell_preset, notebook); - console.log('Raw Cell Format toolbar preset loaded.'); }; return {'register': register}; diff --git a/notebook/static/notebook/js/celltoolbarpresets/slideshow.js b/notebook/static/notebook/js/celltoolbarpresets/slideshow.js index 5fc5ee27c..9ae7641c7 100644 --- a/notebook/static/notebook/js/celltoolbarpresets/slideshow.js +++ b/notebook/static/notebook/js/celltoolbarpresets/slideshow.js @@ -39,7 +39,6 @@ define([ slideshow_preset.push('slideshow.select'); CellToolbar.register_preset('Slideshow',slideshow_preset, notebook); - console.log('Slideshow extension for metadata editing loaded.'); }; return {'register': register}; }); diff --git a/notebook/static/notebook/js/commandpalette.js b/notebook/static/notebook/js/commandpalette.js index 7b7f7ccbe..dc6f9f3c4 100644 --- a/notebook/static/notebook/js/commandpalette.js +++ b/notebook/static/notebook/js/commandpalette.js @@ -169,7 +169,7 @@ define(function(require){ group: ["group", "{{group}} command group"], searchOnFocus: true, mustSelectItem: true, - template: '{{display}}
{{shortcut}}
', + template: '{{display}}
{{shortcut}}
', order: "asc", source: src, callback: { diff --git a/notebook/static/notebook/js/keyboardmanager.js b/notebook/static/notebook/js/keyboardmanager.js index 717492d17..c7f2505a1 100644 --- a/notebook/static/notebook/js/keyboardmanager.js +++ b/notebook/static/notebook/js/keyboardmanager.js @@ -42,6 +42,26 @@ define([ this.edit_shortcuts = new keyboard.ShortcutManager(undefined, options.events, this.actions, this.env); this.edit_shortcuts.add_shortcuts(this.get_default_common_shortcuts()); this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts()); + + + this.config = options.config; + var that = this; + + this.config.loaded.then(function(){ + + (((that.config.data.keys||{}).edit||{}) + .unbind||[]) + .forEach(function(u){that.edit_shortcuts.remove_shortcut(u)}); + (((that.config.data.keys||{}).command||{}) + .unbind||[]) + .forEach(function(u){that.command_shortcuts.remove_shortcut(u)}); + + that.command_shortcuts.add_shortcuts( ((that.config.data.keys||{}).command||{}).bind); + that.edit_shortcuts.add_shortcuts( ((that.config.data.keys||{}).edit ||{}).bind); + + } + ); + Object.seal(this); }; diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index f5621f6b7..5689cfd5a 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -84,7 +84,9 @@ require([ var keyboard_manager = new keyboardmanager.KeyboardManager({ pager: pager, events: events, - actions: acts }); + actions: acts, + config: config_section, + }); var save_widget = new savewidget.SaveWidget('span#save_widget', { events: events, keyboard_manager: keyboard_manager}); diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index ce2d24235..30ea63362 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -164,6 +164,7 @@ define(function (require) { Object.seal(this); }; + Notebook.options_default = { // can be any cell type, or the special values of // 'above', 'below', or 'selected' to get the value from another cell. @@ -2410,7 +2411,7 @@ define(function (require) { var cell = cells[i]; cell.remove_unused_attachments(); } - } + }; /** * Load a notebook from JSON (.ipynb). diff --git a/notebook/static/notebook/js/quickhelp.js b/notebook/static/notebook/js/quickhelp.js index cb3944e37..f816bb31a 100644 --- a/notebook/static/notebook/js/quickhelp.js +++ b/notebook/static/notebook/js/quickhelp.js @@ -189,7 +189,7 @@ define([ doc.append( 'The Jupyter Notebook has two different keyboard input modes. Edit mode '+ 'allows you to type code/text into a cell and is indicated by a green cell '+ - 'border. Command mode binds the keyboard to notebook level actions '+ + 'border. Command mode binds the keyboard to notebook level commands '+ 'and is indicated by a grey cell border with a blue left margin.' ); element.append(doc); diff --git a/notebook/static/notebook/less/commandpalette.less b/notebook/static/notebook/less/commandpalette.less index f7f4e89d8..28e738660 100644 --- a/notebook/static/notebook/less/commandpalette.less +++ b/notebook/static/notebook/less/commandpalette.less @@ -29,11 +29,12 @@ ul.typeahead-list { } .no-shortcut{ - display:none; + min-width: 20px; + color: transparent; } .command-shortcut:before{ - content:"(command)"; + content:"(command mode)"; padding-right:3px; color:@gray-light; } diff --git a/notebook/static/services/config.js b/notebook/static/services/config.js index 95ccaeffa..a4a207c9d 100644 --- a/notebook/static/services/config.js +++ b/notebook/static/services/config.js @@ -81,7 +81,7 @@ function(utils) { if (this.classname) { return this.section.data[this.classname] || {}; } else { - return this.section.data + return this.section.data; } }; @@ -92,7 +92,7 @@ function(utils) { ConfigWithDefaults.prototype.get = function(key) { var that = this; return this.section.loaded.then(function() { - return that._class_data()[key] || that.defaults[key] + return that._class_data()[key] || that.defaults[key]; }); };