2016-06-14 12 views
1

Basierend auf einem JavaScript-Boolean, muss ich die font-family von CKEditor zu Meiryo ändern.CKEditor - Schriftfamilie beim Laden der Seite ändern

Bis jetzt habe ich versucht, das folgende in meinem kundenspezifischen JS innerhalb eines if Zustandes hinzuzufügen. Das ändert aber nichts an der font-family.

config.font_style = 
{ 
    element  : 'span', 
    styles  : { 'font-family' : '#Meiryo' }, 
    overrides : [ { element : 'font', attributes : { 'face' : null } } ] 
}; 

und dies auch in meinem benutzerdefinierten Skript

config.font_defaultLabel = 'Meiryo'; 
config.fontSize_defaultLabel = '12px'; 

Keiner von ihnen arbeitete. Bitte lass mich wissen, was ich falsch mache.

Vielen Dank im Voraus!

+0

Bitte überprüfen Sie Ihre js-Konsole auf Fehler. – dorado

Antwort

1

Es ist:

config.font_style = 
    { 
     element  : 'span', 
     styles  : { 'font-family' : '#(Meiryo)' }, 
     overrides : [ { element : 'font', attributes : { 'face' : null } } ] 
    }; 

statt:

config.font_style = 
{ 
    element  : 'span', 
    styles  : { 'font-family' : '#Meiryo' }, 
    overrides : [ { element : 'font', attributes : { 'face' : null } } ] 
}; 

Alle akzeptiert:

145 CKEDITOR.config.font_names = 
146  'Arial/Arial, Helvetica, sans-serif;' + 
147  'Comic Sans MS/Comic Sans MS, cursive;' + 
148  'Courier New/Courier New, Courier, monospace;' + 
149  'Georgia/Georgia, serif;' + 
150  'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' + 
151  'Tahoma/Tahoma, Geneva, sans-serif;' + 
152  'Times New Roman/Times New Roman, Times, serif;' + 
153  'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' + 
154  'Verdana/Verdana, Geneva, sans-serif'; 

Von:

http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.font_style