Skip to content

Commit

Permalink
prep build 01/26
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jan 26, 2022
2 parents a94bfbc + 4ab1bab commit 20a067b
Show file tree
Hide file tree
Showing 28 changed files with 396 additions and 54 deletions.
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Set line width to 80.
4857ad58c1241b3d63d21a6880c989b85746c3dc

# ESLint updates.
f63053cace3c02e284f00918e1854284c85b9132
5 changes: 4 additions & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ jobs:
- name: Compare performance with base branch
if: github.event_name == 'push'
# The base hash used here need to be a commit that is compatible with the current WP version
# The current one is debd225d007f4e441ceec80fbd6fa96653f94737 and it needs to be updated every WP major release.
# It is used as a base comparison point to avoid fluctuation in the performance metrics.
run: |
WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' readme.txt)
IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION"
WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}"
./bin/plugin/cli.js perf --ci $GITHUB_SHA wp/5.8 --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR"
./bin/plugin/cli.js perf --ci $GITHUB_SHA debd225d007f4e441ceec80fbd6fa96653f94737 --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR"
- uses: actions/[email protected]
if: github.event_name == 'push'
Expand Down
226 changes: 226 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions docs/contributors/code/git-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,21 @@ git push
```

The above commands will update your `trunk` branch from _upstream_. To update any other branch replace `trunk` with the respective branch name.

## Miscellaneous

### Git Archeology

When looking for a commit that introduced a specific change, it might be helpful to ignore revisions that only contain styling or formatting changes.

Fortunately, newer versions of `git` gained the ability to skip commits in history:

```
git blame --ignore-rev f63053cace3c02e284f00918e1854284c85b9132 -L 66,73 packages/api-fetch/src/middlewares/media-upload.js
```

All styling and formatting revisions are tracked using the `.git-blame-ignore-revs` file in the Gutenberg repository. You can use this file to ignore them all at once:

```
git blame --ignore-revs-file .git-blame-ignore-revs -L 66,73 packages/api-fetch/src/middlewares/media-upload.js
```
2 changes: 1 addition & 1 deletion docs/how-to-guides/designers/block-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ You can add a description by using the description attribute in the [registerBlo

Stick to a single imperative sentence with an action + subject format. Examples:

- Start with the building block of all narrative.
- Start with the basic building block of all narrative.
- Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.
- Create a bulleted or numbered list.

Expand Down
4 changes: 4 additions & 0 deletions docs/how-to-guides/themes/block-theme-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ theme
|__ footer.html
|__ sidebar.html
|__ ...
|__ styles
|__ red.json
|__ blue.json
|__ ...
```

