Silverstripe 3:将自定义块添加到HtmlEditor字段

Silverstripe 3:将自定义块添加到HtmlEditor字段,silverstripe,Silverstripe,我想在html编辑器字段中添加创建“div”的选项 如何向格式下拉列表中添加一个选项,以创建具有特定类的div 我已经使用editor.css中的代码成功地将样式添加到样式下拉列表中 。响应表{ 溢出-x:滚动; } 我正在使用silverstripe 3,希望能够将我自己的选项添加到格式下拉列表中,以创建各种元素。在silverstripe 3中,我们可以通过将以下内容添加到我们的mysite/_config.php来编辑我们的htmleditor字段中的样式下拉列表项: HtmlEdito

我想在html编辑器字段中添加创建“div”的选项

如何向格式下拉列表中添加一个选项,以创建具有特定类的div

我已经使用editor.css中的代码成功地将样式添加到样式下拉列表中

。响应表{
溢出-x:滚动;
}

我正在使用silverstripe 3,希望能够将我自己的选项添加到格式下拉列表中,以创建各种元素。

在silverstripe 3中,我们可以通过将以下内容添加到我们的
mysite/_config.php
来编辑我们的
htmleditor字段中的样式下拉列表项:

HtmlEditorConfig::get('cms')->setOption('style_formats', [
    [
        'title' => 'Responsive table',
        'attributes' => ['class' => 'responsive-table'],
        'selector' => 'div',
    ],
]);
上述代码将使
htmleditor字段
样式下拉列表中有一项,即可应用于
div
元素的
响应表
选项。如果我们希望将其应用于
元素,我们可以在
选择器
选项中对其进行更改

下面是一个方便的模块,展示了如何在SilverStripe 3中更改
HTMLEditorField

我已经完成了这项工作并创建了一个div。但是,我也有一些自定义样式,我正在editor.css中编辑,包括使用
HtmlEditorConfig::get('cms')->setOption('content_css',project()。/css/editor.css')
是否可以在不将旧样式编码到config.php中的情况下使其仍能工作?不幸的是,我认为这是其中之一。您可以通过上述
setOption
style\u formats
方法或通过
setOption
content\u css
方法设置样式下拉列表的所有选项,该方法链接到
editor.css
文件中的类。