Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const nextIndex = curIndex + 1;
// When at the end, create a new cell
if (nextIndex >= cellOrder.size) {
if (!action.payload.createCellIfUndefined) {
return state;
}
const cellId: string = uuid();
const cell = curCellType === "code" ? emptyCodeCell : emptyMarkdownCell;
const notebook: ImmutableNotebook = state.get("notebook");
return state
.set("cellFocused", cellId)
.set("notebook", insertCellAt(notebook, cell, cellId, nextIndex));
}
// When in the middle of the notebook document, move to the next cell
return state.set("cellFocused", cellOrder.get(nextIndex));
}
return state.update("notebook", (notebook: ImmutableNotebook) => {
const index = notebook.get("cellOrder", List()).indexOf(id) + 1;
return insertCellAt(
notebook,
(cell as ImmutableMarkdownCell).set("source", source),
cellId,
index
);
});
}
return state.update("notebook", (notebook: ImmutableNotebook) => {
const cellOrder: List = notebook.get("cellOrder", List());
const index = cellOrder.indexOf(id);
return insertCellAt(notebook, cell, cellId, index);
});
}
function createCellAppend(
state: NotebookModel,
action: actionTypes.CreateCellAppend
): RecordOf {
const { cellType } = action.payload;
const notebook: ImmutableNotebook = state.get("notebook");
const cellOrder: List = 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));
}