TinyMCE:使用链接标签手动加载样式表

发布于 2024-11-29 04:47:29 字数 402 浏览 1 评论 0原文

我开始在现有项目中使用 TinyMCE。不幸的是,该项目使用了一个样式表,该样式表为选择器#content td声明了CSS规则,这是设计者的一个错误决定。这些规则打破了 TinyMCE 主题。然而,这些规则在项目中应用得非常频繁。因此,更换它们会非常费力。

#content td 规则具有更高的优先级,因为它们是在 TinyMCE 从 javascript 加载其 CSS 规则之前加载的。如果我能够使用 标签加载 TinyMCE CSS,我可以通过在项目样式表之前加载 TinyMCE 样式表来解决问题。

  • 这个假设正确吗?
  • 有没有办法通过链接标签手动加载tinyMCE样式表?
  • 您还有其他想法吗?

I'm starting to use TinyMCE in an existing project. Unfortunately the project uses a stylesheet which declares CSS rules for selector #content td, which was a bad decision by the designer. Theses rules are breaking the TinyMCE theme. However, the rules are applied very often in the project. Therefore, replacing them would be too much effort.

The #content td rules have higher priority because they are loaded before TinyMCE loads it's CSS rules from javascript. If I was able to load TinyMCE CSS by using a <link> tag, I could solve the problem by loading the TinyMCE stylesheet before the project's stylesheet.

  • Is the assumption correct?
  • Is there a way to manually load tinyMCE stylesheets via link-tag?
  • Do you have any other ideas?

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

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

发布评论

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

评论(2

静若繁花 2024-12-06 04:47:29

使用链接标签加载tinyMCE的样式与javascript并不能解决问题,因为问题在于CSS的特殊性。

CSS 规则规定,具有最高特异性的最后一个有效规则将优先。

TinyMCE的表规则的形式为.mceitemtable td,其特异性为0,1,1。
您的 #content td 规则以 ID 开头,其特异性为 1,0,1。

因此,ID 规则将始终胜过tinyMCE 基于类的规则,无论它们加载的顺序如何。

请参阅http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html 有关 CSS 特异性的更多详细信息。

(旁白:我不认为 TinyMCE 通过 javascript 加载其 CSS?tinyMCE 的默认行为是在 iframe 中加载编辑器,检查所述 iframe 显示该框架通过 < /code> 标签。)

Loading tinyMCE's styles using a link tag vs. javascript won't solve the problem, because the problem lies in CSS specificity.

The rules of CSS state that the last valid rule with the highest specificity will take precedence.

TinyMCE's table rules are of the form .mceitemtable td, which has a specificity of 0,1,1.
Your #content td rules begin with an ID, which has a specificity of 1,0,1.

Therefore, the ID rules will always win over tinyMCE's class-based rules, regardless of the order they're loaded.

See http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html for more detail about CSS specificity.

(Aside: I didn't think TinyMCE loaded its CSS via javascript anyway? The default behaviour for tinyMCE is to load the editor in an iframe, and inspecting said iframe shows that frame loads its own CSS via <link> tags.)

生生漫 2024-12-06 04:47:29

您可以加载自己的样式表以覆盖默认的tinymce css。查看tinymce设置content_css。

You are able to load your own stylesheet in order to overwrite default tinymce css. Have a look at the tinymce setting content_css.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文