Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  131] [ 2]  / answers: 1 / hits: 16474  / 11 Years ago, thu, may 2, 2013, 12:00:00

I use CKEditor 4 and I want to set default font. I added font_defaultLabel with my font choice but it doesn't work ...



I found this solution on the Internet but it's a trick for me and not a true solution :



CKEDITOR.on( 'instanceReady', function( ev ) {
ev.editor.setData('<span style=font-family:Arial, Verdana, sans-serif;>&shy;</span>');
});


Can someone help me?



EpokK


More From » ckeditor

 Answers
100

you can use ckeditor's dataprocessor to modify (for example) paragraphs with your choice for font-size, font-family, this will affect any paragraph entered into ckeditor be it pasted, written or changed in the source; something like this:



CKEDITOR.on('instanceReady', function( ev ) {
ev.editor.dataProcessor.htmlFilter.addRules({
elements: {
p: function (e) { e.attributes.style = 'font-size:' + fontsizevariable + 'px; font-family:' + fontfamilyvariable + ';'; }
}
});
});


same for dataProcessor.dataFilter



But if you intend to view html created outside of your environment, these rules might make it a real mess


[#78475] Tuesday, April 30, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalias

Total Points: 79
Total Questions: 116
Total Answers: 116

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
kalias questions
Fri, May 27, 22, 00:00, 2 Years ago
Thu, Jan 20, 22, 00:00, 2 Years ago
Fri, Jul 30, 21, 00:00, 3 Years ago
Sun, Aug 2, 20, 00:00, 4 Years ago
;