tiptap/docs/api/extensions/character-count.md
2021-10-02 01:20:09 +02:00

1.3 KiB
Raw Blame History

CharacterCount

Version Downloads

The CharacterCount extension limits the number of allowed character to a specific length. Thats it, thats all.

Installation

# with npm
npm install @tiptap/extension-character-count

# with Yarn
yarn add @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

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 youre into.

new Editor({
  onUpdate({ editor }) {
    const wordCount = editor.state.doc.textContent.split(' ').length

    console.log(wordCount)
  },
})