Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type="mce-text/javascript" gets added in tiny mce editor html

Tags:

jquery

tinymce

In TinyMCE editor, while editing HTML, I have added some JS references at the start

<script type="text/javascript" src="Scripts/swiping.js"></script>

which I am using for swiping the <div>'s in my html page.

But sometimes (scenario is not exactly getting reproduced), mce gets added in the type property of the script.

so it becomes,

<script type="mce-text/javascript" src="Scripts/swiping.js"></script>

Because of this, the browser is not recognizing the script and my page swiping logic which is inside the script doesn't work.

Does anyone know the reason why text/javascript is turning into mce-text/javascript?

like image 764
Marcus25 Avatar asked Jun 27 '13 05:06

Marcus25


People also ask

How do you add text in TinyMCE?

For tinyMCE v5 in 2022 You dont need the mceInsertContent command anymore, just add the event to the element you are dragging: var dragCallback = function (e) { e. dataTransfer. setData('Text', 'my-text'); }; document.

How do I re initialize TinyMCE editor?

Use tinymce. remove() method to remove TinyMCE editor from the HTML element and again call tinymce. init() on the selector to reinitialize.


1 Answers

This just happened to me as well.

The replacement happens when you go to your editing page, and then hit refresh. I think that what's happening is that on the first page load, script tags are being replaced with type="mce-text/javascript", which should then be stripped out on save.

Then on page refresh, this text is inserted by your browser, and then TinyMCE sees that the type is already present, so flags the script tag as not needing cleanup when you save.

The only solution I've found is to realise that you shouldn't hit refresh when editing the page. I realise that this isn't a great solution, but at least it should allow you to reproduce the issue.

like image 143
Ben Hitchcock Avatar answered Oct 21 '22 20:10

Ben Hitchcock