##// END OF EJS Templates
give Raw Cells a placeholder...
MinRK -
Show More
@@ -33,9 +33,9 b' var IPython = (function (IPython) {'
33 */
33 */
34 var Cell = function (options) {
34 var Cell = function (options) {
35
35
36 options = this.mergeopt(Cell, options)
36 options = this.mergeopt(Cell, options);
37 // superclass default overwrite our default
37 // superclass default overwrite our default
38
38
39 this.placeholder = options.placeholder || '';
39 this.placeholder = options.placeholder || '';
40 this.read_only = options.cm_config.readOnly;
40 this.read_only = options.cm_config.readOnly;
41 this.selected = false;
41 this.selected = false;
@@ -80,6 +80,7 b' var IPython = (function (IPython) {'
80 }
80 }
81
81
82 Cell.prototype.mergeopt = function(_class, options, overwrite){
82 Cell.prototype.mergeopt = function(_class, options, overwrite){
83 options = options || {};
83 overwrite = overwrite || {};
84 overwrite = overwrite || {};
84 return $.extend(true, {}, _class.options_default, options, overwrite)
85 return $.extend(true, {}, _class.options_default, options, overwrite)
85
86
@@ -46,11 +46,11 b' var IPython = (function (IPython) {'
46
46
47 options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options});
47 options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options});
48
48
49 IPython.Cell.apply(this, [options]);
49 this.cell_type = this.cell_type || 'text';
50
50
51 IPython.Cell.apply(this, [options]);
51
52
52 this.rendered = false;
53 this.rendered = false;
53 this.cell_type = this.cell_type || 'text';
54 };
54 };
55
55
56 TextCell.prototype = new IPython.Cell();
56 TextCell.prototype = new IPython.Cell();
@@ -278,6 +278,9 b' var IPython = (function (IPython) {'
278 var data = IPython.Cell.prototype.toJSON.apply(this);
278 var data = IPython.Cell.prototype.toJSON.apply(this);
279 data.cell_type = this.cell_type;
279 data.cell_type = this.cell_type;
280 data.source = this.get_text();
280 data.source = this.get_text();
281 if (data.source == this.placeholder) {
282 data.source = "";
283 }
281 return data;
284 return data;
282 };
285 };
283
286
@@ -288,12 +291,10 b' var IPython = (function (IPython) {'
288 * @extends IPython.HTMLCell
291 * @extends IPython.HTMLCell
289 */
292 */
290 var MarkdownCell = function (options) {
293 var MarkdownCell = function (options) {
291 var options = options || {};
294 options = this.mergeopt(MarkdownCell, options);
292
293 options = this.mergeopt(MarkdownCell,options);
294 TextCell.apply(this, [options]);
295
295
296 this.cell_type = 'markdown';
296 this.cell_type = 'markdown';
297 TextCell.apply(this, [options]);
297 };
298 };
298
299
299 MarkdownCell.options_default = {
300 MarkdownCell.options_default = {
@@ -334,7 +335,7 b' var IPython = (function (IPython) {'
334 }
335 }
335 this.element.find('div.text_cell_input').hide();
336 this.element.find('div.text_cell_input').hide();
336 this.element.find("div.text_cell_render").show();
337 this.element.find("div.text_cell_render").show();
337 this.typeset()
338 this.typeset();
338 this.rendered = true;
339 this.rendered = true;
339 }
340 }
340 };
341 };
@@ -348,20 +349,21 b' var IPython = (function (IPython) {'
348 * @extends IPython.TextCell
349 * @extends IPython.TextCell
349 */
350 */
350 var RawCell = function (options) {
351 var RawCell = function (options) {
351
352 options = this.mergeopt(RawCell, options);
352 options = this.mergeopt(RawCell,options)
353
353 TextCell.apply(this, [options]);
354
355 this.cell_type = 'raw';
354 this.cell_type = 'raw';
355 TextCell.apply(this, [options]);
356
356
357 var that = this
357 var that = this;
358 this.element.focusout(
358 this.element.focusout(
359 function() { that.auto_highlight(); }
359 function() { that.auto_highlight(); }
360 );
360 );
361 };
361 };
362
362
363 RawCell.options_default = {
363 RawCell.options_default = {
364 placeholder : "Type plain text and LaTeX: $\\alpha^2$"
364 placeholder : "Write raw HTML / LaTeX here, for use with nbconvert.\n" +
365 "It will not be rendered in the notebook.\n" +
366 "When passing through nbconvert, a Raw Cell's content is added to the output unmodified."
365 };
367 };
366
368
367
369
@@ -379,7 +381,10 b' var IPython = (function (IPython) {'
379 /** @method render **/
381 /** @method render **/
380 RawCell.prototype.render = function () {
382 RawCell.prototype.render = function () {
381 this.rendered = true;
383 this.rendered = true;
382 this.edit();
384 var text = this.get_text();
385 if (text === "") { text = this.placeholder; }
386 console.log('rendering', text);
387 this.set_text(text);
383 };
388 };
384
389
385
390
@@ -412,8 +417,7 b' var IPython = (function (IPython) {'
412 /** @method select **/
417 /** @method select **/
413 RawCell.prototype.select = function () {
418 RawCell.prototype.select = function () {
414 IPython.Cell.prototype.select.apply(this);
419 IPython.Cell.prototype.select.apply(this);
415 this.code_mirror.refresh();
420 this.edit();
416 this.code_mirror.focus();
417 };
421 };
418
422
419 /** @method at_top **/
423 /** @method at_top **/
@@ -448,16 +452,16 b' var IPython = (function (IPython) {'
448 * @extends IPython.TextCell
452 * @extends IPython.TextCell
449 */
453 */
450 var HeadingCell = function (options) {
454 var HeadingCell = function (options) {
455 options = this.mergeopt(HeadingCell, options);
451
456
452 options = this.mergeopt(HeadingCell,options)
457 this.level = 1;
458 this.cell_type = 'heading';
453 TextCell.apply(this, [options]);
459 TextCell.apply(this, [options]);
454
460
455 /**
461 /**
456 * heading level of the cell, use getter and setter to access
462 * heading level of the cell, use getter and setter to access
457 * @property level
463 * @property level
458 */
464 */
459 this.level = 1;
460 this.cell_type = 'heading';
461 };
465 };
462
466
463 HeadingCell.options_default = {
467 HeadingCell.options_default = {
General Comments 0
You need to be logged in to leave comments. Login now