#TinyMCE: Style and Script Elements

We have begun using TinyMCE as the primary editor in our CMS system.  Some of the functionality is to store pages that are later rendered as html on websites.  This means that often our designers are adding custom javascript and css styles to pages.  In our most recent release we found that when we switched to TinyMCE we lost the functionality to add custom scripts and styles to the pages.  After a mad dash we found that adding the following code to the TinyMCE editor allows the user to enter <style> and <script> elements via the Source Code window.   TinyMCE does add comments around the code that is added but they do not affect the functionality.

TinyMCE Initalization Settings

//Allow html script, style, etc tags to work in the editors
extended_valid_elements: 'pre[*],script[*],style[*]', 
valid_children: "+body[style|script],pre[script|div|p|br|span|img|style|h1|h2|h3|h4|h5],*[*]",
valid_elements : '*[*]', 

TinyMCE Example Input

<script type="text/javascript">
$(function () {
    Console.log('test');
  });
</script>



<style>
h2 {
        color: #FF0000;
    }
</style>


TinyMCE Example Output

<script type="text/javascript">// <![CDATA[ $(function () { Console.log('test'); }); // ]]></script>


<style><!-- h2 { color: #FF0000; } --></style>


OSS University

Open Source SocietyMy day job is as a software engineer building websites.  I’ve been building software for 15+ years and am always looking at ways to upgrade my skills.  Yesterday I came across this great site that has gathered together free resources that people can use to get themselves a Computer Science education without enrolling in college.  It’s a great resource for people who want to dip their toes in, or to refresh their skills without going back to school.  It would be a wonderful path for a teenager who wants to get started on a solid path for a CS degree.

This is a solid path for those of you who want to complete a Computer Science course on your own time, for free, with courses from the best universities in the World.

In the future, more categories and/or courses will be added to this list or a more advanced/specialized list.

Initially, we will also give preference to MOOC (Massive Open Online Course) type of courses because those courses were created with our style of learning in mind.

~ OSS University