You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.3 KiB
1.3 KiB
layout | title | title_nav | description | keywords |
---|---|---|---|---|
default | Word Count plugin | Word Count | Show a word count in the TinyMCE status bar. | wordcount |
The Word Count plugin adds the functionality for counting words to the TinyMCE editor by placing a counter on the right edge of the status bar. Clicking Word Count in the status bar switches between counting words and characters. A dialog box with both word and character counts can be opened using the menu item situated in the Tools drop-down, or the toolbar button.
Type: String
Example
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "wordcount",
toolbar: "wordcount"
});
API
The Word Count plugin exposes an API for retrieving the word and character count of either the whole document or the current editor selection. Following is an example of how to retrieve each property.
Example
var wordcount = tinymce.activeEditor.plugins.wordcount;
console.log(wordcount.body.getWordCount());
console.log(wordcount.body.getCharacterCount());
console.log(wordcount.body.getCharacterCountWithoutSpaces());
console.log(wordcount.selection.getWordCount());
console.log(wordcount.selection.getCharacterCount());
console.log(wordcount.selection.getCharacterCountWithoutSpaces());