kinglozzer/htmleditorstylinghook

允许为HTMLEditorFields添加CSS类以进行样式钩子操作

安装次数: 4,676

依赖: 0

建议者: 0

安全: 0

星标: 8

关注者: 3

分支: 2

语言:JavaScript

类型:silverstripe-vendormodule

2.0.0 2018-06-06 09:00 UTC

This package is auto-updated.

Last update: 2024-09-04 22:10:47 UTC


README

#HtmlEditorStylingHook#

一个模块,允许轻松地为SilverStripe的HtmlEditorField实例添加CSS类。

###简单示例###

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;
}

目前仅在CMS中使用。要与其他HtmlEditorConfig实例一起使用,只需复制_config.php中的方法即可。