2020-05-25 21:30:55 -05:00
|
|
|
import { NotebookContentRecordProps, selectors } from "@nteract/core";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A bunch of utilities to interact with nteract
|
|
|
|
*/
|
2021-03-09 21:47:02 +05:30
|
|
|
export function getCurrentCellType(content: NotebookContentRecordProps): "markdown" | "code" | "raw" | undefined {
|
|
|
|
if (!content) {
|
|
|
|
return undefined;
|
|
|
|
}
|
2020-05-25 21:30:55 -05:00
|
|
|
|
2021-03-09 21:47:02 +05:30
|
|
|
const cellFocusedId = selectors.notebook.cellFocused(content.model);
|
|
|
|
if (cellFocusedId) {
|
|
|
|
const cell = selectors.notebook.cellById(content.model, { id: cellFocusedId });
|
|
|
|
if (cell) {
|
|
|
|
return cell.cell_type;
|
2020-05-25 21:30:55 -05:00
|
|
|
}
|
|
|
|
}
|
2021-03-09 21:47:02 +05:30
|
|
|
|
|
|
|
return undefined;
|
2020-05-25 21:30:55 -05:00
|
|
|
}
|