How to use the @nteract/commutable.insertCellAt function in @nteract/commutable

To help you get started, we’ve selected a few @nteract/commutable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / nteract / packages / reducers / src / core / entities / contents / notebook.ts View on Github external
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));
}
github nteract / nteract / packages / reducers / src / core / entities / contents / notebook.ts View on Github external
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
    );
  });
}
github nteract / nteract / packages / reducers / src / core / entities / contents / notebook.ts View on Github external
return state.update("notebook", (notebook: ImmutableNotebook) => {
    const cellOrder: List = notebook.get("cellOrder", List());
    const index = cellOrder.indexOf(id);
    return insertCellAt(notebook, cell, cellId, index);
  });
}
github nteract / nteract / packages / reducers / src / core / entities / contents / notebook.ts View on Github external
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));
}