GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

[Question]: How update style manager panel using few devices and custom css class #2586

Closed liudmyla-schastlyvets closed 2 years ago

liudmyla-schastlyvets commented 4 years ago

There is a custom class added to simple grapesjs project:

editor.StyleManager.addProperty('settings', {
     name: 'Size*',
     property: 'font-size',
     type: 'select',
     options: [
        { name: 'default', value:'1.5rem'},
        { name: 'small', value:'1rem'},
        { name: 'large', value:'2rem'}],
        defaults: '1.5rem',
   });
const cc = editor.CssComposer;
cc.setRule('.class', { 'font-size': '2rem' });

If there is no devices and user adds the class into the selectors field Settings sector is updated its font-size property correctly.

Screen Shot 2020-02-19 at 2 33 50 AM

If there are few devices (one of them set like)

        editor.setDevice('Tablet')

and user adds the class into selectors field Settings sector isn't updated its font-size property correctly.

Screen Shot 2020-02-19 at 2 40 29 AM

Could you please help me to solve this problem?

artf commented 4 years ago

Unfortunately, this is due to how getComputedStyle works, which returns resolved values, so by using rem instead of px "confuses" the value. At the moment I don't have any plan on fixing this issue but I'd really appreciate a PR or at least an idea on how to solve this

artf commented 2 years ago

This should be fixed in the latest release https://github.com/artf/grapesjs/releases/tag/v0.18.1