Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
270aaa0
Copy the wp-each implementation
DAreRodz Jan 15, 2024
09972e6
Scaffold files for wp-each e2e tests
DAreRodz Jan 15, 2024
926da69
Process template nodes inside `toVdom()`
DAreRodz Jan 15, 2024
7f2f6c3
Add tests for several list manipulations
DAreRodz Jan 15, 2024
63fa0ef
Add a new test to implement
DAreRodz Jan 15, 2024
5019c6e
Add SSRed elements in PHP
DAreRodz Jan 15, 2024
7819728
Add SSRed elements to letters test
DAreRodz Jan 15, 2024
9308769
Add more test cases
DAreRodz Jan 15, 2024
13be90d
Test support for siblings in template
DAreRodz Jan 15, 2024
e90ddfc
Implement tests for wp-each on navigation
DAreRodz Jan 16, 2024
4643f4b
Update changelog
DAreRodz Jan 16, 2024
07a53b6
Add `wp-each` documentation
DAreRodz Jan 16, 2024
d6b0a4e
Separate the router from the rest of the runtime
DAreRodz Jan 17, 2024
fc423df
Import deps from interactivity module
DAreRodz Jan 17, 2024
77bd06a
Add an entry point for the router
DAreRodz Jan 17, 2024
b3b3ebb
Register interactivity router module
DAreRodz Jan 17, 2024
e38ff22
Add the router module to query block dependencies
DAreRodz Jan 17, 2024
227aa86
Cache regions on DOMContentLoaded
DAreRodz Jan 17, 2024
adf8203
Update query block view
DAreRodz Jan 17, 2024
144c15c
Update e2e tests
DAreRodz Jan 17, 2024
f3a01ee
Make router module a dynamic dependency in tests
DAreRodz Jan 19, 2024
6d245b3
Update tests using navigate
DAreRodz Jan 19, 2024
82a9d4a
Expose `state` & `actions` from router module
DAreRodz Jan 22, 2024
cbf4d3e
Fix module dependency definition for tests
DAreRodz Jan 22, 2024
dd7131e
Fix php lint
DAreRodz Jan 22, 2024
2e5d7e7
Refactor dynamic imports in tests
DAreRodz Jan 22, 2024
8b517b8
Attempt to fix webpack config
DAreRodz Jan 22, 2024
44d2a37
Update caniuse-lite package
sirreal Jan 22, 2024
ffdbdc9
Update snapshots
sirreal Jan 22, 2024
0bf64e3
Cleanup DEWP name, ensure no dupe plugin
sirreal Jan 22, 2024
5c1554f
fixup! Cleanup DEWP name, ensure no dupe plugin
sirreal Jan 22, 2024
93a7ea6
fixup! fixup! Cleanup DEWP name, ensure no dupe plugin
sirreal Jan 22, 2024
94dfd8c
Merge branch 'trunk' into try/interactivity-api-router-module
DAreRodz Jan 23, 2024
f752a94
Convert `navigate` and `prefetch` into actions
DAreRodz Jan 23, 2024
5d55caa
Do not use generator for `prefetch`
DAreRodz Jan 23, 2024
7999837
Add changelog entry
DAreRodz Jan 23, 2024
7b9e112
Create @wordpress/interactivity-router package
DAreRodz Jan 24, 2024
d09960e
Update package-lock
DAreRodz Jan 24, 2024
9916bea
Add the new package to the DEWP
luisherranz Jan 24, 2024
1e6b1c5
Use module as the externals default in the experimental module suppor…
luisherranz Jan 24, 2024
3e50a84
Revert "Update package-lock"
DAreRodz Jan 24, 2024
e551609
Revert "Create @wordpress/interactivity-router package"
DAreRodz Jan 24, 2024
e1bf002
Remove unnecessary DEWP
DAreRodz Jan 24, 2024
19185a3
Merge branch 'trunk' into try/interactivity-api-router-module
luisherranz Jan 24, 2024
4e9d82a
Refactor for new Script Modules API
luisherranz Jan 24, 2024
f42d597
Fix router module name inside DEWP
DAreRodz Jan 24, 2024
f7596c2
Add DEWP to plugins
DAreRodz Jan 24, 2024
337d22a
Revert "Revert "Create @wordpress/interactivity-router package""
DAreRodz Jan 24, 2024
4dcfe20
Revert "Revert "Update package-lock""
DAreRodz Jan 24, 2024
2534189
Update interactivity-router after reverts
DAreRodz Jan 24, 2024
87e162d
Fix module dependencies in Query block
DAreRodz Jan 24, 2024
1aaf239
Add changelog entry
DAreRodz Jan 24, 2024
c15686c
Fix typo
luisherranz Jan 24, 2024
d196e04
Revert adding externalsType in wp-scripts
luisherranz Jan 24, 2024
980ad9b
Merge remote-tracking branch 'origin/try/interactivity-api-router-mod…
luisherranz Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Merge branch 'trunk' into try/interactivity-api-router-module
  • Loading branch information
