You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: $generateNodesFromDOM creates empty list items from whitespace between actual list items #2807
I came here to post this issue. If it is intentional then this PR will get closed anyways, but, worth sharing my use-case. Unlike OP, I am getting an error thrown.
editorState: (editor)=>{constparser=newDOMParser();constdom=parser.parseFromString("<p>foo</p> <p>bar</p>",// NOTE THE SPACE BETWEEN THE P TAGS"text/html");constnodes=$generateNodesFromDOM(editor,dom);constrootNode=$getRoot();rootNode.append(...nodes);// ERROR}
I came here to post this issue. If it is intentional then this PR will get closed anyways, but, worth sharing my use-case. Unlike OP, I am getting an error thrown.
editorState: (editor)=>{constparser=newDOMParser();constdom=parser.parseFromString("<p>foo</p> <p>bar</p>",// NOTE THE SPACE BETWEEN THE P TAGS"text/html");constnodes=$generateNodesFromDOM(editor,dom);constrootNode=$getRoot();rootNode.append(...nodes);// ERROR}
I believe this can be closed now, I have code that uses $generateNodesFromDOM and added a test for this case in our code which shows it no longer creates blank list items, at least when using 0.13.1.
Activity
knpwrs commentedon Aug 16, 2022
This appears to be at least somewhat intentional: https://github.com/facebook/lexical/blob/b7887a02780e40640cf0e7582212f9c29730c14d/packages/lexical-list/src/LexicalListNode.ts#L251
#2509
marwan38 commentedon Nov 15, 2022
I came here to post this issue. If it is intentional then this PR will get closed anyways, but, worth sharing my use-case. Unlike OP, I am getting an error thrown.
Error + stack trace
That empty space is creating empty nodes in between the paragraph ones which is why they then can't be inserted into the root node.
SzDani3l commentedon Dec 20, 2022
I had the same issue, for now I fixed it by skipping the invalid nodes:
Fixed line breaks showing an empty content in nested editors
Fixed line breaks showing an empty content in nested editors (#603)
kevinansfield commentedon Jan 8, 2025
I believe this can be closed now, I have code that uses
$generateNodesFromDOMand added a test for this case in our code which shows it no longer creates blank list items, at least when using 0.13.1.