Table Cell with just <br /> parsed from old editor

Table Cells created with an old editor were creating “br”'s as the only content when they were empty. And because of the hard break it’s creating multiple lines for table cells with this content.

I know its not really a Prosemirror problem, but I’d like find out if there is a way I can parse a table cell with just a “br” in it and remove the “br” if it’s the only content.

You could pre-process the HTML or DOM data to remove such <br> nodes before you give it to ProseMirror’s parser.

1 Like

Thanks, turns out pasting out of the old editor is also a problem, so I’ve used the following regex pre DOMParser and transformPastedHTML

html.replace(/<td(?:[^>]*)>(?:[^<]*)<br(?:[^>]*)>(?:[^<]*)<\/td>/gi, '<td><\/td>')

Edit: Sorry that regex is pretty crude, I’ll refine it a bit to ensure if other content exists with a single br it doesn’t just clear it.