Display only a few desired colors in the CKEditor palette

The default palette in CKEditor windows is as follows:

a busy cat

Is it possible to select only a few colors (I just need three of them), and not show them all? I checked config.js, but it is not possible to set the color limit from there. Is it possible?

+4
source share
2 answers

All colors are defined in ckeditor / ckeditor.js. This is a thumbnail file and therefore difficult to read. If you search in 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 delete or add the desired colors.

Hope this helps!

+6
source

You can set the list via config.colorButton_colors without editing the source code.

Refer to the official CKEditor Documentation about this (v4).

setup rules also recommend that you do the setup on the page when creating the editor instances "to avoid changing the distribution source files in the CKEditor installation folder, which will simplify the update task."

If you build pages on the fly with PHP (the question was tagged php), you could even set different color sets depending on the user ID entry, for example, allowing configuration for each user stored in the database is possible (by writing a little javascript per page).

Example:

 CKEDITOR.replace( 'editor1', { colorButton_colors: '00923e,f8c100,28166c', ... and so on }); 
+1
source

Source: https://habr.com/ru/post/1446970/


All Articles