Attention

This document was written for an old version of Plone, Plone 2.5.x, and was last updated 1596 days ago.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Allow all inline styles in Kupu

by Mike Takahashi last modified Feb 04, 2009 03:03 AM
How to disable Kupu's filtering of all inline styles

By default, Kupu does not allow the use of inline styles unless they are specified in the Style Whitelist.

For example, if you have some HTML as follows:

<div style="width:20px; background-color: #CCCCCC;"> Content Here </div>

Kupu replaces it with:

<div>Content Here</div>

The current method to allow inline style elements such as “width” and “background-color” require you to manually enter it in the Style Whitelist in Kupu’s preferences. However, if you want to allow the use of all inline styles you need to modify kupucontentfilters.js

In the ZMI, go to your Plone Instance. Customize the file /portal_skins/kupu/kupucontentfilters.js and remove the following function call:

if (val) {
    var styles = val.split(/; */);
    for (var i = styles.length; i >= 0; i--) if (styles[i]) {
        var parts = /^([^:]+): *(.*)$/.exec(styles[i]);
        var name = parts[1].toLowerCase();
        if (validation.styleWhitelist[name]) {
            styles[i] = name+': '+parts[2];
        } else {
            styles.splice(i,1); // delete
        }
    }
    if (styles[styles.length-1]) styles.push('');
        val = styles.join('; ').strip();
}

Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.