Show More
@@ -198,9 +198,22 b' define([' | |||
|
198 | 198 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { |
|
199 | 199 | var shortcuts = this.keyboard_manager.edit_shortcuts; |
|
200 | 200 | |
|
201 | var cur = editor.getCursor(); | |
|
202 | if((cur.line !== 0 || cur.ch !==0) && event.keyCode === 38){ | |
|
203 | event._ipkmIgnore = true; | |
|
204 | } | |
|
205 | var nLastLine = editor.lastLine() | |
|
206 | if( ( event.keyCode === 40) | |
|
207 | && (( cur.line !== nLastLine) | |
|
208 | || ( cur.ch !== editor.getLineHandle(nLastLine).text.length)) | |
|
209 | ){ | |
|
210 | event._ipkmIgnore = true; | |
|
211 | } | |
|
201 | 212 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut |
|
202 | 213 | // manager will handle it |
|
203 |
if (shortcuts.handles(event)) { |
|
|
214 | if (shortcuts.handles(event)) { | |
|
215 | return true; | |
|
216 | } | |
|
204 | 217 | |
|
205 | 218 | return false; |
|
206 | 219 | }; |
@@ -291,7 +304,6 b' define([' | |||
|
291 | 304 | * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise |
|
292 | 305 | */ |
|
293 | 306 | Cell.prototype.handle_keyevent = function (editor, event) { |
|
294 | ||
|
295 | 307 | if (this.mode === 'command') { |
|
296 | 308 | return true; |
|
297 | 309 | } else if (this.mode === 'edit') { |
@@ -114,7 +114,7 b' define([' | |||
|
114 | 114 | * @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name |
|
115 | 115 | * for easier sorting and avoid collision |
|
116 | 116 | * @param callback {function(div, cell)} callback that will be called to generate the ui element |
|
117 |
* @param [cell_types] {List |
|
|
117 | * @param [cell_types] {List_of_String|undefined} optional list of cell types. If present the UI element | |
|
118 | 118 | * will be added only to cells of types in the list. |
|
119 | 119 | * |
|
120 | 120 | * |
@@ -163,7 +163,7 b' define([' | |||
|
163 | 163 | * @method register_preset |
|
164 | 164 | * @param name {String} name to use to refer to the preset. It is advised to use a prefix with the name |
|
165 | 165 | * for easier sorting and avoid collision |
|
166 |
* @param preset_list {List |
|
|
166 | * @param preset_list {List_of_String} reverse order of the button in the toolbar. Each String of the list | |
|
167 | 167 | * should correspond to a name of a registerd callback. |
|
168 | 168 | * |
|
169 | 169 | * @private |
@@ -288,8 +288,6 b' define([' | |||
|
288 | 288 | }; |
|
289 | 289 | |
|
290 | 290 | |
|
291 | /** | |
|
292 | */ | |
|
293 | 291 | CellToolbar.utils = {}; |
|
294 | 292 | |
|
295 | 293 | |
@@ -385,7 +383,7 b' define([' | |||
|
385 | 383 | * @method utils.select_ui_generator |
|
386 | 384 | * @static |
|
387 | 385 | * |
|
388 |
* @param list_list {list |
|
|
386 | * @param list_list {list_of_sublist} List of sublist of metadata value and name in the dropdown list. | |
|
389 | 387 | * subslit shoud contain 2 element each, first a string that woul be displayed in the dropdown list, |
|
390 | 388 | * and second the corresponding value to be passed to setter/return by getter. the corresponding value |
|
391 | 389 | * should not be "undefined" or behavior can be unexpected. |
@@ -83,11 +83,7 b' define([' | |||
|
83 | 83 | this.completer = null; |
|
84 | 84 | |
|
85 | 85 | |
|
86 | var cm_overwrite_options = { | |
|
87 | onKeyEvent: $.proxy(this.handle_keyevent,this) | |
|
88 | }; | |
|
89 | ||
|
90 | var config = utils.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options}); | |
|
86 | var config = utils.mergeopt(CodeCell, this.config); | |
|
91 | 87 | Cell.apply(this,[{ |
|
92 | 88 | config: config, |
|
93 | 89 | keyboard_manager: options.keyboard_manager, |
@@ -144,7 +140,7 b' define([' | |||
|
144 | 140 | inner_cell.append(this.celltoolbar.element); |
|
145 | 141 | var input_area = $('<div/>').addClass('input_area'); |
|
146 | 142 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); |
|
147 |
this.code_mirror.on('keydown', $.proxy(this.handle_ |
|
|
143 | this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this)) | |
|
148 | 144 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); |
|
149 | 145 | inner_cell.append(input_area); |
|
150 | 146 | input.append(prompt).append(inner_cell); |
@@ -318,11 +318,13 b' define([' | |||
|
318 | 318 | // Enter |
|
319 | 319 | if (code == keycodes.enter) { |
|
320 | 320 | event.codemirrorIgnore = true; |
|
321 | event._ipkmIgnore = true; | |
|
321 | 322 | event.preventDefault(); |
|
322 | 323 | this.pick(); |
|
323 | 324 | // Escape or backspace |
|
324 | 325 | } else if (code == keycodes.esc || code == keycodes.backspace) { |
|
325 | 326 | event.codemirrorIgnore = true; |
|
327 | event._ipkmIgnore = true; | |
|
326 | 328 | event.preventDefault(); |
|
327 | 329 | this.close(); |
|
328 | 330 | } else if (code == keycodes.tab) { |
@@ -343,6 +345,7 b' define([' | |||
|
343 | 345 | // need to do that to be able to move the arrow |
|
344 | 346 | // when on the first or last line ofo a code cell |
|
345 | 347 | event.codemirrorIgnore = true; |
|
348 | event._ipkmIgnore = true; | |
|
346 | 349 | event.preventDefault(); |
|
347 | 350 | |
|
348 | 351 | var options = this.sel.find('option'); |
@@ -356,7 +359,7 b' define([' | |||
|
356 | 359 | index = Math.min(Math.max(index, 0), options.length-1); |
|
357 | 360 | this.sel[0].selectedIndex = index; |
|
358 | 361 | } else if (code == keycodes.pageup || code == keycodes.pagedown) { |
|
359 | CodeMirror.e_stop(event); | |
|
362 | event._ipkmIgnore = true; | |
|
360 | 363 | |
|
361 | 364 | var options = this.sel.find('option'); |
|
362 | 365 | var index = this.sel[0].selectedIndex; |
@@ -227,6 +227,9 b' define([' | |||
|
227 | 227 | help : 'select previous cell', |
|
228 | 228 | help_index : 'da', |
|
229 | 229 | handler : function (event) { |
|
230 | if(event.codemirrorIgnore===true){ | |
|
231 | return false; | |
|
232 | } | |
|
230 | 233 | var index = that.notebook.get_selected_index(); |
|
231 | 234 | if (index !== 0 && index !== null) { |
|
232 | 235 | that.notebook.select_prev(); |
@@ -239,6 +242,9 b' define([' | |||
|
239 | 242 | help : 'select next cell', |
|
240 | 243 | help_index : 'db', |
|
241 | 244 | handler : function (event) { |
|
245 | if(event.codemirrorIgnore===true){ | |
|
246 | return false; | |
|
247 | } | |
|
242 | 248 | var index = that.notebook.get_selected_index(); |
|
243 | 249 | if (index !== (that.notebook.ncells()-1) && index !== null) { |
|
244 | 250 | that.notebook.select_next(); |
@@ -508,6 +514,9 b' define([' | |||
|
508 | 514 | KeyboardManager.prototype.bind_events = function () { |
|
509 | 515 | var that = this; |
|
510 | 516 | $(document).keydown(function (event) { |
|
517 | if(event._ipkmIgnore==true||event.originalEvent._ipkmIgnore==true){ | |
|
518 | return false; | |
|
519 | } | |
|
511 | 520 | return that.handle_keydown(event); |
|
512 | 521 | }); |
|
513 | 522 | }; |
@@ -893,7 +893,7 b' define([' | |||
|
893 | 893 | * Insert an element at given cell index. |
|
894 | 894 | * |
|
895 | 895 | * @method _insert_element_at_index |
|
896 |
* @param element {dom |
|
|
896 | * @param element {dom_element} a cell element | |
|
897 | 897 | * @param [index] {int} a valid index where to inser cell |
|
898 | 898 | * @private |
|
899 | 899 | * |
General Comments 0
You need to be logged in to leave comments.
Login now