4
votes

I've been trying to stop the latest version of Umbraco's tinyMCE editor from automatically stripping any script tags. This was working fine some months ago. Umbraco has not been updated to my knowledge.

I have tried a number of solutions, mostly summed up in this thread: https://our.umbraco.org/forum/using/ui-questions/48866-RTE-not-updating-to-show-new-HTML-tags-in-Umbraco-7

I have edited umbracoSettings.config

<content>
    <TidyEditorContent>False</TidyEditorContent>
    <errors>...

And have allowed all in validElements in tinyMceConfig.config

<validElements><![CDATA[*[*]]]></validElements>

Finally I changed wed.config in order to force Umbraco to reload.

I still cannot get the script tags to save?

Any suggestions appreciated.

2

2 Answers

1
votes

First off, This Is A Very Bad Idea (tm) - don't do it - you'll open it up to all sorts of problems.

The better way to do it is develop a macro that takes a block of text as a parameter, and make that macro useable in the Richtext Edit control.

Your Macro Script can then render the input any way you want, including using script tags (which probably should be part of the macro script). This way you have complete control over what's rendered.

0
votes

I know this is old but this works on all versions of 7+

To enable javascript to be added to the editor you need to change the following.

You need to replace some of the configs in the config > tinyMceConfig.config file

<![CDATA[+a[id|style|rel|data-id|data-udi|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|
ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],
-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|reversed|start|style|type],-ul[class|style],-li[class|style],br[class],
img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align|umbracoorgwidth|umbracoorgheight|onresize|onresizestart|onresizeend|rel|data-id],
-sub[style|class],-sup[style|class],-blockquote[dir|style|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],
-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],
thead[id|class],tfoot[id|class],#td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],
-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],
-span[class|align|style],-pre[class|align|style],address[class|align|style],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],
-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|style|dir|class|align|style],hr[class|style],small[class|style],
dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang],object[class|id|width|height|codebase|*],
param[name|value|_value|class],embed[type|width|height|src|class|*],map[name|class],area[shape|coords|href|alt|target|class],bdo[class],button[class],iframe[*],script[language|type|src]]]>
  </validElements>
  <invalidElements>font</invalidElements>
  <!-- this area is for custom config settings that should be added during TinyMCE initialization -->
  <customConfig>
    <!--    <config key="myKey">mySetting</config>-->
    <config key="entity_encoding">raw</config>
    <config key="codemirror">
      {
      "indentOnInit": false,
      "path": "../../../../lib/codemirror",
      "config": {
      },
      "jsFiles": [
      ],
      "cssFiles": [
      ]
      }
    </config>
<config key="allow_script_urls">true</config>