mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 09:25:29 +08:00
fix: allow null and undefined for CharacterCount limit, fix #2276
This commit is contained in:
parent
9e6fbd6c88
commit
dd4bcb81f0
@ -20,7 +20,7 @@ npm install @tiptap/extension-character-count
|
|||||||
|
|
||||||
The maximum number of characters that should be allowed.
|
The maximum number of characters that should be allowed.
|
||||||
|
|
||||||
Default: `0`
|
Default: `null`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
CharacterCount.configure({
|
CharacterCount.configure({
|
||||||
|
@ -6,7 +6,7 @@ export interface CharacterCountOptions {
|
|||||||
/**
|
/**
|
||||||
* The maximum number of characters that should be allowed. Defaults to `0`.
|
* 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'.
|
* The mode by which the size is calculated. Defaults to 'textSize'.
|
||||||
*/
|
*/
|
||||||
@ -35,7 +35,7 @@ export const CharacterCount = Extension.create<CharacterCountOptions, CharacterC
|
|||||||
|
|
||||||
addOptions() {
|
addOptions() {
|
||||||
return {
|
return {
|
||||||
limit: 0,
|
limit: null,
|
||||||
mode: 'textSize',
|
mode: 'textSize',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -80,7 +80,7 @@ export const CharacterCount = Extension.create<CharacterCountOptions, CharacterC
|
|||||||
const limit = this.options.limit
|
const limit = this.options.limit
|
||||||
|
|
||||||
// Nothing has changed or no limit is defined. Ignore it.
|
// 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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user