|
@@ -61,11 +61,6 @@ export interface INotebookModel extends DocumentRegistry.IModel {
|
|
* The array of deleted cells since the notebook was last run.
|
|
* The array of deleted cells since the notebook was last run.
|
|
*/
|
|
*/
|
|
readonly deletedCells: string[];
|
|
readonly deletedCells: string[];
|
|
-
|
|
|
|
- /**
|
|
|
|
- * The default cell type for new cells.
|
|
|
|
- */
|
|
|
|
- defaultCell: nbformat.CellType;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -78,13 +73,8 @@ export class NotebookModel extends DocumentModel implements INotebookModel {
|
|
constructor(options: NotebookModel.IOptions = {}) {
|
|
constructor(options: NotebookModel.IOptions = {}) {
|
|
super(options.languagePreference, options.modelDB);
|
|
super(options.languagePreference, options.modelDB);
|
|
let factory = options.contentFactory || NotebookModel.defaultContentFactory;
|
|
let factory = options.contentFactory || NotebookModel.defaultContentFactory;
|
|
- this._defaultCell = options.defaultCell || 'code';
|
|
|
|
this.contentFactory = factory.clone(this.modelDB.view('cells'));
|
|
this.contentFactory = factory.clone(this.modelDB.view('cells'));
|
|
this._cells = new CellList(this.modelDB, this.contentFactory);
|
|
this._cells = new CellList(this.modelDB, this.contentFactory);
|
|
- // Add an initial code cell by default.
|
|
|
|
- if (!this._cells.length) {
|
|
|
|
- this._cells.push(factory.createCell(this.defaultCell, {}));
|
|
|
|
- }
|
|
|
|
this._cells.changed.connect(this._onCellsChanged, this);
|
|
this._cells.changed.connect(this._onCellsChanged, this);
|
|
|
|
|
|
// Handle initial metadata.
|
|
// Handle initial metadata.
|
|
@@ -156,19 +146,6 @@ export class NotebookModel extends DocumentModel implements INotebookModel {
|
|
return info ? info.name : '';
|
|
return info ? info.name : '';
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * The default cell type for new cells.
|
|
|
|
- */
|
|
|
|
- get defaultCell(): nbformat.CellType {
|
|
|
|
- return this._defaultCell;
|
|
|
|
- }
|
|
|
|
- set defaultCell(value: nbformat.CellType) {
|
|
|
|
- if (this._defaultCell === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._defaultCell = value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Dispose of the resources held by the model.
|
|
* Dispose of the resources held by the model.
|
|
*/
|
|
*/
|
|
@@ -334,17 +311,6 @@ export class NotebookModel extends DocumentModel implements INotebookModel {
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- let factory = this.contentFactory;
|
|
|
|
- // Add code cell if there are no cells remaining.
|
|
|
|
- if (!this.cells.length) {
|
|
|
|
- // Add the cell in a new context to avoid triggering another
|
|
|
|
- // cell changed event during the handling of this signal.
|
|
|
|
- requestAnimationFrame(() => {
|
|
|
|
- if (!this.isDisposed && !this.cells.length) {
|
|
|
|
- this.cells.push(factory.createCell(this.defaultCell, {}));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
this.triggerContentChange();
|
|
this.triggerContentChange();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -362,7 +328,6 @@ export class NotebookModel extends DocumentModel implements INotebookModel {
|
|
}
|
|
}
|
|
|
|
|
|
private _cells: CellList;
|
|
private _cells: CellList;
|
|
- private _defaultCell: nbformat.CellType = 'code';
|
|
|
|
private _nbformat = nbformat.MAJOR_VERSION;
|
|
private _nbformat = nbformat.MAJOR_VERSION;
|
|
private _nbformatMinor = nbformat.MINOR_VERSION;
|
|
private _nbformatMinor = nbformat.MINOR_VERSION;
|
|
private _deletedCells: string[];
|
|
private _deletedCells: string[];
|
|
@@ -392,11 +357,6 @@ export namespace NotebookModel {
|
|
* A modelDB for storing notebook data.
|
|
* A modelDB for storing notebook data.
|
|
*/
|
|
*/
|
|
modelDB?: IModelDB;
|
|
modelDB?: IModelDB;
|
|
-
|
|
|
|
- /**
|
|
|
|
- * A default cell type for new cells.
|
|
|
|
- */
|
|
|
|
- defaultCell?: nbformat.CellType;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|