Make WordPress Core


Ignore:
Timestamp:
09/26/2023 02:20:18 PM (3 years ago)
Author:
karmatosed
Message:

Update editor related npm packages

The npm packages needed updating for 6.4 to the latest.

Props mikachan, mukesdpanchal27, luisherranz, youknowriad, tellthemachines, gziolo, ockham, michalczaplinski

Fixes #59411

File:
1 edited

Legend:

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

    r56065 r56710  
    66 */
    77
    8 if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
    9         /**
    10          * Replaces view script for the File block with version using Interactivity API.
    11          *
    12          * @param array $metadata Block metadata as read in via block.json.
    13          *
    14          * @return array Filtered block type metadata.
    15          */
    16         function gutenberg_block_core_file_update_interactive_view_script( $metadata ) {
    17                 if ( 'core/file' === $metadata['name'] ) {
    18                         $metadata['viewScript'] = array( 'file:./interactivity.min.js' );
    19                 }
    20                 return $metadata;
    21         }
    22         add_filter( 'block_type_metadata', 'gutenberg_block_core_file_update_interactive_view_script', 10, 1 );
    23 }
    24 
    258/**
    26  * When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-file-view` script.
     9 * When the `core/file` block is rendering, check if we need to enqueue the `wp-block-file-view` script.
    2710 *
    2811 * @param array    $attributes The block attributes.
    … …  
    7255
    7356        // If it uses the Interactivity API, add the directives.
    74         if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
     57        if ( $should_load_view_script ) {
    7558                $processor = new WP_HTML_Tag_Processor( $content );
    7659                $processor->next_tag();
    7760                $processor->set_attribute( 'data-wp-interactive', '' );
    7861                $processor->next_tag( 'object' );
    79                 $processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
    80                 $processor->set_attribute( 'hidden', true );
     62                $processor->set_attribute( 'data-wp-style--display', 'selectors.core.file.hasPdfPreview' );
    8163                return $processor->get_updated_html();
    8264        }
    … …  
    8466        return $content;
    8567}
     68
     69/**
     70 * Ensure that the view script has the `wp-interactivity` dependency.
     71 *
     72 * @since 6.4.0
     73 *
     74 * @global WP_Scripts $wp_scripts
     75 */
     76function block_core_file_ensure_interactivity_dependency() {
     77        global $wp_scripts;
     78        if (
     79                isset( $wp_scripts->registered['wp-block-file-view'] ) &&
     80                ! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-file-view']->deps, true )
     81        ) {
     82                $wp_scripts->registered['wp-block-file-view']->deps[] = 'wp-interactivity';
     83        }
     84}
     85
     86add_action( 'wp_print_scripts', 'block_core_file_ensure_interactivity_dependency' );
    8687
    8788/**
Note: See TracChangeset for help on using the changeset viewer.