-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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]: While setting content
directly while using CharacterCount with limit is not obeyed
#5851
Comments
Character count is implemented as filtering transactions. So if an edit were to occur, it will either reject the transaction or attempt to slice it such that it fits. tiptap/packages/extension-character-count/src/character-count.ts Lines 99 to 154 in 93bc933
This is not run on the initial content (perhaps because the initial content would be expected to be valid?). Because it is waiting for a transaction that changes the document. That can probably be resolved by having a flag that if it has not run before, it can run on a transaction that did not even change the document. A number of transactions go through after creation so only one of them would be needed to trigger the re-evaluation. Feel free to contribute a PR implementing this or another solution you find. |
@nperez0111 Thanks for your input, I have raised a PR for this, please take a look when you get a chance |
…nt with limit is not obeyed ueberdosis#5851
…nt with limit is not obeyed ueberdosis#5851
…nt with limit is not obeyed ueberdosis#5851
v2.10.3 resolves this |
Affected Packages
core,extension-character-count,react
Version(s)
2.10.x
Bug Description
I thought I messed up something, my editor was not recognizing the content, it was just white screen. After investigating I found out that, I was using
CharacterCount
extension with limit set to1000
, my content length was longer than that.Now there's another bug that I found is, my setup use the below way to set the content,
While the limit is obeyed and no content is set in the above way, but by directly passing the
content
to theuseEditor
hook sets the content in the editor bypassing the limit.I have added a CodeSandbox to reproduce this issue, please let me know if I can be of help
Browser Used
Firefox
Code Example URL
https://codesandbox.io/p/sandbox/tiptap-react-qidlsv
Expected Behavior
The
content
should not be set when thelimit
is set & the size of the content is longer than the allowed limit.Additional Context (Optional)
No response
Dependency Updates
The text was updated successfully, but these errors were encountered: