agb.plugin icon indicating copy to clipboard operation
agb.plugin copied to clipboard

Some themes override color/margin/padding in advanced blocks

Open fsvm88 opened this issue 4 years ago • 2 comments

Hello,

I have been using Advanced Gutenberg Blocks for a couple weeks, and always noticed that with the Advanced Code blocks, the theme I'm using sends inline CSS to force the color of the text to a specific value. Not only that, it also overrides padding and margin, so that the lines appear with huge spacing and make the editing almost impractical.

I solved my use case by appending the following to dist/blocks.style.build.css: .wp-block-advanced-gutenberg-blocks-code .CodeMirror pre{color:inherit;margin:inherit;padding:inherit;}

This way I can finally edit plain text with a black background, and with the paddings/margins that appear in the published post.

Would it be possible to make this a feature, adding an on/off checkbox in the "Tweak Editor" settings page? Something like "Workaround for themes forcing styles in ACB". I am not sure if those are the only 3 properties being overwritten by the theme, but I guess they're the most important ones to not mess up the preview (and esp. allowing seeing the text, when you have theme text color == block background color).

For reference, the theme displaying the issue for me is Typology: https://mekshq.com/theme/typology/

fsvm88 avatar Jun 18 '20 18:06 fsvm88

It's always an hassle to deal with CSS in Gutenberg because of styles inheritances, since the beginning of the project.

Maybe I can always add this CSS to CodeMirror in order to prevent suchs cases. Would it work every time ?

Thank you for your feedback!

maximebj avatar Jun 19 '20 16:06 maximebj

I am not sure it will work every time, but in my case I have seen that the theme was sending inline CSS that was overriding the AGB one as it was more specific, so this fix works. I guess it really depends on whether the theme has more specific selectors, and at which point in the hierarchy.

fsvm88 avatar Jun 21 '20 16:06 fsvm88