Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/border-box-control-clear-button
Browse files Browse the repository at this point in the history
  • Loading branch information
shimotmk authored Feb 7, 2025
2 parents b3149c9 + c9ee64a commit 34db926
Show file tree
Hide file tree
Showing 40 changed files with 345 additions and 161 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/upload-release-to-plugin-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
steps:
- name: Install Subversion
run: |
apt-get update -y && apt-get install -y subversion
sudo apt-get update -y && sudo apt-get install -y subversion
- name: Check out Gutenberg trunk from WP.org plugin repo
run: |
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
steps:
- name: Install Subversion
run: |
apt-get update -y && apt-get install -y subversion
sudo apt-get update -y && sudo apt-get install -y subversion
- name: Download and unzip Gutenberg plugin asset into tags folder
env:
Expand Down
File renamed without changes.
12 changes: 11 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
== Changelog ==

= 20.2.0-rc.1 =
= 20.0.1 =

## Changelog

### Bug Fixes

- iAPI Router: add missing changelog entry for [#68923](https://github.com/WordPress/gutenberg/pull/68945)


= 20.2.0 =

## Changelog

Expand Down Expand Up @@ -143,6 +151,8 @@ The following contributors merged PRs in this release:
@afercia @benazeer-ben @fabiankaegy @himanshupathak95 @im3dabasia @Infinite-Null @justlevine @karthick-murugan @Mamaduka @Mayank-Tripathi32 @SainathPoojary @shail-mehta @shimotmk @Soean @spacedmonkey @stokesman @Sukhendu2002 @t-hamano @yogeshbhutkar




= 20.1.0 =

## Changelog
Expand Down
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
* Requires at least: 6.6
* Requires PHP: 7.2
* Version: 20.2.0-rc.1
* Version: 20.2.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
18 changes: 9 additions & 9 deletions 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": "20.2.0-rc.1",
"version": "20.2.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
43 changes: 34 additions & 9 deletions packages/api-fetch/src/middlewares/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,40 @@ function createPreloadingMiddleware( preloadedData ) {
* @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,
} )
);
if ( parse ) {
return Promise.resolve( responseData.body );
}

try {
return Promise.resolve(
new window.Response( JSON.stringify( responseData.body ), {
status: 200,
statusText: 'OK',
headers: responseData.headers,
} )
);
} catch {
// See: https://github.com/WordPress/gutenberg/issues/67358#issuecomment-2621163926.
Object.entries( responseData.headers ).forEach( ( [ key, value ] ) => {
if ( key.toLowerCase() === 'link' ) {
responseData.headers[ key ] = value.replace(
/<([^>]+)>/,
( /** @type {any} */ _, /** @type {string} */ url ) =>
`<${ encodeURI( url ) }>`
);
}
} );

return Promise.resolve(
parse
? responseData.body
: new window.Response( JSON.stringify( responseData.body ), {
status: 200,
statusText: 'OK',
headers: responseData.headers,
} )
);
}
}

export default createPreloadingMiddleware;
51 changes: 51 additions & 0 deletions packages/api-fetch/src/middlewares/test/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,57 @@ describe( 'Preloading Middleware', () => {
expect( secondMiddleware ).toHaveBeenCalledTimes( 1 );
} );

it( 'should not throw an error when non-ASCII headers are present', async () => {
const noResponseMock = 'undefined' === typeof window.Response;
if ( noResponseMock ) {
window.Response = class {
constructor( body, options ) {
this.body = JSON.parse( body );
this.headers = options.headers;

// Check for non-ASCII characters in headers
for ( const [ key, value ] of Object.entries(
this.headers || {}
) ) {
if ( /[^\x00-\x7F]/.test( value ) ) {
throw new Error(
`Invalid non-ASCII character found in header: ${ key }`
);
}
}
}
};
}

const data = {
body: 'Hello',
headers: {
Link: '<http://example.com/ویدیو/example>; rel="alternate"; type=text/html',
},
};

const preloadedData = {
'wp/v2/example': data,
};

const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );

const requestOptions = {
method: 'GET',
path: 'wp/v2/example',
parse: false,
};

await expect(
preloadingMiddleware( requestOptions, () => {} )
).resolves.not.toThrow();

if ( noResponseMock ) {
delete window.Response;
}
} );

