kinglozzer / htmleditorstylinghook
Allows adding CSS classes to HTMLEditorFields for styling hooks
Package info
github.com/kinglozzer/htmleditorstylinghook
Language:JavaScript
Type:silverstripe-vendormodule
pkg:composer/kinglozzer/htmleditorstylinghook
2.0.0
2018-06-06 09:00 UTC
Requires
This package is auto-updated.
Last update: 2026-03-05 01:32:45 UTC
README
#HtmlEditorStylingHook#
A module to allow easy adding of CSS classes to SilverStripe's HtmlEditorField instances.
###Simple example###
HomePage.php
<?php use SilverStripe\Forms\FieldList; class HomePage extends Page { public function getCMSFields() { $this->beforeUpdateCMSFields(function (FieldList $fields) { if ($content = $fields->dataFieldByName('Content')) { $content->setAttribute('data-mce-body-class', 'HomePage'); } }); return parent::getCMSFields(); } }
editor.css
.HomePage { background: #000; color: #fff; }
Currently only set up for use in the CMS. To use with a different HtmlEditorConfig instance, simply copy the approach in _config.php