Closed hatsumatsu closed 5 years ago
That's not a bug, these blocks opt-out of the default className.
@youknowriad okay, but why? In the editor these are treated as and called blocks
. Shouldn't it be possible to target all blocks in CSS via a generic class?
Coming from https://github.com/WordPress/gutenberg/issues/6639 it seems that both workarounds to easily target all blocks via one CSS selector don't work.
okay, but why? In the editor these are treated as and called blocks
Because they are blocks, a block is not necessary something with a given class. A block can even be multiple DOM elements without any wrapper. A block doesn't map to a DOM element, it's just an entity that wrappes a fragment of content and allows you to edit it visually.
In the case of paragraphs, headings and images we decided to opt-out of these classNames because these blocks are too common and we don't want to pollute the post-content with these.
I hope that answers your questions.
Okay, thanks for clarifying. Guess the expectations of what the desired markup looks like differ based on different frontend workflows. I was just hoping for a clean BEM-like code style...
Describe the bug The filter
blocks.getBlockDefaultClassName
does not alter the class attribute of heading, paragraph and image block.To reproduce Steps to reproduce the behavior:
// Adding the filter wp.hooks.addFilter( 'blocks.getBlockDefaultClassName', 'my-plugin/add-block-custom-class-name', addBlockCustomClassName );