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