question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CharacterCount counts non-existing characters

See original GitHub issue

What happens? CharacterCount extension counts non-existing characters.

An empty editor with CharacterCount enabled will show +2 for every newline, and + 4 for every list; even though there are no characters. When adding characters, the count increments on top of those non-existing counted characters.

I haven’t tested “Code” and “CodeBlock”, but I expect a similar result.

Steps to reproduce the behavior:

1. Go to the editor on https://next.tiptap.dev/api/extensions/character-count/
2. On a newline, type "Enter".
3. See count + 2, where it should be + 0.
1. Create a default editor with "Ordered List" or "Unordered List".
2. Add "CharacterCount" extension.
2. On a newline, create a list.
3. See count + 4, where it should be + 0.

Create a new Codesandbox replicating your error Try in the documentation editor: https://next.tiptap.dev/api/extensions/character-count/

What behavior did you expect? Count +0 on newlines and lists.

What’s your environment?

  • macOS
  • Chrome
  • Desktop

Anything else? I haven’t tested “Code” and “CodeBlock”, but I expect a similar result.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
philippkuehncommented, Mar 27, 2021

Maybe we could add an option { mode: 'nodeSize' | 'textSize' }?

0reactions
hanspagelcommented, Mar 30, 2021

This is used in the Editor too, so that would require us to add the ability to register helper functions through extensions. 👀

https://github.com/ueberdosis/tiptap-next/blob/main/packages/core/src/Editor.ts#L426

Read more comments on GitHub >

github_iconTop Results From Across the Web

Character Count Tool - The Best Character Counter
The must-have character counter that provides an extensive report about the character count, word count, and many other useful statistics.
Read more >
Character Counter - WordCounter.net
Character Count is a free online tool that calculates the number of characters and words written in your writing.
Read more >
How to Stay Under the Character Count in Essay Contests
If the rules don't explicitly state that some characters are excluded from the character count, play it safe by counting them all.
Read more >
Count characters in cells - Microsoft Support
Count characters in cells by using the LEN function. This topic explains how to count one or more cells and use LEN in...
Read more >
Count the number of occurrences of a character in a string
For this particular instance, counting characters, I would prefer collections.counter. For finding instances of a specific substring, I would use a regular ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found