import type { MountedEditorView } from '@admin/utils/editor/mounted-editor-view' import type { Editor } from '@tiptap/react' import { getTablePositionForElement } from '@admin/utils/editor/get-table-position-for-element' export function getTableFromWrapper( editor: Editor, view: MountedEditorView, wrapper: HTMLElement ): { pos: number; wrapper: HTMLElement } | null { const tableElement = wrapper.querySelector('table') if (!(tableElement instanceof HTMLTableElement)) return null const pos = getTablePositionForElement(editor, view, tableElement) return pos === null ? null : { pos, wrapper } }