I apologize if this is the wrong place to be asking this question, but I'm trying to determine if I can easily configure WYSIWYG / CKEditor to use classes instead of inline styles when formatting text (e.g. - applying indents to paragraphs). Using CKEditor directly (w/o the WYSIWYG module installed), the default config appeared to apply styles like 'rteindent' for indents. Now that I have WYSIWYG running, the indent function uses 'margin-left' instead, and those styles are subsequently stripped out of Filtered HTML. I really like both CKEditor and the WYSIWYG module, and options like running WYSIWYG Filter or using a Full HTML input format each have their drawbacks, so I suspect I'm just missing the obvious fix. How do I configure CKEditor to continue using classes instead of inline styles?

Comments

TwoD’s picture

Status: Active » Fixed

Yes, that is possible. CKEditor has settings for using classes instead of many inline styles, but we don't have a GUI to set them (yet). But we have a Drupal hook you can implement to override the CKEditor settings generated by Wysiwyg module.
For an example of how to use classes for alignment, see #732846-1: CKEditor configuration via ckeditor.config.js.
There's also the indentClasses setting you can change in the same way.

I'd like to suggest checking out WYSIWYG Filter, a replacement for Drupal core's "HTML Filter". It can be configured to allow style attributes and individual style properties on the tags you need them on. Read the instructions carefully, it takes some time to set up the first time since it gives you so many options.

Hope that fixes things for you.

jessegue’s picture

Thank you TwoD!

I took the custom module route using your 'mymodule_wysiwyg_editor_settings_alter' hook, and that method seems to work as advertised for indent classes. I was hesitant to use the WYSIWYG filter because its project status is unknown, and I am grateful that this hook options is effective.

Thanks again for your help!

TwoD’s picture

You're welcome!

Unknown status just means the maintainer hasn't selected anything yet. The last commit to the repository - not counting the Git migration - was in January, it's got 4k users and only 5 known issues (not very serious ones it seems) and I'm personally using it on several sites so I can vouch for it being functional and stable. :)

jessegue’s picture

OK, thanks for the recommendation! Maybe I should reconsider some of the other 'project status: unknown' modules I avoided in the past...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.