如何将css样式添加到Silverstripe 4中HTMLEditorField内容编辑器中的元素?
在SS3.x中,我们可以使用以下代码通过如何将css样式添加到Silverstripe 4中HTMLEditorField内容编辑器中的元素?,silverstripe,silverstripe-4,Silverstripe,Silverstripe 4,在SS3.x中,我们可以使用以下代码通过样式下拉列表将自定义元素添加到htmleditor字段内容编辑器中。我的主要用途是将标准链接转换为样式化的按钮链接 我们如何在SS4.x中实现这一点 在3.x中就是这样做的 \u config.php <?php $formats = array( array( 'title' => 'Buttons' ), array( 'title' => 'Custom Button',
样式
下拉列表将自定义元素添加到htmleditor字段
内容编辑器中。我的主要用途是将标准链接转换为样式化的按钮链接
我们如何在SS4.x中实现这一点
在3.x中就是这样做的
\u config.php
<?php
$formats = array(
array(
'title' => 'Buttons'
),
array(
'title' => 'Custom Button',
'attributes' => array('class'=>'custom-btn'),
'selector' => 'a'
)
);
//Set the dropdown menu options
HtmlEditorConfig::get('cms')->setOption('style_formats',$formats);
看起来您只需创建一个编辑器.css
文件,将您的样式放入其中,然后将以下代码片段放入您的mysite/\u config.php
文件中
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
TinyMCEConfig::get('cms')
->addButtonsToLine(1, 'styleselect')
->setOption('importcss_append', true);
样式将自动添加到下拉列表中
参考: