If you paste a listitem that doesn't have a parent list into the editor you can get into an invalid state that throws errors if you try to add more list items. For example, if a page has the html;
<ul>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
hello world
<li>test</li>
and you copy that page's content and paste into the editor things break.
Of course the original html is invalid, but I would expect graceful handling of this as can not make guarantees about external content.
Lexical version: 0.8.0
Steps To Reproduce
- Create a page with invalid html (codepen) and copy the rendered content
- Go to the lexical playground and paste the content. Note that the last list item's parent is a paragraph, not a list.
- Put cursor at the end of
foo and hit enter.
The current behavior
No new list item is inserted and an error is thrown;
Uncaught Error: Minified Lexical error #39; visit https://lexical.dev/docs/error?code=39 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at qy (main.bd972200.js:21:233277)
at nv.insertAfter (main.bd972200.js:21:236788)
at nv.insertNewAfter (main.bd972200.js:21:237313)
at pf.insertParagraph (main.bd972200.js:21:166539)
at Array.<anonymous> (main.bd972200.js:21:260975)
at Vf (main.bd972200.js:21:180784)
at Rm.dispatchCommand (main.bd972200.js:21:208977)
at Array.<anonymous> (main.bd972200.js:21:264129)
at Vf (main.bd972200.js:21:180784)
at main.bd972200.js:21:180583
The expected behavior
A new list item to be inserted. More generally, I imagine the pasted list item should have had a list inserted automatically as it's parent.
After experimenting with other tools some (namely Apple's Notes app) just drops the list item and treats it as a paragraph, which would also be acceptable. The important thing is that don't end up in an invalid state.
If you paste a listitem that doesn't have a parent list into the editor you can get into an invalid state that throws errors if you try to add more list items. For example, if a page has the html;
and you copy that page's content and paste into the editor things break.
Of course the original html is invalid, but I would expect graceful handling of this as can not make guarantees about external content.
Lexical version: 0.8.0
Steps To Reproduce
fooand hit enter.The current behavior
No new list item is inserted and an error is thrown;
The expected behavior
A new list item to be inserted. More generally, I imagine the pasted list item should have had a list inserted automatically as it's parent.
After experimenting with other tools some (namely Apple's Notes app) just drops the list item and treats it as a paragraph, which would also be acceptable. The important thing is that don't end up in an invalid state.