mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-17 12:39:54 +08:00
Fix cell attachments copy/paste
This commit is contained in:
parent
ac9a345400
commit
c8266aa507
@ -228,6 +228,9 @@ define([
|
||||
'#toggle_all_output': 'toggle-all-cells-output-collapsed',
|
||||
'#toggle_all_output_scroll': 'toggle-all-cells-output-scrolled',
|
||||
'#clear_all_output': 'clear-all-cells-output',
|
||||
'#cut_cell_attachments': 'cut-cell-attachments',
|
||||
'#copy_cell_attachments': 'copy-cell-attachments',
|
||||
'#paste_cell_attachments': 'paste-cell-attachments',
|
||||
'#insert_image': 'insert-image',
|
||||
};
|
||||
|
||||
|
@ -126,6 +126,7 @@ define(function (require) {
|
||||
this.kernel = null;
|
||||
this.kernel_busy = false;
|
||||
this.clipboard = null;
|
||||
this.clipboard_attachments = null;
|
||||
this.undelete_backup_stack = [];
|
||||
this.paste_enabled = false;
|
||||
this.paste_attachments_enabled = false;
|
||||
@ -1709,11 +1710,13 @@ define(function (require) {
|
||||
*/
|
||||
Notebook.prototype.cut_cell_attachments = function() {
|
||||
var cell = this.get_selected_cell();
|
||||
this.clipboard_attachments = cell.attachments;
|
||||
this.enable_attachments_paste();
|
||||
cell.attachments = {};
|
||||
cell.unrender();
|
||||
cell.render();
|
||||
if (cell.attachments !== undefined) {
|
||||
this.clipboard_attachments = cell.attachments;
|
||||
this.enable_attachments_paste();
|
||||
delete cell.attachments;
|
||||
cell.unrender();
|
||||
cell.render();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1721,12 +1724,13 @@ define(function (require) {
|
||||
*/
|
||||
Notebook.prototype.copy_cell_attachments = function() {
|
||||
var cell = this.get_selected_cell();
|
||||
// Do a deep copy of attachments to avoid subsequent modification
|
||||
// to the cell to modify the clipboard
|
||||
this.clipboard_attachments = $.extend(true, {}, cell.attachments);
|
||||
this.enable_attachments_paste();
|
||||
cell.unrender();
|
||||
cell.render();
|
||||
if (cell.attachments !== undefined) {
|
||||
// Do a deep copy of attachments to avoid subsequent modification
|
||||
// to the cell to modify the clipboard
|
||||
console.log(cell.attachments);
|
||||
this.clipboard_attachments = $.extend(true, {}, cell.attachments);
|
||||
this.enable_attachments_paste();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1737,6 +1741,9 @@ define(function (require) {
|
||||
if (this.clipboard_attachments !== null &&
|
||||
this.paste_attachments_enabled) {
|
||||
var cell = this.get_selected_cell();
|
||||
if (cell.attachments === undefined) {
|
||||
cell.attachments = {};
|
||||
}
|
||||
$.extend(cell.attachments, this.clipboard_attachments);
|
||||
cell.unrender();
|
||||
cell.render();
|
||||
|
@ -215,7 +215,8 @@ define([
|
||||
}
|
||||
// Deepcopy the attachments so copied cells don't share the same
|
||||
// objects
|
||||
if (this.attachments !== undefined) {
|
||||
if (this.attachments !== undefined
|
||||
&& Object.keys(this.attachments).length > 0) {
|
||||
data.attachments = JSON.parse(JSON.stringify(this.attachments));
|
||||
}
|
||||
return data;
|
||||
|
Loading…
Reference in New Issue
Block a user