Disable block gap rendering between root-level blocks.

Top level blocks are post content and header and footer wrapping blocks.
Disabling the gap between these blocks prevents rendering a gap between
post-content blocks and header and footer.
[MAILPOET-6088]
This commit is contained in:
Rostislav Wolny
2024-10-23 12:30:45 +02:00
committed by Jan Lysý
parent 4a04744d1c
commit e3d5b7a7e0
2 changed files with 7 additions and 3 deletions

View File

@@ -16,8 +16,13 @@ class SpacingPreprocessor implements Preprocessor {
foreach ($parsedBlocks as $key => $block) {
$parentBlockName = $parentBlock['blockName'] ?? '';
// Do not add a gap to the first child, or if the parent block is a buttons block (where buttons are side by side).
if ($key !== 0 && $gap && $parentBlockName !== 'core/buttons') {
/**
* Do not add a gap to:
* - the top level blocks - they are post-content, and header and footer wrappers and we don't want a gap between those
* - first child
* - parent block is a buttons block (where buttons are side by side).
**/
if ($parentBlock && $key !== 0 && $gap && $parentBlockName !== 'core/buttons') {
$block['email_attrs']['margin-top'] = $gap;
}