Tiptap: Adding rowspan="1" and colspan="1"

I’ve noticed that Tiptap adds colspan="1" rowspan="1" to all my tables, this should not be needed as far as I can see?

I understand that this does not really have any impact but I just don’t like to store and render unnecessary attributers.

Did anyone face the same problem and found a solution?

I tried to replace the built in extensions for Umb.Tiptap.Table but it felt like a rabbit hole.

So I ended up with a tiptapExtension that just preforms a monkey patch of the getHTML() method of Tiptap.

export default class HtmlCleanupTiptapExtensionApi extends UmbTiptapExtensionApiBase {

  getTiptapExtensions = () => [];

  override setEditor(editor: Editor | undefined) {

      super.setEditor(editor!);

      if (!editor) {
          return;
      }

      const originalGetHtml = editor.getHTML.bind(editor);

      editor.getHTML = () => {
          const html = originalGetHtml();
          return cleanTableHtml(html);
      };
  }
}

If someone has a better or cleaner approach I would love to hear!

I’m not sure why you would want to do that. To me, this seems like adding additional logic that can break over time for the sake of saving a few bytes. I would like to invite you to read my blog about it :wink:

@Luuk I did see your blog post and you have some fair points that I do agree with. But I also think that Tiptap is broken in some ways and that you’re basically encourage readers to accept flaws or straight out issues - that does not cut it for me :slight_smile:

We’re migrating a site where this does matter so I’m not looking for a discussion around it - I was looking for approaches to solve the problem.

My point was: just leave it in, what’s the issue with that? Just to be clear, I will never say that TipTap is perfect and I think there have been serious issues with it :slight_smile: . So I didn’t mean to defend TipTap, but in thas case, I really feel like: why would you want to change the behaviour?

I dove a little deeper into this issue and I think we can consider it a ‘bug’ in TipTap v2. In v2, TipTap created an extension for working with certain table stuffs. Before that it only relied on ProseMirror’s functionality (the base engine) and that ACTUALLY strips colspan and rowspan if the value is 1/default.

With TipTap v2 and the new extension that they introduced, they didn’t do this. I would consider it an oversight. It’s the default values for colspan and rowspan, so it’s not neccessarily bad perse, just redundant. And I would consider it a bug because the underlying engine actually removes them explicitly.

I created a bug report with them: TableCell and TableHeader serialize default colspan="1" and rowspan="1" attributes · Issue #8176 · ueberdosis/tiptap · GitHub