CharacterCount not working when multiples editor instances live in the same page
See original GitHub issueWhat’s the bug you are facing?
@tiptap/extension-character-count
not working when two or more editors instances live in the same page.
- The first editor instance does not update unless the second editor instance updates
- When the first editor instance update char count, it updates using the char count of the second editor instance
How can we reproduce the bug on our side?
- Create an editor using https://tiptap.dev/api/extensions/character-count extension, remember to display the char count using
editor.storage.characterCount.characters()
- Invoke two instances of the previously created editor on the same page
- Update each editor content
Can you provide a CodeSandbox?
https://codesandbox.io/s/lively-glade-8h4rc8?file=/src/App.js
What did you expect to happen?
Each editor instance should update char count separately
Anything to add? (optional)
Nope
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. 💖
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to make show a character counter for several textareas in ...
You need to do querySelectorAll on all the inputs and then attach a oninput event listener, like this: var textareas = document.
Read more >Word Count & Char Count Plugin | CKEditor.com
WordCount Plugin for CKEditor that counts the words an shows the word count in the footer of the editor. DEMO Page. License.
Read more >How to count characters in Excel cell and range - Ablebits
Want to know how many characters there are in a certain cell? This tutorial will help you choose an Excel formula for character...
Read more >Video: Work with word counts in your document
To see the number of words in your document, look at the status bar at the lower left bottom of the Word window....
Read more >Show word count - Microsoft Support
Word counts the number of words in a document while you type. Word also counts pages, paragraphs, lines, and characters. Windows macOSWeb.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So the reason why having multiple contexts without using
.configure
is not working right now is because of the way the extensions are created. Right now, when you write your own extension you need to write something like this:The important thing here is, that we are not creating a new instance here but create one global instance of the extension right at the point where the extension is created.
In Extension.ts line 318 we can see, that
Extension.create
is doing the following:That means we will always have one object instanced from this Extension class for every editor. The
Extension.configure
function is callingExtension.extend
which will create a new child extension everytime it’s called which is why it’s working fine when.configure
is used.I referenced this in a new ticket #2694.
@obetomuniz @cooliopas I hope for now my temporary solution works fine!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.