@@ -19,7 +19,10 @@ import { useState } from "react";
1919
2020export default function CellOptions ( { cell } : { cell : NbCell } ) {
2121 const dispatch = useDispatch ( ) ;
22- const { cells, cellIds } = useSelector ( ( state : { app : AppState } ) => state . app )
22+ const { notebooks, activeNotebookName } = useSelector ( ( state : { app : AppState } ) => state . app )
23+ const notebook = notebooks [ activeNotebookName ]
24+ const { cellIds, cells } = notebook
25+
2326 const languages = Object . keys ( cellLanguages ) as LangaugeOption [ ] ;
2427
2528 const [ copied , setCopied ] = useState ( false ) ;
@@ -30,7 +33,7 @@ export default function CellOptions({ cell }: { cell: NbCell }) {
3033 const language = e . target . value as LangaugeOption
3134 const newCurrCell = { ...cell , mode : language }
3235 const newCells = { ...cells , [ cell . id ] : newCurrCell }
33- dispatch ( updateCells ( newCells ) )
36+ dispatch ( updateCells ( { newCells, activeNotebookName } ) )
3437 }
3538
3639 const handleAddNewCellBelowCurrentCell = ( ) => {
@@ -47,8 +50,8 @@ export default function CellOptions({ cell }: { cell: NbCell }) {
4750 newCellIds . splice ( topCellIdIndex + 1 , 0 , newId )
4851
4952 const newCells = { ...cells , [ newId ] : newCell }
50- dispatch ( updateCells ( newCells ) )
51- dispatch ( updateCellIds ( newCellIds ) )
53+ dispatch ( updateCells ( { newCells, activeNotebookName } ) )
54+ dispatch ( updateCellIds ( { newCellIds, activeNotebookName } ) )
5255 }
5356
5457 const handleMoveCurrentCellUp = ( ) => {
@@ -58,7 +61,7 @@ export default function CellOptions({ cell }: { cell: NbCell }) {
5861 newCellIds . splice ( currentCellIdIndex - 1 , 0 , cell . id )
5962 newCellIds . splice ( currentCellIdIndex + 1 , 1 )
6063
61- dispatch ( updateCellIds ( newCellIds ) )
64+ dispatch ( updateCellIds ( { newCellIds, activeNotebookName } ) )
6265 }
6366
6467 const handleMoveCurrentCellDown = ( ) => {
@@ -71,15 +74,15 @@ export default function CellOptions({ cell }: { cell: NbCell }) {
7174 newCellIds . splice ( currentCellIdIndex , 1 , downCellId )
7275 newCellIds . splice ( downCellIdIndex , 1 , cell . id )
7376
74- dispatch ( updateCellIds ( newCellIds ) )
77+ dispatch ( updateCellIds ( { newCellIds, activeNotebookName } ) )
7578 }
7679
7780 const handleDeleteCurrentCell = ( ) => {
7881 const newCellIds = [ ...cellIds ]
7982 const currentCellIdIndex = cellIds . indexOf ( cell . id )
8083 newCellIds . splice ( currentCellIdIndex , 1 )
8184
82- dispatch ( updateCellIds ( newCellIds ) )
85+ dispatch ( updateCellIds ( { newCellIds, activeNotebookName } ) )
8386 }
8487
8588 const handleCopyCurrentCellContentToClipBoard = async ( ) => {
@@ -134,6 +137,7 @@ export default function CellOptions({ cell }: { cell: NbCell }) {
134137 < IconButton
135138 aria-label = "delete"
136139 color = "warning"
140+ disabled = { currentCellIdIndex === 0 }
137141 onClick = { handleDeleteCurrentCell }
138142 >
139143 < DeleteIcon />
0 commit comments