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
?
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.
Use tinymce. remove() method to remove TinyMCE editor from the HTML element and again call tinymce. init() on the selector to reinitialize.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With