Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php-transformer/src/HtmlToBlocks/BlockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function normalizeAttrsForBlock(string $name, array $attrs): array

// These core save functions do not reproduce dimensions.maxWidth. Inline
// max-width is retained by the generated geometry carrier stylesheet.
if ( in_array($name, array( 'core/group', 'core/columns', 'core/list-item', 'core/paragraph', 'core/separator' ), true) ) {
if ( in_array($name, array( 'core/group', 'core/column', 'core/columns', 'core/list-item', 'core/paragraph', 'core/separator' ), true) ) {
unset($attrs['style']['dimensions']['maxWidth']);
if ( empty($attrs['style']['dimensions']) ) {
unset($attrs['style']['dimensions']);
Expand Down
13 changes: 13 additions & 0 deletions php-transformer/tests/contract/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,19 @@ public function match(DOMElement $element, PatternContext $context): ?array
$assert(array('top' => '0', 'bottom' => '0') === ($boundedSeparatorAttrs['style']['spacing']['margin'] ?? null) && ! isset($boundedSeparatorAttrs['style']['dimensions']), 'separator keeps only spacing supported by its canonical core block attributes');
$assert(! str_contains($boundedSeparatorMarkup, 'margin-left:auto') && ! str_contains($boundedSeparatorMarkup, 'max-width:var(--max)') && str_contains($boundedSeparatorCss, 'margin-left:auto !important') && str_contains($boundedSeparatorCss, 'margin-right:auto !important') && str_contains($boundedSeparatorCss, 'max-width:var(--max) !important'), 'separator moves unsupported horizontal and width geometry to its generated carrier stylesheet');

$boundedColumn = ( new HtmlTransformer() )->transform(
'<main><div class="column-row" style="display:flex"><article class="bounded-column"><h2>Article</h2><p>Body</p></article><aside><p>Aside</p></aside></div></main>',
array('static_css' => ':root{--measure:42rem}.bounded-column{max-width:var(--measure);padding:1rem}')
)->toArray();
$boundedColumnBlock = $boundedColumn['blocks'][0]['innerBlocks'][0] ?? array();
$boundedColumnAttrs = $boundedColumnBlock['attrs'] ?? array();
$boundedColumnMarkup = (string) ($boundedColumn['serialized_blocks'] ?? '');
$boundedColumnCss = implode("\n", array_map(static fn (array $asset): string => (string) ($asset['content'] ?? ''), $boundedColumn['assets'] ?? array()));
$assert('core/column' === ($boundedColumnBlock['blockName'] ?? '') && 'bounded-column' === ($boundedColumnAttrs['className'] ?? ''), 'bounded source child becomes a core/column and retains its class-owned geometry selector');
$assert(! isset($boundedColumnAttrs['style']['dimensions']['maxWidth']) && ! str_contains($boundedColumnMarkup, 'max-width:var(--measure)'), 'column omits max-width unsupported by its canonical Gutenberg save wrapper');
$assert(str_contains($boundedColumnCss, '.bounded-column{max-width:var(--measure);padding:1rem}'), 'generated stylesheet retains the exact class-owned column max-width geometry');
$assert('pass' === ($boundedColumn['source_reports']['wp_block_validity']['status'] ?? ''), 'bounded column serialization passes canonical Gutenberg wrapper validity');

$customStateFindings = ( new CanonicalSaveShapeValidator() )->findings(array(array(
'blockName' => 'core/group',
'attrs' => array(),
Expand Down
Loading