Prevent uneditable cells from having their type changed

This commit is contained in:
Jessica B. Hamrick 2017-10-29 12:06:20 +00:00
parent f5ba79e625
commit 4b2975659c
2 changed files with 20 additions and 7 deletions

View File

@ -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 {

View File

@ -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) {