A new 'monocell' notebook with a single empty code cell. This function is useful if you are looking to initialize a fresh, new notebook.
A function that appends a new cell to a CellStructure object.
The cellOrder and cellMap of the current notebook
The cell that will be inserted into the cellStructure
The id of the new cell, defaults to a new UUID
Cell structure with the new cell appended at the end
A function that appends a cell to an immutable notebook.
An immutable data structure representing the notebook that will be modified
The new cell that will be inserted into the notebook
The modified notebook
Converts an immutable cell to a JSON cell.
An immutable representation of a cell.
A JSON representation of the same cell.
Converts an immutable representation of a code cell to a JSON representation.
An immutable representation of a code cell.
A JSON representation of the same code cell.
Converts a JSON representation of a cell of any type to the correct immutable representation, per the v4 nbformat specification.
A JSON representation of a cell.
An immutable representation of the same cell.
Handle the old v3 version of the media
Converts a mutable representation of metadata to an immutable representation.
A JSON representation of notebook metadata.
ImmutableMetadata An immutable representation of the metadata.
Converts a mutable representation of an output to an immutable representation.
The mutable output that will be converted.
ImmutableOutput An immutable representation of the same output.
Delete a cell with CellID at a given location.
The notebook containing the cell.
The modified notebook
Turn nbformat multiline strings (arrays of strings for simplifying diffs) into strings
Inserts a new cell with cellID before an existing cell with priorCellID in the notebook.
The notebook the cell will be inserted into.
The cell that will be inserted
Inserts a cell with cellID at a given index within the notebook.
The notebook the cell will be inserted into.
The cell that will be inserted
The position we would like to insert the cell at
The modified notebook.
Mark a cell as deleting; can be undone.
The notebook containing the cell.
The modified notebook
Undo marking a cell as deleting.
The notebook containing the cell.
The modified notebook
Converts a string representation of a notebook into a JSON representation.
A string representation of a notebook.
A JSON representation of the same notebook.
Converts an immutable representation of a raw cell to a JSON representation.
An immutable representation of a raw cell.
A JSON representation of the same raw cell.
Deprecated: Delete a cell with CellID at a given location.
Note that this function is deprecated in favor of deleteCell
.
The notebook containing the cell.
The modified notebook
Split string into a list of strings delimited by newlines; useful for on-disk git comparisons; and is the expectation for jupyter notebooks on disk
Converts a JSON representation of a notebook into a string representation.
The JSON representation of a notebook.
A string containing the notebook data.
Converts an immutable representation of a notebook to a JSON representation.
The immutable representation of a notebook.
The JSON representation of a notebook.
Converts an immutable representation of a notebook to a JSON representation of the notebook using the v4 of the nbformat specification.
The immutable representation of a notebook.
The JSON representation of a notebook.
Generated using TypeDoc
@nteract/commutable
Commutable is a package to represent a Jupyter notebook document, as well as operations on the notebook, as a series of immutable notebooks, each one with its own state at a point in time.
This package follows the principles below, based on Tom MacWright's outline for practical undo.
Installation
$ yarn add @nteract/commutable
$ npm install --save @nteract/commutable
Usage
The example below shows how we can create an empty Markdown cell in our nteract notebook application. We use the
emptyMarkdownCell
immutable object exported from this package to represent a new empty Markdown cell in a notebook document.import { emptyMarkdownCell } from "@nteract/commutable";
export default () => ( <MarkdownPreview id="a-random-cell-id" cell={emptyMarkdownCell} editorFocused={false} /> );
Documentation
You can view the reference documentation for
@nteract/commutable
in the package docs.Support
If you experience an issue while using this package or have a feature request, please file an issue on the issue board and, if possible, add the
pkg:commutable
label.License
BSD-3-Clause