1

我在网站上有多个(6)个具有两个不同类(.html_edit_simple、.html_edit_advanced)的可编辑项,我想将它们按类划分,每个都有自己的 contentHandler 设置。

但无论我尝试什么,都只会加载默认设置。

下面定义的那些window.Aloha.settings.contentHandler.handler.sanitize根本不适用。

我使用的设置代码如下:

(function(window, undefined) {
    if (window.Aloha === undefined || window.Aloha === null) {
        window.Aloha = {};
    }

    window.Aloha.settings = { sidebar: { disabled: true } };
    window.Aloha.settings.contentHandler = {
        insertHtml: [ 'word', 'generic', 'oembed', 'sanitize' ],
        initEditable: [ 'sanitize' ],
        getContents: [ 'blockelement', 'sanitize', 'basic' ],
        sanitize: 'relaxed', // relaxed, restricted, basic,
        allows: {
            elements: ['strong', 'em', 'i', 'b', 'blockquote', 'br', 'cite', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'i', 'li', 'ol', 'p', 'pre', 'q', 'small', 'strike', 'sub', 'sup', 'u', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'img', 'video', 'audio']
        },
        handler: {
            generic: {
                transformFormattings: false
            },
            sanitize: {
                '.html_edit_simple': { elements: [ 'b', 'i', 'strong', 'em', 'strike', 'u', 'a' ] },
                '.html_edit_advanced': { elements: [ 'b', 'i', 'strong', 'em', 'strike', 'u', 'a', 'br', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'sub', 'sup', 'ul', 'ol', 'li', 'div', 'img', 'video', 'audio' ] }
            }
        }
    }
})(window);

我在 Aloha.ready 之前制作了一个控制台日志,并且所有内容都正确加载。那么问题可能出在哪里。

4

0 回答 0