Skip to content
Closed
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
14 changes: 14 additions & 0 deletions src/wp-includes/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,20 @@ function wp_typography_get_preset_inline_style_value( $style_value, $css_propert
function wp_render_typography_support( $block_content, $block ) {
if ( ! empty( $block['attrs']['fitText'] ) && ! is_admin() ) {
wp_enqueue_script_module( '@wordpress/block-editor/utils/fit-text-frontend' );

// Add Interactivity API directives for fit text to work with client-side navigation.
if ( ! empty( $block_content ) ) {
$processor = new WP_HTML_Tag_Processor( $block_content );
if ( $processor->next_tag() ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Do we need to check if the block has the fitText attribute before setting it? Otherwise, this logic might apply the attribute to all block content elements, not just the ones that support fitText.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mukeshpanchal27, we are checking if the block has fittext attribute on the condition above: if ( ! empty( $block['attrs']['fitText'] ) && ! is_admin() ) {.

if ( ! $processor->get_attribute( 'data-wp-interactive' ) ) {
$processor->set_attribute( 'data-wp-interactive', true );
}
$processor->set_attribute( 'data-wp-context---core-fit-text', 'core/fit-text::{"fontSize":""}' );
$processor->set_attribute( 'data-wp-init---core-fit-text', 'core/fit-text::callbacks.init' );
$processor->set_attribute( 'data-wp-style--font-size', 'core/fit-text::context.fontSize' );
$block_content = $processor->get_updated_html();
}
}
}
if ( ! isset( $block['attrs']['style']['typography']['fontSize'] ) ) {
return $block_content;
Expand Down
Loading