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: body.getCharacterCount() Returns 1 Instead of 0 After Entering and Deleting Multiple Spaces #9828

Open
Cho-SeongJu opened this issue Aug 16, 2024 · 2 comments

Comments

@Cho-SeongJu
Copy link

📝 Provide detailed reproduction steps (if any)

Please provide the steps to reproduce and if possible a minimal demo of the problem via fiddle.tiny.cloud or similar.

Hello. First, I want to mention that I am using the tiny editor effectively before submitting a bug report.
I am using the wordCount.body.getCharacterCount() method from const wordCount = editor.plugins.wordcount to check the character count of the editor. There is a bug where the count does not become 0 when the spacebar is pressed twice and then deleted. I would appreciate it if you could resolve this bug.

✔️ Expected result

What is the expected result of the above steps?

2024-08-16.3.23.09.mov

const wordCount = editor.plugins.wordCount; console.log(wordCount.body.getCharacterCount()) // expected result : 0

❌ Actual result

What is the actual result of the above steps?

However, when checking with console.log(), it shows 1 instead of 0.

console.log(wordCount.body.getCharacterCount()) // Actual result : 1

❓ Possible solution

If you have ideas, you can list them here. Otherwise, you can delete this section.

📃 Other details

  • Browser: …
  • OS: …
  • First affected version: …
  • Worked in version: …

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@lostkeys
Copy link
Member

Hi @Cho-SeongJu. I'm unable to replicate your issue. Typing two spaces and deleting them, then requesting the character count returns zero. See example. Can you replicate your issue in our fiddle?

@Cho-SeongJu
Copy link
Author

Cho-SeongJu commented Aug 16, 2024

@lostkeys

I am currently using the following versions.

"@tinymce/tinymce-react": "^4.3.0", "tinymce": "^6.3.1",

and example codes

import { Editor } from '@tinymce/tinymce-react';
import type { TinyMCEEditor } from 'tinymce';

const handleEditorValueChange = (value: string, editor: TinyMCEEditor) => {
    const wordCount = editor.plugins.wordcount;

    console.log(wordCount.body.getCharacterCount());  
}

<Editor
  onEditorChange={handleEditorValueChange}
/>
2024-08-16.4.17.05.mov

Is there a need for version upgrades?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants