@lifterlms/quill-wordcount-module
v2.0.0
Published
Wordcount module for Quill.js
Downloads
4
Readme
Quill Word Count Module
Word count module for Quill.
Uses words-count to perform word counting in multiple languages and character sets.
Installation
Install the module
npm install --save @lifterlms/quill-wordcount-module`
After loading Quill use the module:
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.
},
},
},
} );
} )();
Changelog
Options
| Option Key | Type | Default | Description |
| ------------ | ---------- | ------- | ------------------------------------------------------------------------------ |
| min | ?number
| null
| The minimum required words. If null
no minimum will be enforced. |
| max | ?number
| null
| The maximum required words. If null
no maximum will be enforced. |
| colorWarning | string
| #ff922b | A CSS color code used when approaching the maximum word count. |
| colorError | string
| #e5554e | A CSS color code used when below the minimum or above the maximum word count. |
| onChange | Function
| - | 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. |
| l10n | Object
| - | An object of language strings used in the module's UI. See Localization below. |
Options: Localization
| Option Key | Type | Default | Description |
| ------------- | ---------- | ------- | ------------------------------------------------------------------------------ |
| l10n.singular | string
| word | The singular unit. |
| l10n.plural | string
| words | The plural unit. |
| l10n.min | string
| Minimum | Text to display for minimum count. |
| l10n.max | string
| Maximum | Text to display for maximum count. |
API Docs
default
Registers the Word Count module with Quill.
Returns
Boolean
: Returnstrue
when registered andfalse
if Quill is not available.