facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
19.98k stars 1.7k forks source link

Bug: If you add a table on a list it adds it above the list and results in invalid exported HTML #6849

Open osc245 opened 5 days ago

osc245 commented 5 days ago

If you add an unordered list and then on the list add a table it will add it above the list item and the exported HTML will contain an empty unordered list tag which is invalid HTML.

Lexical version: 0.17.1

Steps To Reproduce

  1. Add unordered list
  2. Click on the top list element
  3. Add a table
  4. Observe the table is above the list element and if you call the $generateHtmlFromNodes function it will contain an empty <ul> tag

Link to code example:

I noticed this in my own app using the INSERT_TABLE_COMMAND command but was able to reproduce it in the Lexical playground so I thought it was easier if I just demoed it using that.

https://github.com/user-attachments/assets/4858287e-071a-484e-803b-05117e99fc88

The current behavior

Table gets added above the list item and exported HTML contains an empty <ul> tag

The expected behavior

Table gets added below the list item and exported HTML does not contain a empty <ul> tag

Impact of fix