lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Fix table of contents for headings in tables and collapsible sections

Open KatsiarynaDzibrova opened this issue 1 year ago • 2 comments

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: toc-before

After: toc-after

KatsiarynaDzibrova avatar Apr 23 '24 16:04 KatsiarynaDzibrova

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

vercel[bot] avatar Apr 23 '24 16:04 vercel[bot]

Made the following changes:

  1. Explicitly checking if the heading is already in TOC to avoid duplicates
  2. Replaced dfs with listener on root updates, which updates all child headings
  3. 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

KatsiarynaDzibrova avatar Apr 29 '24 09:04 KatsiarynaDzibrova