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 } ) => ( { id , contentRef } ) ; export const cellFromState = ( state , { id , contentRef } ) => { 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 ; } ;