Question

In TinyMCE version 3.3.9.4, it was possible to limit the styles to alignment (rejecting coloring options and the like), by using the ´undocumented´ valid_styles option (TinyMCE valid elements: only allow specific CSS rules):

    valid_styles : { '*' : 'text-align' },

Now with the 4.x version, this doesn't seem to work any more. Is there a way to filter valid styles in TinyMCE 4.x, preferably by using built-in editor (client side) methods?

Was it helpful?

Solution

valid_styles seems well documented for version 4 :

This option enables you specify the available styles for each element. This means you can force ordering and only specific styles to be valid within style attribute values. Specify the element name, then it's styles or * for all elements.

tinymce.init({
    ...
    valid_styles: {
        "*": "border,font-size",
        "div": "width,height"
    }
});

Here is a tinymce fiddle you can play with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top