gpt4 book ai didi

silverstripe - 如何在 Silverstripe 4 的 HTMLEditorField 内容编辑器中向元素添加 css 样式?

转载 作者:行者123 更新时间:2023-12-04 15:59:02 25 4
gpt4 key购买 nike

在 SS 3.x 中,我们可以使用以下代码通过 Styles 下拉列表将自定义元素添加到 HTMLEditorField 内容编辑器中。我的主要用途是将标准链接变成样式化的按钮链接。

我们如何在 SS 4.x 中实现这一目标?

这是在 3.x 中的做法

_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);

最佳答案

看起来您需要做的就是创建一个 editor.css 文件,将您的样式放入其中,然后将以下代码片段放入您的 mysite/_config.php 文件。

use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;

TinyMCEConfig::get('cms')
->addButtonsToLine(1, 'styleselect')
->setOption('importcss_append', true);

样式会自动添加到下拉列表中。

引用:https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/typography/#custom-style-dropdown

关于silverstripe - 如何在 Silverstripe 4 的 HTMLEditorField 内容编辑器中向元素添加 css 样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50978397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com