Make WordPress Core


Ignore:
Timestamp:
02/08/2024 10:39:24 AM (4 months ago)
Author:
gziolo
Message:

Editor: Add viewScriptModule handling to block.json metadata

Syncing changes from the Gutenberg plugin: https://github.com/WordPress/gutenberg/pull/57437.

Scripts and styles can be registered for blocks via block.json metadata. There is now a Modules API, but was no way to register or associate module assets with blocks via block.json.

Fixes #60233.
Props jonsurrell, gziolo, cbravobernal, luisherranz, youknowriad.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block.php

    r57562 r57565  
    471471        }
    472472
     473        if ( ! empty( $this->block_type->view_script_module_ids ) ) {
     474            foreach ( $this->block_type->view_script_module_ids as $view_script_module_id ) {
     475                wp_enqueue_script_module( $view_script_module_id );
     476            }
     477        }
     478
    473479        if ( ( ! empty( $this->block_type->style_handles ) ) ) {
    474480            foreach ( $this->block_type->style_handles as $style_handle ) {
Note: See TracChangeset for help on using the changeset viewer.