WordCountButton Plugin Documentation
The WordCountButton
plugin is a valuable addition to the On-Codemerge editor that allows users to easily count the number of words and characters in their editor content. This plugin is particularly useful for writers, editors, and content creators who need to keep track of their text's length and word count.
Installation
To integrate the WordCountButton
plugin with the On-Codemerge editor, follow these steps:
- Import the
WordCountButton
class from the plugin package. - Initialize an instance of
EditorCore
. - Register the
WordCountButton
as a module using theregisterModule
method.
Here's an example of how to integrate the WordCountButton
plugin:
on-CodeMerge
import EditorCore from 'on-codemerge';
import { WordCountButton } from 'on-codemerge/wordCountButton';
document.addEventListener('DOMContentLoaded', () => {
const appElement = document.getElementById('app');
if (appElement) {
const editor = new EditorCore(appElement);
// Create and register the WordCountButton module
const wordCountButton = new WordCountButton();
editor.registerModule(wordCountButton);
}
});
Usage
The WordCountButton
plugin is a simple yet powerful tool for anyone using the On-Codemerge editor for content creation. By enabling real-time word and character counting, it helps you keep track of your content's length and ensures you meet specific word count requirements.
Features
Real-time Word and Character Count
- Word Count: The plugin provides a real-time word count for the content within the editor. It counts words as non-empty elements separated by spaces.
- Character Count: It also displays the character count for the content, including spaces.
Immediate Updates
- Instant Feedback: The word and character counts are updated instantly as you type or modify the content in the editor. You always have the latest counts at your fingertips.
User-Friendly Display
- Display Elements: The plugin adds two display elements to the editor's footer: one for word count and one for character count. These elements are updated automatically.
Example Usage
Imagine you are working on a writing project with a specific word limit. You can utilize the WordCountButton
plugin to keep track of your progress. Here's how:
- Open the On-Codemerge editor with the
WordCountButton
plugin integrated. - Start typing or paste your content into the editor.
- As you work, observe the "Words" and "Chars" counts in the editor's footer. These counts update in real-time.
- Keep an eye on the word count to ensure it meets your project's requirements.
Conclusion
The WordCountButton
plugin enhances the functionality of the On-Codemerge editor by providing a simple yet valuable feature for content creators. With real-time word and character counting, you can efficiently manage your writing tasks and meet specific content length requirements.