@@ -36,9 +36,9 @@ import {
3636 */
3737export interface TableHandlesProps {
3838 /**
39- * The OpenBlockEditor instance.
39+ * The OpenBlockEditor instance (can be null during initialization) .
4040 */
41- editor : OpenBlockEditor ;
41+ editor : OpenBlockEditor | null ;
4242
4343 /**
4444 * Additional class name for the handles container.
@@ -144,6 +144,8 @@ export function TableHandles({
144144
145145 // Track mouse position to detect which row/col is hovered
146146 useEffect ( ( ) => {
147+ if ( ! editor || editor . isDestroyed ) return ;
148+
147149 let hideTimeout : ReturnType < typeof setTimeout > | null = null ;
148150
149151 const clearHideTimeout = ( ) => {
@@ -286,7 +288,7 @@ export function TableHandles({
286288
287289 const handleAddRow = useCallback (
288290 ( index : number ) => {
289- if ( ! tableState ) return ;
291+ if ( ! editor || editor . isDestroyed || ! tableState ) return ;
290292 addRowAtIndex ( editor . pm . state , editor . pm . view . dispatch , tableState . tablePos , index ) ;
291293 editor . pm . view . focus ( ) ;
292294 setShowRowMenu ( null ) ;
@@ -296,7 +298,7 @@ export function TableHandles({
296298
297299 const handleDeleteRow = useCallback (
298300 ( index : number ) => {
299- if ( ! tableState ) return ;
301+ if ( ! editor || editor . isDestroyed || ! tableState ) return ;
300302 deleteRowAtIndex ( editor . pm . state , editor . pm . view . dispatch , tableState . tablePos , index ) ;
301303 editor . pm . view . focus ( ) ;
302304 setShowRowMenu ( null ) ;
@@ -306,7 +308,7 @@ export function TableHandles({
306308
307309 const handleAddCol = useCallback (
308310 ( index : number ) => {
309- if ( ! tableState ) return ;
311+ if ( ! editor || editor . isDestroyed || ! tableState ) return ;
310312 addColumnAtIndex ( editor . pm . state , editor . pm . view . dispatch , tableState . tablePos , index ) ;
311313 editor . pm . view . focus ( ) ;
312314 setShowColMenu ( null ) ;
@@ -316,15 +318,15 @@ export function TableHandles({
316318
317319 const handleDeleteCol = useCallback (
318320 ( index : number ) => {
319- if ( ! tableState ) return ;
321+ if ( ! editor || editor . isDestroyed || ! tableState ) return ;
320322 deleteColumnAtIndex ( editor . pm . state , editor . pm . view . dispatch , tableState . tablePos , index ) ;
321323 editor . pm . view . focus ( ) ;
322324 setShowColMenu ( null ) ;
323325 } ,
324326 [ editor , tableState ]
325327 ) ;
326328
327- if ( ! tableState ) return null ;
329+ if ( ! editor || editor . isDestroyed || ! tableState ) return null ;
328330
329331 const tableRect = tableState . tableElement . getBoundingClientRect ( ) ;
330332
0 commit comments