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
allow all node types as content
handle each case (e.g. different types of atom nodes) differently
try to convert everything to compatible nodes aka text
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.
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)