TinyMCE剥离HTML [英] TinyMCE stripping HTML

查看:640
本文介绍了TinyMCE剥离HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初我认为问题是与iframe,但现在我已经意识到问题是从TinyMCE剥离HTML从文本。



我试图使TinyMCE停止剥离iframe标签,让我保存到数据库。我试图使用extended_valid_elements,但TinyMCE不服从配置,并继续剥离iframe的标签。我一直在寻找2天已经,我想我错过了一些非常基本的,因为我只是不能找到一个解决方案,也没有任何人有同样的问题,这不是因为他们错了东西...

我复制了TinyMCE文档中的完整配置并从那里开始工作。



我的配置:

  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媒体| forecolor背景颜色表情,
模板:[
{title:'测试模板1',内容:'测试1'},
{title:'测试模板2' '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,
});





当我点击预览按钮,然后将其保存到bd中,它会正确显示iframe(和所有其他东西,比如对齐一个例子) 。



现在我已经意识到问题不是与iframe,而是与一切,因为我保存格式化的文本到bd,并通过编辑我的

解决方案

问题是我正在处理文本两次,一次保存,另一个显示它。当我处理文本只显示它,没有问题。


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.

解决方案

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.

这篇关于TinyMCE剥离HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