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
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,31 @@ private static function is_numeric_label_span($element): bool
*/
private static function create_inline_span_label_paragraph($element): array
{
return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', array('content' => \trim($element->get_outer_html())));
$attributes = array('content' => \trim($element->get_outer_html()));
self::apply_inline_preservation_paragraph_spacing($attributes);
return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', $attributes);
}
/**
* Removes default paragraph margins from paragraphs standing in for inline markup.
*
* @param array $attributes Paragraph block attributes.
*/
private static function apply_inline_preservation_paragraph_spacing(array &$attributes): void
{
if (!isset($attributes['style']) || !\is_array($attributes['style'])) {
$attributes['style'] = array();
}
if (!isset($attributes['style']['spacing']) || !\is_array($attributes['style']['spacing'])) {
$attributes['style']['spacing'] = array();
}
if (!isset($attributes['style']['spacing']['margin']) || !\is_array($attributes['style']['spacing']['margin'])) {
$attributes['style']['spacing']['margin'] = array();
}
foreach (array('top', 'right', 'bottom', 'left') as $side) {
if (!isset($attributes['style']['spacing']['margin'][$side])) {
$attributes['style']['spacing']['margin'][$side] = '0';
}
}
}
/**
* Checks whether an aria-hidden div is only inline span labels.
Expand Down Expand Up @@ -998,6 +1022,7 @@ private static function is_visual_diagram_span_container($element): bool
private static function create_aria_hidden_inline_span_paragraph($element): array
{
$attributes = self::get_block_support_attributes($element, array('anchor' => \true, 'class_name' => \true, 'colors' => \true, 'typography' => \true, 'spacing' => \true, 'border' => \true));
self::apply_inline_preservation_paragraph_spacing($attributes);
$attributes['content'] = \trim($element->get_inner_html());
return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', $attributes);
}
Expand Down Expand Up @@ -1047,6 +1072,7 @@ private static function is_branded_inline_anchor($element): bool
private static function create_branded_inline_anchor_paragraph($element): array
{
$attributes = self::get_block_support_attributes($element, array('anchor' => \true));
self::apply_inline_preservation_paragraph_spacing($attributes);
$attributes['content'] = \trim($element->get_outer_html());
return HTML_To_Blocks_Block_Factory::create_block('core/paragraph', $attributes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function serialize_blocks(array $blocks): string
$assert(!\str_contains($aria_hidden_span_ruler, '<!-- wp:html -->'), 'aria-hidden-span-ruler-avoids-core-html', $aria_hidden_span_ruler);
$assert(\str_contains($aria_hidden_span_ruler, '<!-- wp:paragraph'), 'aria-hidden-span-ruler-uses-paragraph', $aria_hidden_span_ruler);
$assert(\str_contains($aria_hidden_span_ruler, 'class="ruler"'), 'aria-hidden-span-ruler-preserves-class', $aria_hidden_span_ruler);
$assert(\str_contains($aria_hidden_span_ruler, 'margin-top:0'), 'aria-hidden-span-ruler-resets-wrapper-margin', $aria_hidden_span_ruler);
$assert(\str_contains($aria_hidden_span_ruler, '<span>0</span><span>6</span><span>12</span><span>18</span><span>24</span>'), 'aria-hidden-span-ruler-preserves-direct-spans', $aria_hidden_span_ruler);
$assert(!\str_contains($aria_hidden_span_ruler, '<div class="wp-block-group ruler'), 'aria-hidden-span-ruler-does-not-add-group-wrapper', $aria_hidden_span_ruler);
$visible_span_group = serialize_blocks(html_to_blocks_raw_handler(['HTML' => '<div class="ruler"><span>0</span><span>6</span></div>']));
Expand All @@ -146,6 +147,7 @@ function serialize_blocks(array $blocks): string
$assert(!\str_contains($visible_diagram_span_group, '<!-- wp:html -->'), 'visible-diagram-span-container-avoids-core-html', $visible_diagram_span_group);
$assert(\str_contains($visible_diagram_span_group, '<!-- wp:paragraph'), 'visible-diagram-span-container-uses-paragraph', $visible_diagram_span_group);
$assert(\str_contains($visible_diagram_span_group, 'class="cushion-diagram"'), 'visible-diagram-span-container-preserves-class', $visible_diagram_span_group);
$assert(\str_contains($visible_diagram_span_group, 'margin-top:0'), 'visible-diagram-span-container-resets-wrapper-margin', $visible_diagram_span_group);
$assert(\str_contains($visible_diagram_span_group, '<span class="diagram-label fabric">performance fabric</span> <span class="diagram-label wrap">dacron wrap</span>'), 'visible-diagram-span-container-preserves-direct-spans', $visible_diagram_span_group);
$visible_diagram_mixed_group = serialize_blocks(html_to_blocks_raw_handler(['HTML' => '<div class="cushion-diagram"><span class="diagram-label fabric">performance fabric</span><em>caption</em></div>']));
$assert(!\str_contains($visible_diagram_mixed_group, '<!-- wp:paragraph'), 'visible-diagram-mixed-container-does-not-use-span-only-transform', $visible_diagram_mixed_group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function serialize_blocks(array $blocks): string
$service_card_serialized = serialize_blocks($service_card_blocks);
$service_card_names = $flatten_block_names($service_card_blocks);
$assert(!\in_array('core/html', $service_card_names, \true), 'service-card-label-spans-avoid-core-html', 'Blocks: ' . \implode(', ', $service_card_names));
$assert(\strpos($service_card_serialized, 'margin-top:0') !== \false, 'service-card-label-wrapper-resets-margin', $service_card_serialized);
$assert(\strpos($service_card_serialized, '<span class="service-number">01</span>') !== \false, 'service-card-classed-span-preserved', $service_card_serialized);
$assert(\strpos($service_card_serialized, '<span class="tag">window seats</span>') !== \false, 'service-card-tag-span-preserved', $service_card_serialized);
$assert(\strpos($service_card_serialized, '<p class="service-number">01</p>') === \false, 'service-card-classed-span-not-rewritten-to-paragraph', $service_card_serialized);
Expand Down
Loading