mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Merge pull request #2993 from jhamrick/editable-bug
Prevent uneditable cells from having their type changed
This commit is contained in:
commit
881268f642
@ -80,11 +80,17 @@ define([
|
||||
.append(multiselect);
|
||||
this.notebook.keyboard_manager.register_events(sel);
|
||||
this.events.on('selected_cell_type_changed.Notebook', function (event, data) {
|
||||
if ( that.notebook.get_selected_cells_indices().length > 1) {
|
||||
if (data.editable === false) {
|
||||
sel.attr('disabled', true);
|
||||
} else {
|
||||
sel.removeAttr('disabled');
|
||||
}
|
||||
|
||||
if (that.notebook.get_selected_cells_indices().length > 1) {
|
||||
multiselect.show();
|
||||
sel.val('multiselect');
|
||||
} else {
|
||||
multiselect.hide()
|
||||
multiselect.hide();
|
||||
if (data.cell_type === 'heading') {
|
||||
sel.val('Markdown');
|
||||
} else {
|
||||
|
@ -855,11 +855,18 @@ define([
|
||||
this.update_soft_selection();
|
||||
if (cell.cell_type === 'heading') {
|
||||
this.events.trigger('selected_cell_type_changed.Notebook',
|
||||
{'cell_type':cell.cell_type, level:cell.level}
|
||||
{
|
||||
'cell_type': cell.cell_type,
|
||||
'level': cell.level,
|
||||
'editable': cell.is_editable()
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.events.trigger('selected_cell_type_changed.Notebook',
|
||||
{'cell_type':cell.cell_type}
|
||||
{
|
||||
'cell_type': cell.cell_type,
|
||||
'editable': cell.is_editable()
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1416,7 +1423,7 @@ define([
|
||||
var i = this.index_or_selected(index);
|
||||
if (this.is_valid_cell_index(i)) {
|
||||
var source_cell = this.get_cell(i);
|
||||
if (!(source_cell instanceof codecell.CodeCell)) {
|
||||
if (!(source_cell instanceof codecell.CodeCell) && source_cell.is_editable()) {
|
||||
var target_cell = this.insert_cell_below('code',i);
|
||||
var text = source_cell.get_text();
|
||||
if (text === source_cell.placeholder) {
|
||||
@ -1466,7 +1473,7 @@ define([
|
||||
if (this.is_valid_cell_index(i)) {
|
||||
var source_cell = this.get_cell(i);
|
||||
|
||||
if (!(source_cell instanceof textcell.MarkdownCell)) {
|
||||
if (!(source_cell instanceof textcell.MarkdownCell) && source_cell.is_editable()) {
|
||||
var target_cell = this.insert_cell_below('markdown',i);
|
||||
var text = source_cell.get_text();
|
||||
|
||||
@ -1521,7 +1528,7 @@ define([
|
||||
var target_cell = null;
|
||||
var source_cell = this.get_cell(i);
|
||||
|
||||
if (!(source_cell instanceof textcell.RawCell)) {
|
||||
if (!(source_cell instanceof textcell.RawCell) && source_cell.is_editable()) {
|
||||
target_cell = this.insert_cell_below('raw',i);
|
||||
var text = source_cell.get_text();
|
||||
if (text === source_cell.placeholder) {
|
||||
|
Loading…
Reference in New Issue
Block a user