New HTMl cell working with CodeMirror editing.

Brian E. Granger 15 years ago
parent a003af7977
commit 9964704b73

@ -201,11 +201,11 @@ div.output_html {
div.output_png {
}
div.text_cell {
div.html_cell {
background-color: white;
}
textarea.text_cell_input {
textarea.html_cell_input {
/* Slightly bigger than the rest of the notebook */
font-size: 116%;
font-family: monospace;
@ -218,7 +218,7 @@ textarea.text_cell_input {
color: black;
}
div.text_cell_render {
div.html_cell_render {
font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
/* Slightly bigger than the rest of the notebook */
font-size: 116%;
@ -230,25 +230,25 @@ div.text_cell_render {
color: black;
}
div.text_cell_render em {font-style: italic;}
div.text_cell_render strong {font-weight: bold;}
div.text_cell_render u {text-decoration: underline;}
div.text_cell_render :link { text-decoration: underline }
div.text_cell_render :visited { text-decoration: underline }
div.text_cell_render h1 {font-size: 197%; margin: .67em 0; font-weight: bold;}
div.text_cell_render h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;}
div.text_cell_render h3 {font-size: 116%; margin: .83em 0; font-weight: bold;}
div.text_cell_render h4 {margin: 1.12em 0; font-weight: bold;}
div.text_cell_render h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;}
div.text_cell_render h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;}
div.text_cell_render ul {list-style:disc; margin-left: 40px;}
div.text_cell_render ul ul {list-style:square; margin-left: 40px;}
div.text_cell_render ul ul ul {list-style:circle; margin-left: 40px;}
div.text_cell_render ol {list-style:upper-roman; margin-left: 40px;}
div.text_cell_render ol ol {list-style:upper-alpha;}
div.text_cell_render ol ol ol {list-style:decimal;}
div.text_cell_render ol ol ol ol {list-style:lower-alpha;}
div.text_cell_render ol ol ol ol ol {list-style:lower-roman;}
div.html_cell_render em {font-style: italic;}
div.html_cell_render strong {font-weight: bold;}
div.html_cell_render u {text-decoration: underline;}
div.html_cell_render :link { text-decoration: underline }
div.html_cell_render :visited { text-decoration: underline }
div.html_cell_render h1 {font-size: 197%; margin: .67em 0; font-weight: bold;}
div.html_cell_render h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;}
div.html_cell_render h3 {font-size: 116%; margin: .83em 0; font-weight: bold;}
div.html_cell_render h4 {margin: 1.12em 0; font-weight: bold;}
div.html_cell_render h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;}
div.html_cell_render h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;}
div.html_cell_render ul {list-style:disc; margin-left: 40px;}
div.html_cell_render ul ul {list-style:square; margin-left: 40px;}
div.html_cell_render ul ul ul {list-style:circle; margin-left: 40px;}
div.html_cell_render ol {list-style:upper-roman; margin-left: 40px;}
div.html_cell_render ol ol {list-style:upper-alpha;}
div.html_cell_render ol ol ol {list-style:decimal;}
div.html_cell_render ol ol ol ol {list-style:lower-alpha;}
div.html_cell_render ol ol ol ol ol {list-style:lower-roman;}
.CodeMirror {

@ -320,10 +320,10 @@ var IPython = (function (IPython) {
}
Notebook.prototype.insert_text_cell_before = function (index) {
Notebook.prototype.insert_html_cell_before = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var cell = new IPython.TextCell(this);
var cell = new IPython.HTMLCell(this);
cell.config_mathjax();
this.insert_cell_before(cell, i);
this.select(this.find_cell_index(cell));
@ -331,10 +331,10 @@ var IPython = (function (IPython) {
}
Notebook.prototype.insert_text_cell_after = function (index) {
Notebook.prototype.insert_html_cell_after = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var cell = new IPython.TextCell(this);
var cell = new IPython.HTMLCell(this);
cell.config_mathjax();
this.insert_cell_after(cell, i);
this.select(this.find_cell_index(cell));
@ -342,31 +342,32 @@ var IPython = (function (IPython) {
}
Notebook.prototype.text_to_code = function (index) {
Notebook.prototype.html_to_code = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var source_element = this.cell_elements().eq(i);
var source_cell = source_element.data("cell");
if (source_cell instanceof IPython.TextCell) {
if (source_cell instanceof IPython.HTMLCell) {
this.insert_code_cell_after(i);
var target_cell = this.cells()[i+1];
target_cell.set_code(source_cell.get_text());
target_cell.set_code(source_cell.get_source());
source_element.remove();
};
};
Notebook.prototype.code_to_text = function (index) {
Notebook.prototype.code_to_html = function (index) {
// TODO: Bounds check for i
var i = this.index_or_selected(index);
var source_element = this.cell_elements().eq(i);
var source_cell = source_element.data("cell");
if (source_cell instanceof IPython.CodeCell) {
this.insert_text_cell_after(i);
this.insert_html_cell_after(i);
var target_cell = this.cells()[i+1];
var text = source_cell.get_code();
if (text === "") {text = target_cell.placeholder;};
target_cell.set_text(text);
target_cell.set_source(text);
target_cell.set_render(text);
source_element.remove();
target_cell.edit();
};
@ -508,7 +509,7 @@ var IPython = (function (IPython) {
var code = cell.get_code();
var msg_id = that.kernel.execute(cell.get_code());
that.msg_cell_map[msg_id] = cell.cell_id;
} else if (cell instanceof IPython.TextCell) {
} else if (cell instanceof IPython.HTMLCell) {
cell.render();
}
if (default_options.terminal) {
@ -561,8 +562,8 @@ var IPython = (function (IPython) {
if (cell_data.cell_type == 'code') {
new_cell = this.insert_code_cell_after();
new_cell.fromJSON(cell_data);
} else if (cell_data.cell_type === 'text') {
new_cell = this.insert_text_cell_after();
} else if (cell_data.cell_type === 'html') {
new_cell = this.insert_html_cell_after();
new_cell.fromJSON(cell_data);
};
};

@ -96,7 +96,7 @@
<div class="section_row">
<span id="cell_type" class="section_row_buttons">
<button id="to_code">Code</button>
<button id="to_text">Text</button>
<button id="to_html">HTML</button>
</span>
<span class="button_label">Cell Type</span>
</div>
@ -174,7 +174,7 @@
<script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/htmlcell.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
<script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>

Loading…
Cancel
Save