Files
Momento/memento-note/lib/editor/block-at-drag-handle.ts
Antigravity f46654f574 feat: editor improvements and architectural grid prototype
Multiple feature additions and improvements across the application:

- NextGen Editor: drag handles, smart paste, block actions
- Structured views: Kanban and table layouts for notes
- Architectural Grid: new brainstorming/agent interface prototype
- Flashcards: SM-2 revision algorithm with AI generation
- MCP server: robustness improvements
- Graph/PDF chat: fix click propagation and copy behavior
- Various UI/UX enhancements and bug fixes

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 19:45:15 +00:00

26 lines
958 B
TypeScript

import type { Editor } from '@tiptap/core'
import type { Node as PMNode } from '@tiptap/pm/model'
export const BLOCK_DRAG_HANDLE_ID = 'notion-block-drag-handle'
export const BLOCK_DRAG_HANDLE_WIDTH = 20
/** Même logique de résolution de bloc que tiptap-extension-global-drag-handle */
export function resolveBlockAtDragHandle(editor: Editor): { node: PMNode; pos: number } | null {
const handle = document.getElementById(BLOCK_DRAG_HANDLE_ID)
if (!handle || editor.isDestroyed) return null
const rect = handle.getBoundingClientRect()
const coords = editor.view.posAtCoords({
left: rect.right + 50 + BLOCK_DRAG_HANDLE_WIDTH,
top: rect.top + rect.height / 2,
})
if (coords?.pos == null) return null
const $pos = editor.state.doc.resolve(coords.pos)
const blockPos = $pos.depth > 1 ? $pos.before($pos.depth) : coords.pos
const node = editor.state.doc.nodeAt(blockPos)
if (!node) return null
return { node, pos: blockPos }
}