ckeditor4 icon indicating copy to clipboard operation
ckeditor4 copied to clipboard

Always use normalized color hex value in language files

Open f1ames opened this issue 8 years ago • 0 comments

Are you reporting a feature request or a bug?

Task

Provide detailed reproduction steps (if any)

The default list of colors in colorbutton is defined as follows:

config.colorButton_colors =
    '000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,' +
    'B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,' +
    'F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,' +
    'FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,' +
    'FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF';

all these color names are translated so proper color name is shown when e.g. color in colorbutton panel is hovered. However, the translation keys for some of them are shorter forms, like 000, FFF, DDD, etc. When config contains the full hex like FFFFFF (or ffffff or fff) the color name is not shown (as translation key does not match).

To fix the situation we need two things:

  1. Always use normalized color hex representation when getting color name (so no matter the input, the full, uppercase format should be always used when retrieving color name).
  2. Normalize color translation keys (FFF -> FFFFFF).

Alternatively to not mess the translations we may use different normalization function which will produce:

  • short representation if possible (so FFF, 00F, etc),
  • full representation in other cases.

The second solution will work out of the box with current translations (no need to add new translations for new representations like FFFFFF), but might be a little confusing if someone don't know the details.

Other details

  • Browser: All
  • OS: All
  • CKEditor version: 4.7.3
  • Installed CKEditor plugins: colorbutton

f1ames avatar Oct 23 '17 15:10 f1ames