0
votes

I want to insert custom html code in document via code button (like this for example taken from bootstrap + some JS code):

<link rel="stylesheet" ref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>

<script>
    $(document).ready(function() {
    console.log("Hello world");
        });
</script>

I wan't this to be in the source code of the document (not in text) so it can be rendered properly. I have tried many settings (it would be long list, I spent whole afternoon with this smile) but nothing works, i.e. code is stripped / changed when I close the code window and open again. for the context, I use TinyMCE as editor for CMS and sometimes there is need to add extra style or javascript library So I would be very grateful if somebody could post tinymce 4.2 init settings which allows this... or say if it's even possible

1

1 Answers

1
votes

You may use the tinymce command mceInsertContent:

my_editor_instance.execCommand('mceInsertContent', ui, '<my>html</my>');