TYPO3:如何向 RTE 添加元素,允许用户使用定义的 CSS 类
我希望用户能够在 RTE 中选择文本样式,例如“详细信息”、“重要信息”、“人员姓名”等。所以我想定义一个 CSS 并且这个选项应该在 RTE 中显示。 CSS 样式应该是 span
并且仅设置颜色。
目前我有以下代码:
RTE.classes{
highlight{
name = test
value = color:#0A8AD2;
}
}
RTE.default{
ignoreMainStyleOverride = 1
useCSS = 1
contentCSS = fileadmin/templates/css/rte_formats.css
classesCharacter := addToList(highlight)
classesParagraph := addToList(highlight)
proc.allowedClasses := addToList(highlight)
}
CSS 文件的内容是
span.highlight, p.highlight {
color:#0A8AD2;
}
但新添加的样式未显示在下拉列表中(textstyle)。我还在 rtehtmlarea 配置中启用了“附加内联元素”。我还尝试设置 showTagFreeClasses 等,但没有成功。然后我读到了缓存问题。我删除了 RTE 缓存以及浏览器缓存。还是没有结果。有什么问题吗?
I want that the user should be able to select an textstyle in RTE like Detail, Important, Name of person and so on. So I would like to define a CSS and this option should be shown in RTE. The CSS style should be a span
and only setting a color.
Currently I have the following code:
RTE.classes{
highlight{
name = test
value = color:#0A8AD2;
}
}
RTE.default{
ignoreMainStyleOverride = 1
useCSS = 1
contentCSS = fileadmin/templates/css/rte_formats.css
classesCharacter := addToList(highlight)
classesParagraph := addToList(highlight)
proc.allowedClasses := addToList(highlight)
}
The content of the CSS file is
span.highlight, p.highlight {
color:#0A8AD2;
}
But the new added style isn't shown in the drop down (textstyle). I also enabled "additonal inline elements" in th rtehtmlarea configuration. I also tried to set showTagFreeClasses
and so on without success. Then I read about caching problems. I deleted the RTE cache as well as the browser cache. Still no result. What can be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你基本上走在正确的轨道上!
我在使用 inlineStyle 时遇到了很多问题。其中之一是您必须显式取消定义
contentCSS
才能使内联工作(仅设置ignoreMainStyleOverride = 0
是不够的!):我个人更喜欢专用的外部 CSS文件。需要了解的重要一点是,TYPO3 RTE 确实会解析此 CSS 文件,并且仅提供实际在其中找到的那些类!
因此,您必须使用
contentCSS
参数来定义 CSS,并且该 CSS 必须确实包含您希望向用户提供的类。下面是您必须如何定义它:CSS 文件必须存在在给定的 URL 处,并且它必须包含您想要提供的 CSS 类的定义(如CSS 文件确实已解析,缺少的类不会显示在下拉选择器中):
还有一个提示:
我建议不要用您自己的类名覆盖 allowedClasses,而是附加到它们:
祝你好运!
You are basically on the right track!
I have experienced quite some problems using inlineStyle. One of them being that you have to explicitly undefine the
contentCSS
to make the inlines work (only settingignoreMainStyleOverride = 0
is not enought!):I personally prefer a dedicated external CSS file. The important thing to know is that the TYPO3 RTE really parses this CSS file and only offers those classes that are actually found in there!
So you have to use the
contentCSS
parameter to define a CSS and this CSS must really contain the classes that you want to make available to the user. Here is how you must define it:The CSS file must exist at the give URL and it must contain a definition for the CSS class that you want to provide (as said the CSS file is really parsed and missing classes will not show up in the dropdown selector):
And one more hint:
I recommend not to overwrite the allowedClasses with your own class name(s), but append to them:
Good luck!