import type { ContentEditorFocusBlock } from './content-editor-focus-block' import type { Editor } from '@tiptap/react' export function getContentEditorFocusBlock( editor: Editor, container: HTMLElement ): ContentEditorFocusBlock | null { const { $from } = editor.state.selection if ($from.depth < 1) return null const blockElement = editor.view.nodeDOM($from.before(1)) if (!(blockElement instanceof HTMLElement)) return null const containerTop = container.getBoundingClientRect().top const blockRect = blockElement.getBoundingClientRect() return { top: blockRect.top - containerTop, bottom: blockRect.bottom - containerTop } }