From 42febd2e8a1593208e686775daf509bdc650820f Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 12 Jul 2021 09:00:20 +0100 Subject: [PATCH 01/12] Skip unstable e2e tests (#33352) --- .../e2e-tests/specs/experiments/multi-entity-saving.test.js | 2 +- packages/e2e-tests/specs/widgets/customizing-widgets.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js b/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js index 937ba8a090ecbf..5a137f5e0eeccd 100644 --- a/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js +++ b/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js @@ -82,7 +82,7 @@ describe( 'Multi-entity save flow', () => { expect( multiSaveButton ).toBeNull(); }; - it( 'Save flow should work as expected.', async () => { + it.skip( 'Save flow should work as expected.', async () => { await createNewPost(); // Edit the page some. await page.click( '.editor-post-title' ); diff --git a/packages/e2e-tests/specs/widgets/customizing-widgets.test.js b/packages/e2e-tests/specs/widgets/customizing-widgets.test.js index 960d93ce1b2992..e61709adf0e834 100644 --- a/packages/e2e-tests/specs/widgets/customizing-widgets.test.js +++ b/packages/e2e-tests/specs/widgets/customizing-widgets.test.js @@ -150,7 +150,7 @@ describe( 'Widgets Customizer', () => { ); } ); - it( 'should open the inspector panel', async () => { + it.skip( 'should open the inspector panel', async () => { const widgetsPanel = await find( { role: 'heading', name: /Widgets/, From daf7814d0ce7b9c1312498e598918e2ef0e7dc24 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 12 Jul 2021 10:00:35 +0200 Subject: [PATCH 02/12] Update getTermsInfo() to workaround parsing issue for translatable strings (#33341) --- packages/block-library/src/query/utils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/query/utils.js b/packages/block-library/src/query/utils.js index d8edac0adb145a..6ff6e026e08b3b 100644 --- a/packages/block-library/src/query/utils.js +++ b/packages/block-library/src/query/utils.js @@ -39,9 +39,8 @@ import { store as coreStore } from '@wordpress/core-data'; * @param {WPTerm[]} terms The terms to extract of helper object. * @return {QueryTermsInfo} The object with the terms information. */ -export const getTermsInfo = ( terms ) => ( { - terms, - ...terms?.reduce( +export const getTermsInfo = ( terms ) => { + const mapping = terms?.reduce( ( accumulator, term ) => { const { mapById, mapByName, names } = accumulator; mapById[ term.id ] = term; @@ -50,8 +49,13 @@ export const getTermsInfo = ( terms ) => ( { return accumulator; }, { mapById: {}, mapByName: {}, names: [] } - ), -} ); + ); + + return { + terms, + ...mapping, + }; +}; /** * Returns a helper object that contains: From c3c29ebc79857fd8c31b53df68d980e78ed9ec44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Mon, 12 Jul 2021 10:56:37 +0200 Subject: [PATCH 03/12] Specify what settings can be part of `settings.layout` (#33303) --- lib/class-wp-theme-json-gutenberg.php | 5 ++++- phpunit/class-wp-theme-json-test.php | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 92bd630ad2fffa..0b4ae918037a14 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -92,7 +92,10 @@ class WP_Theme_JSON_Gutenberg { 'palette' => null, ), 'custom' => null, - 'layout' => null, + 'layout' => array( + 'contentSize' => null, + 'wideSize' => null, + ), 'spacing' => array( 'customMargin' => null, 'customPadding' => null, diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 91974e8ef6b480..6d44ca15362111 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -16,6 +16,10 @@ function test_get_settings() { 'color' => array( 'custom' => false, ), + 'layout' => array( + 'contentSize' => 'value', + 'invalid/key' => 'value', + ), 'invalid/key' => 'value', 'blocks' => array( 'core/group' => array( @@ -44,6 +48,9 @@ function test_get_settings() { 'color' => array( 'custom' => false, ), + 'layout' => array( + 'contentSize' => 'value', + ), 'blocks' => array( 'core/group' => array( 'color' => array( From 23369aac7c95ef11525c4ee3b9a184372885f344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Mon, 12 Jul 2021 11:02:48 +0200 Subject: [PATCH 04/12] Update conditions to hide duotone panel (#33295) --- docs/how-to-guides/themes/theme-json.md | 2 ++ lib/class-wp-theme-json-gutenberg.php | 1 + lib/experimental-default-theme.json | 5 +++-- .../duotone-control/duotone-picker-popover.js | 2 ++ .../src/components/duotone-control/index.js | 6 ++---- packages/block-editor/src/hooks/duotone.js | 14 ++++++++++++-- .../src/duotone-picker/duotone-picker.js | 6 ++++-- 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/how-to-guides/themes/theme-json.md b/docs/how-to-guides/themes/theme-json.md index 0990c618ea9f4e..6e751aa2e19ff8 100644 --- a/docs/how-to-guides/themes/theme-json.md +++ b/docs/how-to-guides/themes/theme-json.md @@ -169,6 +169,7 @@ The settings section has the following structure: "settings": { "color": { "custom": true, + "customDuotone": true, "customGradient": true, "duotone": [], "gradients": [], @@ -220,6 +221,7 @@ The settings section has the following structure: }, "color": { "custom": true, + "customDuotone": true, "customGradient": true, "duotone": [], "gradients": [], diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 0b4ae918037a14..335d461b695f26 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -85,6 +85,7 @@ class WP_Theme_JSON_Gutenberg { ), 'color' => array( 'custom' => null, + 'customDuotone' => null, 'customGradient' => null, 'duotone' => null, 'gradients' => null, diff --git a/lib/experimental-default-theme.json b/lib/experimental-default-theme.json index e12e4231018a36..bf7ef9ef5147ba 100644 --- a/lib/experimental-default-theme.json +++ b/lib/experimental-default-theme.json @@ -169,8 +169,9 @@ } ], "custom": true, - "link": false, - "customGradient": true + "customDuotone": true, + "customGradient": true, + "link": false }, "typography": { "dropCap": true, diff --git a/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js b/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js index c277b07ad1487a..64f4c1cf225c2b 100644 --- a/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js +++ b/packages/block-editor/src/components/duotone-control/duotone-picker-popover.js @@ -11,6 +11,7 @@ function DuotonePickerPopover( { duotonePalette, colorPalette, disableCustomColors, + disableCustomDuotone, } ) { return ( diff --git a/packages/block-editor/src/components/duotone-control/index.js b/packages/block-editor/src/components/duotone-control/index.js index eb675639a5f143..757e83803e86b7 100644 --- a/packages/block-editor/src/components/duotone-control/index.js +++ b/packages/block-editor/src/components/duotone-control/index.js @@ -15,15 +15,12 @@ function DuotoneControl( { colorPalette, duotonePalette, disableCustomColors, + disableCustomDuotone, value, onChange, } ) { const [ isOpen, setIsOpen ] = useState( false ); - if ( ! duotonePalette ) { - return null; - } - const onToggle = () => { setIsOpen( ( prev ) => ! prev ); }; @@ -55,6 +52,7 @@ function DuotoneControl( { duotonePalette={ duotonePalette } colorPalette={ colorPalette } disableCustomColors={ disableCustomColors } + disableCustomDuotone={ disableCustomDuotone } /> ) } diff --git a/packages/block-editor/src/hooks/duotone.js b/packages/block-editor/src/hooks/duotone.js index 6e5a79766cae86..c0de112b020d8d 100644 --- a/packages/block-editor/src/hooks/duotone.js +++ b/packages/block-editor/src/hooks/duotone.js @@ -21,6 +21,8 @@ import { useSetting, } from '../components'; +const EMPTY_ARRAY = []; + /** * Convert a list of colors to an object of R, G, and B values. * @@ -124,15 +126,23 @@ function DuotonePanel( { attributes, setAttributes } ) { const style = attributes?.style; const duotone = style?.color?.duotone; - const duotonePalette = useSetting( 'color.duotone' ); - const colorPalette = useSetting( 'color.palette' ); + const duotonePalette = useSetting( 'color.duotone' ) || EMPTY_ARRAY; + const colorPalette = useSetting( 'color.palette' ) || EMPTY_ARRAY; const disableCustomColors = ! useSetting( 'color.custom' ); + const disableCustomDuotone = + ! useSetting( 'color.customDuotone' ) || + ( colorPalette?.length === 0 && disableCustomColors ); + + if ( duotonePalette?.length === 0 && disableCustomDuotone ) { + return null; + } return ( { diff --git a/packages/components/src/duotone-picker/duotone-picker.js b/packages/components/src/duotone-picker/duotone-picker.js index bbc546acec1c46..fa01fd82707671 100644 --- a/packages/components/src/duotone-picker/duotone-picker.js +++ b/packages/components/src/duotone-picker/duotone-picker.js @@ -22,6 +22,7 @@ function DuotonePicker( { colorPalette, duotonePalette, disableCustomColors, + disableCustomDuotone, value, onChange, } ) { @@ -29,6 +30,7 @@ function DuotonePicker( { () => getDefaultColors( colorPalette ), [ colorPalette ] ); + return ( { @@ -74,10 +76,10 @@ function DuotonePicker( { } > - { ! disableCustomColors && ( + { ! disableCustomColors && ! disableCustomDuotone && ( ) } - { colorPalette && ( + { ! disableCustomDuotone && ( Date: Mon, 12 Jul 2021 10:13:44 +0100 Subject: [PATCH 05/12] Skipping more e2e tests (#33353) --- .../e2e-tests/specs/editor/various/inserting-blocks.test.js | 2 +- .../specs/experiments/post-editor-template-mode.test.js | 2 +- packages/e2e-tests/specs/widgets/editing-widgets.test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js b/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js index acc7965c5621d2..98da1a81e4429b 100644 --- a/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js +++ b/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js @@ -57,7 +57,7 @@ describe( 'Inserting blocks', () => { return page.mouse.click( x, y ); } - it( 'Should insert content using the placeholder and the regular inserter', async () => { + it.skip( 'Should insert content using the placeholder and the regular inserter', async () => { // This ensures the editor is loaded in navigation mode. await page.reload(); await page.waitForSelector( '.edit-post-layout' ); diff --git a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js index 5e8d80b1f45c51..cf229daa06a40c 100644 --- a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js +++ b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js @@ -145,7 +145,7 @@ describe( 'Post Editor Template mode', () => { ); } ); - it( 'Allow creating custom block templates in classic themes', async () => { + it.skip( 'Allow creating custom block templates in classic themes', async () => { await activateTheme( 'twentytwentyone' ); await createNewPost(); // Create a random post. diff --git a/packages/e2e-tests/specs/widgets/editing-widgets.test.js b/packages/e2e-tests/specs/widgets/editing-widgets.test.js index c626564bb37e11..623cd89fd798c0 100644 --- a/packages/e2e-tests/specs/widgets/editing-widgets.test.js +++ b/packages/e2e-tests/specs/widgets/editing-widgets.test.js @@ -240,7 +240,7 @@ describe( 'Widgets screen', () => { ` ); } ); - it( 'Should insert content using the inline inserter', async () => { + it.skip( 'Should insert content using the inline inserter', async () => { const [ firstWidgetArea ] = await findAll( { role: 'group', name: 'Block: Widget Area', From bbaeea2056c96af931170da1665d5d98c79b4b8d Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 12 Jul 2021 10:38:40 +0100 Subject: [PATCH 06/12] Prevent entering invalid values in the Query Loop block config (#33285) --- .../src/query/edit/query-toolbar.js | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/query/edit/query-toolbar.js b/packages/block-library/src/query/edit/query-toolbar.js index db4de14f297b19..92db79c7dad7b2 100644 --- a/packages/block-library/src/query/edit/query-toolbar.js +++ b/packages/block-library/src/query/edit/query-toolbar.js @@ -61,11 +61,18 @@ export default function QueryToolbar( { labelPosition="edge" min={ 1 } max={ 100 } - onChange={ ( value ) => + onChange={ ( value ) => { + if ( + isNaN( value ) || + value < 1 || + value > 100 + ) { + return; + } setQuery( { - perPage: +value ?? -1, - } ) - } + perPage: value, + } ); + } } step="1" value={ query.perPage } isDragEnabled={ false } @@ -78,9 +85,16 @@ export default function QueryToolbar( { labelPosition="edge" min={ 0 } max={ 100 } - onChange={ ( value ) => - setQuery( { offset: +value } ) - } + onChange={ ( value ) => { + if ( + isNaN( value ) || + value < 0 || + value > 100 + ) { + return; + } + setQuery( { offset: value } ); + } } step="1" value={ query.offset } isDragEnabled={ false } @@ -98,9 +112,12 @@ export default function QueryToolbar( { label={ __( 'Max page to show' ) } labelPosition="edge" min={ 0 } - onChange={ ( value ) => - setQuery( { pages: +value } ) - } + onChange={ ( value ) => { + if ( isNaN( value ) || value < 0 ) { + return; + } + setQuery( { pages: value } ); + } } step="1" value={ query.pages } isDragEnabled={ false } From b2f1af2bc95c0e8c9b0d2109f1acfe2b889cd48d Mon Sep 17 00:00:00 2001 From: Ceyhun Ozugur Date: Mon, 12 Jul 2021 12:37:43 +0200 Subject: [PATCH 07/12] Mobile Release v1.57.0 (#33322) --- packages/react-native-aztec/package.json | 2 +- packages/react-native-bridge/package.json | 2 +- packages/react-native-editor/ios/Podfile.lock | 10 +++++----- packages/react-native-editor/package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/react-native-aztec/package.json b/packages/react-native-aztec/package.json index 0b0fcc20e5514d..f567091186d8d5 100644 --- a/packages/react-native-aztec/package.json +++ b/packages/react-native-aztec/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-aztec", - "version": "1.56.0", + "version": "1.57.0", "description": "Aztec view for react-native.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-bridge/package.json b/packages/react-native-bridge/package.json index 7b946159f0d851..7ce5ff3235252e 100644 --- a/packages/react-native-bridge/package.json +++ b/packages/react-native-bridge/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-bridge", - "version": "1.56.0", + "version": "1.57.0", "description": "Native bridge library used to integrate the block editor into a native App.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-editor/ios/Podfile.lock b/packages/react-native-editor/ios/Podfile.lock index 135e8c97bfa777..f7dc687b0d70ab 100644 --- a/packages/react-native-editor/ios/Podfile.lock +++ b/packages/react-native-editor/ios/Podfile.lock @@ -12,7 +12,7 @@ PODS: - React-jsi (= 0.64.0) - ReactCommon/turbomodule/core (= 0.64.0) - glog (0.3.5) - - Gutenberg (1.56.0): + - Gutenberg (1.57.0): - React-Core (= 0.64.0) - React-CoreModules (= 0.64.0) - React-RCTImage (= 0.64.0) @@ -303,7 +303,7 @@ PODS: - React-Core - RNSVG (9.13.6-gb): - React-Core - - RNTAztecView (1.56.0): + - RNTAztecView (1.57.0): - React-Core - WordPress-Aztec-iOS (~> 1.19.4) - WordPress-Aztec-iOS (1.19.4) @@ -457,9 +457,9 @@ SPEC CHECKSUMS: BVLinearGradient: b2d297a15cf094d1947df4f0519779bb3a7f2392 DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de FBLazyVector: 49cbe4b43e445b06bf29199b6ad2057649e4c8f5 - FBReactNativeSpec: 80e9cf1155002ee4720084d8813326d913815e2f + FBReactNativeSpec: 47ea6a66a418fe8bdbf26d3cc53d16dea40bae80 glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 - Gutenberg: 92bec6d8f160c51fd16b7538ff750e1136e8a134 + Gutenberg: bb77241bcf984883fea30a910d8ccec46de54205 RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c RCTRequired: 2f8cb5b7533219bf4218a045f92768129cf7050a RCTTypeSafety: 512728b73549e72ad7330b92f3d42936f2a4de5b @@ -496,7 +496,7 @@ SPEC CHECKSUMS: RNReanimated: f05baf4cd76b6eab2e4d7e2b244424960b968918 RNScreens: 953633729a42e23ad0c93574d676b361e3335e8b RNSVG: 46c4b680fe18237fa01eb7d7b311d77618fde31f - RNTAztecView: 2d4d506e2e203ad07ff911adf7eeb9a36a87512b + RNTAztecView: 44570e19f7141c5d7be9ddc23efdb4d6d6cf02e2 WordPress-Aztec-iOS: 870c93297849072aadfc2223e284094e73023e82 Yoga: 8c8436d4171c87504c648ae23b1d81242bdf3bbf diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index d3c5b7d53a1154..0701c64844da27 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-editor", - "version": "1.56.0", + "version": "1.57.0", "description": "Mobile WordPress gutenberg editor.", "author": "The WordPress Contributors", "license": "GPL-2.0-or-later", From ea498919b3ada6a799a0b26864708e44fe0a7dbb Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 12 Jul 2021 12:06:41 +0100 Subject: [PATCH 08/12] Tag Cloud: Remove editor style so editor matches frontend (#33289) * Tag Cloud: Remove editor style so editor matches frontend * Remove all editor styles * move editor styles to the frontend --- packages/block-library/src/editor.scss | 1 - packages/block-library/src/tag-cloud/editor.scss | 13 ------------- packages/block-library/src/tag-cloud/style.scss | 11 +++++++++++ 3 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 packages/block-library/src/tag-cloud/editor.scss diff --git a/packages/block-library/src/editor.scss b/packages/block-library/src/editor.scss index b813152d2f1900..a3f9b9ce885c3b 100644 --- a/packages/block-library/src/editor.scss +++ b/packages/block-library/src/editor.scss @@ -42,7 +42,6 @@ @import "./social-links/editor.scss"; @import "./spacer/editor.scss"; @import "./table/editor.scss"; -@import "./tag-cloud/editor.scss"; @import "./template-part/editor.scss"; @import "./text-columns/editor.scss"; @import "./video/editor.scss"; diff --git a/packages/block-library/src/tag-cloud/editor.scss b/packages/block-library/src/tag-cloud/editor.scss deleted file mode 100644 index a554d72ee004e7..00000000000000 --- a/packages/block-library/src/tag-cloud/editor.scss +++ /dev/null @@ -1,13 +0,0 @@ -.wp-block-tag-cloud { - a { - display: inline-block; - margin-right: 5px; - } - - span { - display: inline-block; - margin-left: 5px; - color: $gray-700; - text-decoration: none; - } -} diff --git a/packages/block-library/src/tag-cloud/style.scss b/packages/block-library/src/tag-cloud/style.scss index 3592e5d2473142..1d1c63364147a9 100644 --- a/packages/block-library/src/tag-cloud/style.scss +++ b/packages/block-library/src/tag-cloud/style.scss @@ -7,4 +7,15 @@ padding-left: 1em; padding-right: 1em; } + + a { + display: inline-block; + margin-right: 5px; + } + + span { + display: inline-block; + margin-left: 5px; + text-decoration: none; + } } From bf4f3ec9e453065ee00daf92243b3c8aafada13c Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 12 Jul 2021 12:37:17 +0100 Subject: [PATCH 09/12] Latest posts: Remove grey color for dark themes (#33325) --- packages/block-library/src/latest-posts/style.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/block-library/src/latest-posts/style.scss b/packages/block-library/src/latest-posts/style.scss index 2df097b3fc9907..3ea00a015063ba 100644 --- a/packages/block-library/src/latest-posts/style.scss +++ b/packages/block-library/src/latest-posts/style.scss @@ -43,7 +43,6 @@ .wp-block-latest-posts__post-date, .wp-block-latest-posts__post-author { display: block; - color: #555; font-size: 0.8125em; } From 940c279792ca17180d5537d8a7899427dcecc37d Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Mon, 12 Jul 2021 14:48:54 +0300 Subject: [PATCH 10/12] Add a "separator" attribute to post-terms block (#32812) * Add a "separator" attribute to post-terms * Change default from a pipe to a comma * fix defaults * Add separator class * update fixtures * change selector from sep to separator * Add styles * indentation fix * import style Co-authored-by: ntsekouras --- .../block-library/src/post-terms/block.json | 7 ++++- packages/block-library/src/post-terms/edit.js | 26 ++++++++++++++++--- .../block-library/src/post-terms/index.php | 26 +++++++------------ .../block-library/src/post-terms/style.scss | 3 +++ packages/block-library/src/style.scss | 1 + .../fixtures/blocks/core__post-terms.json | 4 ++- 6 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 packages/block-library/src/post-terms/style.scss diff --git a/packages/block-library/src/post-terms/block.json b/packages/block-library/src/post-terms/block.json index 1f9f61738eb599..a79af6ef85539c 100644 --- a/packages/block-library/src/post-terms/block.json +++ b/packages/block-library/src/post-terms/block.json @@ -11,6 +11,10 @@ }, "textAlign": { "type": "string" + }, + "separator": { + "type": "string", + "default": ", " } }, "usesContext": [ "postId", "postType" ], @@ -24,5 +28,6 @@ "lineHeight": true, "fontSize": true } - } + }, + "style": "wp-block-post-terms" } diff --git a/packages/block-library/src/post-terms/edit.js b/packages/block-library/src/post-terms/edit.js index 15b981bf69af6b..4a939e2af579cd 100644 --- a/packages/block-library/src/post-terms/edit.js +++ b/packages/block-library/src/post-terms/edit.js @@ -8,11 +8,12 @@ import classnames from 'classnames'; */ import { AlignmentToolbar, + InspectorAdvancedControls, BlockControls, Warning, useBlockProps, } from '@wordpress/block-editor'; -import { Spinner } from '@wordpress/components'; +import { Spinner, TextControl } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { store as coreStore } from '@wordpress/core-data'; @@ -27,7 +28,7 @@ export default function PostTermsEdit( { context, setAttributes, } ) { - const { term, textAlign } = attributes; + const { term, textAlign, separator } = attributes; const { postId, postType } = context; const selectedTerm = useSelect( @@ -78,6 +79,17 @@ export default function PostTermsEdit( { } } /> + + { + setAttributes( { separator: nextValue } ); + } } + help={ __( 'Enter character(s) used to separate terms.' ) } + /> +
{ isLoading && } { ! isLoading && @@ -92,7 +104,15 @@ export default function PostTermsEdit( { { postTerm.name } ) ) - .reduce( ( prev, curr ) => [ prev, ' | ', curr ] ) } + .reduce( ( prev, curr ) => ( + <> + { prev } + + { separator || ' ' } + + { curr } + + ) ) } { ! isLoading && ! hasPostTerms && ( selectedTerm?.labels?.no_terms || diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 436611d7567042..2573c4f0fba4bc 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -23,10 +23,7 @@ function render_block_core_post_terms( $attributes, $content, $block ) { } $post_terms = get_the_terms( $block->context['postId'], $attributes['term'] ); - if ( is_wp_error( $post_terms ) ) { - return ''; - } - if ( empty( $post_terms ) ) { + if ( is_wp_error( $post_terms ) || empty( $post_terms ) ) { return ''; } @@ -35,21 +32,16 @@ function render_block_core_post_terms( $attributes, $content, $block ) { $classes .= ' has-text-align-' . $attributes['textAlign']; } - $terms_links = ''; - foreach ( $post_terms as $term ) { - $terms_links .= sprintf( - '%2$s | ', - get_term_link( $term->term_id ), - esc_html( $term->name ) - ); - } - $terms_links = trim( $terms_links, ' | ' ); + $separator = empty( $attributes['separator'] ) ? ' ' : $attributes['separator']; + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); - return sprintf( - '
%2$s
', - $wrapper_attributes, - $terms_links + return get_the_term_list( + $block->context['postId'], + $attributes['term'], + "
", + '' . $separator . '', + '
' ); } diff --git a/packages/block-library/src/post-terms/style.scss b/packages/block-library/src/post-terms/style.scss new file mode 100644 index 00000000000000..e447f1fd6b60d6 --- /dev/null +++ b/packages/block-library/src/post-terms/style.scss @@ -0,0 +1,3 @@ +.wp-block-post-terms__separator { + white-space: pre-wrap; +} diff --git a/packages/block-library/src/style.scss b/packages/block-library/src/style.scss index 92e10a3dee23a6..c475eab47f5dcd 100644 --- a/packages/block-library/src/style.scss +++ b/packages/block-library/src/style.scss @@ -31,6 +31,7 @@ @import "./post-comments/style.scss"; @import "./post-comments-form/style.scss"; @import "./post-excerpt/style.scss"; +@import "./post-terms/style.scss"; @import "./post-title/style.scss"; @import "./preformatted/style.scss"; @import "./pullquote/style.scss"; diff --git a/packages/e2e-tests/fixtures/blocks/core__post-terms.json b/packages/e2e-tests/fixtures/blocks/core__post-terms.json index 18f7983b7b80a9..34cd4804b0160d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__post-terms.json +++ b/packages/e2e-tests/fixtures/blocks/core__post-terms.json @@ -3,7 +3,9 @@ "clientId": "_clientId_0", "name": "core/post-terms", "isValid": true, - "attributes": {}, + "attributes": { + "separator": ", " + }, "innerBlocks": [], "originalContent": "" } From 1a8f8501c7cb85f4fbb1c24786d30015bb328b6e Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 12 Jul 2021 13:53:44 +0100 Subject: [PATCH 11/12] RSS Block: Update block styles (#33294) * RSS Block: Update block styles * Add ul for the editor * Update comment --- packages/block-library/src/rss/style.scss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/rss/style.scss b/packages/block-library/src/rss/style.scss index 3a3995cf6e384e..f7360ec76f85ac 100644 --- a/packages/block-library/src/rss/style.scss +++ b/packages/block-library/src/rss/style.scss @@ -1,4 +1,7 @@ -.wp-block-rss { +ul.wp-block-rss { // The ul is needed for specificity to override the reset styles in the editor. + list-style: none; + padding: 0; + // This needs extra specificity due to the reset mixin on the parent: https://github.com/WordPress/gutenberg/blob/a250e9e5fe00dd5195624f96a3d924e7078951c3/packages/edit-post/src/style.scss#L54 &.wp-block-rss { box-sizing: border-box; @@ -36,6 +39,5 @@ .wp-block-rss__item-publish-date, .wp-block-rss__item-author { display: block; - color: #555; font-size: 0.8125em; } From f3797c37b2f0b5d3ee52282bb3cd5563db8e9b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Mon, 12 Jul 2021 15:46:24 +0200 Subject: [PATCH 12/12] Block Editor API: Changes to support multiple admin screens in WP 5.8 (#33262) * Block Editor API: Changes to support multiple admin screens in WP 5.8 See https://make.wordpress.org/core/2021/06/16/block-editor-api-changes-to-support-multiple-admin-screens-in-wp-5-8/. * Add a note explaining how to use the deprecated filters --- .../reference-guides/filters/block-filters.md | 51 +++++++++++-------- .../filters/editor-filters.md | 50 ++++++++++++++++-- 2 files changed, 75 insertions(+), 26 deletions(-) diff --git a/docs/reference-guides/filters/block-filters.md b/docs/reference-guides/filters/block-filters.md index 02a28e8f433830..57e227c4a6a8a4 100644 --- a/docs/reference-guides/filters/block-filters.md +++ b/docs/reference-guides/filters/block-filters.md @@ -339,48 +339,57 @@ wp.blocks.getBlockTypes().forEach( function ( blockType ) { ## Hiding blocks from the inserter -On the server, you can filter the list of blocks shown in the inserter using the `allowed_block_types` filter. You can return either true (all block types supported), false (no block types supported), or an array of block type names to allow. You can also use the second provided param `$post` to filter block types based on its content. +### `allowed_block_types_all` + +_**Note:** Before WordPress 5.8 known as `allowed_block_types`. In the case when you want to support older versions of WordPress you might need a way to detect which filter should be used – the deprecated one vs the new one. The recommended way to proceed is to check if the `WP_Block_Editor_Context` class exists._ + +On the server, you can filter the list of blocks shown in the inserter using the `allowed_block_types_all` filter. You can return either true (all block types supported), false (no block types supported), or an array of block type names to allow. You can also use the second provided param `$editor_context` to filter block types based on its content. ```php post_type !== 'post' ) { - return $allowed_block_types; +function filter_allowed_block_types_when_post_provided( $allowed_block_types, $editor_context ) { + if ( ! empty( $editor_context->post ) ) { + return array( 'core/paragraph', 'core/heading' ); } - return array( 'core/paragraph' ); + return $allowed_block_types; } -add_filter( 'allowed_block_types', 'my_plugin_allowed_block_types', 10, 2 ); +add_filter( 'allowed_block_types_all', 'filter_allowed_block_types_when_post_provided', 10, 2 ); ``` ## Managing block categories -It is possible to filter the list of default block categories using the `block_categories` filter. You can do it on the server by implementing a function which returns a list of categories. It is going to be used during blocks registration and to group blocks in the inserter. You can also use the second provided param `$post` to generate a different list depending on the post's content. +### `block_categories_all` + +_**Note:** Before WordPress 5.8 known as `block_categories`. In the case when you want to support older versions of WordPress you might need a way to detect which filter should be used – the deprecated one vs the new one. The recommended way to proceed is to check if the `WP_Block_Editor_Context` class exists._ + +It is possible to filter the list of default block categories using the `block_categories_all` filter. You can do it on the server by implementing a function which returns a list of categories. It is going to be used during blocks registration and to group blocks in the inserter. You can also use the second provided param `$editor_context` to filter the based on its content. ```php post_type !== 'post' ) { - return $categories; - } - return array_merge( - $categories, - array( +function filter_block_categories_when_post_provided( $block_categories, $editor_context ) { + if ( ! empty( $editor_context->post ) ) { + array_push( + $block_categories, array( - 'slug' => 'my-category', - 'title' => __( 'My category', 'my-plugin' ), - 'icon' => 'wordpress', - ), - ) - ); + 'slug' => 'custom-category', + 'title' => __( 'Custom Category', 'custom-plugin' ), + 'icon' => null, + ) + ); + } + return $block_categories; } -add_filter( 'block_categories', 'my_plugin_block_categories', 10, 2 ); + +add_filter( 'block_categories_all', 'filter_block_categories_when_post_provided', 10, 2 ); ``` +### `wp.blocks.updateCategory` + You can also display an icon with your block category by setting an `icon` attribute. The value can be the slug of a [WordPress Dashicon](https://developer.wordpress.org/resource/dashicons/). You can also set a custom icon in SVG format. To do so, the icon should be rendered and set on the frontend, so it can make use of WordPress SVG, allowing mobile compatibility and making the icon more accessible. diff --git a/docs/reference-guides/filters/editor-filters.md b/docs/reference-guides/filters/editor-filters.md index 94d27c9fd994da..a445abe95e177b 100644 --- a/docs/reference-guides/filters/editor-filters.md +++ b/docs/reference-guides/filters/editor-filters.md @@ -64,13 +64,51 @@ addFilter( ## Editor settings -### `block_editor_settings` +### `block_editor_settings_all` + +_**Note:** Before WordPress 5.8 known as `block_editor_settings`. In the case when you want to support older versions of WordPress you might need a way to detect which filter should be used – the deprecated one vs the new one. The recommended way to proceed is to check if the `WP_Block_Editor_Context` class exists._ This is a PHP filter which is applied before sending settings to the WordPress block editor. -You may find details about this filter [on its WordPress Code Reference page](https://developer.wordpress.org/reference/hooks/block_editor_settings/). +You may find details about this filter [on its WordPress Code Reference page](https://developer.wordpress.org/reference/hooks/block_editor_settings_all/). + +The filter will send any setting to the initialized Editor, which means any editor setting that is used to configure the editor at initialiation can be filtered by a PHP WordPress plugin before being sent. + +_Example:_ + +```php +post ) ) { + $editor_settings['maxUploadFileSize'] = 12345; + } + return $editor_settings; +} + +add_filter( 'block_editor_settings_all', 'filter_block_editor_settings_when_post_provided', 10, 2 ); +``` + +#### `block_editor_rest_api_preload_paths` + +Filters the array of REST API paths that will be used to preloaded common data to use with the block editor. + +_Example:_ + +```php +post ) ) { + array_push( $preload_paths, array( '/wp/v2/blocks', 'OPTIONS' ) ); + } + return $preload_paths; +} + +add_filter( 'block_editor_rest_api_preload_paths', 'filter_block_editor_rest_api_preload_paths_when_post_provided', 10, 2 ); +``` ### Available default editor settings @@ -88,9 +126,11 @@ If set to false the user will not be able to switch between visual and code edit ### Block Directory -The Block Directory enables installing new block plugins from [WordPress.org.](https://wordpress.org/plugins/browse/block/) It can be disabled by removing the actions that enqueue it. In WordPress core, the function is `wp_enqueue_editor_block_directory_assets`, and Gutenberg uses `gutenberg_enqueue_block_editor_assets_block_directory`. To remove the feature, use [`remove_action`,](https://developer.wordpress.org/reference/functions/remove_action/) like this: +The Block Directory enables installing new block plugins from [WordPress.org.](https://wordpress.org/plugins/browse/block/) It can be disabled by removing the actions that enqueue it. In WordPress core, the function is `wp_enqueue_editor_block_directory_assets`. To remove the feature, use [`remove_action`,](https://developer.wordpress.org/reference/functions/remove_action/) like this: ```php +