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

[Bug]: Newline characters are replaced with spaces when any key is pressed #5501

Open
1 task done
gabe-ambit opened this issue Aug 15, 2024 · 1 comment
Open
1 task done
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@gabe-ambit
Copy link

Affected Packages

core, react

Version(s)

2.5.9

Bug Description

When newline (\n) characters are inserted into the editor, any change to the editor content immediately replaces all of them with spaces.

To reproduce:

  1. Extend Paragraph this way:
Paragraph.extend({
      addKeyboardShortcuts() {
        return {
          Enter: () => this.editor.commands.insertContent("\n"),
        };
      },
    })
  1. Hit enter a few times in the editor to create some newlines.

  2. Type any other character.

Note: preserveWhitespace doesn't seem to have any impact here.

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

I expect newlines to be preserved, at least if preserveWhitespace is enabled.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@gabe-ambit gabe-ambit added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Aug 15, 2024
@elliott-king
Copy link

Also having this issue - example codepen. I tried passing content as a raw string, and also tried generateJSON beforehand.

My guess: generateJSON creates a paragraph array with only one element: a string containing the \n characters. However, the editor usually represents these a new elements in the array / new <p> tags. Seems like the code editor can't handle the newline character correctly. I'm not sure if this is an issue with tiptap, or prosemirror.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Triage open
Development

No branches or pull requests

2 participants