Set notebook as trusted after executing a cell. (#9108)

* Also set trusted by default when opening a notebook without any code cells.
This commit is contained in:
Cory Rivera
2020-02-10 17:03:57 -08:00
committed by GitHub
parent 45341d786b
commit 3a8b74a311
4 changed files with 18 additions and 6 deletions

View File

@@ -339,6 +339,8 @@ export class CellModel implements ICellModel {
}
let content = this.source;
if ((Array.isArray(content) && content.length > 0) || (!Array.isArray(content) && content)) {
this.notebookModel.trustedMode = true;
// requestExecute expects a string for the code parameter
content = Array.isArray(content) ? content.join('') : content;
const future = kernel.requestExecute({

View File

@@ -308,6 +308,11 @@ export class NotebookModel extends Disposable implements INotebookModel {
});
}
}
// Trust notebook by default if there are no code cells
if (this._cells.length === 0 || this._cells.every(cell => cell.cellType === CellTypes.Markdown)) {
this.trustedMode = true;
}
} catch (error) {
this._inErrorState = true;
throw error;