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: