xdan / jodit

Jodit - Best WYSIWYG Editor for You
https://xdsoft.net/jodit/
MIT License
1.71k stars 354 forks source link

Font size module misbehaves #1197

Open cezarypiatek opened 5 days ago

cezarypiatek commented 5 days ago

Jodit Version: 4.2.43

Browser: Chrome OS: Windows Is React App: True

Issue 1: Incorrectly displayed font size

Jodit config

{
    defaultFontSizePoints: 'pt',
    controls: {
        fontsize: {
            component: 'select',
                list: Jodit.atom([8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72])
        }
    }
}

After changing font size the value is displayed incorrectly on the toolbar (unit duplicated)

chrome_1hmyg4VJK6

Issue 2: After starting new line, the font size in the toolbar has wrong value (14 -> 18 -> 14)

1) Change font to different size then default 2) type 3 lines of text - when starting 3rd line the font size on the toolbard has changed by itself

chrome_yvMhFROjUx

Issue 3: Default font size not working correctly

Setting the default font size to 12pt is displayed as 16pt (probably pt <--> px conversion issue)

image

cezarypiatek commented 4 days ago

I did some investigation and it looks like the method below has invalid signature and hence is not used at all (typo in name s vs z and secod parameter is never passed) https://github.com/xdan/jodit/blob/30bb40f3301a9f85dd3c7a6dcace2cbd6cfe5d30/src/plugins/font/config.ts#L39

Another problem with it is that value sometimes comes without unit and it's impossible to tell what is the actual unit (sometimes the values is express in px and sometimes in pt)

The problems might be cause by the fact that here is used totally different implementation responsible for value normalization https://github.com/xdan/jodit/blob/30bb40f3301a9f85dd3c7a6dcace2cbd6cfe5d30/src/plugins/font/font.ts#L43

Also calling normalize on the list indices seems to be sth completly wrong

https://github.com/xdan/jodit/blob/30bb40f3301a9f85dd3c7a6dcace2cbd6cfe5d30/src/plugins/font/config.ts#L99