DOMParser.parseSlice not parsing correctly empty table cell?

This issue was observed when pasting a single table. When parsing the table, if it contains a cell without any content, DOMParser.parseSlice does not add an empty paragraph to that empty cell as defined in the schema. However, if the parsing is done using DOMParser.parse or if the first pasted element is not a table but a paragraph, then the parsing is correct and an empty paragraph is added to the empty cell.

These three examples can be seen here: ecstatic-swanson-c2coc0 - CodeSandbox

Am I missing something?

This is how parseSlice is specified—it leaves the slice open at the sides, meaning those open nodes are partial nodes and will not have required content added, because they are assumed to be attached to some other partial node of that type before becoming part of a document. Use parse if you want to parse a full node.

Thanks @marijn Actually, this issue arises when attempting to copy and paste a single table. I mentioned parseSlice because I noticed that parseFromClipboard uses it to parse the content that is pasted. I actually was able to reproduce this issue in the ProseMirror table demo: the paste operation works fine, but when dragging columns, an error occurs with the message ‘Invalid content for node type table_cell’. Additionally, it becomes impossible to insert any content into the cell with the missing content.

Hence, I am wondering if this behavior is expected. It is possible that I may have misunderstood the problem, and the issue might not be directly related to parseSlice .

Error can be seen here: Shared with Zight

The parseSlice behavior is expected.

That screencast doesn’t say much without knowing what you are pasting and how you copied it.

Got it. In this demo is easy to reproduce this issue :loving-wildflower-5i02n1 - CodeSandbox

I’m copying the red table on top with cmd+c Screen Recording 2023-05-15 at 05.52.46 PM

When logging the HTML from transformPastedHTML I get:

<meta charset='utf-8'><table class="tb"><tbody><tr><td colspan="3"></td></tr><tr><td>One</td><td>Two</td><td>Three</td></tr></tbody></table>

Thanks, that helped reproduce it. The bug was in the special handling of isolating nodes in the paste code of prosemirror-view. This patch should help.

It fixes the issue! Thank you so much!