composer require drmartingonzo/ss-tinymce-charcount ^1.1.0
- SilverStripe CMS ^4.0
In your _config.php file, add :
use SilverStripe\Forms\HTMLEditor\HtmlEditorConfig;
use SilverStripe\Core\Manifest\ModuleResourceLoader;
Then add whatever plugins you wish to enable, + charcount
HtmlEditorConfig::get('cms')
->enablePlugins([
'template',
'fullscreen',
'hr',
'contextmenu',
'charmap',
'visualblocks',
'lists',
'charcount' => ModuleResourceLoader::resourceURL('drmartingonzo/ss-tinymce-charcount:client/dist/js/bundle.js'),
])
Finally run dev/build
with flush to remove previous TinyMCE javascript cache.
Set data-maxchar
on HTMLEditorField.
Example :
HTMLEditorField::create(
"Content",
'Content'
)->setAttribute('data-maxchar', 526),
Set data-maxword
on HTMLEditorField.
Example :
HTMLEditorField::create(
"Content",
'Content'
)->setAttribute('data-maxword', 120),