0

I am building a Drupal 7 boostrap subtheme. I don't want users to be able to add their own fonts and styles to content. I want to force them to use the paragraph and heading tags as defined in my site's CSS.

When users paste in from other sources (eg word) I do not want the styles brought in. Additionally, our site uses Open Sans. This is not appearing in the TinyMCE font list, can this be fixed?

How does one do this with TinyMCE?

3
  • Add style to the tags of the text that TinyMCE generates it
    – M a m a D
    Commented Jul 7, 2015 at 5:54
  • Excuse my ignorance, but how does one do that?
    – tanbog
    Commented Jul 7, 2015 at 23:54
  • I give you my solution as an answer
    – M a m a D
    Commented Jul 8, 2015 at 0:03

1 Answer 1

0

I had the same issue with CKEditor. the h1,h2,h3,h4,h5,p tags and color picker were available to the user But we wanted every available tag to has a custom color. To do so I put the CKEditor output which was body inside a DIV with some ID,say node-body-wrapper, then added styles like this

#node-body-wrapper h1{
     color : red !important;
} 

...

In this way I solved the problem. I recommend you to do the same.

7
  • I do not like this answer. It seems an abuse of the !important flag and not optimal CSS. Why can TinyMCE simple be toold NOT to add inline font and font-size styles?
    – tanbog
    Commented Jul 26, 2015 at 5:25
  • You can eliminate !important and it still works. I usually look for the most straightforward solutions.
    – M a m a D
    Commented Jul 26, 2015 at 5:36
  • Ok but then my markup is still littered with completely redundant inline styles.
    – tanbog
    Commented Jul 26, 2015 at 11:48
  • It is not inline style, inline styles are on html tags!!! Besides that inline styles are not redundant, they have more priority than other styles.
    – M a m a D
    Commented Jul 26, 2015 at 14:08
  • TinyMCE places style tags in-line, directly on the html output. That is what I am trying to avoid. It is filling my page's html with pointless style tags.
    – tanbog
    Commented Jul 27, 2015 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.