luisherranz committed Jan 24, 2024
commit 19185a35d21df643e28fdf4078597cdde36778a0
13 changes: 13 additions & 0 deletions docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,19 @@ _Returns_

- `WPBlock[]`: Block objects.

### getBlocksByName

Returns all blocks that match a blockName. Results include nested blocks.

_Parameters_

- _state_ `Object`: Global application state.
- _blockName_ `?string`: Optional block name, if not specified, returns an empty array.

_Returns_

- `Array`: Array of clientIds of blocks with name equal to blockName.

### getBlockSelectionEnd

Returns the current block selection end. This value may be null, and it may represent either a singular block selection or multi-selection end. A selection is singular if its start and end match.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-notices.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const ExampleComponent = () => {
const notices = useSelect( ( select ) =>
select( noticesStore ).getNotices()
);
const { removeNotices } = useDispatch( noticesStore );
const { removeAllNotices } = useDispatch( noticesStore );
return (
<>
<ul>
Expand Down
5 changes: 2 additions & 3 deletions lib/block-supports/shadow.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ function gutenberg_apply_shadow_support( $block_type, $block_attributes ) {

$shadow_block_styles = array();

$preset_shadow = array_key_exists( 'shadow', $block_attributes ) ? "var:preset|shadow|{$block_attributes['shadow']}" : null;
$custom_shadow = isset( $block_attributes['style']['shadow'] ) ? $block_attributes['style']['shadow'] : null;
$shadow_block_styles['shadow'] = $preset_shadow ? $preset_shadow : $custom_shadow;
$custom_shadow = $block_attributes['style']['shadow'] ?? null;
$shadow_block_styles['shadow'] = $custom_shadow;

$attributes = array();
$styles = gutenberg_style_engine_get_styles( $shadow_block_styles );
Expand Down
21 changes: 0 additions & 21 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,27 +440,6 @@ function gutenberg_legacy_wp_block_post_meta( $value, $object_id, $meta_key, $si
add_filter( 'default_post_metadata', 'gutenberg_legacy_wp_block_post_meta', 10, 4 );


/**
* Registers the metadata block attribute for all block types.
*
* @param array $args Array of arguments for registering a block type.
* @return array $args
*/
function gutenberg_register_metadata_attribute( $args ) {
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}

if ( ! array_key_exists( 'metadata', $args['attributes'] ) ) {
$args['attributes']['metadata'] = array(
'type' => 'object',
);
}

return $args;
}
add_filter( 'register_block_type_args', 'gutenberg_register_metadata_attribute' );

/**
* Strips all HTML from the content of footnotes, and sanitizes the ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function replace_html( $block_content, $block_name, $block_attr, $source_
foreach ( $selector_attribute_names as $name ) {
$selector_attrs[ $name ] = $block_reader->get_attribute( $name );
}
$selector_markup = "<$selector>" . esc_html( $source_value ) . "</$selector>";
$selector_markup = "<$selector>" . wp_kses_post( $source_value ) . "</$selector>";
$amended_content = new WP_HTML_Tag_Processor( $selector_markup );
$amended_content->next_tag();
foreach ( $selector_attrs as $attribute_key => $attribute_value ) {
Expand Down
35 changes: 35 additions & 0 deletions lib/compat/wordpress-6.5/block-bindings/sources/pattern.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Add the metadata source to the block bindings API.
*
* @package gutenberg
*/
if ( function_exists( 'wp_block_bindings_register_source' ) ) {
$pattern_source_callback = function ( $source_attrs, $block_instance, $attribute_name ) {
if ( ! _wp_array_get( $block_instance->attributes, array( 'metadata', 'id' ), false ) ) {
return null;
}
$block_id = $block_instance->attributes['metadata']['id'];
$attribute_override = _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id, $attribute_name ), null );
if ( null === $attribute_override ) {
return null;
}
switch ( $attribute_override[0] ) {
case 0: // remove
/**
* TODO: This currently doesn't remove the attribute, but only set it to an empty string.
* It's a temporary solution until the block binding API supports different operations.
*/
return '';
case 1: // replace
return $attribute_override[1];
default:
return null;
}
};
wp_block_bindings_register_source(
'pattern_attributes',
__( 'Pattern Attributes', 'gutenberg' ),
$pattern_source_callback
);
}
102 changes: 102 additions & 0 deletions lib/compat/wordpress-6.5/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,105 @@ function gutenberg_register_block_type_args_shim( $args ) {
if ( ! method_exists( 'WP_Block_Type', 'get_variations' ) ) {
add_filter( 'register_block_type_args', 'gutenberg_register_block_type_args_shim' );
}


/**
* Registers the metadata block attribute for all block types.
*
* @param array $args Array of arguments for registering a block type.
* @return array $args
*/
function gutenberg_register_metadata_attribute( $args ) {
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}

if ( ! array_key_exists( 'metadata', $args['attributes'] ) ) {
$args['attributes']['metadata'] = array(
'type' => 'object',
);
}

return $args;
}
add_filter( 'register_block_type_args', 'gutenberg_register_metadata_attribute' );


if ( ! function_exists( 'gutenberg_process_block_bindings' ) ) {
/**
* Process the block bindings attribute.
*
* @param string $block_content Block Content.
* @param array $block Block attributes.
* @param WP_Block $block_instance The block instance.
*/
function gutenberg_process_block_bindings( $block_content, $block, $block_instance ) {

// Allowed blocks that support block bindings.
// TODO: Look for a mechanism to opt-in for this. Maybe adding a property to block attributes?
$allowed_blocks = array(
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget' ),
);

// If the block doesn't have the bindings property or isn't one of the allowed block types, return.
if ( ! isset( $block['attrs']['metadata']['bindings'] ) || ! isset( $allowed_blocks[ $block_instance->name ] ) ) {
return $block_content;
}

/*
* Assuming the following format for the bindings property of the "metadata" attribute:
*
* "bindings": {
* "title": {
* "source": {
* "name": "post_meta",
* "attributes": { "value": "text_custom_field" }
* }
* },
* "url": {
* "source": {
* "name": "post_meta",
* "attributes": { "value": "text_custom_field" }
* }
* }
* }
*/

$block_bindings_sources = wp_block_bindings_get_sources();
$modified_block_content = $block_content;
foreach ( $block['attrs']['metadata']['bindings'] as $binding_attribute => $binding_source ) {

// If the attribute is not in the list, process next attribute.
if ( ! in_array( $binding_attribute, $allowed_blocks[ $block_instance->name ], true ) ) {
continue;
}
// If no source is provided, or that source is not registered, process next attribute.
if ( ! isset( $binding_source['source'] ) || ! isset( $binding_source['source']['name'] ) || ! isset( $block_bindings_sources[ $binding_source['source']['name'] ] ) ) {
continue;
}

$source_callback = $block_bindings_sources[ $binding_source['source']['name'] ]['apply'];
// Get the value based on the source.
if ( ! isset( $binding_source['source']['attributes'] ) ) {
$source_args = array();
} else {
$source_args = $binding_source['source']['attributes'];
}
$source_value = $source_callback( $source_args, $block_instance, $binding_attribute );
// If the value is null, process next attribute.
if ( is_null( $source_value ) ) {
continue;
}

// Process the HTML based on the block and the attribute.
$modified_block_content = wp_block_bindings_replace_html( $modified_block_content, $block_instance->name, $binding_attribute, $source_value );
}
return $modified_block_content;
}
}

add_filter( 'render_block', 'gutenberg_process_block_bindings', 20, 3 );
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.