silverstripe - 将样式添加到“样式”中编辑器上的下拉菜单

发布于 2024-08-19 09:39:31 字数 66 浏览 8 评论 0原文

从上面的问题来看,我认为这相对容易,但我找不到任何有关如何将样式添加到“样式”下拉菜单的文档。谁能把我推向正确的方向?

from the question above, I thought it would be relatively easy but i can not find any documentation on on how to add styles to the 'styles' drop down menu. can anyone push me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鼻尖触碰 2024-08-26 09:39:31

样式下拉列表会根据主题的typography.css 文件中找到的类自动填充。要添加类,只需确保它们已在那里定义即可。或者,如果您想为类提供更友好的名称或从列表中删除某些类,您可以通过将其放入 _config.php 文件中来显式定义要列出的样式。

HtmlEditorConfig::get('cms')->setOption('theme_advanced_styles', 
    'Name 1=class1;Name 2=class2');

这是TinyMCE(WYSIWYG 编辑器组件)提供的功能,这一行只是设置TinyMCE 在CMS 使用时的theme_advanced_styles 设置。 TinyMCE 站点上的这个帖子 也对此进行了讨论。

另请注意下面 Markus 的回答: editor.css 需要位于主题 css 文件夹中并包含typography.css。

The styles dropdown is automatically populated based on classes found in your theme's typography.css file. To add classes, just ensure that they are defined there. Alternatively, if you want to give the classes friendlier names or to remove some classes from the list, you can explicitly define the styles that you want listed by putting this in your _config.php file.

HtmlEditorConfig::get('cms')->setOption('theme_advanced_styles', 
    'Name 1=class1;Name 2=class2');

It's a feature provided by TinyMCE, the WYSIWYG editor component, and this line is just setting the theme_advanced_styles setting of TinyMCE when used by the CMS. This thread on the TinyMCE site also discusses it.

Also note Markus' answer below: editor.css needs to be in the theme css folder and include the typography.css.

恋你朝朝暮暮 2024-08-26 09:39:31

@Sam Minnée 的答案只有在 editor.css 也在主题 css 文件夹中并且包含typography.css 的情况下才有效。

这是更详细说明 这两个如何一起玩。

如果您在编辑器中显示新样式时遇到问题,请尝试以下操作:

  • yoursite.com/admin/?flush=1
  • 检查 mythemes/css/editor.css 文件的文件权限。它应该可以被网络服务器用户读取。

The answer of @Sam Minnée only works, if the editor.css is also in the theme css folder and includes the typography.css.

Here is a more detailed description of how these two play together.

If you have troubles getting the new styles appear in the editor, try the following:

  • yoursite.com/admin/?flush=1
  • Check the file permissions on your mythemes/css/editor.css file. It should be readable by the webserver user.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文