mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Ongoing work on cell splitting.
This commit is contained in:
parent
177fb9bb5d
commit
b3322fc2d5
@ -167,6 +167,13 @@ var IPython = (function (IPython) {
|
||||
};
|
||||
}
|
||||
},
|
||||
'alt+-' : {
|
||||
help : 'split cell',
|
||||
handler : function (event) {
|
||||
IPython.notebook.split_cell();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// Command mode defaults
|
||||
|
@ -1053,27 +1053,31 @@ var IPython = (function (IPython) {
|
||||
if (cell.is_splittable()) {
|
||||
var texta = cell.get_pre_cursor();
|
||||
var textb = cell.get_post_cursor();
|
||||
var mode = cell.mode;
|
||||
if (cell instanceof IPython.CodeCell) {
|
||||
// In this case the operations keep the notebook in its existing mode
|
||||
// so we don't need to do any post-op mode changes.
|
||||
cell.set_text(textb);
|
||||
var new_cell = this.insert_cell_above('code');
|
||||
new_cell.set_text(texta);
|
||||
this.select_next();
|
||||
} else if (cell instanceof IPython.MarkdownCell) {
|
||||
var render = cell.rendered;
|
||||
} else if (cell instanceof IPython.MarkdownCell && !cell.rendered) {
|
||||
cell.set_text(textb);
|
||||
cell.render();
|
||||
var new_cell = this.insert_cell_above('markdown');
|
||||
new_cell.unrender(); // editor must be visible to call set_text
|
||||
// Editor must be visible to call set_text, so we unrender.
|
||||
// Note that this call will focus the CM editor, which selects
|
||||
// this cell and enters edit mode.
|
||||
new_cell.unrender();
|
||||
new_cell.set_text(texta);
|
||||
new_cell.render();
|
||||
this.select_next();
|
||||
if (!render) {
|
||||
// The final rendered state of the split cells should
|
||||
// match the original cell's state. The order matters
|
||||
// here as we want the lower cell (cell) to be selected.
|
||||
new_cell.unrender();
|
||||
cell.unrender();
|
||||
}
|
||||
// The final rendered state of the split cells should
|
||||
// match the original cell's state. The order matters
|
||||
// here as we want the lower cell (cell) to be selected.
|
||||
// Each of these involves a CM focus and cell select.
|
||||
new_cell.unrender();
|
||||
cell.unrender();
|
||||
console.log('setting edit mode...')
|
||||
this.edit_mode();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -262,21 +262,6 @@ var IPython = (function (IPython) {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/** @method at_bottom **/
|
||||
TextCell.prototype.at_bottom = function () {
|
||||
if (this.rendered) {
|
||||
return true
|
||||
} else {
|
||||
var cursor = this.code_mirror.getCursor();
|
||||
if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @method at_bottom
|
||||
* @return {Boolean}
|
||||
|
Loading…
Reference in New Issue
Block a user