mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-25 04:19:02 +08:00
1.3 KiB
1.3 KiB
description | icon |
---|---|
Limit the number of characters in your editor, or at least count them. | calculator-line |
CharacterCount
The CharacterCount
extension limits the number of allowed character to a specific length. That’s it, that’s all.
Installation
npm install @tiptap/extension-character-count
Settings
limit
The maximum number of characters that should be allowed. |
Default: 0
CharacterCount.configure({
limit: 240,
})
Source code
packages/extension-character-count/
Usage
https://embed.tiptap.dev/preview/Extensions/CharacterCount
Count words, emojis, letters …
Want to count words instead? Or emojis? Or the letter a? Sure, no problem. You can access the textContent
directly and count whatever you’re into.
new Editor({
onUpdate({ editor }) {
const wordCount = editor.state.doc.textContent.split(' ').length
console.log(wordCount)
},
})