Sitecore 富文本编辑器的单独 .css 文件

Separated .css file for Sitecore Rich Text Editor

我正在尝试在 Sitecore 富文本编辑器中使用自定义样式。我找到了描述如何操作的文章,但我必须将我的样式放在 default.css 文件中。 我想在单独的 .css 文件中添加我的自定义样式以避免潜在的问题(例如,在升级版本时覆盖默认的 .css 文件等)。 有没有办法同时使用 default.css 和 custom.css 文件?

您可以使用 @import 规则:https://developer.mozilla.org/en/docs/Web/CSS/@import

您唯一需要做的就是在 default.css 文件的开头添加这一行:

@import 'customStyles.css';

它仍然是 default.css 中的一个更改,但只有一个,如果您升级,您会注意到您的自定义样式不再存在,因此您会记得将此 @import customStyle.css 行添加到新的default.css 文件。

您可以将配置中 WebStylesheet 设置的值更新为您希望使用的 css 文件的位置。 RTE 将改为加载它。

<!--
  WEB SITE STYLESHEET
            CSS file for HTML content of Sitecore database.
            The file pointed to by WebStylesheet setting is automatically included in Html and Rich Text fields.
            By using it, you can make the content of HTML fields look the same as the actual Web Site

-->
<setting name="WebStylesheet">
  <patch:attribute name="value">/location/to/custom.css</patch:attribute>
</setting>

以上使用补丁配置来更新值。