TinyMCE stripping HTML

一笑奈何 提交于 2019-12-11 04:49:09

问题


Originally I thought the problem was with the iframe, but now I've realized the problem is with TinyMCE stripping HTML from the Text.

I'm trying to make TinyMCE stop from stripping the iframe tags for me to save into the database. I tried to use the extended_valid_elements, but TinyMCE doesn't obey to the configuration and keep stripping the iframe's tags. I've been looking for 2 days already and I think i've missed something very basic because I just can't seem to find a solution, nor anybody who have the same problem and it's not because they mistyped something...

I copied the full configuration on the TinyMCE documentation and worked from there.

My configuration:

tinymce.init({
    selector: "textarea",
    theme: "modern",
    plugins: [
    "advlist autolink lists link image charmap print preview hr anchor pagebreak",
    "searchreplace wordcount visualblocks visualchars code fullscreen",
    "insertdatetime media nonbreaking save table contextmenu directionality",
    "emoticons template paste"
    ],
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter     alignright alignjustify | bullist numlist outdent indent | link image",
    toolbar2: "print preview media | forecolor backcolor emoticons",
    templates: [
    {title: 'Test template 1', content: 'Test 1'},
    {title: 'Test template 2', content: 'Test 2'}
    ],
    language: "pt_BR",
    extended_valid_elements: "iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder]",  
    document_base_url: "<?php echo base_url(); ?>",
    relative_urls: true,  
});

Thanks in advance.

When I click on the preview button before saving it into the bd it shows the iframe correctly (And all the other stuff too, like alignments for an example).

Now I've realized that the problem is not with iframe, but with everything, because after I save the formatted text into the bd and open it again by editing my post everything is deconfigured and even in the preview button I only see the stripped html.


回答1:


i think use global pass for elements you want

extended_valid_elements:"iframe[*]"

hope this 'll help




回答2:


The problem was that I was treating the text twice. Once to save it, another to show it. When I treat the Text only to show it, there was no problem.



来源:https://stackoverflow.com/questions/16366883/tinymce-stripping-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!