Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix new lines being added via elementFromString #4767

Merged
merged 1 commit into from Jan 10, 2024

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Jan 10, 2024

Please describe your changes

This PR fixes an issue that adds new lines on the parser level of the browser. It traverses through the actual dom instead of using string replacements removing all newlines added additionally by the parser.

How did you accomplish your changes

See above

How have you tested your changes

I added a new test to check if newlines are kept in pre tags.

How can we verify your changes

Check out the local demo of Issue #2720

Checklist

  • The changes are not breaking the editor
  • Added tests where possible
  • Followed the guidelines
  • Fixed linting issues

Copy link

netlify bot commented Jan 10, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 15af206
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/659e8ba977648f00080ab08f
😎 Deploy Preview https://deploy-preview-4767--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bdbch bdbch merged commit b7a2504 into develop Jan 10, 2024
14 checks passed
@bdbch bdbch deleted the fix/linebreak-fix branch January 10, 2024 12:43
bdbch added a commit that referenced this pull request Jan 10, 2024

removeWhitespaces(html)

return removeWhitespaces(html)
Copy link

@yurtsiv yurtsiv Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but does it have to be two calls of removeWhitespaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - going to remove this for the next patch release.

@Marvelousy20
Copy link

Updated @tiptap/core to v2.2.1 and this issue is still there.

@bdbch
Copy link
Contributor Author

bdbch commented Feb 5, 2024

What kind of content do you try to insert into the editor? @Marvelousy20

@Marvelousy20
Copy link

Marvelousy20 commented Feb 5, 2024

What kind of content do you try to insert into the editor? @Marvelousy20

I created some custom nodes, so I am passing them like this. The name of the node here is textarea.

{
      title: "Text Area",
      icon: "/dashboard/h3.svg",
      command: ({ editor, range }) =>
        editor
          .chain()
          .insertContentAt(range, {
            type: "textarea",
          })
          .focus()
          .run(),
    },

@okejminja
Copy link

Any updates regarding this issue?
When trying to call .insertContentAt() with <p>content</p> I get an unnecessary paragraph inserted above my content

editor.commands.insertContentAt(
  insertAfter,
  {
    type: "paragraph",
    content: [{ type: "text", text: modifiedContent }],
  },
  { parseOptions: { preserveWhitespace: false } },
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants