Wordcount module for Quill.js
npm install @lifterlms/quill-wordcount-moduleWord count module for Quill.
Uses words-count to perform word counting in multiple languages and character sets.
Install the module
``bash
npm install --save @lifterlms/quill-wordcount-module
``
After loading Quill use the module:
`jsx
import quillWordcountModule from '@lifterlms/quill-wordcount-module';
( function() {
// Registers the module with Quill.
quillWordcountModule();
// Loads the module in a new editor instance.
const ed = = new Quill( '#my-quill-container', {
modules: {
wordcount: {
onChange: ( quill, options, wordCount ) => {
// Do something when the editor's text updates and you need to know the new word count.
},
},
},
} );
} )();
`
| Option Key | Type | Default | Description |
| ------------ | ---------- | ------- | ------------------------------------------------------------------------------ |
| min | ?number | null | The minimum required words. If null no minimum will be enforced. |?number
| max | | null | The maximum required words. If null no maximum will be enforced. |string
| colorWarning | | #ff922b | A CSS color code used when approaching the maximum word count. |string
| colorError | | #e5554e | A CSS color code used when below the minimum or above the maximum word count. |Function
| onChange | | - | Callback function invoked when the quill text changes. This function is passed 3 parameters: the quill object, the module options object, and the current number of words. |Object
| l10n | | - | An object of language strings used in the module's UI. See Localization below. |
| Option Key | Type | Default | Description |
| ------------- | ---------- | ------- | ------------------------------------------------------------------------------ |
| l10n.singular | string | word | The singular unit. |string
| l10n.plural | | words | The plural unit. |string
| l10n.min | | Minimum | Text to display for minimum count. |string
| l10n.max | | Maximum | Text to display for maximum count. |
Registers the Word Count module with Quill.
_Returns_
- Boolean: Returns true when registered and false` if Quill is not available.