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]: Active marks stop applying to new text after cursor moves from an empty line to another empty line #5849

Closed
1 task done
sophie-meruscase opened this issue Nov 20, 2024 · 2 comments
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

@sophie-meruscase
Copy link

sophie-meruscase commented Nov 20, 2024

Affected Packages

react

Version(s)

2.9.1

Bug Description

When using any extension involving marks such as bold, textstyle (font family), etc., if you hit enter, go to another line, and then move the cursor back to the empty line, the active style doesn't apply to the new text when you start typing. This does not happen if you start typing just after hitting enter, only if you move away from the empty line and then back to it. This is observable in the fontFamily example from TipTap's own documentation.

bug.mov

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

The active style should apply to any new text even if the line starts empty.

Extra Information

editor.on('selectionUpdate', () => {
    const isEmpty = (editor.isEmpty || editor.state.selection.$head.parent.content.size === 0);
    if (isEmpty) {
      editor.chain().focus().setFontFamily(fontFamily).run();
    }
  })

Adding this to the editor will cause the font family to be applied on blank lines, but one would have to check for and manually apply all styles here for any mark, so it's not an ideal solution.

Dependency Updates

  • Yes, I've updated all my dependencies.
@sophie-meruscase sophie-meruscase 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 Nov 20, 2024
@nperez0111
Copy link
Contributor

font-family is a mark that applied to text, so when the paragraph has no text, it cannot preserve the font-family. So, this is expected behavior.

You could maybe try to apply font-family at the paragraph level but you'd still need it as a mark to change the font within a line.

Either way, I don't think there is a good solution here in Tiptap, you can handle it in your application if you deem it necessary.

@sophie-meruscase
Copy link
Author

@nperez0111 Thank you for the reply, but I don't feel this fully addresses the issue. This is a problem not just for font family, but for bold, italics, underline, and I'm sure many other marks as well. Solutions for all these, if they are even possible, degrade performance since they involve checks at every selection update.

Please think of this from a user's perspective. Would you expect all the styling you have active to disappear when moving the cursor down to a blank line? Of course not. There is no text editor out there that would behave this way.

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
None yet
Development

No branches or pull requests

2 participants