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

CharacterCount config limit doesn't work correctly #2245

Closed
1 of 2 tasks
minhlt-fa opened this issue Dec 7, 2021 · 2 comments · Fixed by #2256
Closed
1 of 2 tasks

CharacterCount config limit doesn't work correctly #2245

minhlt-fa opened this issue Dec 7, 2021 · 2 comments · Fixed by #2256
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@minhlt-fa
Copy link

What’s the bug you are facing?

I have issue when I use extension CharacterCount

  1. When I press Enter, the function editor.getCharacterCount() count character is 2.
  2. When I type and reach the limit, then I set the caret in the middle of the text. If I type, the new text will insert and remove the last text

How can we reproduce the bug on our side?

Issue 1:

  1. Import extension CharacterCount
  2. Use editor.getCharacterCount() below the editor to show the character have count like Usage in document https://tiptap.dev/api/extensions/character-count
  3. Check charecter

Issue 2:

  1. Import extension CharacterCount and set config limit
  2. Type text reach to the limit
  3. Set caret in the middle of the text
  4. Type some text and watch the last text

Can you provide a CodeSandbox?

https://codesandbox.io/s/character-count-error-qe7yz?file=/src/App.vue

What did you expect to happen?

I expect in
Issue 1: When I press Enter then character just count 1 instead of count 2
Issue 2: Can not type in the middle of the text if reach the limit

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. 💖
@minhlt-fa minhlt-fa added the Type: Bug The issue or pullrequest is related to a bug label Dec 7, 2021
@philippkuehn
Copy link
Contributor

For the future please create a separate issue for each bug.

First issue is a duplicate of #1839

@minhlt-fa
Copy link
Author

Yes, I will separate issue for each bug next time. Thank you so much.

philippkuehn added a commit that referenced this issue Dec 8, 2021
…#1049, fix #1550, fix #1839, fix #2245

* fix a bug when exceeding the character limit

* find a better way to limit the doc size

* check paste events

* add storage method

* refactoring

* use textBetween instead of textContent

* return early if no limit is set

* add words method to storage

* show word count in charactercount demo

Co-authored-by: Philipp Kühn <philippkuehn@MacBook-Pro-von-Philipp.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants