Hi Prabu,
What you want is possible. The simplest fix is to use the following ckeditor.config.overlayed.json value:
{
extraAllowedContent: ‘p{*}’
}
Some background: the default configuration of rich text fields already contains the following ‘extraAllowedContent’ property [1]:
embed[allowscriptaccess,height,src,type,width]; img[border,hspace,vspace]; object[align,data,height,id,title,type,width]; p[align]; param[name,value]; table[width]; td[valign,width]; th[valign,width];
It specifies the ‘p’ tag with the allowed attribute ‘align’:
p[align]
Adding the attribute ‘style’ won’t work because CKEditor’s advanced content filter (a.k.a. client-side HTML cleaning) treats styling separately. You can specify the allowed CSS properties between curly braces. For example, to only allow the ‘color’ and ‘padding’ properties use:
p{color,padding}
It’s also possible to allow all CSS properties using p{*} .
More background: the long default extraAllowedContent property value primarily exists for backwards-compatibility. The ‘simple fix’ above overrides it completely. The safest fix is to extend the default value with the extra configuration for the ‘p’ tag. In Hippo 11, that’s only possible by re-specifying the whole extraAllowedContent property in ckeditor.config.overlayed.json:
{
extraAllowedContent: ‘embed[allowscriptaccess,height,src,type,width]; img[border,hspace,vspace]; object[align,data,height,id,title,type,width]; p[align]{*}; param[name,value]; table[width]; td[valign,width]; th[valign,width];’
}
In version 12 it has become easier to extend the default extraAllowedContent property using ckeditor.config.appended.json. The default config there uses the ‘object notation’ instead of the ‘string notation’. See [3] for more details.
BTW: spec-wise, a ‘style’ attribute is valid for any HTML element. It’s a ‘global’ attribute [3].
hth,
Mathijs
[1] https://code.onehippo.org/cms-community/hippo-cms/blob/hippo-cms-4.2.11/richtext/ckeditor/frontend/src/main/java/org/hippoecm/frontend/plugins/ckeditor/CKEditorNodePlugin.java#L80
[2] https://www.onehippo.org/library/upgrade-11-to-12/upgrade-the-cms.html#ckeditor-changes
[3] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style