Alex-D / Trumbowyg

A lightweight and amazing WYSIWYG JavaScript editor under 10kB
https://alex-d.github.io/Trumbowyg
MIT License
4.02k stars 614 forks source link

Font size label and value #1219

Closed spacedog4 closed 3 years ago

spacedog4 commented 3 years ago

Would be great if you could provide a list of labels and values on fontsize plugin, so I can do values as "2rem" but the user see "32px" or "32pt" I have to do accessibility on this website, so the paragraphs need to be in em or rem

Alex-D commented 3 years ago

You can already do this by using translations :) I admit, its a little bit hacky, but you can put some labels like this:

//                 v--- 'en' or any language you are using
$.trumbowyg.langs.en.fontsizes = [
    '1rem': '14px',
    '1.2rem': '17px',
    '1.5rem': '21px'
};

$('#editor-custom-font-sizes')
.trumbowyg({
    btns: [
        ['fontsize']
    ],
    plugins: {
        fontsize: {
            sizeList: [
                '1rem',
                '1.2rem',
                '1.5rem'
            ],
            allowCustomSize: false
        }
    }
});