Show More
@@ -993,19 +993,21 define([ | |||||
993 | Notebook.prototype.to_code = function (index) { |
|
993 | Notebook.prototype.to_code = function (index) { | |
994 | var i = this.index_or_selected(index); |
|
994 | var i = this.index_or_selected(index); | |
995 | if (this.is_valid_cell_index(i)) { |
|
995 | if (this.is_valid_cell_index(i)) { | |
996 |
|
|
996 | var source_cell = this.get_cell(i); | |
997 | var source_cell = source_element.data("cell"); |
|
|||
998 | if (!(source_cell instanceof codecell.CodeCell)) { |
|
997 | if (!(source_cell instanceof codecell.CodeCell)) { | |
999 | var target_cell = this.insert_cell_below('code',i); |
|
998 | var target_cell = this.insert_cell_below('code',i); | |
1000 | var text = source_cell.get_text(); |
|
999 | var text = source_cell.get_text(); | |
1001 | if (text === source_cell.placeholder) { |
|
1000 | if (text === source_cell.placeholder) { | |
1002 | text = ''; |
|
1001 | text = ''; | |
1003 | } |
|
1002 | } | |
|
1003 | //metadata | |||
|
1004 | target_cell.metadata = source_cell.metadata; | |||
|
1005 | ||||
1004 | target_cell.set_text(text); |
|
1006 | target_cell.set_text(text); | |
1005 | // make this value the starting point, so that we can only undo |
|
1007 | // make this value the starting point, so that we can only undo | |
1006 | // to this state, instead of a blank cell |
|
1008 | // to this state, instead of a blank cell | |
1007 | target_cell.code_mirror.clearHistory(); |
|
1009 | target_cell.code_mirror.clearHistory(); | |
1008 | source_element.remove(); |
|
1010 | source_cell.element.remove(); | |
1009 | this.select(i); |
|
1011 | this.select(i); | |
1010 | var cursor = source_cell.code_mirror.getCursor(); |
|
1012 | var cursor = source_cell.code_mirror.getCursor(); | |
1011 | target_cell.code_mirror.setCursor(cursor); |
|
1013 | target_cell.code_mirror.setCursor(cursor); | |
@@ -1023,21 +1025,24 define([ | |||||
1023 | Notebook.prototype.to_markdown = function (index) { |
|
1025 | Notebook.prototype.to_markdown = function (index) { | |
1024 | var i = this.index_or_selected(index); |
|
1026 | var i = this.index_or_selected(index); | |
1025 | if (this.is_valid_cell_index(i)) { |
|
1027 | if (this.is_valid_cell_index(i)) { | |
1026 |
|
|
1028 | var source_cell = this.get_cell(i); | |
1027 | var source_cell = source_element.data("cell"); |
|
1029 | ||
1028 | if (!(source_cell instanceof textcell.MarkdownCell)) { |
|
1030 | if (!(source_cell instanceof textcell.MarkdownCell)) { | |
1029 | var target_cell = this.insert_cell_below('markdown',i); |
|
1031 | var target_cell = this.insert_cell_below('markdown',i); | |
1030 | var text = source_cell.get_text(); |
|
1032 | var text = source_cell.get_text(); | |
|
1033 | ||||
1031 | if (text === source_cell.placeholder) { |
|
1034 | if (text === source_cell.placeholder) { | |
1032 | text = ''; |
|
1035 | text = ''; | |
1033 | } |
|
1036 | } | |
|
1037 | // metadata | |||
|
1038 | target_cell.metadata = source_cell.metadata | |||
1034 | // We must show the editor before setting its contents |
|
1039 | // We must show the editor before setting its contents | |
1035 | target_cell.unrender(); |
|
1040 | target_cell.unrender(); | |
1036 | target_cell.set_text(text); |
|
1041 | target_cell.set_text(text); | |
1037 | // make this value the starting point, so that we can only undo |
|
1042 | // make this value the starting point, so that we can only undo | |
1038 | // to this state, instead of a blank cell |
|
1043 | // to this state, instead of a blank cell | |
1039 | target_cell.code_mirror.clearHistory(); |
|
1044 | target_cell.code_mirror.clearHistory(); | |
1040 | source_element.remove(); |
|
1045 | source_cell.element.remove(); | |
1041 | this.select(i); |
|
1046 | this.select(i); | |
1042 | if ((source_cell instanceof textcell.TextCell) && source_cell.rendered) { |
|
1047 | if ((source_cell instanceof textcell.TextCell) && source_cell.rendered) { | |
1043 | target_cell.render(); |
|
1048 | target_cell.render(); | |
@@ -1058,22 +1063,24 define([ | |||||
1058 | Notebook.prototype.to_raw = function (index) { |
|
1063 | Notebook.prototype.to_raw = function (index) { | |
1059 | var i = this.index_or_selected(index); |
|
1064 | var i = this.index_or_selected(index); | |
1060 | if (this.is_valid_cell_index(i)) { |
|
1065 | if (this.is_valid_cell_index(i)) { | |
1061 | var source_element = this.get_cell_element(i); |
|
|||
1062 | var source_cell = source_element.data("cell"); |
|
|||
1063 | var target_cell = null; |
|
1066 | var target_cell = null; | |
|
1067 | var source_cell = this.get_cell(i); | |||
|
1068 | ||||
1064 | if (!(source_cell instanceof textcell.RawCell)) { |
|
1069 | if (!(source_cell instanceof textcell.RawCell)) { | |
1065 | target_cell = this.insert_cell_below('raw',i); |
|
1070 | target_cell = this.insert_cell_below('raw',i); | |
1066 | var text = source_cell.get_text(); |
|
1071 | var text = source_cell.get_text(); | |
1067 | if (text === source_cell.placeholder) { |
|
1072 | if (text === source_cell.placeholder) { | |
1068 | text = ''; |
|
1073 | text = ''; | |
1069 | } |
|
1074 | } | |
|
1075 | //metadata | |||
|
1076 | target_cell.metadata = source_cell.metadata; | |||
1070 | // We must show the editor before setting its contents |
|
1077 | // We must show the editor before setting its contents | |
1071 | target_cell.unrender(); |
|
1078 | target_cell.unrender(); | |
1072 | target_cell.set_text(text); |
|
1079 | target_cell.set_text(text); | |
1073 | // make this value the starting point, so that we can only undo |
|
1080 | // make this value the starting point, so that we can only undo | |
1074 | // to this state, instead of a blank cell |
|
1081 | // to this state, instead of a blank cell | |
1075 | target_cell.code_mirror.clearHistory(); |
|
1082 | target_cell.code_mirror.clearHistory(); | |
1076 | source_element.remove(); |
|
1083 | source_cell.element.remove(); | |
1077 | this.select(i); |
|
1084 | this.select(i); | |
1078 | var cursor = source_cell.code_mirror.getCursor(); |
|
1085 | var cursor = source_cell.code_mirror.getCursor(); | |
1079 | target_cell.code_mirror.setCursor(cursor); |
|
1086 | target_cell.code_mirror.setCursor(cursor); | |
@@ -1093,9 +1100,9 define([ | |||||
1093 | level = level || 1; |
|
1100 | level = level || 1; | |
1094 | var i = this.index_or_selected(index); |
|
1101 | var i = this.index_or_selected(index); | |
1095 | if (this.is_valid_cell_index(i)) { |
|
1102 | if (this.is_valid_cell_index(i)) { | |
1096 |
|
|
1103 | var source_cell = this.get_cell(i); | |
1097 | var source_cell = source_element.data("cell"); |
|
|||
1098 | var target_cell = null; |
|
1104 | var target_cell = null; | |
|
1105 | ||||
1099 | if (source_cell instanceof textcell.HeadingCell) { |
|
1106 | if (source_cell instanceof textcell.HeadingCell) { | |
1100 | source_cell.set_level(level); |
|
1107 | source_cell.set_level(level); | |
1101 | } else { |
|
1108 | } else { | |
@@ -1104,6 +1111,8 define([ | |||||
1104 | if (text === source_cell.placeholder) { |
|
1111 | if (text === source_cell.placeholder) { | |
1105 | text = ''; |
|
1112 | text = ''; | |
1106 | } |
|
1113 | } | |
|
1114 | //metadata | |||
|
1115 | target_cell.metadata = source_cell.metadata; | |||
1107 | // We must show the editor before setting its contents |
|
1116 | // We must show the editor before setting its contents | |
1108 | target_cell.set_level(level); |
|
1117 | target_cell.set_level(level); | |
1109 | target_cell.unrender(); |
|
1118 | target_cell.unrender(); | |
@@ -1111,7 +1120,7 define([ | |||||
1111 | // make this value the starting point, so that we can only undo |
|
1120 | // make this value the starting point, so that we can only undo | |
1112 | // to this state, instead of a blank cell |
|
1121 | // to this state, instead of a blank cell | |
1113 | target_cell.code_mirror.clearHistory(); |
|
1122 | target_cell.code_mirror.clearHistory(); | |
1114 | source_element.remove(); |
|
1123 | source_cell.element.remove(); | |
1115 | this.select(i); |
|
1124 | this.select(i); | |
1116 | var cursor = source_cell.code_mirror.getCursor(); |
|
1125 | var cursor = source_cell.code_mirror.getCursor(); | |
1117 | target_cell.code_mirror.setCursor(cursor); |
|
1126 | target_cell.code_mirror.setCursor(cursor); |
General Comments 0
You need to be logged in to leave comments.
Login now