Show More
@@ -385,7 +385,8 b' define([' | |||||
385 | **/ |
|
385 | **/ | |
386 | Cell.prototype.toJSON = function () { |
|
386 | Cell.prototype.toJSON = function () { | |
387 | var data = {}; |
|
387 | var data = {}; | |
388 | data.metadata = this.metadata; |
|
388 | // deepcopy the metadata so copied cells don't share the same object | |
|
389 | data.metadata = JSON.parse(JSON.stringify(this.metadata)); | |||
389 | data.cell_type = this.cell_type; |
|
390 | data.cell_type = this.cell_type; | |
390 | return data; |
|
391 | return data; | |
391 | }; |
|
392 | }; | |
@@ -404,22 +405,32 b' define([' | |||||
404 |
|
405 | |||
405 |
|
406 | |||
406 | /** |
|
407 | /** | |
407 | * can the cell be split into two cells |
|
408 | * can the cell be split into two cells (false if not deletable) | |
408 | * @method is_splittable |
|
409 | * @method is_splittable | |
409 | **/ |
|
410 | **/ | |
410 | Cell.prototype.is_splittable = function () { |
|
411 | Cell.prototype.is_splittable = function () { | |
411 |
return t |
|
412 | return this.is_deletable(); | |
412 | }; |
|
413 | }; | |
413 |
|
414 | |||
414 |
|
415 | |||
415 | /** |
|
416 | /** | |
416 | * can the cell be merged with other cells |
|
417 | * can the cell be merged with other cells (false if not deletable) | |
417 | * @method is_mergeable |
|
418 | * @method is_mergeable | |
418 | **/ |
|
419 | **/ | |
419 | Cell.prototype.is_mergeable = function () { |
|
420 | Cell.prototype.is_mergeable = function () { | |
420 |
return t |
|
421 | return this.is_deletable(); | |
421 | }; |
|
422 | }; | |
422 |
|
423 | |||
|
424 | /** | |||
|
425 | * is the cell deletable? (true by default) | |||
|
426 | * @method is_deletable | |||
|
427 | **/ | |||
|
428 | Cell.prototype.is_deletable = function () { | |||
|
429 | if (this.metadata.deletable === undefined) { | |||
|
430 | return true; | |||
|
431 | } | |||
|
432 | return Boolean(this.metadata.deletable); | |||
|
433 | }; | |||
423 |
|
434 | |||
424 | /** |
|
435 | /** | |
425 | * @return {String} - the text before the cursor |
|
436 | * @return {String} - the text before the cursor |
@@ -765,7 +765,11 b' define([' | |||||
765 | */ |
|
765 | */ | |
766 | Notebook.prototype.delete_cell = function (index) { |
|
766 | Notebook.prototype.delete_cell = function (index) { | |
767 | var i = this.index_or_selected(index); |
|
767 | var i = this.index_or_selected(index); | |
768 |
var cell = this.get_ |
|
768 | var cell = this.get_cell(i); | |
|
769 | if (!cell.is_deletable()) { | |||
|
770 | return this; | |||
|
771 | } | |||
|
772 | ||||
769 | this.undelete_backup = cell.toJSON(); |
|
773 | this.undelete_backup = cell.toJSON(); | |
770 | $('#undelete_cell').removeClass('disabled'); |
|
774 | $('#undelete_cell').removeClass('disabled'); | |
771 | if (this.is_valid_cell_index(i)) { |
|
775 | if (this.is_valid_cell_index(i)) { | |
@@ -1193,6 +1197,10 b' define([' | |||||
1193 | Notebook.prototype.copy_cell = function () { |
|
1197 | Notebook.prototype.copy_cell = function () { | |
1194 | var cell = this.get_selected_cell(); |
|
1198 | var cell = this.get_selected_cell(); | |
1195 | this.clipboard = cell.toJSON(); |
|
1199 | this.clipboard = cell.toJSON(); | |
|
1200 | // remove undeletable status from the copied cell | |||
|
1201 | if (this.clipboard.metadata.deletable !== undefined) { | |||
|
1202 | delete this.clipboard.metadata.deletable; | |||
|
1203 | } | |||
1196 | this.enable_paste(); |
|
1204 | this.enable_paste(); | |
1197 | }; |
|
1205 | }; | |
1198 |
|
1206 |
General Comments 0
You need to be logged in to leave comments.
Login now