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>
20 lines
657 B
TypeScript
20 lines
657 B
TypeScript
import type { EditorState } from '@tiptap/pm/state'
|
|
import type { Node as PMNode } from '@tiptap/pm/model'
|
|
|
|
function isEmptyParagraph(node: PMNode): boolean {
|
|
if (node.type.name !== 'paragraph') return false
|
|
return node.textContent.trim() === '' && node.content.size <= 1
|
|
}
|
|
|
|
/** Paragraphe vide sous le curseur (critère US-3 Smart Paste). */
|
|
export function getEmptyParagraphAtSelection(
|
|
state: EditorState,
|
|
): { pos: number; node: PMNode } | null {
|
|
const { $from, empty } = state.selection
|
|
if (!empty) return null
|
|
if (!isEmptyParagraph($from.parent)) return null
|
|
|
|
const pos = $from.before($from.depth)
|
|
return { pos, node: $from.parent }
|
|
}
|