feat: add some improvements to CharacterCount extension (#2256), fix #1049, fix #1550, fix #1839, fix #2245

* fix a bug when exceeding the character limit

* find a better way to limit the doc size

* check paste events

* add storage method

* refactoring

* use textBetween instead of textContent

* return early if no limit is set

* add words method to storage

* show word count in charactercount demo

Co-authored-by: Philipp Kühn <philippkuehn@MacBook-Pro-von-Philipp.local>
This commit is contained in:
Philipp Kühn
2021-12-08 21:26:30 +01:00
committed by GitHub
parent f0b363c475
commit 5daa870b09
8 changed files with 170 additions and 45 deletions

View File

@@ -92,13 +92,6 @@ editor.isActive('heading', { level: 2 })
editor.isActive({ textAlign: 'justify' })
```
### getCharacterCount()
Get the number of characters for the current document.
```js
editor.getCharacterCount()
```
### registerPlugin()
Register a ProseMirror plugin.
@@ -124,14 +117,14 @@ editor.setOptions({
},
})
```
### setEditable()
Update editable state of the editor.
| Parameter | Type | Description |
| --------- | ------- | ------------------------------------------------------------- |
| editable | boolean | `true` when the user should be able to write into the editor. |
```js
// Make the editor read-only
editor.setEditable(false)