Pasting incompatible nodes into tables

Hi, I don’t really have a clear question here, but just wanted to garner some ideas as to better handle pasting incompatible content in tables. Whenever pasting incompatible content, it will break the table into two, which I guess is to be expected? Some solutions we’re thinking around are

  1. allow all node types as content
  2. handle each case (e.g. different types of atom nodes) differently
  3. try to convert everything to compatible nodes aka text

Any pointers would be helpful, Thanks

I think many table setups do variant 1—allowing whatever is allowed at the top level inside tables. But when that is not an option, you will indeed probably want some kind of custom paste handler to ‘clean up’ pasted content inside cells.

I’m running into the same issue (when past rich text on table cell, the table is broken · Issue #1077 · TypeCellOS/BlockNote · GitHub) and wondering what you ended up doing @linsannety or if there’s any new guidance on this @marijn.

Variant 1 is not an option in our case; we don’t want to allow any content in tables at this point, but only allow simple paragraphs with simple formatting (marks). This follows the same UX as simple tables (not databases) in Notion. By restricting some of the possibilities, we find it helps users to create and maintain clean documents (i.e.: they can’t make a mess of documents by having nested tables, images / heading inside tables, etc).

I was thinking, we could:

  • preprocess HTML (seems a bit ugly)
  • modify existing parserules to not match when pasting in a table (not sure if this is possible, because we can’t have negation in the “context” parameter)
  • use a custom DOMParser with a subset of pasterules (haven’t tried this yet)

Thanks!