Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stevewithington/b215b7af9551aa59155c606cbb66c491 to your computer and use it in GitHub Desktop.
Save stevewithington/b215b7af9551aa59155c606cbb66c491 to your computer and use it in GitHub Desktop.
Mura CMS: How to add word count and character count to HTML Editors
/*
There's an elegant way to restrict character or word count in Mura CMS HTMLEditors.
1. Download the Word Count & Char Count Plugin:
https://ckeditor.com/cke4/addon/wordcount
2. Download the Notification plugin:
https://ckeditor.com/cke4/addon/notification
3. Unzip the the plugins and add the directories to the CKEditor plugins directory:
Pre-v7.1: /requirements/ckeditor/plugins/
v7.1+: /core/vendor/ckeditor/plugins/
4. Edit the file located under {ThemeName}/js/editor/config.js.cfm
(if the file doesn't exist, create it ... if the config.js.cfm.txt file exists, rename it to remove '.txt')
5. Add the following code to the config.js.cfm file.
*/
if ( 'CKEDITOR' in window) {
CKEDITOR.editorConfig = function( config ) {
config.extraPlugins += ',wordcount,notification';
/* To apply to ALL HTML Editors ...
config.wordcount = {
showParagraphs: true,
showWordCount: true,
showCharCount: true,
countSpacesAsChars: false,
countHTML: false,
countLineBreaks: false,
maxWordCount: -1,
maxCharCount: 300,
pasteWarningDuration: 0,
};
*/
};
// Applies character count restriction to the 'summary' editor ONLY
CKEDITOR.instances.summary.config.wordcount = {
showParagraphs: true,
showWordCount: true,
showCharCount: true,
countSpacesAsChars: false,
countHTML: false,
countLineBreaks: false,
maxWordCount: -1,
maxCharCount: 300,
pasteWarningDuration: 0
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment