|
|
|
|
@ -140,6 +140,36 @@ var IPython = (function (IPython) {
|
|
|
|
|
that.to_rst();
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 49 && that.control_key_active) {
|
|
|
|
|
// To Heading 1 = 1
|
|
|
|
|
that.to_heading(undefined, 1);
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 50 && that.control_key_active) {
|
|
|
|
|
// To Heading 2 = 2
|
|
|
|
|
that.to_heading(undefined, 2);
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 51 && that.control_key_active) {
|
|
|
|
|
// To Heading 3 = 3
|
|
|
|
|
that.to_heading(undefined, 3);
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 52 && that.control_key_active) {
|
|
|
|
|
// To Heading 4 = 4
|
|
|
|
|
that.to_heading(undefined, 4);
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 53 && that.control_key_active) {
|
|
|
|
|
// To Heading 5 = 5
|
|
|
|
|
that.to_heading(undefined, 5);
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 54 && that.control_key_active) {
|
|
|
|
|
// To Heading 6 = 6
|
|
|
|
|
that.to_heading(undefined, 6);
|
|
|
|
|
that.control_key_active = false;
|
|
|
|
|
return false;
|
|
|
|
|
} else if (event.which === 84 && that.control_key_active) {
|
|
|
|
|
// Toggle output = t
|
|
|
|
|
that.toggle_output();
|
|
|
|
|
@ -483,6 +513,8 @@ var IPython = (function (IPython) {
|
|
|
|
|
cell = new IPython.HTMLCell(this);
|
|
|
|
|
} else if (type === 'rst') {
|
|
|
|
|
cell = new IPython.RSTCell(this);
|
|
|
|
|
} else if (type === 'heading') {
|
|
|
|
|
cell = new IPython.HeadingCell(this);
|
|
|
|
|
};
|
|
|
|
|
if (cell !== null) {
|
|
|
|
|
if (this.ncells() === 0) {
|
|
|
|
|
@ -515,6 +547,8 @@ var IPython = (function (IPython) {
|
|
|
|
|
cell = new IPython.HTMLCell(this);
|
|
|
|
|
} else if (type === 'rst') {
|
|
|
|
|
cell = new IPython.RSTCell(this);
|
|
|
|
|
} else if (type === 'heading') {
|
|
|
|
|
cell = new IPython.HeadingCell(this);
|
|
|
|
|
};
|
|
|
|
|
if (cell !== null) {
|
|
|
|
|
if (this.ncells() === 0) {
|
|
|
|
|
@ -615,6 +649,33 @@ var IPython = (function (IPython) {
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Notebook.prototype.to_heading = function (index, level) {
|
|
|
|
|
level = level || 1;
|
|
|
|
|
var i = this.index_or_selected(index);
|
|
|
|
|
if (this.is_valid_cell_index(i)) {
|
|
|
|
|
var source_element = this.get_cell_element(i);
|
|
|
|
|
var source_cell = source_element.data("cell");
|
|
|
|
|
var target_cell = null;
|
|
|
|
|
if (source_cell instanceof IPython.HeadingCell) {
|
|
|
|
|
source_cell.set_level(level);
|
|
|
|
|
} else {
|
|
|
|
|
target_cell = this.insert_cell_below('heading',i);
|
|
|
|
|
var text = source_cell.get_text();
|
|
|
|
|
if (text === source_cell.placeholder) {
|
|
|
|
|
text = '';
|
|
|
|
|
};
|
|
|
|
|
// The edit must come before the set_text.
|
|
|
|
|
target_cell.set_level(level);
|
|
|
|
|
target_cell.edit();
|
|
|
|
|
target_cell.set_text(text);
|
|
|
|
|
source_element.remove();
|
|
|
|
|
this.dirty = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cut/Copy/Paste
|
|
|
|
|
|
|
|
|
|
Notebook.prototype.enable_paste = function () {
|
|
|
|
|
|