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