##// END OF EJS Templates
Updating JS part of plaintext cell handling.
Brian Granger -
Show More
@@ -129,8 +129,8 b' var IPython = (function (IPython) {'
129 129 this.element.find('#to_markdown').click(function () {
130 130 IPython.notebook.to_markdown();
131 131 });
132 this.element.find('#to_rst').click(function () {
133 IPython.notebook.to_rst();
132 this.element.find('#to_plaintext').click(function () {
133 IPython.notebook.to_plaintext();
134 134 });
135 135 this.element.find('#to_heading1').click(function () {
136 136 IPython.notebook.to_heading(undefined, 1);
@@ -135,9 +135,9 b' var IPython = (function (IPython) {'
135 135 that.to_markdown();
136 136 that.control_key_active = false;
137 137 return false;
138 } else if (event.which === 82 && that.control_key_active) {
139 // To RST = r
140 that.to_rst();
138 } else if (event.which === 84 && that.control_key_active) {
139 // To Plaintext = r
140 that.to_plaintext();
141 141 that.control_key_active = false;
142 142 return false;
143 143 } else if (event.which === 49 && that.control_key_active) {
@@ -170,8 +170,8 b' var IPython = (function (IPython) {'
170 170 that.to_heading(undefined, 6);
171 171 that.control_key_active = false;
172 172 return false;
173 } else if (event.which === 84 && that.control_key_active) {
174 // Toggle output = t
173 } else if (event.which === 79 && that.control_key_active) {
174 // Toggle output = o
175 175 that.toggle_output();
176 176 that.control_key_active = false;
177 177 return false;
@@ -511,8 +511,8 b' var IPython = (function (IPython) {'
511 511 cell = new IPython.MarkdownCell(this);
512 512 } else if (type === 'html') {
513 513 cell = new IPython.HTMLCell(this);
514 } else if (type === 'rst') {
515 cell = new IPython.RSTCell(this);
514 } else if (type === 'plaintext') {
515 cell = new IPython.PlaintextCell(this);
516 516 } else if (type === 'heading') {
517 517 cell = new IPython.HeadingCell(this);
518 518 };
@@ -545,8 +545,8 b' var IPython = (function (IPython) {'
545 545 cell = new IPython.MarkdownCell(this);
546 546 } else if (type === 'html') {
547 547 cell = new IPython.HTMLCell(this);
548 } else if (type === 'rst') {
549 cell = new IPython.RSTCell(this);
548 } else if (type === 'plaintext') {
549 cell = new IPython.PlaintextCell(this);
550 550 } else if (type === 'heading') {
551 551 cell = new IPython.HeadingCell(this);
552 552 };
@@ -628,14 +628,14 b' var IPython = (function (IPython) {'
628 628 };
629 629
630 630
631 Notebook.prototype.to_rst = function (index) {
631 Notebook.prototype.to_plaintext = function (index) {
632 632 var i = this.index_or_selected(index);
633 633 if (this.is_valid_cell_index(i)) {
634 634 var source_element = this.get_cell_element(i);
635 635 var source_cell = source_element.data("cell");
636 636 var target_cell = null;
637 if (!(source_cell instanceof IPython.RSTCell)) {
638 target_cell = this.insert_cell_below('rst',i);
637 if (!(source_cell instanceof IPython.PlaintextCell)) {
638 target_cell = this.insert_cell_below('plaintext',i);
639 639 var text = source_cell.get_text();
640 640 if (text === source_cell.placeholder) {
641 641 text = '';
@@ -34,13 +34,14 b' var IPython = (function (IPython) {'
34 34 {key: 'Ctrl-m d', help: 'delete cell'},
35 35 {key: 'Ctrl-m a', help: 'insert cell above'},
36 36 {key: 'Ctrl-m b', help: 'insert cell below'},
37 {key: 'Ctrl-m t', help: 'toggle output'},
37 {key: 'Ctrl-m o', help: 'toggle output'},
38 38 {key: 'Ctrl-m l', help: 'toggle line numbers'},
39 39 {key: 'Ctrl-m s', help: 'save notebook'},
40 40 {key: 'Ctrl-m j', help: 'move cell down'},
41 41 {key: 'Ctrl-m k', help: 'move cell up'},
42 42 {key: 'Ctrl-m y', help: 'code cell'},
43 43 {key: 'Ctrl-m m', help: 'markdown cell'},
44 {key: 'Ctrl-m t', help: 'plaintext cell'},
44 45 {key: 'Ctrl-m p', help: 'select previous'},
45 46 {key: 'Ctrl-m n', help: 'select next'},
46 47 {key: 'Ctrl-m i', help: 'interrupt kernel'},
@@ -237,26 +237,26 b' var IPython = (function (IPython) {'
237 237 };
238 238
239 239
240 // RSTCell
240 // PlaintextCell
241 241
242 var RSTCell = function (notebook) {
243 this.placeholder = "Type *ReStructured Text* and LaTeX: $\\alpha^2$";
242 var PlaintextCell = function (notebook) {
243 this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
244 244 this.code_mirror_mode = 'rst';
245 245 IPython.TextCell.apply(this, arguments);
246 this.cell_type = 'rst';
246 this.cell_type = 'plaintext';
247 247 };
248 248
249 249
250 RSTCell.prototype = new TextCell();
250 PlaintextCell.prototype = new TextCell();
251 251
252 252
253 RSTCell.prototype.render = function () {
253 PlaintextCell.prototype.render = function () {
254 254 this.rendered = true;
255 255 this.edit();
256 256 };
257 257
258 258
259 RSTCell.prototype.select = function () {
259 PlaintextCell.prototype.select = function () {
260 260 IPython.Cell.prototype.select.apply(this);
261 261 // In some cases (inserting a new cell) we need a refresh before and
262 262 // after the focus. Not sure why this is the case.
@@ -266,7 +266,7 b' var IPython = (function (IPython) {'
266 266 };
267 267
268 268
269 RSTCell.prototype.at_top = function () {
269 PlaintextCell.prototype.at_top = function () {
270 270 var cursor = this.code_mirror.getCursor();
271 271 if (cursor.line === 0) {
272 272 return true;
@@ -276,7 +276,7 b' var IPython = (function (IPython) {'
276 276 };
277 277
278 278
279 RSTCell.prototype.at_bottom = function () {
279 PlaintextCell.prototype.at_bottom = function () {
280 280 var cursor = this.code_mirror.getCursor();
281 281 if (cursor.line === (this.code_mirror.lineCount()-1)) {
282 282 return true;
@@ -341,7 +341,7 b' var IPython = (function (IPython) {'
341 341 IPython.TextCell = TextCell;
342 342 IPython.HTMLCell = HTMLCell;
343 343 IPython.MarkdownCell = MarkdownCell;
344 IPython.RSTCell = RSTCell;
344 IPython.PlaintextCell = PlaintextCell;
345 345 IPython.HeadingCell = HeadingCell;
346 346
347 347
@@ -119,7 +119,7 b''
119 119 <hr/>
120 120 <li id="to_code"><a href="#">Code</a></li>
121 121 <li id="to_markdown"><a href="#">Markdown </a></li>
122 <li id="to_rst"><a href="#">RST</a></li>
122 <li id="to_plaintext"><a href="#">Plaintext</a></li>
123 123 <li id="to_heading1"><a href="#">Heading 1</a></li>
124 124 <li id="to_heading2"><a href="#">Heading 2</a></li>
125 125 <li id="to_heading3"><a href="#">Heading 3</a></li>
General Comments 0
You need to be logged in to leave comments. Login now