Potential Issue with transform.map in Table Operations

Hi Marijn,

I’ve encountered what appears to be an issue with transform.map during table operations. Here’s a minimal reproduction:

Scenario:

Initial document contains a table with two cells

Client X performs: Adjusts column width of the second cell

Client Y performs: Deletes the second cell and inserts new content

After rebase, it generates an invalid ReplaceAroundStep

Result:

Creates an empty td (content-less table cell) in the document

Throws error: “Invalid content for node type table_cell”

Demo:

https://codesandbox.io/p/sandbox/2fztcm?file=%2Fsrc%2Findex.js%3A10%2C28

By the way, prior to upgrading, I was using prosemirror-transform@1.1.3 where this issue did not occur.

1 Like

I don’t see the error you mention, neither in the codesandbox link nor when I try to run that code locally. Is anything else needed to make the issue show up?

Correction to My Previous Description:

Apologies for the confusion in my initial report. As you can see from the console output in the demo:

  1. The steps.length is 4
  2. The final step is an invalid ReplaceAroundStep
  3. The doc contains an invalid td node

Regarding the "Invalid content for node type table_cell" error:

  • This error only surfaces in the view layer when clicking into the table
  • The demo doesn’t explicitly trigger this error (it occurs during user interaction)

Are you able to set up a demo that reproduces this directly, so that I can see it happen?

I’ve updated the demo, could you please take another look?

Thanks, that made it easy to track this down. It was indeed a problem in the library—ReplaceAroundStep could, in some circumstances, be applied even if it produced an invalid node. This patch should help.

2 Likes