describe.each( [ [ 'GET' ], [ 'OPTIONS' ] ] )( '%s', ( method ) => {
describe.each( [
[ 'all empty', {} ],
Expand Down
5 changes: 5 additions & 0 deletions packages/babel-preset-default/polyfill-exclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ module.exports = [
//
// @see https://github.com/WordPress/gutenberg/pull/67230
/^es(next)?\.set\./,
// Remove Iterator feature polyfills.
// For the same reasoning as for Set exlusion above, we're excluding all iterator helper polyfills.
//
// @see https://github.com/WordPress/wordpress-develop/pull/8224#issuecomment-2636390007.
/^es(next)?\.iterator\./,
];
2 changes: 1 addition & 1 deletion packages/block-directory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-directory",
"version": "5.17.0",
"version": "5.17.1",
"description": "Extend editor with block directory features to search, download and install blocks.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
3 changes: 3 additions & 0 deletions packages/block-directory/src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel
import getInstallMissing from './get-install-missing';

registerPlugin( 'block-directory', {
// The icon is explicitly set to undefined to prevent PluginPrePublishPanel
// from rendering the fallback icon pluginIcon.
icon: undefined,
render() {
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { _n, sprintf } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { blockDefault } from '@wordpress/icons';
import { PluginPrePublishPanel } from '@wordpress/editor';

/**
Expand All @@ -24,7 +23,6 @@ export default function InstalledBlocksPrePublishPanel() {

return (
<PluginPrePublishPanel
icon={ blockDefault }
title={ sprintf(
// translators: %d: number of blocks (number).
_n(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { store as blockEditorStore } from '../../store';

const SEARCH_THRESHOLD = 6;
const SHOWN_BLOCK_TYPES = 6;
const SHOWN_BLOCK_PATTERNS = 2;

export default function QuickInserter( {
onSelect,
Expand Down Expand Up @@ -106,7 +107,9 @@ export default function QuickInserter( {
rootClientId={ rootClientId }
clientId={ clientId }
isAppender={ isAppender }
maxBlockPatterns={ 0 }
maxBlockPatterns={
!! filterValue ? SHOWN_BLOCK_PATTERNS : 0
}
maxBlockTypes={ SHOWN_BLOCK_TYPES }
isDraggable={ false }
selectBlockOnInsert={ selectBlockOnInsert }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ function InserterSearchResults( {
] = useBlockTypesState( destinationRootClientId, onInsertBlocks, isQuick );
const [ patterns, , onClickPattern ] = usePatternsState(
onInsertBlocks,
destinationRootClientId
destinationRootClientId,
undefined,
isQuick
);

const filteredBlockPatterns = useMemo( () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ $block-inserter-tabs-height: 44px;
text-align: center;
}

.block-editor-inserter__no-results-icon {
fill: $gray-600;
}

.block-editor-inserter__child-blocks {
padding: 0 $grid-unit-20;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,7 @@ import {
__experimentalUseCustomUnits as useCustomUnits,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import {
useSettings,
privateApis as blockEditorPrivateApis,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import { unlock } from '../lock-unlock';

const { ResolutionTool } = unlock( blockEditorPrivateApis );
import { useSettings } from '@wordpress/block-editor';

const SCALE_OPTIONS = (
<>
Expand All @@ -45,7 +33,6 @@ const SCALE_OPTIONS = (
);

const DEFAULT_SCALE = 'cover';
const DEFAULT_SIZE = 'full';

const scaleHelp = {
cover: __(
Expand All @@ -61,9 +48,8 @@ const scaleHelp = {

const DimensionControls = ( {
clientId,
attributes: { aspectRatio, width, height, scale, sizeSlug },
attributes: { aspectRatio, width, height, scale },
setAttributes,
media,
} ) => {
const [ availableUnits, defaultRatios, themeRatios, showDefaultRatios ] =
useSettings(
Expand All @@ -75,18 +61,6 @@ const DimensionControls = ( {
const units = useCustomUnits( {
availableUnits: availableUnits || [ 'px', '%', 'vw', 'em', 'rem' ],
} );
const imageSizes = useSelect(
( select ) => select( blockEditorStore ).getSettings().imageSizes,
[]
);
const imageSizeOptions = imageSizes
.filter( ( { slug } ) => {
return media?.media_details?.sizes?.[ slug ]?.source_url;
} )
.map( ( { name, slug } ) => ( {
value: slug,
label: name,
} ) );

const onDimensionChange = ( dimension, nextValue ) => {
const parsedValue = parseFloat( nextValue );
Expand Down Expand Up @@ -230,21 +204,6 @@ const DimensionControls = ( {
</ToggleGroupControl>
</ToolsPanelItem>
) }
{ !! imageSizeOptions.length && (
<ResolutionTool
panelId={ clientId }
value={ sizeSlug }
defaultValue={ DEFAULT_SIZE }
options={ imageSizeOptions }
onChange={ ( nextSizeSlug ) =>
setAttributes( { sizeSlug: nextSizeSlug } )
}
isShownByDefault={ false }
resetAllFilter={ () => ( {
sizeSlug: DEFAULT_SIZE,
} ) }
/>
) }
</>
);
};
Expand Down
Loading

0 comments on commit 34db926

Please sign in to comment.