fix: Outline se met à jour en temps réel quand les titres changent
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 5m39s
CI / Deploy production (on server) (push) Successful in 21s

Ajout d'un listener editor.on('update') dans OutlineView.
Avant: le sommaire était figé au moment de l'insertion.
Maintenant: il se recalcule à chaque ajout/modif/suppression de titre.
This commit is contained in:
Antigravity
2026-06-20 16:28:54 +00:00
parent 87efb807f3
commit 35c79ffd1c

View File

@@ -1,5 +1,6 @@
'use client'
import { useState, useEffect, useRef } from 'react'
import { Node, mergeAttributes } from '@tiptap/core'
import { ReactNodeViewRenderer, NodeViewWrapper } from '@tiptap/react'
import { List, X } from 'lucide-react'
@@ -37,7 +38,14 @@ function collectHeadings(editor: Editor): HeadingEntry[] {
const OutlineView = ({ editor, deleteNode }: any) => {
const { t } = useLanguage()
const headings = collectHeadings(editor as Editor)
const [headings, setHeadings] = useState<HeadingEntry[]>(() => collectHeadings(editor as Editor))
// Re-collect headings when the editor content changes
useEffect(() => {
const update = () => setHeadings(collectHeadings(editor as Editor))
editor.on('update', update)
return () => { editor.off('update', update) }
}, [editor])
const scrollToHeading = (pos: number) => {
const docSize = editor.state.doc.content.size