Returns the JSON representation of the notebook.
Returns the stringified version of a notebook. Returns an empty string if no notebookJS exists. Note that this is called asString instead of toString so that REPLs don't think of this as the representation of this module.
Returns the CodeMirror mode of the current notebook. This value can be used
to initialize the mode
option in CodeMirror. Returns text
if no mode
is set.
Returns the type of host the nteract application is currently connected to. This is set to "jupyter" by default.
Returns the kernelspec of the kernel that we are currently connected to. Returns null if there is no kernel.
Returns the state of the kernel the nteract application is currently connected to. Returns "not connected" if there is no kernel.
Returns the type of the kernel the nteract application is currently
connected to. Returns null
if there is no kernel.
Returns the theme of the notebook. Returns "light" if no theme is defined.
This is an alias for the userTheme
selector.
Returns the display name of the kernel the notebook is currently running against.
Returns the ID of the GitHub Gist the notebook has been recently published to.
Returns the GitHub username the user has authenticated through.
Returns true if the host we are currently connected to is a Jupyter kernel.
Returns whether or not we are currently connected to the kernel through a websocket connection.
Returns whether or not we are currently connected to the kernel through a ZeroMQ connection.
Returns true if the notebook differs from the version saved to disk, and false otherwise.
Returns the version of the nteract application.
Returns the auto-save interval to be used in the notebook. Returns an interval around the two minute range if one is not provided in the config.
Returns the cell within a notebook with a particular ID. Returns undefined if no cell with that ID is found in the model
The notebook model to extract the cell from
Undefined or a cell with the given ID
Returns the ID of the focused cell within a notebook.
The notebook to extract the focused cell from
The ID of the focused cell
Returns the cellMap within a given NotebookModel. Returns an empty Immutable.Map if no cellMap exists in the NotebookModel.
The notebook model to extract the cell map from
The cell map within the notebook or an empty map
Returns the cell order within a notebook. Returns an empty list if the notebook contains no cellOrder.
The notebook model to extract the cell order list from
The cell order within a notebook or an empty list
Returns the CellIds of the code cells within a notebook.
Returns a list of CellIds below the currently focused cell in a notebook.
The notebook to extract the code cells from
The IDs of cells below the currently focused cell
Returns the Jupyter comms data for a given nteract application.
The state of the nteract application
The ContentRecord for the given ref
Returns the contents, such as notebooks and files, that are currently accessible within the current notebook application.
The state of the nteract application
The contents in scope by the nteract application by ID
Returns the ContentRef associated with a given filepath.
The state of the nteract application
An object containing the filepath
The ContentRef for the content under a filepath
Returns the host the nteract application is connected to.
Returns the KernelRef for the kernel the nteract application is currently connected to.
The state of the nteract application
The KernelRef for the kernel
Returns the kernelspec of the kernel that the nteract application is currently connected to.
Returns a ref to the kernelspec of the kernel the nteract application is currently connected to.
The state of the nteract application
A ref to the kernelspec
Returns the delete delay to be used in the notebook.
Returns the CellId of the cell with the currently focused editor within the notebook.
The notebook to extract the focused editor from
The ID of the cell with the currently focused editor
Returns the filepath for the content identified by a given ContentRef.
The state of the nteract application
An object containing the ContentRef
The filepath for the content
Returns the CellIds of the hidden cells in a notebook.
Returns the HostRecord associated with a hostRef.
const hostRef = "someHostRef";
const hostRecord = selectors.hostRecordByHostRef(state, { hostRef });
The current application sate
Returns the HostRef associated with a HostRecord.
const host = makeJupyterHostRecord({ endpoint: "https://example.com "});
const ref = selectors.hostRefByHostRecord(state, { host });
The current application state
Returns the hosts currently registered on the application by their refs.
The crrent application state
Returns the CellIds of the cells with hidden outputs in the notebook.
Returns the information associated with currently registered comms.
Returns the information associated with a comm registered at a certain id.
The current application state
Returns the kernel associated with a given KernelRef.
The state of the nteract application
The kernel for the KernelRef
Returns a ref to the kernel associated with a particular type of content. Currently, this only support kernels associated with notebook contents. Returns null if there are no contents or if the contents are not a notebook.
The state of the nteract application
The kernel associated with a notebook
Returns a map of the available kernels keyed by the kernel ref.
The state of the nteract application
The kernels by ref
Returns a Map of the kernelspecs associated with each kernelspec ref.
The state of the nteract application
An association between a kernelspec ref and the kernelspec
Returns the metadata of a notebook. Returns an empty Immutable.Map if no metadata is defined.
The notebook to extract the metadata from
An empty Map or a Map containing the metadata of the notebook
Returns the type of modal, such as the about modal, that is currently open in the nteract application.
Returns the model within the ContenteRecrd specified by contentRef. For example, if the ContentRecord is a reference to a notebook object, the model would contain the NotebookModel.
The state of the nteract application
The model of the content under the current ref
Returns the model associated with a comm at a certain id.
The current application state
Returns the comms models that are stored in the nteract application state.
Returns the notification system currently configured on the nteract application. This can be used to display informational or error-related alerts to the user.
Creates a server configuration from details about a given Jupyter host.
The Jupyter host we are connected to
An object contain the endpoint, token
Returns the handler associated with a comm target at a certain id.
The current application state
Returns the registered comm targets that are stored in the nteract application state.
Returns a transient version of the cell map within a notebook. This cell map is a copy of the original cell map that is transient.
The notebook to extract the transient cell map from
The tranisent cell map
Returns the theme of the notebook. Returns "light" if no theme is defined.
The state of the nteract application
The theme of the nteract application
Generated using TypeDoc
@nteract/selectors
This package provides a set of selectors and functions that allow you to extract important information from the state of your nteract application. To see a full set of the data stored in application state that be extracted with this package, you can view the AppState type.
Installation
$ yarn add @nteract/selectors
$ npm install --save @nteract/selectors
Usage
import { modalType, currentTheme } from "@nteract/selectors";
const state = { config: { theme: "dark" }, core: { entities: { modals: { modalType: "ABOUT" } } } };
const theme = currentTheme(state); const currentModal = modalType(state); console.log(
Rendering ${currentModal} modal using ${theme} theme.
); > Rendering ABOUT modal using dark theme.Documentation
You can view the reference documentation for
@nteract/selectors
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 add the
pkg:selectors
label.License
BSD-3-Clause