kinglozzer/htmleditorstylinghook

Allows adding CSS classes to HTMLEditorFields for styling hooks

Installs: 4 639

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 3

Forks: 2

Language:JavaScript

Type:silverstripe-vendormodule

2.0.0 2018-06-06 09:00 UTC

This package is auto-updated.

Last update: 2024-04-04 21:24:13 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