mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Cells call grow by hand when they reload from JSON.
This commit is contained in:
parent
cc4a8cff40
commit
9edf46f9dc
@ -580,6 +580,23 @@ var Cell = function (notebook) {
|
||||
};
|
||||
|
||||
|
||||
Cell.prototype.grow = function(element) {
|
||||
// Grow the cell by hand. This is used upon reloading from JSON, when the
|
||||
// autogrow handler is not called.
|
||||
var dom = element.get(0);
|
||||
var lines_count = 0;
|
||||
// modified split rule from
|
||||
// http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
|
||||
var lines = dom.value.split(/\r|\r\n|\n/);
|
||||
lines_count = lines.length;
|
||||
if (lines_count >= 1) {
|
||||
dom.rows = lines_count;
|
||||
} else {
|
||||
dom.rows = 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Cell.prototype.select = function () {
|
||||
this.element.addClass('ui-widget-content ui-corner-all');
|
||||
this.selected = true;
|
||||
@ -658,6 +675,7 @@ CodeCell.prototype.append_pyout = function (data, n) {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
CodeCell.prototype.append_pyerr = function (ename, evalue, tb) {
|
||||
var s = '';
|
||||
var len = tb.length;
|
||||
@ -752,6 +770,7 @@ CodeCell.prototype.fromJSON = function (data) {
|
||||
if (data.cell_type === 'code') {
|
||||
this.set_code(data.code);
|
||||
this.set_input_prompt(data.prompt_number);
|
||||
this.grow(this.element.find("textarea.input_textarea"));
|
||||
};
|
||||
};
|
||||
|
||||
@ -853,6 +872,7 @@ TextCell.prototype.set_text = function(text) {
|
||||
TextCell.prototype.fromJSON = function (data) {
|
||||
if (data.cell_type === 'text') {
|
||||
this.set_text(data.text);
|
||||
this.grow(this.element.find("textarea.text_cell_input"));
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user