如何使Froala编辑器允许所有内联HTML标签?

3

我正在使用"froala"编辑器将电子邮件模板添加到数据库中,但是"froala"编辑器总是会删除一些HTML标记,例如:

<div [removed]="table-layout:fixed; width: 100%;" class="mailwrapper">
<br>

<table [removed]="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-smooth: always; -webkit-font-smoothing: antialiased; height: 16px; -premailer-height: 16;" align="center" cellpadding="0" cellspacing="0" class="mainTable">

这是我的代码

    $(function () {
    $('#editor').froalaEditor({
        inlineMode: false,
        //toolbarInline: true,
        charCounterCount: true,
        toolbarButtons: ['fontFamily', 'fontSize', 'color', 'paragraphFormat', 'bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', '|', 'align', 'formatOL', 'formatUL', 'indent', 'outdent', '-', 'insertImage', 'insertLink', 'emoticons', 'insertVideo', 'insertTable', 'undo', 'redo', 'fullscreen', 'html'],
        toolbarVisibleWithoutSelection: true,
        heightMin: 500,
        height: 500,
        htmlAllowedTags: ['.*'],
        htmlAllowedAttrs: ['.*'],
        allowedContent : true
    });
});
1个回答

0

我阅读了压缩/美化版本的Froala,我怀疑通配符在这种情况下不起作用。

Froala选项块不是实现您想要的功能的好方法,因为您允许的标记和属性替换默认允许的标记列表,而不是扩展它。

我选择在代码中修改编辑器的allowedHtmlTags数组,在我的插件的_init代码中。您不需要插件即可完成此操作,该代码也可以在编辑器引导序列期间的事件侦听器中应用。

    public _init() {
// ... misc init code
        const opts: any = this._editor.opts;
// just routine safety
        if (opts.htmlAllowedTags && opts.htmlAllowedTags.push) {
            opts.htmlAllowedTags.push("myTag");
        }
    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接