CKEditor: Different color palettes for Text Color

2019-08-07 18:12发布

I am using CKEditor (v3.6.4) and try to find out how to change the palettes for Text Color and Background Color separately.

I found config.colorButton_colors in the docs which allows me to define the color palette. However, this palette is assigned to both, text and background.

How can I have two different palettes?

3条回答
可以哭但决不认输i
2楼-- · 2019-08-07 18:50

Yes its actually possible. Just dont pick colors from the config but rather do the following in colorbutton/plugin.js:

        var textColors = '1ABC9C,2ECC71,3498DB,9B59B6,4E5F70,F1C40F,' +
                        '16A085,27AE60,2980B9,8E44AD,2C3E50,F39C12,' +
                        'E67E22,E74C3C,ECF0F1,95A5A6,DDD,FFF,' +
                        'D35400,C0392B,BDC3C7,7F8C8D,999,000';

        var backgroundColors = 'cee8fe,b1d7ff,c7d3f3,dfd6eb,e4cafe,ffbbff,ffbfd2,ff9999,ffdeb3,ffefb0,f4f98a,ffffbb,d3f1a1,bbffbb,bbffff,a6e3dc,c1ebc7,eddec9,f2ebd3,d3eaf2,e1eff3,ffbe61,ffdc61,e1f29d';


        var colors = (type == 'back') ? backgroundColors.split(',') : textColors.split(',');
查看更多
再贱就再见
3楼-- · 2019-08-07 18:52

The best and easy way is, Include required plugin at the download time or link below

Ckeditor Builder

查看更多
小情绪 Triste *
4楼-- · 2019-08-07 18:58

You can't do that because the color palette is defined for the text color and background.

CKEDITOR.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';

Or you can change the Text Color plugin :)

查看更多
登录 后发表回答