Skip to content

Commit

Permalink
prep build 12/02
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Dec 2, 2023
2 parents 5ad28e8 + ded792b commit f8a0185
Show file tree
Hide file tree
Showing 111 changed files with 19,905 additions and 10,663 deletions.
41 changes: 33 additions & 8 deletions bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ const LABEL_FEATURE_MAPPING = {
'[Feature] Raw Handling': 'Block Editor',
'[Package] Edit Post': 'Post Editor',
'[Package] Icons': 'Icons',
'[Package] Block Editor': 'Block Editor',
'[Package] Block editor': 'Block Editor',
'[Package] Block library': 'Block Library',
'[Package] Editor': 'Post Editor',
'[Package] Edit Site': 'Site Editor',
'[Package] Edit Widgets': 'Widgets Editor',
'[Package] Widgets Customizer': 'Widgets Editor',
'[Package] Components': 'Components',
'[Package] Block Library': 'Block Library',
'[Package] Rich text': 'Block Editor',
'[Package] Data': 'Data Layer',
'[Package] Commands': 'Commands',
'[Block] Legacy Widget': 'Widgets Editor',
'REST API Interaction': 'REST API',
'New Block': 'Block Library',
Expand Down Expand Up @@ -220,9 +222,18 @@ function getTypesByLabels( labels ) {
...new Set(
labels
.filter( ( label ) =>
Object.keys( LABEL_TYPE_MAPPING ).includes( label )
Object.keys( LABEL_TYPE_MAPPING )
.map( ( currentLabel ) => currentLabel.toLowerCase() )
.includes( label.toLowerCase() )
)
.map( ( label ) => LABEL_TYPE_MAPPING[ label ] )
.map( ( label ) => {
const lowerCaseLabel =
Object.keys( LABEL_TYPE_MAPPING ).find(
( key ) => key.toLowerCase() === label.toLowerCase()
) || label;

return LABEL_TYPE_MAPPING[ lowerCaseLabel ];
} )
),
];
}
Expand All @@ -236,11 +247,24 @@ function getTypesByLabels( labels ) {
* @return {string[]} Feature candidates.
*/
function mapLabelsToFeatures( labels ) {
return labels
.filter( ( label ) =>
Object.keys( LABEL_FEATURE_MAPPING ).includes( label )
)
.map( ( label ) => LABEL_FEATURE_MAPPING[ label ] );
return [
...new Set(
labels
.filter( ( label ) =>
Object.keys( LABEL_FEATURE_MAPPING )
.map( ( currentLabel ) => currentLabel.toLowerCase() )
.includes( label.toLowerCase() )
)
.map( ( label ) => {
const lowerCaseLabel =
Object.keys( LABEL_FEATURE_MAPPING ).find(
( key ) => key.toLowerCase() === label.toLowerCase()
) || label;

return LABEL_FEATURE_MAPPING[ lowerCaseLabel ];
} )
),
];
}

/**
Expand Down Expand Up @@ -1070,4 +1094,5 @@ async function getReleaseChangelog( options ) {
getChangelog,
getUniqueByUsername,
skipCreatedByBots,
mapLabelsToFeatures,
};
324 changes: 191 additions & 133 deletions bin/plugin/commands/test/__snapshots__/changelog.js.snap

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions bin/plugin/commands/test/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getChangelog,
getContributorProps,
getContributorsList,
mapLabelsToFeatures,
} from '../changelog';
import _pullRequests from './fixtures/pull-requests.json';
import botPullRequestFixture from './fixtures/bot-pull-requests.json';
Expand Down Expand Up @@ -312,18 +313,35 @@ describe( 'sortGroup', () => {
} );

describe( 'getTypesByLabels', () => {
it( 'returns all normalized type candidates by type prefix', () => {
it( 'returns all normalized type candidates by type prefix. it is case insensitive', () => {
const result = getTypesByLabels( [
'[Type] Regression',
'[Type] Bug',
'[Package] Blocks',
'[Type] Performance',
'[Type] performance',
] );

expect( result ).toEqual( [ 'Bug Fixes', 'Performance' ] );
} );
} );

describe( 'mapLabelsToFeatures', () => {
it( 'returns all normalized feature candidates by feature prefix. it is case insensitive', () => {
const result = mapLabelsToFeatures( [
'[Package] Commands',
'[Package] Block Library',
'[Feature] Link Editing',
'[Feature] block Multi Selection',
] );

expect( result ).toEqual( [
'Commands',
'Block Library',
'Block Editor',
] );
} );
} );

describe( 'getTypesByTitle', () => {
it.each( [
[ 'Fix Typography panel rendering from style hooks' ],
Expand Down Expand Up @@ -473,7 +491,7 @@ describe( 'getFormattedItemDescription', () => {
describe( 'getChangelog', () => {
test( 'verify that the changelog is properly formatted', () => {
// The fixture with the list of pull requests was generated by running the following command:
// npm run other:changelog -- --milestone="Gutenberg 11.3"
// npm run other:changelog -- --milestone="Gutenberg 16.8"
// The response from the `fetchAllPullRequests` call in the `getChangelog` method was stored in the JSON file.
expect( getChangelog( pullRequests ) ).toMatchSnapshot();
} );
Expand Down
27,622 changes: 18,335 additions & 9,287 deletions bin/plugin/commands/test/fixtures/pull-requests.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
== Changelog ==

= 17.1.4 =

## Changelog

### Bug Fixes

#### Block Library
- Post Template: Fix incorrect offset query. ([56440](https://github.com/WordPress/gutenberg/pull/56440))

## Contributors

The following contributors merged PRs in this release:

@t-hamano


= 17.2.0-rc.1 =


Expand Down
34 changes: 17 additions & 17 deletions docs/getting-started/fundamentals/block-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ At [**Metadata in block.json**](https://developer.wordpress.org/block-editor/ref

Through properties of the `block.json`, we can define how the block will be uniquely identified, how it can be found, and the info displayed for the block in the Block Editor. Some of these properties are:

- `apiVersion`: the version of [the API](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/) used by the block (current version is 2).
- `name`: a unique identifier for a block, including a namespace.
- `title`: a display title for a block.
- `category`: a block category for the block in the Inserter panel.
- `icon`: a [Dashicon](https://developer.wordpress.org/resource/dashicons) slug or a custom SVG icon.
- `description`: a short description visible in the block inspector.
- `keywords`: to locate the block in the inserter.
- `textdomain`: the plugin text-domain (important for things such as translations).
- [`apiVersion`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#api-version): the version of [the API](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/) used by the block (current version is 2).
- [`name`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#name): a unique identifier for a block, including a namespace.
- [`title`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#title): a display title for a block.
- [`category`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#category): a block category for the block in the Inserter panel.
- [`icon`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#icon): a [Dashicon](https://developer.wordpress.org/resource/dashicons) slug or a custom SVG icon.
- [`description`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#description): a short description visible in the block inspector.
- [`keywords`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#keywords): to locate the block in the inserter.
- [`textdomain`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#text-domain): the plugin text-domain (important for things such as translations).

## Files for the block's behavior, output, or style

The `editorScript` and `editorStyle` properties allow defining Javascript and CSS files to be enqueued and loaded **only in the editor**.
The [`editorScript`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-script) and [`editorStyle`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style) properties allow defining Javascript and CSS files to be enqueued and loaded **only in the editor**.

The `script` and `style` properties allow the definition of Javascript and CSS files to be enqueued and loaded **in both the editor and the front end**.
The [`script`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#script) and [`style`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) properties allow the definition of Javascript and CSS files to be enqueued and loaded **in both the editor and the front end**.

The `viewScript` property allow us to define the Javascript file or files to be enqueued and loaded **only in the front end**.
The [`viewScript`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script) property allow us to define the Javascript file or files to be enqueued and loaded **only in the front end**.

All these properties (`editorScript`, `editorStyle`, `script` `style`,`viewScript`) accept as a value a path for the file, a handle registered with `wp_register_script` or `wp_register_style`, or an array with a mix of both. Paths values in `block.json` are prefixed with `file:`.
All these properties (`editorScript`, `editorStyle`, `script` `style`,`viewScript`) accept as a value a [path for the file](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#wpdefinedpath) (prefixed with `file:`), a [handle registered with `wp_register_script` or `wp_register_style`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#wpdefinedasset), or an array with a mix of both.

The `render` property ([introduced on WordPress 6.1](https://make.wordpress.org/core/2022/10/12/block-api-changes-in-wordpress-6-1/)) sets the path of a `.php` template file that will render the markup returned to the front end. This only method will be used to return the markup for the block on request only if `$render_callback` function has not been passed to the `register_block_type` function.
The [`render`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#render) property ([introduced on WordPress 6.1](https://make.wordpress.org/core/2022/10/12/block-api-changes-in-wordpress-6-1/)) sets the path of a `.php` template file that will render the markup returned to the front end. This only method will be used to return the markup for the block on request only if `$render_callback` function has not been passed to the `register_block_type` function.

## Data Storage in the Block with `attributes`

The [`attributes` property](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/) allows a block to declare "variables" that store data or content for the block.
The [`attributes` property](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#attributes) allows a block to declare "variables" that store data or content for the block.

_Example: Attributes as defined in block.json_
```json
Expand All @@ -69,9 +69,9 @@ _Example: Atributes stored in the Markup representation of the block_
<!-- /wp:block-development-examples/copyright-date-block-09aac3 -->x
```

These attributes are passed to the React component `Edit`(to display in the Block Editor) and the `save` function (to return the markup saved to the DB) of the block, and to any server-side render definition for the block (see `render` prop above).
These [`attributes`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#attributes) are passed to the React component `Edit`(to display in the Block Editor) and the `save` function (to return the markup saved to the DB) of the block, and to any server-side render definition for the block (see `render` prop above).

The `Edit` component receives exclusively the capability of updating the attributes via the `setAttributes` function.
The `Edit` component receives exclusively the capability of updating the attributes via the [`setAttributes`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#setattributes) function.

_See how the attributes are passed to the [`Edit` component](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/copyright-date-block-09aac3/src/edit.js), [the `save` function](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/copyright-date-block-09aac3/src/save.js) and [the `render.php`](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/copyright-date-block-09aac3/src/render.php) in this [full block example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/copyright-date-block-09aac3) of the code above_

Expand All @@ -84,7 +84,7 @@ Check the <a href="https://developer.wordpress.org/block-editor/reference-guides

## Enable UI settings panels for the block with `supports`

The `supports` property allows a block to declare support for certain features, enabling users to customize specific settings (like colors or margins) from the Settings Sidebar.
The [`supports`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#supports) property allows a block to declare support for certain features, enabling users to customize specific settings (like colors or margins) from the Settings Sidebar.

_Example: Supports as defined in block.json_

Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started/fundamentals/block-wrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ The use of <code>supports</code> generates a set of properties that need to be m

A block can have three sets of markup defined, each one of them with a specific target and purpose:

- The one for the **Block Editor**, defined through a `edit` React component passed to `registerBlockType` when registering the block in the client.
- The one for the **Block Editor**, defined through a `edit` React component passed to [`registerBlockType`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#registerblocktype) when registering the block in the client.
- The one used to **save the block in the DB**, defined through a `save` function passed to `registerBlockType` when registering the block in the client.
- This markup will be returned to the front end on request if no dynamic render has been defined for the block.
- The one used to **dynamically render the markup of the block** returned to the front end on request, defined through the `render_callback` on `register_block_type` or the `render` PHP file in `block.json`
- The one used to **dynamically render the markup of the block** returned to the front end on request, defined through the `render_callback` on [`register_block_type`](https://developer.wordpress.org/reference/functions/register_block_type/) or the [`render`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#render) PHP file in `block.json`
- If defined, this server-side generated markup will be returned to the front end, ignoring the markup stored in DB.

For the React component `edit` and the `save` function, the block wrapper element should be a native DOM element (like `<div>`) or a React component that forwards any additional props to native DOM elements. Using a <Fragment> or <ServerSideRender> component, for instance, would be invalid.
For the [`edit` React component and the `save` function](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/), the block wrapper element should be a native DOM element (like `<div>`) or a React component that forwards any additional props to native DOM elements. Using a <Fragment> or <ServerSideRender> component, for instance, would be invalid.


## The Edit component's markup

The `useBlockProps()` hook available on the `@wordpress/block-editor` allows passing the required attributes for the Block Editor to the `edit` block's outer wrapper.
The [`useBlockProps()`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops) hook available on the [`@wordpress/block-editor`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor) allows passing the required attributes for the Block Editor to the `edit` block's outer wrapper.

Among other things, the `useBlockProps()` hook takes care of including in this wrapper:
- An `id` for the block's markup
Expand Down
Loading

0 comments on commit f8a0185

Please sign in to comment.