Make WordPress Core


Ignore:
Timestamp:
02/08/2024 10:39:24 AM (3 years 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/tests/phpunit/tests/rest-api/rest-block-type-controller.php

    r57521 r57565  
    262262                $this->assertSameSets( array(), $data['script_handles'] );
    263263                $this->assertSameSets( array(), $data['view_script_handles'] );
     264                $this->assertSameSets( array(), $data['view_script_module_ids'] );
    264265                $this->assertSameSets( array(), $data['editor_style_handles'] );
    265266                $this->assertSameSets( array(), $data['style_handles'] );
    … …  
    340341                $this->assertSameSets( array(), $data['script_handles'] );
    341342                $this->assertSameSets( array(), $data['view_script_handles'] );
     343                $this->assertSameSets( array(), $data['view_script_module_ids'] );
    342344                $this->assertSameSets( array(), $data['editor_style_handles'] );
    343345                $this->assertSameSets( array(), $data['style_handles'] );
    … …  
    563565                $data       = $response->get_data();
    564566                $properties = $data['schema']['properties'];
    565                 $this->assertCount( 32, $properties );
     567                $this->assertCount( 33, $properties );
    566568                $this->assertArrayHasKey( 'api_version', $properties );
    567569                $this->assertArrayHasKey( 'name', $properties );
    … …  
    587589                $this->assertArrayHasKey( 'script_handles', $properties );
    588590                $this->assertArrayHasKey( 'view_script_handles', $properties );
     591                $this->assertArrayHasKey( 'view_script_module_ids', $properties );
    589592                $this->assertArrayHasKey( 'editor_style_handles', $properties );
    590593                $this->assertArrayHasKey( 'style_handles', $properties );
    … …  
    719722                        'script_handles',
    720723                        'view_script_handles',
     724                        'view_script_module_ids',
    721725                        'editor_style_handles',
    722726                        'style_handles',
Note: See TracChangeset for help on using the changeset viewer.