Reputation:
The default palette in a CKEditor windows is like this:
Is it possible to select only a few colors (I just need three of them) instead of showing them all? I checked the config.js but it doesn't seems possible to set colors limit from there. Is this possible?
Upvotes: 5
Views: 913
Reputation: 637
All colors are defined in ckeditor/ckeditor.js. This is a minified file, so it is hard to read. If you perform a search on colorButton_colors, you will find the following definition:
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';
Just remove, or add colors you want.
Hope that helps!
Upvotes: 8
Reputation: 1223
You can set the list via config.colorButton_colors without editing source code.
See the official CKEditor documentation on this (v4).
The configuration guidelines also recommend doing on-page configuration when creating editor instances to "avoid modifying the original distribution files in the CKEditor installation folder, making the upgrade task easier."
If you're building pages on the fly with PHP (the question was tagged with php) you could even set different colour sets depending on logged in user id, for example, allowing per-user configuration stored in a database, maybe (by writing a bit of javascript into the page).
Example:
CKEDITOR.replace( 'editor1', {
colorButton_colors: '00923e,f8c100,28166c',
... and so on
});
Upvotes: 1