Example #1
0
function createCellAppend(
  state: NotebookModel,
  action: actionTypes.CreateCellAppend
): RecordOf<DocumentRecordProps> {
  const { cellType } = action.payload;
  const notebook: ImmutableNotebook = state.get("notebook");
  const cellOrder: List<CellId> = notebook.get("cellOrder", List());
  const cell: ImmutableCell =
    cellType === "markdown" ? emptyMarkdownCell : emptyCodeCell;
  const index = cellOrder.count();
  const cellId = uuid();
  return state.set("notebook", insertCellAt(notebook, cell, cellId, index));
}