Custom font sizes problem

See original GitHub issue

Hi, I’m trying to add custom font sizes to the editor by using customOptions but somehow the editor doesn’t show the proper labels and the inline style is not applied. Here is my config (modules and customOptions) from the component.ts:

this.customOptions = [{
    import: 'attributors/style/size',
    whitelist: ['10', '16', '22', '36', '48', '72', '144']
}];

this.quillModules = {
    toolbar: [
        [{ 'size': [false, '10', '16', '22', '36', '48', '72', '144'] }],
        ['bold', 'italic', 'underline', 'strike'],
        [{ 'color': [] }, { 'background': [] }],
        [{ 'align': [false, 'center', 'right', 'justify'] }],
        [{ 'indent': '-1' }, { 'indent': '+1' }],
        [{ 'list': 'ordered' }, { 'list': 'bullet' }],
    ]
};

The view - component.html:

<quill-editor *ngIf="isInEditMode" 
    [(ngModel)]="content" 
    [modules]="quillModules"
    [customOptions]="customOptions"
    (onEditorCreated)="setFocus($event)">
</quill-editor>

How it is manifested: screen shot 2018-05-17 at 15 45 50

What is generated (from the dev tools): screen shot 2018-05-17 at 16 04 36

Can you take a look and possibly guide to right direction? Maybe I’m missing something.

Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
KillerCodeMonkeycommented, May 17, 2018

i think you need to create a custom toolbar with the correct labels and values or create the mandatory css-classes for each size:

https://stackoverflow.com/questions/38623716/how-to-add-custom-font-sizes-to-quilljs-editor

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="14px"]::before {
    content: 'Normal';
    font-size: 14px !important;
}

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="16px"]::before {
    content: 'Large';
    font-size: 16px !important;
}

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="18px"]::before {
    content: 'Huge';
    font-size: 18px !important;
}
1reaction
djfishecommented, May 17, 2018

Yeah this works! I would like to add that, in order to see the current selection in the dropdown, you need to add additional selectors, like this:

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="10px"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-label.ql-active[data-value="10px"]::before {
    content: '10px';
}

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="16px"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-label.ql-active[data-value="16px"]::before {
    content: '16px';
}

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="22px"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-label.ql-active[data-value="22px"]::before {
    content: '22px';
}

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Font size problem when working with different Window Menus
I have settings to custom scaling at 125% and ease of access make text bigger. Windows menus come up at different sizes like...
Read more >
Font Size Problems? Check Here First! - Codecademy
In the search box type in font. Click enter. Click on the Custom bar and select a smaller font size. Hope this helps...
Read more >
Custom Font Sizing in Xcode 6 Size Classes not working ...
Fast fix: 1) Set fonts as System for size classes. Label attributes inspector. 2) Subclass UILabel and override "layoutSubviews" method like:
Read more >
font-size - CSS: Cascading Style Sheets - MDN Web Docs
The font-size CSS property sets the size of the font. Changing the font size also updates the sizes of the font size-relative <length>...
Read more >
Solved: Inconsistent Font Sizing on Custom Template - 388444
My font sizes are showing up on my bosses phone inconsistently. I have triple checked that they are all Georgia font 12. How...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found