Browse Source

Copying a cell should not preserve metadata.deletable.

Brian E. Granger 6 years ago
parent
commit
0c5cb548bc
1 changed files with 9 additions and 2 deletions
  1. 9 2
      packages/notebook/src/actions.tsx

+ 9 - 2
packages/notebook/src/actions.tsx

@@ -31,6 +31,7 @@ import * as React from 'react';
 import { INotebookModel } from './model';
 
 import { Notebook } from './widget';
+import { JSONObject } from '../../../node_modules/@phosphor/coreutils';
 
 // The message to display to the user when prompting to trust the notebook.
 const TRUST_MESSAGE = (
@@ -1542,9 +1543,15 @@ namespace Private {
     notebook.mode = 'command';
     clipboard.clear();
 
-    const data = notebook.widgets
+    let data = notebook.widgets
       .filter(cell => notebook.isSelectedOrActive(cell))
-      .map(cell => cell.model.toJSON());
+      .map(cell => cell.model.toJSON())
+      .map(cellJSON => {
+        if ((cellJSON.metadata as JSONObject).deletable !== undefined) {
+          delete (cellJSON.metadata as JSONObject).deletable;
+        }
+        return cellJSON;
+      });
 
     clipboard.setData(JUPYTER_CELL_MIME, data);
     if (cut) {