简体   繁体   English

关于TinyMCE内容CSS的问题

[英]Question about TinyMCE content CSS

I am facing a problem with TinyMCE . 我面对TinyMCE的问题。

I am developing a functionality on the administration side of my website, where the administrator can edit the content of pages. 我正在网站的管理端开发一项功能,管理员可以在其中编辑页面内容。 I have provided them with the TinyMCE for that purpose. 我已为此目的向他们提供了TinyMCE。

Suppose they are editing Page 'page1'. 假设他们正在编辑页面“ page1”。

They will provide its content in TinyMCE, and save it. 他们将在TinyMCE中提供其内容并保存。

When somebody is visiting that Page 'page1' all I am doing is: 当有人访问该页面“ page1”时,我要做的是:

  <html>
      <head>.........</head>
      <body>
          .......
          <div class='page_content'>
              <?php echo $page1->getContent(); ?>
          </div>
          ......
      </body>
  </html>

Everything is working fine. 一切正常。

Now, TinyMCE provides a feature where you tell which CSS will it use. 现在,TinyMCE提供了一项功能,您可以在其中告诉它将使用哪种CSS。 You set the required CSS to the 'content_css' property of the TinyMCE init function. 您将所需的CSS设置为TinyMCE初始化函数的'content_css'属性。

I did that, I provided the CSS which I was using to style my page content. 我这样做了,我提供了用来设置页面内容样式的CSS。

Now, my problem is this: 现在,我的问题是这样的:

The content of my page is in div.page_content . 我页面的内容在div.page_content But in TinyMCE, the content of this page is not in any other thing (any div.page_content ). 但是在TinyMCE中,此页面的内容没有任何其他内容(任何div.page_content )。 So the style which TinyMCE is applying to my content, while I am editing it, is not visually effective. 因此,在我编辑内容时,TinyMCE应用于我的内容的样式在视觉上无效。

The only way, which I can think of, for resolving this problem is by telling TinyMCE to add 我能想到的解决此问题的唯一方法是告诉TinyMCE添加

   <div class='page_content'>

at the top. 在顶部。 And then, when the administrator submits the data, I will just strip this extra div. 然后,当管理员提交数据时,我将删除该额外的div。

Any suggestions? 有什么建议么?

There is an option in TinyMCE configuration called 'body_class'. TinyMCE配置中有一个名为“ body_class”的选项。 You just have to add "body_class = 'page_content'" 您只需要添加“ body_class ='page_content'”

The way I would solve this is by adding the class "mceContentBody" to the CSS definitions with a comma as seperator. 我要解决此问题的方法是将类“ mceContentBody”添加到带有逗号作为分隔符的CSS定义中。 For example: 例如:

.page_content, .mceContentBody {
   put your code here..
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM