An original museum newsletter contains a curator introduction, three exhibition notes and visitor information. An editor needs the length of the second exhibition note while keeping the full issue's total visible. A single unlabeled number would leave the editor unsure which text it describes.
Add the counter and the detailed dialog
Add wordcount to the existing plugin list. Add the same identifier to the toolbar if authors need a visible dialog button:
const countOptions = {
plugins: 'wordcount',
toolbar: 'undo redo | wordcount'
};
Merge these entries with the application's normal TinyMCE configuration; retain its other plugins, toolbar controls, selector and license settings. With the status bar enabled, the plugin provides a counter there. Clicking that status-bar counter switches between words and characters. The dialog provides the fuller breakdown, including the selection when one exists.
A custom application control can open the dialog on the correct initialized instance:
editor.execCommand('mceWordCount');
Select only the second exhibition note before opening it. Decide whether the note's heading belongs in the requested count, then keep that same selection policy when comparing revisions.
Label body and selection statistics explicitly
This helper reads two different scopes:
function readIssueCounts(editor) {
const counter = editor.plugins.wordcount;
return {
issueWords: counter.body.getWordCount(),
selectedWords: counter.selection.getWordCount(),
selectedCharacters: counter.selection.getCharacterCount(),
selectedCharactersWithoutSpaces:
counter.selection.getCharacterCountWithoutSpaces()
};
}
Use labels such as “Whole issue” and “Selected text.” Update the selection statistics when the author changes the selection, as well as when the document changes. If there is no text selection, show that condition clearly instead of leaving the previous passage's total on screen.
An external button can change focus or selection. Read the selection while it still represents the author's intended passage, and verify the actual button's behavior in the running application. The code above reads the current state; it does not preserve a previous selection for you.
Understand the boundaries before comparing another tool
TinyMCE defines word boundaries explicitly. Spaces, commas and forward slashes divide words; embedded hyphens, full stops and colons do not. Under those documented rules, these short fixtures illustrate different segmentation:
| Passage | Boundary rule to examine |
|---|---|
archive-room |
The embedded hyphen keeps the expression together |
archive/room |
The forward slash separates the terms |
archive,room |
The comma separates the terms |
archive:room |
The embedded colon keeps the expression together |
Use these as comparison inputs in your installed editor. Do not assume another newsletter system, language or submission portal applies the same algorithm. If a receiving system owns the final limit, compare representative passages there.
The plugin also excludes certain characters added for document management. Its documentation illustrates empty paragraphs containing nonbreaking spaces that do not add to the character total. Consequently, the length of editor.getContent() is not the visible-text count: that string includes HTML markup and serialization details.
Keep counting separate from a length restriction
The Word Count plugin supplies statistics. A publication rule that rejects long notes needs its own defined scope and validation. This newsletter's editor might shorten the second note while leaving the whole issue longer; a document-wide rejection would address a different task.
For a form that enforces a final submission limit, the word-count submission guide explains why current capture and server validation require separate consideration. Use the APIs for your own installed editor when implementing that policy.
Return to the newsletter and select the revised second note, including the agreed heading. Read its words and characters, clear the selection and confirm the whole-issue total remains labeled correctly. Then save the wording through the normal document workflow; the displayed statistic is not a saved revision by itself.