lexical
lexical copied to clipboard
Fix table of contents for headings in tables and collapsible sections
Fixes following issues with table of contents:
- The order in table of contents is wrong for heading inside tables and collapsible sections.
- The heading is duplicated when resizing parent table cell
Now on each heading update dfs is used to get all headings and create a new TOC from scratch. It might take more time, but the change shouldn't be noticeable
Before:
After:
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| lexical | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 29, 2024 3:43pm |
| lexical-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 29, 2024 3:43pm |
Made the following changes:
- Explicitly checking if the heading is already in TOC to avoid duplicates
- Replaced dfs with listener on root updates, which updates all child headings
- Find previous heading for a new heading only when it's updated The performance should be much better now as we only visit updated nodes
@zurfyx feel free to take a look