Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/command-palette-delete-template-nav
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Jun 29, 2023
2 parents e78cc31 + 69ad318 commit 4d99fb4
Show file tree
Hide file tree
Showing 159 changed files with 4,696 additions and 949 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const restrictedImports = [
'isPlainObject',
'isString',
'isUndefined',
'kebabCase',
'keyBy',
'keys',
'last',
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ coverage
*.log
yarn.lock
/artifacts
/test/e2e/artifacts
/perf-envs
/composer.lock

Expand Down
1 change: 0 additions & 1 deletion bin/build-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ build_files=$(
build/block-library/blocks/*.php \
build/block-library/blocks/*/block.json \
build/block-library/blocks/*/*.{js,js.map,css,asset.php} \
build/block-library/interactivity/*.{js,js.map,asset.php} \
build/edit-widgets/blocks/*/block.json \
build/widgets/blocks/*.php \
build/widgets/blocks/*/block.json \
Expand Down
4 changes: 4 additions & 0 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ async function runPerformanceTests( branches, options ) {
path.join( environmentDirectory, '.wp-env.json' ),
JSON.stringify(
{
config: {
WP_DEBUG: false,
SCRIPT_DEBUG: false,
},
core: 'WordPress/WordPress',
plugins: [ path.join( environmentDirectory, 'plugin' ) ],
themes: [
Expand Down
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,12 @@
"markdown_source": "../packages/icons/README.md",
"parent": "packages"
},
{
"title": "@wordpress/interactivity",
"slug": "packages-interactivity",
"markdown_source": "../packages/interactivity/README.md",
"parent": "packages"
},
{
"title": "@wordpress/interface",
"slug": "packages-interface",
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ Add a link to a downloadable file. ([Source](https://github.com/WordPress/gutenb

- **Name:** core/file
- **Category:** media
- **Supports:** align, anchor, color (background, gradients, link, ~~text~~)
- **Supports:** align, anchor, color (background, gradients, link, ~~text~~), interactivity
- **Attributes:** displayPreview, downloadButtonText, fileId, fileName, href, id, previewHeight, showDownloadButton, textLinkHref, textLinkTarget

## Footnotes
Expand Down Expand Up @@ -421,7 +421,7 @@ A collection of blocks that allow visitors to get around your site. ([Source](ht

- **Name:** core/navigation
- **Category:** theme
- **Supports:** align (full, wide), inserter, layout (allowSizingOnChildren, default, ~~allowInheriting~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), inserter, interactivity, layout (allowSizingOnChildren, default, ~~allowInheriting~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** __unstableLocation, backgroundColor, customBackgroundColor, customOverlayBackgroundColor, customOverlayTextColor, customTextColor, hasIcon, icon, maxNestingLevel, openSubmenusOnClick, overlayBackgroundColor, overlayMenu, overlayTextColor, ref, rgbBackgroundColor, rgbTextColor, showSubmenuIcon, templateLock, textColor

## Custom Link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function prepare_item_for_response( $item, $request ) {
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern-category',
Expand All @@ -73,6 +77,8 @@ public function get_item_schema() {
),
);

return $this->add_additional_fields_schema( $schema );
$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public function prepare_item_for_response( $item, $request ) {
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern',
Expand Down Expand Up @@ -153,7 +157,9 @@ public function get_item_schema() {
),
);

return $this->add_additional_fields_schema( $schema );
$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}

/**
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.3/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function gutenberg_get_default_block_template_types( $default_template_types ) {
}
if ( isset( $default_template_types['home'] ) ) {
$default_template_types['home'] = array(
'title' => _x( 'Home', 'Template name', 'gutenberg' ),
'title' => _x( 'Blog Home', 'Template name', 'gutenberg' ),
'description' => __(
'Displays the latest posts as either the site homepage or as the "Posts page" as defined under reading settings. If it exists, the Front Page template overrides this template when posts are shown on the homepage.',
'gutenberg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function prepare_item_for_response( $item, $request ) {
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern',
Expand Down Expand Up @@ -150,6 +154,8 @@ public function get_item_schema() {
),
);

return $this->add_additional_fields_schema( $schema );
$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function get_item_schema() {
return $this->add_additional_fields_schema( $this->schema );
}

$this->schema = array(
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-editor-settings-item',
'type' => 'object',
Expand Down Expand Up @@ -311,6 +311,8 @@ public function get_item_schema() {
),
);

$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}
}
5 changes: 3 additions & 2 deletions lib/experimental/interactivity-api/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/**
* Extend WordPress core blocks to use the Interactivity API.
*
* @package gutenberg
* @package Gutenberg
* @subpackage Interactivity API
*/

/**
Expand All @@ -17,7 +18,7 @@ function gutenberg_block_update_interactive_view_script( $metadata ) {
in_array( $metadata['name'], array( 'core/image' ), true ) &&
str_contains( $metadata['file'], 'build/block-library/blocks' )
) {
$metadata['viewScript'] = array( 'file:./interactivity.min.js' );
$metadata['viewScript'] = array( 'file:./view-interactivity.min.js' );
}
return $metadata;
}
Expand Down
77 changes: 77 additions & 0 deletions lib/experimental/interactivity-api/class-wp-directive-context.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Context data implementation.
*
* @package Gutenberg
* @subpackage Interactivity API
*/

/**
* This is a data structure to hold the current context.
*
* Whenever encountering a `data-wp-context` directive, we need to update
* the context with the data found in that directive. Conversely,
* when "leaving" that context (by encountering a closing tag), we
* need to reset the context to its previous state. This means that
* we actually need sort of a stack to keep track of all nested contexts.
*
* Example:
*
* <div data-wp-context='{ "foo": 123 }'>
* <!-- foo should be 123 here. -->
* <div data-wp-context='{ "foo": 456 }'>
* <!-- foo should be 456 here. -->
* </div>
* <!-- foo should be reset to 123 here. -->
* </div>
*/
class WP_Directive_Context {
/**
* The stack used to store contexts internally.
*
* @var array An array of contexts.
*/
protected $stack = array( array() );

/**
* Constructor.
*
* Accepts a context as an argument to initialize this with.
*
* @param array $context A context.
*/
function __construct( $context = array() ) {
$this->set_context( $context );
}

/**
* Return the current context.
*
* @return array The current context.
*/
public function get_context() {
return end( $this->stack );
}

/**
* Set the current context.
*
* @param array $context The context to be set.
*
* @return void
*/
public function set_context( $context ) {
if ( $context ) {
array_push( $this->stack, array_replace_recursive( $this->get_context(), $context ) );
}
}

/**
* Reset the context to its previous state.
*
* @return void
*/
public function rewind_context() {
array_pop( $this->stack );
}
}
Loading

0 comments on commit 4d99fb4

Please sign in to comment.