fix: drag handle resolve container blocks + menu popup clamp viewport
- Drag handle résout les blocs conteneurs (columns, toggle, callout) au lieu du paragraphe intérieur - Delete agit sur tout le bloc conteneur, pas juste le paragraphe - Menu popup (block action menu) clampé dans le viewport (Math.min + overflow auto) - Drag handle clamped dans le viewport via MutationObserver + scroll/resize
This commit is contained in:
@@ -21,5 +21,20 @@ export function resolveBlockAtDragHandle(editor: Editor): { node: PMNode; pos: n
|
||||
const node = editor.state.doc.nodeAt(blockPos)
|
||||
if (!node) return null
|
||||
|
||||
// Climb up to container blocks (columns, toggleBlock, calloutBlock)
|
||||
// so the drag handle operates on the whole container, not inner paragraphs
|
||||
const CONTAINER_TYPES = ['columns', 'toggleBlock', 'calloutBlock']
|
||||
const $blockPos = editor.state.doc.resolve(blockPos)
|
||||
for (let depth = $blockPos.depth; depth > 0; depth--) {
|
||||
const ancestor = $blockPos.node(depth)
|
||||
if (CONTAINER_TYPES.includes(ancestor.type.name)) {
|
||||
const containerPos = $blockPos.before(depth)
|
||||
const containerNode = editor.state.doc.nodeAt(containerPos)
|
||||
if (containerNode) {
|
||||
return { node: containerNode, pos: containerPos }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { node, pos: blockPos }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user