Repository: plone/Products.CMFPlone

Issue:
Tinymce: unable to set an alignment style
I want to continue a discussion started on the [forum](https://community.plone.org/t/tinymce-unable-to-set-an-alignment-style/5480) and on irc today.

The problem is that when you want to align some text, Tiny add an inline style to selected tag, but on save, Plone filters remove that attributes (styles) because they are blacklisted.

Going deeper in this feature, i’ve found that from 5.0 to 5.1 the html filters control panel has changed, and exactly [this commit](https://github.com/plone/Products.CMFPlone/commit/d975d1fdcbd050052401b4e11104fdfe2679b67b#diff-fa6b670554e72078393552c295dc150dL406) introduced the “problem”:
in Plone 5.0 there was a “_style_whitelist_” field with a set of allowed styles (also text-align), but in the new control panel we have less fields and we can only enable the whole “styles” attribute.

@MrTango did that change ;)

Obviously i don’t know all the background about this decision, but can this be some kind of regression?

I see two possible solutions:

- add the config in tiny control panel + some css classes in the theme
- revert attributes filter and controlpanel entry and allow text-align styles.

For a customer we did the first one without problems, as gp54321 (sorry, i don't know your github account) suggested.
We only needed to update tinymce config, and add a set of css classes like this:

     "alignleft": {
         "classes": "tinyAlignLeft",
         "block": "div"
      },
      "aligncenter": {
          "classes": "tinyAlignCenter",
          "block": "div"
      },
      "alignright": {
          "classes": "tinyAlignRight",
          "block": "div"
      }

And add these classes to our theme to have some text-align styles (i haven't found anything similar in barceloneta).


Discussion:
this is odd ... just wondered why my mosaic html tiles do not want to align the text ... it's exactly the same problem there. Tiny's base formatting functions should not be filtered out by default ... @agitator @MrTango 
One year has passed and we have been building Plone 5.1 sites with the classes fix proposed above, because it just works. (Actually, I set `p` instead of `div` in the `block` property, but it works)

Still, I think we should find a better solution for this, for these reasons:
- As of today, the core text editor in Plone does not work out-of-the-box.
- We fixed text align styles, but what other styles need to be fixed? I see table styles in a linked issue above, for example. Can we find an exact list, or is it safer/faster to just re-enable the previous behavior? Another example: aligning text works with the above mentioned classes fix, but it actually doesn't work inside tables.

I feel like this issue looks like a small issue for us but it's actually a big deal to achieve editor satisfaction in using Plone.
@cekk @petschki  The main reason why we don't have the style_whitelist anymore, is that the underlaying library we use for filtering has changed. That was already the case when i worked on that. 
Also the TinyMCE filters are synced with the backend filtering, so that we havfe a consistent behavior in backend and frontend. 
I think we should just add these behavior to TinyMCE config by default.
Feel free to do it ;)
And yes @pnicolli is right it should be a p-tag not a div ;)
This is still an issue in 5.2, as tested on http://demo.plone.org/en. 

Resolving patch:
diff --git a/Products/CMFPlone/interfaces/controlpanel.py b/Products/CMFPlone/interfaces/controlpanel.py
--- a/Products/CMFPlone/interfaces/controlpanel.py
+++ b/Products/CMFPlone/interfaces/controlpanel.py
@@ -246,6 +246,7 @@ class IFilterSchema(Interface):
             u'head',
             u'header',
             u'hgroup',
+            u'hr',
             u'html',
             u'i',
             u'iframe',
@@ -297,7 +298,7 @@ class IFilterSchema(Interface):
     custom_attributes = schema.List(
         title=_(u'Custom attributes'),
         description=_(u'These attributes are additionally allowed.'),
-        default=[],
+        default=['style'],
         value_type=schema.TextLine(),
         missing_value=[],
         required=False)


Test patch: