Setting and clearing background colour does not work with 'non-canonical' styling
|Reported by:||thiloplanz||Owned by:|
|Component:||Core : Styles||Version:||FCKeditor 2.4|
When setting and clearing background colour settings, it is necessary to parse and update the currently active settings (the same process that as applying other styling). Unfortunately, there are many different ways to specify background colour, and only a very narrow combination of them works. Basically, any background colour that has been set using a different method then the current FCK/browser combination would do it, is likely do not work properly.
The effect (on the HTML) of applying a background colour differs by browser:
- Firefox creates <span style="background-color: rgb(255, 0, 0);">
- IE creates <span style="background-color: #ff0000">
- Firefox automatically converts the IE-style into its own style, even when not changing anything in the editor
- HTML received from other sources (e.g. copy-paste, or legacy data after updating the rich text editor to FCK) can also use <span style='background-color: red'>
- it is also possible to get HTML that does not use "background-color", but the composite "background" style property
By going to the source pane on the FCK demo site, and changing the style setting to reflect the above variations, a number of situations where the background colour button does not work properly can be demonstrated.
- Display of background colours works correctly, because all browsers supports all combinations. Applying additional background colour styling however fails in some cases.
- Operations on the complete range usually work (they just need to rewrite the outer-most style). It can still fail when nested styling would need to be removed.
- Operations on incomplete ranges or super-ranges usually do not work. These operations involve splitting ranges and properly parsing the style settings of nested elements, which mostly fails.
- Clearing the background colour is more difficult than applying extra background colour, because this needs to remove existing styling rather than just piling on new spans (which in the absence of nesting works).
- Operation on ranges using "background" instead of "background-colour" create additional complications.
While the priority of supporting arbitrary styling from external sources may be low, it is possible to create a text that does not work properly by just editing it in FCK repeatedly with different browsers.
Workaround: use the "style clear" button to remove all styles (which works reliably), and then re-apply.