fix: allow null and undefined for CharacterCount limit, fix #2276

This commit is contained in:
Philipp Kühn 2021-12-14 19:26:13 +01:00
parent 9e6fbd6c88
commit dd4bcb81f0
2 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ npm install @tiptap/extension-character-count
The maximum number of characters that should be allowed.
Default: `0`
Default: `null`
```js
CharacterCount.configure({

View File

@ -6,7 +6,7 @@ export interface CharacterCountOptions {
/**
* The maximum number of characters that should be allowed. Defaults to `0`.
*/
limit: number,
limit: number | null | undefined,
/**
* The mode by which the size is calculated. Defaults to 'textSize'.
*/
@ -35,7 +35,7 @@ export const CharacterCount = Extension.create<CharacterCountOptions, CharacterC
addOptions() {
return {
limit: 0,
limit: null,
mode: 'textSize',
}
},
@ -80,7 +80,7 @@ export const CharacterCount = Extension.create<CharacterCountOptions, CharacterC
const limit = this.options.limit
// Nothing has changed or no limit is defined. Ignore it.
if (!transaction.docChanged || limit === 0) {
if (!transaction.docChanged || limit === 0 || limit === null || limit === undefined) {
return true
}