'Set default config fonts in ckeditor 5
I have project with ckeditor 5. I try to set default config for family and size font's. In ckeditor 4 we could set default config fonts by
font_defaultLabel and fontSize_defaultLabel.
So how i can set this same in ckeditor 5 ?
function SetDefaultFont(fontSize) {
CKEDITOR.config.fontSize_defaultLabel = fontSize;
}
function SetDefaultFontFamily(fontFamily) {
CKEDITOR.config.font_defaultLabel = fontFamily;
}
Solution 1:[1]
I don't know if this is the answer you're looking for, but I also had a similar problem and found the following solution while searching.
By default, the default font-size is 1em. Therefore, if you adjust the font-size of the parent element, the font size inside the editor is linked and adjusted.
Solution 2:[2]
You can do that by setting a css variable and set the variable as your preferred one.
css class:
.ck-editor__editable_inline p
{
font-size: var(--fontSize) !important;
font-family: var(--fontFamily) !important;
}
and then ngOnInit (I'm using Angular version)
ngOnInit() {
document.documentElement.style.setProperty('--fontSize', '15px');
document.documentElement.style.setProperty('--fontFamily', 'Cairo');
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dolphinwow |
| Solution 2 | Amer84 |
