0
votes

I'm working on an email client within an HTML web application and am using TinyMCE as the text editor. One of my requirements is to allow the input of full HTML email creatives and am attempting to paste them into the source code input. When I do this however and save it, TinyMCE appears to be removing a lot of the code from the pasted creative, for example the doctype tag, html tags, entire head section (including inline CSS), and various other tags for example tbody etc.

I've also noticed that the text within the title tag has been put inside p tags at the start of the document.

Ideally I'd prefer to have the ability to paste the full document and not have any of the source altered, any suggestions would be appreciated.

Here is the code I'm using to initialise TinyMCE:

tinymce.init({
    selector: '.js-email-editor',
    plugins: [
        'advlist autolink lists link image charmap print preview hr anchor pagebreak legacyoutput',
        'searchreplace wordcount visualblocks visualchars code',
        'insertdatetime media nonbreaking save table contextmenu directionality',
        'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help'
    ],
    toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
    toolbar2: 'print preview media | forecolor backcolor emoticons | codesample help',
    image_advtab: true,
    content_css: [
        '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
        '//www.tinymce.com/css/codepen.min.css'
    ],
    branding: false,
    valid_elements: '*[*]'
});
2

2 Answers

1
votes

The fullpage plugin will allow TinyMCE to work with a full HTML page of content. By default, you are working with items inside the <body> tag of an HTML document. Running the fullpage plugin will allow you to work with the entire page.

https://www.tinymce.com/docs/plugins/fullpage/

0
votes

In "Tools" tab in menu you can switch to "Source code". Paste your code as the source code and then go back to WYSIWYG editor.