How to setup htmLawed so that it allows text alignment? I want authenticated users can use text alignment in ckeditor.

Thanks-

CommentFileSizeAuthor
#5 Screen Shot 2013-03-22 at 3.34.23 PM.jpg97.24 KBAnonymous (not verified)

Comments

alpha2zee’s picture

Is the markup for alignment produced by ckeditor 'style' (tag attribute) based? If so, you will have to edit the value for 'Config.' as the default value denies use of the 'style' attribute. You can remove , style from 'deny_attribute'=>'id, style' in 'Config.'.

Note that this will permit anything (besides text alignment properties) within 'style'. If ckeditor cannot be configured to restrict what is allowed within 'style' and you want only text-alignment property, then consider using the 'Spec.' form-field for htmLawed module settings. E.g., to permit 'style' with only 'text-align' property within only 'p', 'div' and 'td' tags, keep 'deny_attribute'=>'id, style' in 'Config.'. Then, for 'Spec.', put in p=*, style(match="/^\s*text-align\s*:\s*((left)|(right)|(center));*\s*$/"); div=*, style(match="/^\s*text-align\s*:\s*((left)|(right)|(center));*\s*$/"); td=*, style(match="/^\s*text-align\s*:\s*((left)|(right)|(center));*\s*$/");. The 'Config.' value denies 'style' for all tags. Then, the 'Spec.' value causes 'style' to be allowed for 'p', 'div' and 'td' as long as it contains only 'text-align: left;', etc.

For more on 'Spec.', see http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/htm....

CFW’s picture

Thanks, it works the way I wanted.

I also want user to able to insert images, see below. I read the documentation but don't understand all of it.

<img alt="Alt" src="http://localhost/sites/default/files/styles/thumbnail/public/pictures/picture-1-1309446318.png" style="border-bottom: 2px solid; border-left: 2px solid; margin: 1px 10px; width: 97px; float: left; height: 100px; border-top: 2px solid" />

Thanks again,

alpha2zee’s picture

In my first reply, the example value suggested for 'Spec.' tells htmLawed to allow style within 'p', 'div' and 'td' as long as 'style' contains only 'text-align...'. To allow 'style' for 'img', you have to add this rule to 'Spec.'. E.g., you can append img=*, style; to the example 'Spec.' value above. With this, 'img' can have 'style' with anything. If you are good at regular expressions, then you can create a pattern so that 'style' for 'img' can contain only certain values.

If you think you get content with a lot of HTML tags with 'style' values with lots of different style-properties, I suggest not using 'Spec.' at all and instead removing 'style' from 'deny_attribute' in 'Config.' (see the beginning of my first reply).

CFW’s picture

Status: Active » Closed (fixed)

Thanks for your help alpha2zee.

Anonymous’s picture

StatusFileSize
new97.24 KB

Does this still work? I'm attaching screenshots of my configuration....seems like everything is correct I only took off the "td" element for Spec. Help...please...

Just for clarification, I want to allow the various text-alignments in "style" for both "p" and "div". Thanks!!!!