import { findParentNodeOfType , FindProsemirrorNodeResult , Selection } from '@remirror/core' ; import { blockNodePositioner , Positioner } from '@remirror/extension-positioner' ; import { CellSelection } from '@remirror/pm/tables' ; const cellNodeTypes = [ 'tableCell' , 'tableHeaderCell' ] ; function findMenuTableCell ( selection ) { if ( selection instanceof CellSelection ) { return findParentNodeOfType ( { selection : selection . $head , types : cellNodeTypes } ) ; } return findParentNodeOfType ( { selection : selection , types : cellNodeTypes } ) ; } /**
 * Creates a positioner for the current table cell node which will show the
 * cell menu.
 *
 * It spans the full width and height of the table cell node.
 */ export const menuCellPositioner = blockNodePositioner . clone ( ( ) => ( { getActive : ( props ) => { const result = findMenuTableCell ( props . state . selection ) ; return result ? [ result ] : Positioner . EMPTY ; } , } ) ) ;