tiptap: [Bug]: 2.1.15 and up breaks dozens of our tests

Which packages did you experience the bug in?

core

What Tiptap version are you using?

2.1.15

What’s the bug you are facing?

This version and 2.1.16 break a dozen of our tests which seemingly have nothing to do with the only documented change:

fix(core): fix insertContentAt keeping new lines in html content by @bdbch in https://github.com/ueberdosis/tiptap/pull/4465

The tests that are broken are as diverse as special modes of splitting list items to handling pasted links to inserting lines above the current line.

Even tests which don’t seem to use insertContentAt in any way are broken.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

Patch versions should never break tests.

Anything to add? (optional)

I really don’t want to be needing to rethink complex logic all over our app because of this change caused by an issue that originated almost 2 years ago (https://github.com/ueberdosis/tiptap/issues/2720)

I tried updating our insertContentAt calls to use preserveWhitespace with 'full', true and false - all result in still broken tests.

Do we have any remedy here besides just not upgrading until we find spare weeks for this? We’re never going to have time to fix all of the problems that change caused.

Example of broken output:

    Expected: "<p>https://example.org\"&gt;https://example.org|&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;|</p>"
    Received: "<p>|</p>"

@svenadlung @bdbch

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

For your case I created a fix at #4895 which would reuse the same logic insertContent is using. In theory that should help.

Yeah I’m running into the same problem. I’ll check out what’s happening.

I’ll try your case with a set content test

I added the following test in our latest version:

it('should keep newlines and tabulators', () => {
  cy.get('.tiptap').then(([{ editor }]) => {
    editor.commands.insertContent('<p>Hello\n\tworld\n\t\thow\n\t\t\tnice.</p>')
    cy.get('.tiptap').should('contain.html', '<p>Hello\n\tworld\n\t\thow\n\t\t\tnice.</p>')
  })
})

and it seems to work I think?

image

Same with newlines and tabulators inside pre tags:

image

I guess that’s how it is supposed to look like?

Also do you know which version was the last version that was working? Then I could compare the versions up to the point this test would break and figure out where the root cause comes from.

I guess 2.1.14?

Sorry for the late answer. I was already taking a look into this but didn’t had time to get finished. I’ll get back at this ASAP as the changes I made should not lead to such issues and were not intended.

I’ll add tests for the usecases you specified as we lack tests currently that try to add this type of content into the editor currently.