Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

tinymce能不能不过滤内容,如link,style,script标签被过滤

当前配置

{
        // selector: 'textarea',
        // plugins是tinymce的各种插件
        plugins: 'link lists image code table colorpicker textcolor wordcount contextmenu codesample',
        // 语言包可以使用tinymce提供的网址,但是墙的原因,会连不上,所以还是自行下载,放到assets里面
        language_url: '/assets/plugs/tinymce/zh_CN.js',
        language: 'zh_CN',
        // toolbar定义快捷栏的操作, | 用来分隔显示
        toolbar: 'codesample | bold italic underline strikethrough | fontsizeselect | forecolor backcolor | alignleft'
            + ' aligncenter alignright alignjustify | bullist numlist | outdent indent blockquote | undo redo '
            + '| link unlink image code | removeformat | h2 h3 h4',
        height: 600,
        // 这里是代码块的一些语言选择,好像暂时还没支持typescript,所以博文都是js格式
        codesample_languages: [
            { text: 'HTML/XML', value: 'markup' },
            { text: 'JavaScript', value: 'javascript' },
            { text: 'CSS', value: 'css' },
            { text: 'Java', value: 'java' }
        ],
        extended_valid_elements: 'link,script,style',
        paste_webkit_styles: true,
        valid_children : '+div[style]',
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

加了一些配置

valid_elements: '*[*]',
valid_children: '*[*]',
extended_valid_elements: 'style,link[href|rel],script',
custom_elements: 'style,link,~link,script',

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...