Make WordPress Core


Ignore:
Timestamp:
10/21/2025 07:11:53 AM (3 months ago)
Author:
ellatrix
Message:

Editor: update packages.

Updates the packages to match Gutenberg version 21.9.0 RC2.

Also updates the sync script to work with the new package-lock.json format.
Some reusable block tests were adjusted to work with more render arguments.
Added core-data to the ignore list for verify:source-maps because Yjs has been bundled by accident. To be removed in a follow-up. See https://core.trac.wordpress.org/ticket/64120. See https://github.com/WordPress/gutenberg/pull/72503.

See: https://github.com/WordPress/wordpress-develop/pull/10355.
See: https://core.trac.wordpress.org/ticket/64117.

Props ellatrix, dmsnell.
Fixes #64117.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/file.php

    r59079 r61009  
    1111 * @since 5.8.0
    1212 *
    13  * @param array    $attributes The block attributes.
    14  * @param string   $content    The block content.
    15  * @param WP_Block $block      The parsed block.
     13 * @param array  $attributes The block attributes.
     14 * @param string $content    The block content.
    1615 *
    1716 * @return string Returns the block content.
    1817 */
    1918function render_block_core_file( $attributes, $content ) {
    20     // If it's interactive, enqueue the script module and add the directives.
    21     if ( ! empty( $attributes['displayPreview'] ) ) {
    22         wp_enqueue_script_module( '@wordpress/block-library/file/view' );
    23 
    24         $processor = new WP_HTML_Tag_Processor( $content );
    25         $processor->next_tag();
    26         $processor->set_attribute( 'data-wp-interactive', 'core/file' );
    27         $processor->next_tag( 'object' );
    28         $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
    29         $processor->set_attribute( 'hidden', true );
    30 
    31         $filename     = $processor->get_attribute( 'aria-label' );
    32         $has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
    33         $label        = $has_filename ? sprintf(
    34             /* translators: %s: filename. */
    35             __( 'Embed of %s.' ),
    36             $filename
    37         ) : __( 'PDF embed' );
    38 
    39         // Update object's aria-label attribute if present in block HTML.
    40         // Match an aria-label attribute from an object tag.
    41         $processor->set_attribute( 'aria-label', $label );
    42 
    43         return $processor->get_updated_html();
     19    if ( empty( $attributes['displayPreview'] ) ) {
     20        return $content;
    4421    }
    4522
    46     return $content;
     23    // If it's interactive, enqueue the script module and add the directives.
     24    wp_enqueue_script_module( '@wordpress/block-library/file/view' );
     25
     26    $processor = new WP_HTML_Tag_Processor( $content );
     27    if ( $processor->next_tag() ) {
     28        $processor->set_attribute( 'data-wp-interactive', 'core/file' );
     29    }
     30
     31    // If there are no OBJECT elements, something might have already modified the block.
     32    if ( ! $processor->next_tag( 'OBJECT' ) ) {
     33        return $content;
     34    }
     35
     36    $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
     37    $processor->set_attribute( 'hidden', true );
     38
     39    $filename     = $processor->get_attribute( 'aria-label' );
     40    $has_filename = is_string( $filename ) && ! empty( $filename ) && 'PDF embed' !== $filename;
     41    $label        = $has_filename ? sprintf(
     42        /* translators: %s: filename. */
     43        __( 'Embed of %s.' ),
     44        $filename
     45    ) : __( 'PDF embed' );
     46
     47    // Update object's aria-label attribute if present in block HTML.
     48    // Match an aria-label attribute from an object tag.
     49    $processor->set_attribute( 'aria-label', $label );
     50
     51    return $processor->get_updated_html();
    4752}
    4853
Note: See TracChangeset for help on using the changeset viewer.