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]: Pasting formatted content over the CharacterCount limit doesn't seem to work - content left blank #4820

Open
1 of 2 tasks
tobewisebeforeiamold opened this issue Jan 22, 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

@tobewisebeforeiamold
Copy link

Which packages did you experience the bug in?

CharacterCount, react

What Tiptap version are you using?

2.1.15

What’s the bug you are facing?

When using CharacterCount.configure({ limit: 240 }) and attempting to paste in more than 240 characters that is not unformatted text from the clipboard, the input remains empty.

I can reproduce this in the "Usage" example on at the bottom of https://tiptap.dev/docs/editor/api/extensions/character-count#usage.

This page (https://tiptap.dev/blog/release-notes/new-character-count-extension) seems to indicate that this copy/paste behavior is a bug.

To Reproduce

  1. Visit https://tiptap.dev/blog/release-notes/new-character-count-extension and select all of the paragraphs and ordered list from that page and copy it to your clipboard
  2. Then visit https://tiptap.dev/docs/editor/api/extensions/character-count and scroll down to the "Usage" section
  3. Paste in the text you copied into your clipboard into that example - see that the copy does not change; that the pasted content is rejected

What browser are you using?

Firefox

Code example

https://tiptap.dev/docs/editor/api/extensions/character-count#usage

What did you expect to happen?

If I configure CharacterCount to use a limit of 240 characters, and I paste in 250 characters, even if it's formatted, I would expect to see 240 of those 250 characters

Anything to add? (optional)

No response

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. 💖
@tobewisebeforeiamold tobewisebeforeiamold 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 Jan 22, 2024
@xavivars
Copy link

xavivars commented Apr 6, 2024

I'm facing this same problem. It's a bug in this part of the code:

https://github.com/ueberdosis/tiptap/blob/main/packages/extension-character-count/src/character-count.ts#L115C10-L119C81

In my case, I'm not pasting any complex node: I'm literally pasting a long text file that contains no format at all: it's coming with a .txt file with a lot of lines (which become paragraphs). In my case, tr.doc.content.size is 22730, while newSize is being calculated as 21516 (I'm working with a limit of 10000).

After deleting the amount of characters that are supposed to be over (11516), the remaining size is 10664.

To be honest, the behavior is pretty unintuitive.

@tsl1127
Copy link

tsl1127 commented Apr 29, 2024

i have the same problem(when i use insertContent with many nodes at once);It would be best if it can be intercepted automatically

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

3 participants