Skip to content

Commit

Permalink
Merge pull request #5928 from mishaschwartz/persist-cell-id
Browse files Browse the repository at this point in the history
Ensure that cell ids persist after save
  • Loading branch information
kevin-bates authored Jan 12, 2021
2 parents 8d0af52 + a5d7528 commit 57db709
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions notebook/static/notebook/js/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ define([
var data = {};
// deepcopy the metadata so copied cells don't share the same object
data.metadata = JSON.parse(JSON.stringify(this.metadata));
if (this.id !== undefined) {
data.id = this.id;
}
if (data.metadata.deletable) {
delete data.metadata.deletable;
}
Expand All @@ -511,6 +514,9 @@ define([
if (data.metadata !== undefined) {
this.metadata = data.metadata;
}
if (data.id !== undefined) {
this.id = data.id;
}
};


Expand Down
3 changes: 3 additions & 0 deletions notebook/static/notebook/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,9 @@ define([
if (cell_json.metadata.deletable !== undefined) {
delete cell_json.metadata.deletable;
}
if (cell_json.id !== undefined) {
delete cell_json.id;
}
this.clipboard.push(cell_json);
}
this.enable_paste();
Expand Down

0 comments on commit 57db709

Please sign in to comment.