2.0.0 • Published 2 years ago

@lifterlms/quill-wordcount-module v2.0.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 years ago

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 KeyTypeDefaultDescription
min?numbernullThe minimum required words. If null no minimum will be enforced.
max?numbernullThe maximum required words. If null no maximum will be enforced.
colorWarningstring#ff922bA CSS color code used when approaching the maximum word count.
colorErrorstring#e5554eA CSS color code used when below the minimum or above the maximum word count.
onChangeFunction-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.
l10nObject-An object of language strings used in the module's UI. See Localization below.

Options: Localization

Option KeyTypeDefaultDescription
l10n.singularstringwordThe singular unit.
l10n.pluralstringwordsThe plural unit.
l10n.minstringMinimumText to display for minimum count.
l10n.maxstringMaximumText 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.