import type { TableRect } from '@tiptap/pm/tables' import type { Editor } from '@tiptap/react' import { TableMap } from '@tiptap/pm/tables' export function getTableRectAtPosition(editor: Editor, tablePos: number): TableRect | null { const table = editor.state.doc.nodeAt(tablePos) if (!table || table.type.name !== 'table') return null const map = TableMap.get(table) return { bottom: map.height, left: 0, map, right: map.width, table, tableStart: tablePos + 1, top: 0 } }