ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.8k stars 2.48k forks source link

`CKEDITOR.config.font_names` is not respected as a config option #4907

Open sridharravva opened 3 years ago

sridharravva commented 3 years ago

I am trying to add the new font family "Helvetica" in the Font dropdown in CkEditor Standard Package Version 4.16.1. I have tried adding this "Helvetica" font to the Font dropdown but the selected text using this font "Helvetica" does not get applied with effect of this font to the selected text. Instead it simply shows the Arial font or nothing happens for the selected text. I am not sure if this is something bug with CKEditor or if I am missing anything over here. Here it is the sample code that I have added "Helvetica" to the font plugin.js file. Please let me know how to add this font to the Font dropdown. Thanks!

\ckeditor\plugins\font\plugin.js

CKEDITOR.config.font_names = 'Arial/Arial, Helvetica, sans-serif;' + 'Helvetica;' + 'Comic Sans MS/Comic Sans MS, cursive;' + 'Courier New/Courier New, Courier, monospace;' + 'Georgia/Georgia, serif;' + 'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' + 'Tahoma/Tahoma, Geneva, sans-serif;' + 'Times New Roman/Times New Roman, Times, serif;' + 'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' + 'Verdana/Verdana, Geneva, sans-serif';

sridharravva commented 3 years ago

Please let me know if there is any updates on this. Any help on this would be great. Thanks so much!

sculpt0r commented 3 years ago

Hi @sridharravva , I can confirm this issue. For some reason this config options has a default value, despite it's set via CKEDITOR.config. However, you can provide font_names in the editor instance configuration and it works fine:

CKEDITOR.replace( 'editor', {
  font_names: 'Arial/Arial, Helvetica, sans-serif;' +
'Helvetica;' +
'Comic Sans MS/Comic Sans MS, cursive;' +
'Courier New/Courier New, Courier, monospace;' +
'Georgia/Georgia, serif;' +
'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' +
'Tahoma/Tahoma, Geneva, sans-serif;' +
'Times New Roman/Times New Roman, Times, serif;' +
'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' +
'Verdana/Verdana, Geneva, sans-serif'
} );

Also, it looks like this is happening even in very old versions (like 4.14). This is happening on FF, Safari, and Chrome.

sculpt0r commented 3 years ago

I allowed myself to change the issue title to sth that matches the bug description.