Skip to content
Permalink
e0a1714279
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
29 lines (24 sloc) 669 Bytes
import { AppState, ContentRef } from "@nteract/types";
import { model } from "./index";
import { cellById } from "./notebook";
export interface CellAddress {
id: string;
contentRef: ContentRef;
}
export const cellAddress = ({ id, contentRef }: CellAddress) => (
{ id, contentRef }
);
export const cellFromState = (
state: AppState,
{ id, contentRef }: CellAddress,
) => {
const notebook = model(state, { contentRef });
if (!notebook || notebook.type !== "notebook") {
throw new Error("non-notebook model");
}
const cell = cellById(notebook, { id });
if (!cell) {
throw new Error("cell not found inside cell map");
}
return cell;
};