The difference with existing WordPress themes is that the different templates in the template hierarchy, and template parts, are block templates instead of php files. In addition, this example includes a [`theme.json`](/docs/how-to-guides/themes/theme-json.md) file for some styles.
Expand Down
40 changes: 39 additions & 1 deletion docs/how-to-guides/themes/create-block-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Block themes require WordPress 5.9. To use block themes in earlier versions of W
3. [Creating the templates and template parts](#creating-the-templates-and-template-parts)
4. [Theme.json - Global styles](#themejson---global-styles)
5. [Custom templates](#custom-templates)
6. [Example themes](#example-themes)
6. [Global styles presets](#global-styles-presets)
7. [Example themes](#example-themes)

## What is needed to create a block theme?

Expand All @@ -27,6 +28,7 @@ inside a folder called `templates`.

The theme may optionally include a `functions.php` file and a [theme.json file](/docs/how-to-guides/themes/theme-json.md) to manage global styles.
Template parts are optional. If they are included they must be placed inside a `parts` folder.
The theme may optionally include a `styles` folder to provide [global styles presets](#global-styles-presets).

File structure:

Expand All @@ -43,6 +45,10 @@ theme
|__ header.html
|__ footer.html
|__ ...
|__ styles
|__ red.json
|__ blue.json
|__ ...
```

## Theme setup
Expand Down Expand Up @@ -840,6 +846,38 @@ The key is `postTypes`, followed by the name of the post type:
]
```

## Global styles presets

In addition to the default theme.json file, Block Themes can define multiple global styles presets for users to pick from. For example, a theme author might provide multiple theme color variations for the theme.

To provide a global styles preset, themes can add multiple JSON files inside their `/styles` folder. Each one of these JSON file is a mini theme.json file containing `styles` and/or `settings` that overrides any of the default `theme.json` file settings or styles.

**Example**

```json
// styles/red.json
{
styles: {
colors: {
text: 'red',
background: 'white'
}
}
}
```

```json
// styles/dark.json
{
styles: {
colors: {
text: 'white',
background: 'black'
}
}
}
```

## Example themes

You can find a basic starter theme called "emptytheme" and other example themes
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ body {

Styles found within a block will be enqueued using the block selector.

By default, the block selector is generated based on its name such as `.wp-block-<blockname-without-namespace>`. For example, `.wp-block-group` for the `core/group` block. There are some blocks that want to opt-out from this default behavior. They can do so by explicitly telling the system which selector to use for them via the `__experimentalSelector` key within the `supports` section of its `block.json` file.
By default, the block selector is generated based on its name such as `.wp-block-<blockname-without-namespace>`. For example, `.wp-block-group` for the `core/group` block. There are some blocks that want to opt-out from this default behavior. They can do so by explicitly telling the system which selector to use for them via the `__experimentalSelector` key within the `supports` section of its `block.json` file. Note that the block needs to be registered server-side for the `__experimentalSelector` field to be available to the style engine.

{% codetabs %}
{% Input %}
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ Display a list of all pages. ([Source](https://github.com/WordPress/gutenberg/tr

## Paragraph

Start with the building block of all narrative. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/paragraph))
Start with the basic building block of all narrative. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/paragraph))

- **Name:** core/paragraph
- **Category:** text
Expand Down
17 changes: 16 additions & 1 deletion lib/compat/wordpress-5.9/admin-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,24 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
);
}
}

add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 );

/**
* Override Site Editor URLs to use plugin page.
*
* @param string $url Admin URL link with path.
* @param string $path Path relative to the admin URL.
* @return string Modified Admin URL link.
*/
function gutenberg_override_site_editor_urls( $url, $path ) {
if ( 'site-editor.php' === $path ) {
$url = str_replace( $path, 'themes.php?page=gutenberg-edit-site', $url );
}

return $url;
}
add_filter( 'admin_url', 'gutenberg_override_site_editor_urls', 10, 2 );

/**
* Check if any plugin, or theme features, are using the Customizer.
*
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "12.4.1",
"version": "12.5.0-rc.1",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
4 changes: 4 additions & 0 deletions packages/api-fetch/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking changes

`OPTIONS` requests handled by the preloading middleware are now resolved as `window.Response` objects if you explicitly set `parse: false` (for consistency with how GET requests are resolved). They used to be resolved as `Plain Old JavaScript Objects`.

## 5.2.5 (2021-11-07)

### Internal
Expand Down
68 changes: 39 additions & 29 deletions packages/api-fetch/src/middlewares/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,54 @@ function createPreloadingMiddleware( preloadedData ) {
rawPath = pathFromQuery;
}
}
if ( typeof rawPath === 'string' ) {
const method = options.method || 'GET';
const path = normalizePath( rawPath );
if ( typeof rawPath !== 'string' ) {
return next( options );
}

if ( 'GET' === method && cache[ path ] ) {
const cacheData = cache[ path ];
const method = options.method || 'GET';
const path = normalizePath( rawPath );

// Unsetting the cache key ensures that the data is only used a single time
delete cache[ path ];
if ( 'GET' === method && cache[ path ] ) {
const cacheData = cache[ path ];

return Promise.resolve(
parse
? cacheData.body
: new window.Response(
JSON.stringify( cacheData.body ),
{
status: 200,
statusText: 'OK',
headers: cacheData.headers,
}
)
);
} else if (
'OPTIONS' === method &&
cache[ method ] &&
cache[ method ][ path ]
) {
const cacheData = cache[ method ][ path ];
// Unsetting the cache key ensures that the data is only used a single time
delete cache[ path ];

// Unsetting the cache key ensures that the data is only used a single time
delete cache[ method ][ path ];
return prepareResponse( cacheData, !! parse );
} else if (
'OPTIONS' === method &&
cache[ method ] &&
cache[ method ][ path ]
) {
const cacheData = cache[ method ][ path ];

return Promise.resolve( parse ? cacheData.body : cacheData );
}
// Unsetting the cache key ensures that the data is only used a single time
delete cache[ method ][ path ];

return prepareResponse( cacheData, !! parse );
}

return next( options );
};
}

/**
* This is a helper function that sends a success response.
*
* @param {Record<string, any>} responseData
* @param {boolean} parse
* @return {Promise<any>} Promise with the response.
*/
function prepareResponse( responseData, parse ) {
return Promise.resolve(
parse
? responseData.body
: new window.Response( JSON.stringify( responseData.body ), {
status: 200,
statusText: 'OK',
headers: responseData.headers,
} )
);
}

export default createPreloadingMiddleware;
14 changes: 14 additions & 0 deletions packages/api-fetch/src/middlewares/test/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ describe( 'Preloading Middleware', () => {

describe( 'and the OPTIONS request has a parse flag', () => {
it( 'should return the full response if parse: false', () => {
const noResponseMock =
'undefined' === typeof window.Response;
if ( noResponseMock ) {
window.Response = class {
constructor( body, options ) {
this.body = JSON.parse( body );
this.headers = options.headers;
}
};
}

const data = {
body: {
status: 'this is the preloaded response',
Expand All @@ -85,6 +96,9 @@ describe( 'Preloading Middleware', () => {
};

const response = preloadingMiddleware( requestOptions );
if ( noResponseMock ) {
delete window.Response;
}
return response.then( ( value ) => {
expect( value ).toEqual( data );
} );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/block-card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const MyBlockCard = () => (
<BlockCard
icon={ paragraph }
title="Paragraph"
description="Start with the building block of all narrative."
description="Start with the basic building block of all narrative."
/>
);
```
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
margin-top: auto;
margin-bottom: auto;
flex-direction: column;
max-width: 100%;

> div,
> a {
Expand All @@ -41,7 +42,9 @@
img {
display: block;
height: auto;
max-width: 100%;
// Ensure max-width is not overridden on the img when the parent gallery has
// wide or full alignment.
max-width: 100% !important;
width: auto;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/paragraph/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "core/paragraph",
"title": "Paragraph",
"category": "text",
"description": "Start with the building block of all narrative.",
"description": "Start with the basic building block of all narrative.",
"keywords": [ "text" ],
"textdomain": "default",
"attributes": {
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- Normalized label line-height and spacing within the `ToolsPanel` ([36387](https://github.com/WordPress/gutenberg/pull/36387))
- Remove unused `reakit-utils` from peer dependencies ([#37369](https://github.com/WordPress/gutenberg/pull/37369)).
- Update all Emotion dependencies to the latest version to ensure they work correctly with React types ([#37365](https://github.com/WordPress/gutenberg/pull/37365)).
- `DateTimePicker`: Fix the date format associated to the `is12Hour` prop ([#37465](https://github.com/WordPress/gutenberg/pull/37465))
- Allowed `ToolsPanel` to register items when `panelId` is `null` due to multiple block selection ([37216](https://github.com/WordPress/gutenberg/pull/37216)).

### Enhancements
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/date-time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const MyDateTimePicker = () => {
is12Hour={ true }
/>
);
}
};
```

## Props
Expand All @@ -52,7 +52,7 @@ The function called when a new date or time has been selected. It is passed the

### is12Hour

Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed and the time format is assumed to be MM-DD-YYYY.
Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed and the time format is assumed to be `MM-DD-YYYY` (as opposed to the default format `DD-MM-YYYY`).

- Type: `bool`
- Required: No
Expand All @@ -69,5 +69,5 @@ A callback function which receives a Date object representing a day as an argume

A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument.

- Type: `Function`
- Required: No
- Type: `Function`
- Required: No
Loading

0 comments on commit 20a067b

Please sign in to comment.