@@ -163,13 +163,9 @@ export class TableHandlesView implements PluginView {
163163 any
164164 > ,
165165 private readonly pmView : EditorView ,
166- emitUpdate : ( state : TableHandlesState ) => void ,
166+ emitUpdate : ( state : TableHandlesState | undefined ) => void ,
167167 ) {
168168 this . emitUpdate = ( ) => {
169- if ( ! this . state ) {
170- throw new Error ( "Attempting to update uninitialized image toolbar" ) ;
171- }
172-
173169 emitUpdate ( this . state ) ;
174170 } ;
175171
@@ -298,7 +294,7 @@ export class TableHandlesView implements PluginView {
298294
299295 const hideHandles =
300296 // always hide handles when the actively hovered table changed
301- this . state ?. block . id !== tableBlock . id ||
297+ this . state ?. block ? .id !== tableBlock . id ||
302298 // make sure we don't hide existing handles (keep col / row index) when
303299 // we're hovering just above or to the right of a table
304300 event . clientX > tableRect . right ||
@@ -543,9 +539,9 @@ export class TableHandlesView implements PluginView {
543539 // because yjs replaces the element when for example you change the color via the side menu
544540 ! this . tableElement ?. isConnected
545541 ) {
546- this . state . show = false ;
547- this . state . showAddOrRemoveRowsButton = false ;
548- this . state . showAddOrRemoveColumnsButton = false ;
542+ this . state = undefined ;
543+ this . tableId = undefined ;
544+ this . tableElement = undefined ;
549545 this . emitUpdate ( ) ;
550546
551547 return ;
@@ -628,7 +624,7 @@ export const TableHandlesExtension = createExtension(({ editor }) => {
628624 view : ( editorView ) => {
629625 view = new TableHandlesView ( editor as any , editorView , ( state ) => {
630626 store . setState (
631- state . block
627+ state ? .block
632628 ? {
633629 ...state ,
634630 draggingState : state . draggingState
0 commit comments