@lifterlms/quill-wordcount-module

2.0.0 • Public • Published

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

View the 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: Returns true when registered and false if Quill is not available.

Package Sidebar

Install

npm i @lifterlms/quill-wordcount-module

Weekly Downloads

0

Version

2.0.0

License

GPL-3.0-or-later

Unpacked Size

52.8 kB

Total Files

18

Last publish

Collaborators

  • chrisbadgett
  • brianhogg
  • jasonlifter