[Question]: How update style manager panel using few devices and custom css class
Question
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.
<img width="1440" alt="Screen Shot 2020-02-19 at 2 33 50 AM" src="https://user-images.githubusercontent.com/32596493/74790527-7b0efe00-52c0-11ea-9999-a98fa654de56.png">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.
<img width="1438" alt="Screen Shot 2020-02-19 at 2 40 29 AM" src="https://user-images.githubusercontent.com/32596493/74790751-3cc60e80-52c1-11ea-8fb7-fdaf5ef2b5ff.png">Could you please help me to solve this problem?
Answers (2)
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
This should be fixed in the latest release https://github.com/artf/grapesjs/releases/tag/v0.18.1
Related Questions and Answers
Continue research with similar issue discussions.
Issue #912
[BUG]: HTML attributes/traits not escaped
When double quotes are added to an attribute it breaks the HTML.https://jsfiddle.net/szLp8h4n/Drag in the link block.Click the link in the...
Issue #2364
[Question] How to add toolbar functionality to the layers panel.
I am trying to add the toolbar to the layers panel and I am not sure how to go about this. Is there any way to accomplish this? toolbar Whe...
Issue #2366
Text-shadow removes rgb values when element selected
Example: https://jsfiddle.net/benvmatheson/g1ft06qh/8/ Import a style with a text property. text-shadow:rgb(51, 166, 58) 4px 4px 4px; This...
Issue #2748
[FEATURE REQUEST][BUG] Slider doesn't work with a non-integer step value
Default StyleManager property "slider" doesn't work with a non-integer step value. GrapesJS version: 0.16.1 In many cases, it’s convenient...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.