mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 01:12:56 +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.
|
||||
|
||||
Default: `0`
|
||||
Default: `null`
|
||||
|
||||
```js
|
||||
CharacterCount.configure({
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user