Skip to content

Commit

Permalink
prep build 11/08
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Nov 8, 2023
2 parents c46fc8d + e50aabe commit 097ce55
Show file tree
Hide file tree
Showing 67 changed files with 1,258 additions and 669 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/enforce-pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
count: 1
labels: '[Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core'
add_comment: true
message: "**Warning: Type of PR label error**\n\n To merge this PR, it requires {{ errorString }} {{ count }} label indicating the type of PR. Other labels are optional and not being checked here. \n- **Type-related labels to choose from**: {{ provided }}.\n- **Labels found**: {{ applied }}.\n\nRead more about [Type labels in Gutenberg](https://github.com/WordPress/gutenberg/labels?q=type)."
message: "**Warning: Type of PR label mismatch**\n\n To merge this PR, it requires {{ errorString }} {{ count }} label indicating the type of PR. Other labels are optional and not being checked here. \n- **Type-related labels to choose from**: {{ provided }}.\n- **Labels found**: {{ applied }}.\n\nRead more about [Type labels in Gutenberg](https://github.com/WordPress/gutenberg/labels?q=type). Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task."
exit_type: failure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Get started with create-block

Custom blocks for the Block Editor in WordPress are typically registered using plugins and are defined through a specific set of files. The [`@wordpress/create-block`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/) package is an officially supported tool to scaffold the structure of files needed to create and register a block. It generates all the necessary code to start a project and integrates a modern JavaScript build setup (using [`wp-scripts`](https://developer.wordpress.org/block-editor/getting-started/devenv/get-started-with-wp-scripts.md)) with no configuration required.
Custom blocks for the Block Editor in WordPress are typically registered using plugins and are defined through a specific set of files. The [`@wordpress/create-block`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/) package is an officially supported tool to scaffold the structure of files needed to create and register a block. It generates all the necessary code to start a project and integrates a modern JavaScript build setup (using [`wp-scripts`](https://developer.wordpress.org/block-editor/getting-started/devenv/get-started-with-wp-scripts/)) with no configuration required.

The package is designed to help developers quickly set up a block development environment following WordPress best practices.

Expand Down
26 changes: 26 additions & 0 deletions docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ _Returns_

- `undefined< 'edit' >`: Current user object.

### getDefaultTemplateId

Returns the default template use to render a given query.

_Parameters_

- _state_ `State`: Data state.
- _query_ `TemplateQuery`: Query.

_Returns_

- `string`: The default template id for the given query.

### getEditedEntityRecord

Returns the specified entity record, merged with its edits.
Expand Down Expand Up @@ -648,6 +661,19 @@ _Returns_

- `Object`: Action object.

### receiveDefaultTemplateId

Returns an action object used to set the template for a given query.

_Parameters_

- _query_ `Object`: The lookup query.
- _templateId_ `string`: The resolved template id.

_Returns_

- `Object`: Action object.

### receiveEntityRecords

Returns an action object used in signalling that entity records have been received.
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/data-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function _gutenberg_register_data_views_post_type() {
'wp_dataviews_type',
array( 'wp_dataviews' ),
array(
'public' => true,
'public' => false,
'hierarchical' => false,
'labels' => array(
'name' => __( 'Dataview types', 'gutenberg' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,18 @@ public function update_font_library_permissions_check() {
return true;
}

/**
* Checks whether the font directory exists or not.
*
* @since 6.5.0
*
* @return bool Whether the font directory exists.
*/
private function has_upload_directory() {
$upload_dir = WP_Font_Library::get_fonts_dir();
return is_dir( $upload_dir );
}

/**
* Checks whether the user has write permissions to the temp and fonts directories.
*
Expand Down Expand Up @@ -418,12 +430,29 @@ public function install_fonts( $request ) {
$response_status = 400;
}

if ( $this->needs_write_permission( $fonts_to_install ) && ! $this->has_write_permission() ) {
$errors[] = new WP_Error(
'cannot_write_fonts_folder',
__( 'Error: WordPress does not have permission to write the fonts folder on your server.', 'gutenberg' )
);
$response_status = 500;
if ( $this->needs_write_permission( $fonts_to_install ) ) {
$upload_dir = WP_Font_Library::get_fonts_dir();
if ( ! $this->has_upload_directory() ) {
if ( ! wp_mkdir_p( $upload_dir ) ) {
$errors[] = new WP_Error(
'cannot_create_fonts_folder',
sprintf(
/* translators: %s: Directory path. */
__( 'Error: Unable to create directory %s.', 'gutenberg' ),
esc_html( $upload_dir )
)
);
$response_status = 500;
}
}

if ( $this->has_upload_directory() && ! $this->has_write_permission() ) {
$errors[] = new WP_Error(
'cannot_write_fonts_folder',
__( 'Error: WordPress does not have permission to write the fonts folder on your server.', 'gutenberg' )
);
$response_status = 500;
}
}

if ( ! empty( $errors ) ) {
Expand Down
84 changes: 48 additions & 36 deletions lib/experimental/interactivity-api/directive-processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,66 @@
*/

/**
* Process directives in each block.
*
* @param string $block_content The block content.
* @param array $block The full block.
*
* @return string Filtered block content.
*/
function gutenberg_interactivity_process_directives_in_root_blocks( $block_content, $block ) {
// Don't process inner blocks or root blocks that don't contain directives.
if ( ! WP_Directive_Processor::is_root_block( $block ) || strpos( $block_content, 'data-wp-' ) === false ) {
return $block_content;
}

// TODO: Add some directive/components registration mechanism.
$directives = array(
'data-wp-bind' => 'gutenberg_interactivity_process_wp_bind',
'data-wp-context' => 'gutenberg_interactivity_process_wp_context',
'data-wp-class' => 'gutenberg_interactivity_process_wp_class',
'data-wp-style' => 'gutenberg_interactivity_process_wp_style',
'data-wp-text' => 'gutenberg_interactivity_process_wp_text',
);

$tags = new WP_Directive_Processor( $block_content );
$tags = gutenberg_interactivity_process_directives( $tags, 'data-wp-', $directives );
return $tags->get_updated_html();
}
add_filter( 'render_block', 'gutenberg_interactivity_process_directives_in_root_blocks', 10, 2 );

/**
* Mark the inner blocks with a temporary property so we can discard them later,
* and process only the root blocks.
* Process the Interactivity API directives using the root blocks of the
* outermost rendering, ignoring the root blocks of inner blocks like Patterns,
* Template Parts or Content.
*
* @param array $parsed_block The parsed block.
* @param array $source_block The source block.
* @param array $parent_block The parent block.
*
* @return array The parsed block.
*/
function gutenberg_interactivity_mark_inner_blocks( $parsed_block, $source_block, $parent_block ) {
if ( ! isset( $parent_block ) ) {
function gutenberg_interactivity_process_directives( $parsed_block, $source_block, $parent_block ) {
static $is_inside_root_block = false;
static $process_directives_in_root_blocks = null;

if ( ! isset( $process_directives_in_root_blocks ) ) {
/**
* Process directives in each root block.
*
* @param string $block_content The block content.
* @param array $block The full block.
*
* @return string Filtered block content.
*/
$process_directives_in_root_blocks = static function ( $block_content, $block ) use ( &$is_inside_root_block ) {

if ( WP_Directive_Processor::is_root_block( $block ) ) {

$directives = array(
'data-wp-bind' => 'gutenberg_interactivity_process_wp_bind',
'data-wp-context' => 'gutenberg_interactivity_process_wp_context',
'data-wp-class' => 'gutenberg_interactivity_process_wp_class',
'data-wp-style' => 'gutenberg_interactivity_process_wp_style',
'data-wp-text' => 'gutenberg_interactivity_process_wp_text',
);

$tags = new WP_Directive_Processor( $block_content );
$tags = gutenberg_interactivity_process_rendered_html( $tags, 'data-wp-', $directives );
$is_inside_root_block = false;
return $tags->get_updated_html();

}

return $block_content;
};
add_filter( 'render_block', $process_directives_in_root_blocks, 10, 2 );
}

if ( ! isset( $parent_block ) && ! $is_inside_root_block ) {
WP_Directive_Processor::add_root_block( $parsed_block );
$is_inside_root_block = true;
}

return $parsed_block;
}
add_filter( 'render_block_data', 'gutenberg_interactivity_mark_inner_blocks', 10, 3 );
add_filter( 'render_block_data', 'gutenberg_interactivity_process_directives', 10, 3 );


/**
* Process directives.
* Traverses the HTML searching for Interactivity API directives and processing
* them.
*
* @param WP_Directive_Processor $tags An instance of the WP_Directive_Processor.
* @param string $prefix Attribute prefix.
Expand All @@ -64,7 +76,7 @@ function gutenberg_interactivity_mark_inner_blocks( $parsed_block, $source_block
* @return WP_Directive_Processor The modified instance of the
* WP_Directive_Processor.
*/
function gutenberg_interactivity_process_directives( $tags, $prefix, $directives ) {
function gutenberg_interactivity_process_rendered_html( $tags, $prefix, $directives ) {
$context = new WP_Directive_Context();
$tag_stack = array();

Expand Down
8 changes: 8 additions & 0 deletions packages/block-editor/src/components/link-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ $preview-image-height: 140px;
.block-editor-link-control__field {
margin: $grid-unit-20; // allow margin collapse for vertical spacing.

.components-base-control__label {
color: $gray-900;
}

input[type="text"],
// Specificity overide of URLInput defaults.
&.block-editor-url-input input[type="text"].block-editor-url-input__input {
Expand Down Expand Up @@ -419,6 +423,10 @@ $preview-image-height: 140px;

.components-base-control__field {
display: flex; // don't allow label to wrap under checkbox.

.components-checkbox-control__label {
color: $gray-900;
}
}

// Cancel left margin inherited from WP Admin Forms CSS.
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/form-submit-button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const TEMPLATE = [
{
text: __( 'Submit' ),
tagName: 'button',
type: 'submit',
},
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function OverlayMenuPreview( { setAttributes, hasIcon, icon } ) {
__nextHasNoMarginBottom
label={ __( 'Show icon button' ) }
help={ __(
'Configure the visual appearance of the button opening the overlay menu.'
'Configure the visual appearance of the button that toggles the overlay menu.'
) }
onChange={ ( value ) => setAttributes( { hasIcon: value } ) }
checked={ hasIcon }
Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/query/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ function render_block_core_query( $attributes, $content, $block ) {
$block->block_type->supports['interactivity'] = true;

// Add a div to announce messages using `aria-live`.
$last_div_position = strripos( $content, '</div>' );
$html_tag = 'div';
if ( ! empty( $attributes['tagName'] ) ) {
$html_tag = esc_attr( $attributes['tagName'] );
}
$last_tag_position = strripos( $content, '</' . $html_tag . '>' );
$content = substr_replace(
$content,
'<div
Expand All @@ -57,7 +61,7 @@ class="wp-block-query__enhanced-pagination-animation"
data-wp-class--start-animation="selectors.core.query.startAnimation"
data-wp-class--finish-animation="selectors.core.query.finishAnimation"
></div>',
$last_div_position,
$last_tag_position,
0
);
}
Expand Down
7 changes: 7 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
### Internal

- Migrate `Divider` from `reakit` to `ariakit` ([#55622](https://github.com/WordPress/gutenberg/pull/55622))
- Migrate `DisclosureContent` from `reakit` to `ariakit` and TypeScript ([#55639](https://github.com/WordPress/gutenberg/pull/55639))

### Experimental

- `Tabs`: Add `focusable` prop to the `Tabs.TabPanel` sub-component ([#55287](https://github.com/WordPress/gutenberg/pull/55287))
- `Tabs`: Update sub-components to accept relevant HTML element props ([#55860](https://github.com/WordPress/gutenberg/pull/55860))

### Enhancements

- `ToggleGroupControl`: Add opt-in prop for 40px default size ([#55789](https://github.com/WordPress/gutenberg/pull/55789)).
- `TextControl`: Add opt-in prop for 40px default size ([#55471](https://github.com/WordPress/gutenberg/pull/55471)).

## 25.11.0 (2023-11-02)

Expand Down
11 changes: 0 additions & 11 deletions packages/components/src/disclosure/index.js

This file was deleted.

44 changes: 44 additions & 0 deletions packages/components/src/disclosure/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';

/**
* Internal dependencies
*/
import type { DisclosureContentProps } from './types';
import type { WordPressComponentProps } from '../context';

/**
* Accessible Disclosure component that controls visibility of a section of
* content. It follows the WAI-ARIA Disclosure Pattern.
*/
const UnforwardedDisclosureContent = (
{
visible,
children,
...props
}: WordPressComponentProps< DisclosureContentProps, 'div', false >,
ref: React.ForwardedRef< any >
) => {
const disclosure = Ariakit.useDisclosureStore( { open: visible } );

return (
<Ariakit.DisclosureContent
store={ disclosure }
ref={ ref }
{ ...props }
>
{ children }
</Ariakit.DisclosureContent>
);
};

export const DisclosureContent = forwardRef( UnforwardedDisclosureContent );
export default DisclosureContent;
10 changes: 10 additions & 0 deletions packages/components/src/disclosure/types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type DisclosureContentProps = {
/**
* If set to `true` the content will be shown, otherwise it's hidden.
*/
visible?: boolean;
/**
* The content to display within the component.
*/
children: React.ReactNode;
};
Loading

0 comments on commit 097ce55

Please sign in to comment.