Show More
@@ -999,19 +999,21 b' define([' | |||||
999 | Notebook.prototype.to_code = function (index) { |
|
999 | Notebook.prototype.to_code = function (index) { | |
1000 | var i = this.index_or_selected(index); |
|
1000 | var i = this.index_or_selected(index); | |
1001 | if (this.is_valid_cell_index(i)) { |
|
1001 | if (this.is_valid_cell_index(i)) { | |
1002 |
var source_ |
|
1002 | var source_cell = this.get_cell(i); | |
1003 | var source_cell = source_element.data("cell"); |
|
|||
1004 | if (!(source_cell instanceof codecell.CodeCell)) { |
|
1003 | if (!(source_cell instanceof codecell.CodeCell)) { | |
1005 | var target_cell = this.insert_cell_below('code',i); |
|
1004 | var target_cell = this.insert_cell_below('code',i); | |
1006 | var text = source_cell.get_text(); |
|
1005 | var text = source_cell.get_text(); | |
1007 | if (text === source_cell.placeholder) { |
|
1006 | if (text === source_cell.placeholder) { | |
1008 | text = ''; |
|
1007 | text = ''; | |
1009 | } |
|
1008 | } | |
|
1009 | //metadata | |||
|
1010 | target_cell.metadata = source_cell.metadata; | |||
|
1011 | ||||
1010 | target_cell.set_text(text); |
|
1012 | target_cell.set_text(text); | |
1011 | // make this value the starting point, so that we can only undo |
|
1013 | // make this value the starting point, so that we can only undo | |
1012 | // to this state, instead of a blank cell |
|
1014 | // to this state, instead of a blank cell | |
1013 | target_cell.code_mirror.clearHistory(); |
|
1015 | target_cell.code_mirror.clearHistory(); | |
1014 | source_element.remove(); |
|
1016 | source_cell.element.remove(); | |
1015 | this.select(i); |
|
1017 | this.select(i); | |
1016 | var cursor = source_cell.code_mirror.getCursor(); |
|
1018 | var cursor = source_cell.code_mirror.getCursor(); | |
1017 | target_cell.code_mirror.setCursor(cursor); |
|
1019 | target_cell.code_mirror.setCursor(cursor); | |
@@ -1029,21 +1031,24 b' define([' | |||||
1029 | Notebook.prototype.to_markdown = function (index) { |
|
1031 | Notebook.prototype.to_markdown = function (index) { | |
1030 | var i = this.index_or_selected(index); |
|
1032 | var i = this.index_or_selected(index); | |
1031 | if (this.is_valid_cell_index(i)) { |
|
1033 | if (this.is_valid_cell_index(i)) { | |
1032 |
var source_ |
|
1034 | var source_cell = this.get_cell(i); | |
1033 | var source_cell = source_element.data("cell"); |
|
1035 | ||
1034 | if (!(source_cell instanceof textcell.MarkdownCell)) { |
|
1036 | if (!(source_cell instanceof textcell.MarkdownCell)) { | |
1035 | var target_cell = this.insert_cell_below('markdown',i); |
|
1037 | var target_cell = this.insert_cell_below('markdown',i); | |
1036 | var text = source_cell.get_text(); |
|
1038 | var text = source_cell.get_text(); | |
|
1039 | ||||
1037 | if (text === source_cell.placeholder) { |
|
1040 | if (text === source_cell.placeholder) { | |
1038 | text = ''; |
|
1041 | text = ''; | |
1039 | } |
|
1042 | } | |
|
1043 | // metadata | |||
|
1044 | target_cell.metadata = source_cell.metadata | |||
1040 | // We must show the editor before setting its contents |
|
1045 | // We must show the editor before setting its contents | |
1041 | target_cell.unrender(); |
|
1046 | target_cell.unrender(); | |
1042 | target_cell.set_text(text); |
|
1047 | target_cell.set_text(text); | |
1043 | // make this value the starting point, so that we can only undo |
|
1048 | // make this value the starting point, so that we can only undo | |
1044 | // to this state, instead of a blank cell |
|
1049 | // to this state, instead of a blank cell | |
1045 | target_cell.code_mirror.clearHistory(); |
|
1050 | target_cell.code_mirror.clearHistory(); | |
1046 | source_element.remove(); |
|
1051 | source_cell.element.remove(); | |
1047 | this.select(i); |
|
1052 | this.select(i); | |
1048 | if ((source_cell instanceof textcell.TextCell) && source_cell.rendered) { |
|
1053 | if ((source_cell instanceof textcell.TextCell) && source_cell.rendered) { | |
1049 | target_cell.render(); |
|
1054 | target_cell.render(); | |
@@ -1064,22 +1069,24 b' define([' | |||||
1064 | Notebook.prototype.to_raw = function (index) { |
|
1069 | Notebook.prototype.to_raw = function (index) { | |
1065 | var i = this.index_or_selected(index); |
|
1070 | var i = this.index_or_selected(index); | |
1066 | if (this.is_valid_cell_index(i)) { |
|
1071 | if (this.is_valid_cell_index(i)) { | |
1067 | var source_element = this.get_cell_element(i); |
|
|||
1068 | var source_cell = source_element.data("cell"); |
|
|||
1069 | var target_cell = null; |
|
1072 | var target_cell = null; | |
|
1073 | var source_cell = this.get_cell(i); | |||
|
1074 | ||||
1070 | if (!(source_cell instanceof textcell.RawCell)) { |
|
1075 | if (!(source_cell instanceof textcell.RawCell)) { | |
1071 | target_cell = this.insert_cell_below('raw',i); |
|
1076 | target_cell = this.insert_cell_below('raw',i); | |
1072 | var text = source_cell.get_text(); |
|
1077 | var text = source_cell.get_text(); | |
1073 | if (text === source_cell.placeholder) { |
|
1078 | if (text === source_cell.placeholder) { | |
1074 | text = ''; |
|
1079 | text = ''; | |
1075 | } |
|
1080 | } | |
|
1081 | //metadata | |||
|
1082 | target_cell.metadata = source_cell.metadata; | |||
1076 | // We must show the editor before setting its contents |
|
1083 | // We must show the editor before setting its contents | |
1077 | target_cell.unrender(); |
|
1084 | target_cell.unrender(); | |
1078 | target_cell.set_text(text); |
|
1085 | target_cell.set_text(text); | |
1079 | // make this value the starting point, so that we can only undo |
|
1086 | // make this value the starting point, so that we can only undo | |
1080 | // to this state, instead of a blank cell |
|
1087 | // to this state, instead of a blank cell | |
1081 | target_cell.code_mirror.clearHistory(); |
|
1088 | target_cell.code_mirror.clearHistory(); | |
1082 | source_element.remove(); |
|
1089 | source_cell.element.remove(); | |
1083 | this.select(i); |
|
1090 | this.select(i); | |
1084 | var cursor = source_cell.code_mirror.getCursor(); |
|
1091 | var cursor = source_cell.code_mirror.getCursor(); | |
1085 | target_cell.code_mirror.setCursor(cursor); |
|
1092 | target_cell.code_mirror.setCursor(cursor); | |
@@ -1099,8 +1106,7 b' define([' | |||||
1099 | level = level || 1; |
|
1106 | level = level || 1; | |
1100 | var i = this.index_or_selected(index); |
|
1107 | var i = this.index_or_selected(index); | |
1101 | if (this.is_valid_cell_index(i)) { |
|
1108 | if (this.is_valid_cell_index(i)) { | |
1102 |
var source_ |
|
1109 | var source_cell = this.get_cell(i); | |
1103 | var source_cell = source_element.data("cell"); |
|
|||
1104 | var target_cell = null; |
|
1110 | var target_cell = null; | |
1105 | if (source_cell instanceof textcell.HeadingCell) { |
|
1111 | if (source_cell instanceof textcell.HeadingCell) { | |
1106 | source_cell.set_level(level); |
|
1112 | source_cell.set_level(level); | |
@@ -1110,6 +1116,8 b' define([' | |||||
1110 | if (text === source_cell.placeholder) { |
|
1116 | if (text === source_cell.placeholder) { | |
1111 | text = ''; |
|
1117 | text = ''; | |
1112 | } |
|
1118 | } | |
|
1119 | //metadata | |||
|
1120 | target_cell.metadata = source_cell.metadata; | |||
1113 | // We must show the editor before setting its contents |
|
1121 | // We must show the editor before setting its contents | |
1114 | target_cell.set_level(level); |
|
1122 | target_cell.set_level(level); | |
1115 | target_cell.unrender(); |
|
1123 | target_cell.unrender(); | |
@@ -1117,7 +1125,7 b' define([' | |||||
1117 | // make this value the starting point, so that we can only undo |
|
1125 | // make this value the starting point, so that we can only undo | |
1118 | // to this state, instead of a blank cell |
|
1126 | // to this state, instead of a blank cell | |
1119 | target_cell.code_mirror.clearHistory(); |
|
1127 | target_cell.code_mirror.clearHistory(); | |
1120 | source_element.remove(); |
|
1128 | source_cell.element.remove(); | |
1121 | this.select(i); |
|
1129 | this.select(i); | |
1122 | var cursor = source_cell.code_mirror.getCursor(); |
|
1130 | var cursor = source_cell.code_mirror.getCursor(); | |
1123 | target_cell.code_mirror.setCursor(cursor); |
|
1131 | target_cell.code_mirror.setCursor(cursor); |
General Comments 0
You need to be logged in to leave comments.
Login now