mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-23 12:49:41 +08:00
Clear selected range on entering edit mode
This commit is contained in:
parent
92e266f4e2
commit
dcd676d499
@ -122,6 +122,13 @@ define(function(require){
|
||||
}
|
||||
}
|
||||
},
|
||||
'reset-selection': {
|
||||
help: 'clear selected cells',
|
||||
help_index: 'de',
|
||||
handler: function(env) {
|
||||
env.notebook.reset_selection();
|
||||
}
|
||||
},
|
||||
'cut-selected-cell' : {
|
||||
icon: 'fa-cut',
|
||||
help_index : 'ee',
|
||||
|
@ -725,6 +725,18 @@ define(function (require) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear selection of multiple cells (except the cell at the cursor)
|
||||
*/
|
||||
Notebook.prototype.reset_selection = function() {
|
||||
var current_selection = this.get_selected_cells();
|
||||
for (var i=0; i<current_selection.length; i++) {
|
||||
if (!current_selection[i].selected) {
|
||||
current_selection[i].unselect()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Edit/Command mode
|
||||
|
||||
@ -778,6 +790,7 @@ define(function (require) {
|
||||
if (cell && this.mode !== 'edit') {
|
||||
cell.edit_mode();
|
||||
this.mode = 'edit';
|
||||
this.reset_selection();
|
||||
this.events.trigger('edit_mode.Notebook');
|
||||
this.keyboard_manager.edit_mode();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user