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:
@@ -449,8 +449,12 @@ export class Editor extends EventEmitter<EditorEvents> {
|
||||
|
||||
/**
|
||||
* Get the number of characters for the current document.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public getCharacterCount(): number {
|
||||
console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.')
|
||||
|
||||
return this.state.doc.content.size - 2
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user