From 6774683452144f2f50e1cbcce8344d2bad503525 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Mon, 3 Jul 2023 17:52:54 +1000 Subject: [PATCH] Update/wp6 3 beta3 (#52234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Footnotes: inscrease selector specificity for anchor (#52179) * Patterns: Include template parts for custom areas in Uncategorized category (#52159) * Fix custom patterns console error (#51947) * Fix error with react list key with new custom patterns list in inserter * Update placeholder key * Add comment to explain the different keys * Patterns: Fix missing custom patterns in patterns explorer (#51889) * Add custom patterns to pattern explorer * show custom patterns in the patterns explorer dialog * remove changes from 51877 * Fix up use of async lists * remove a bit of code duplication by adding a new hook * add 51877 fix back to make testing easier * Just assign the key value in one place * Refactor the custom patterns to use the usePatternsState hook * Fix use of async list * Translate strings and remove unneeded fields from pattern object * Try integrating unsynced patterns directly into pattern selectors (#51955) * Include reusable blocks with an undefined sync status in inserter items * Update docs * Remove change to hover dependencies --------- Co-authored-by: Daniel Richards * i18n: Add context to the word "Filters" (#52198) * Update home template icon (#52075) * Centralise all permissions lookup in Link UI and enable (#52166) * BlockRemovalWarningModal: Fix incorrect '_n' usage (#52164) * Fix fetching Nav fallback ID flushing Navigation entity cache (#52069) * Only flush the `getEntityRecords` cache if the fallback isn’t already in state * Save the edited entity record to a const and then invert it to determine whether we should invalidate the recordds --------- Co-authored-by: scruffian * Block Editor: Unify texts for Create pattern modal (#52151) * Fix history back after entering edit mode from Patterns (#52112) * Add template part icons to the library grid items (#51963) * Patterns: Fix sidebar tab label (#51953) * Patterns: Fix setting of sync status for fully synced patterns (#51952) * Library: Reinstate manage all template parts page (#51961) * Command Palette: fix incorrect path and snackbar message when template part is deleted (#52034) * Command Center: Fix incorrect navigation when deleting template part * removeTemplate: consider title type * Drop-indicator: remove white border. (#52122) * Make Navigation fallback selector private (#51413) * Move selector to become private * adds basic lock functionality * remove useless lock-unlock file * map private selectors to resolvers * Unlock the other usage * only create one fallback per session * Fix core-data duplicate private opt-in * Data: bind resolvers to selectors individually, support private selectors --------- Co-authored-by: Andrei Draganescu Co-authored-by: scruffian Co-authored-by: Jarda Snajdr * Focus Mode: Use the symbol icon if a pattern is being edited (#52031) * Footnotes: register meta field for pages (#52024) * Fix unintentional toggling on of distraction free (#52090) * replace toggle with set preference - because I don't read code properly it seems * remove notification * Revert "Updating social link attributes (#51997)" (#52019) This reverts commit c711e2aa613aceb93836635e854badd8ac15310d. * Update home template name (#52048) * Removes unused call (#51988) * Remove ability for user to toggle sync status after pattern creation (#51998) * Fix disable DFM when opening styles command (#52165) * Update custom patterns label to 'My patterns' (#51949) * rename custom patterns to my patterns * Add my patterns label to inserter and show at the top --------- Co-authored-by: Daniel Richards * Library: Add sync status to pattern details screen (#51954) * Patterns: Rename Library to Patterns (#52102) * [Library] Add lock icon for theme patterns (#51990) * Add lock icon for theme patterns * Change to class names * Add aria-description * Change wording * Patterns: Use "detached" copy consistently (#51993) * Editor initrial appender: Zero out margins in constrained layouts. (#52026) * Update pattern creation modal in library (#51946) * Fix missing snackbars in Library (#52021) * Make the entire preview clickable in order to enter "edit" mode in focus mode (#51973) * Page Content Focus: Add welcome guides (#52014) * Page Content Focus: Add welcome guides * Don't show when editor guide is active * Just use regular accent/theme color in all guides * slight copy change page guide * Update components changelog * Disable new guides in E2E tests * Use s.w.org videos --------- Co-authored-by: Saxon Fletcher --------- Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com> Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Co-authored-by: Glen Davies Co-authored-by: Daniel Richards Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Co-authored-by: James Koster Co-authored-by: Dave Smith Co-authored-by: George Mamadashvili Co-authored-by: scruffian Co-authored-by: Kai Hao Co-authored-by: Carolina Nymark Co-authored-by: Joen A <1204802+jasmussen@users.noreply.github.com> Co-authored-by: Andrei Draganescu Co-authored-by: Jarda Snajdr Co-authored-by: Andrei Draganescu Co-authored-by: Ramon Co-authored-by: Nik Tsekouras Co-authored-by: Saxon Fletcher Co-authored-by: Rich Tabor Co-authored-by: Robert Anderson --- .../data/data-core-block-editor.md | 1 - docs/reference-guides/data/data-core.md | 12 -- .../wordpress-6.3/block-template-utils.php | 2 +- .../block-actions-menu.native.js | 12 +- .../block-removal-warning-modal/index.js | 10 +- .../default-block-appender/content.scss | 11 ++ .../components/global-styles/filters-panel.js | 4 +- .../block-patterns-explorer/patterns-list.js | 10 +- .../components/inserter/block-patterns-tab.js | 64 ++--------- .../inserter/hooks/use-block-types-state.js | 7 +- .../inserter/hooks/use-patterns-state.js | 54 +++++---- .../inserter/reusable-blocks-tab.js | 2 +- .../src/components/list-view/style.scss | 3 +- packages/block-editor/src/store/selectors.js | 71 ++++++++---- packages/block-library/src/block/edit.js | 4 +- .../block-library/src/block/edit.native.js | 16 +-- .../block-library/src/footnotes/index.php | 20 ++-- .../block-library/src/footnotes/style.scss | 4 +- .../block-library/src/navigation-link/edit.js | 16 +-- .../src/navigation-link/link-ui.js | 16 ++- .../src/navigation/edit/index.js | 3 +- .../edit/menu-inspector-controls.js | 1 - .../block-library/src/social-link/index.php | 4 +- packages/components/src/guide/icons.tsx | 9 +- packages/components/src/guide/index.tsx | 4 + .../components/src/guide/page-control.tsx | 6 +- packages/components/src/guide/style.scss | 32 ++---- .../src/admin-navigation-commands.js | 2 +- .../src/site-editor-navigation-commands.js | 2 +- packages/core-data/README.md | 12 -- packages/core-data/src/index.js | 7 +- packages/core-data/src/private-selectors.ts | 13 +++ packages/core-data/src/resolvers.js | 13 ++- packages/core-data/src/selectors.ts | 12 -- packages/data/src/redux-store/index.js | 84 +++++++------- .../src/admin/visit-site-editor.ts | 8 ++ packages/e2e-test-utils/src/site-editor.js | 77 +++---------- .../editor/various/reusable-blocks.test.js | 6 +- .../add-new-template/new-template.js | 4 +- .../components/block-editor/editor-canvas.js | 4 +- .../components/create-pattern-modal/index.js | 21 ++-- .../document-actions/index.js | 10 +- .../src/components/page-main/index.js | 9 +- .../grid-item.js | 98 ++++++++++++---- .../{page-library => page-patterns}/grid.js | 2 +- .../{page-library => page-patterns}/index.js | 10 +- .../no-patterns.js | 2 +- .../patterns-list.js | 12 +- .../search-items.js | 0 .../style.scss | 28 +++-- .../use-pattern-settings.js} | 2 +- .../use-patterns.js | 13 ++- .../{page-library => page-patterns}/utils.js | 6 +- .../components/page-template-parts/index.js | 105 ++++++++++++++++++ .../edit-site/src/components/page/index.js | 6 +- .../settings-header/index.js | 9 +- .../index.js | 41 ++++--- .../style.scss | 3 - .../sidebar-navigation-screen-main/index.js | 4 +- .../index.js | 8 +- .../index.js | 16 ++- .../sidebar-navigation-screen-pages/index.js | 4 +- .../index.js | 19 +++- .../style.scss | 4 + .../use-pattern-details.js | 44 +++++++- .../category-item.js | 6 +- .../index.js | 97 ++++++++++++---- .../style.scss | 3 + .../use-default-pattern-categories.js | 0 .../use-my-patterns.js | 23 ++++ .../use-pattern-categories.js | 19 +--- .../use-template-part-areas.js | 0 .../use-theme-patterns.js | 2 +- .../index.js | 2 + .../index.js | 97 +++------------- .../edit-site/src/components/sidebar/index.js | 12 +- .../use-sync-path-with-url.js | 2 +- .../src/components/welcome-guide/editor.js | 2 +- .../src/components/welcome-guide/index.js | 4 + .../src/components/welcome-guide/page.js | 75 +++++++++++++ .../src/components/welcome-guide/style.scss | 16 ++- .../src/components/welcome-guide/styles.js | 2 +- .../src/components/welcome-guide/template.js | 82 ++++++++++++++ .../src/hooks/commands/use-common-commands.js | 14 ++- .../hooks/commands/use-edit-mode-commands.js | 6 +- packages/edit-site/src/index.js | 2 + packages/edit-site/src/store/actions.js | 9 +- packages/edit-site/src/style.scss | 4 +- .../edit-site/src/utils/get-is-list-page.js | 7 +- .../src/components/post-sync-status/index.js | 34 ++---- .../components/post-sync-status/style.scss | 4 +- .../reusable-block-convert-button.js | 3 +- .../reusable-blocks-manage-button.js | 4 +- .../site-editor-url-navigation.spec.js | 2 +- 94 files changed, 1009 insertions(+), 642 deletions(-) rename packages/edit-site/src/components/{page-library => page-patterns}/grid-item.js (67%) rename packages/edit-site/src/components/{page-library => page-patterns}/grid.js (94%) rename packages/edit-site/src/components/{page-library => page-patterns}/index.js (83%) rename packages/edit-site/src/components/{page-library => page-patterns}/no-patterns.js (77%) rename packages/edit-site/src/components/{page-library => page-patterns}/patterns-list.js (89%) rename packages/edit-site/src/components/{page-library => page-patterns}/search-items.js (100%) rename packages/edit-site/src/components/{page-library => page-patterns}/style.scss (78%) rename packages/edit-site/src/components/{page-library/use-library-settings.js => page-patterns/use-pattern-settings.js} (96%) rename packages/edit-site/src/components/{page-library => page-patterns}/use-patterns.js (93%) rename packages/edit-site/src/components/{page-library => page-patterns}/utils.js (76%) create mode 100644 packages/edit-site/src/components/page-template-parts/index.js delete mode 100644 packages/edit-site/src/components/sidebar-navigation-screen-library/style.scss rename packages/edit-site/src/components/{sidebar-navigation-screen-library => sidebar-navigation-screen-patterns}/category-item.js (86%) rename packages/edit-site/src/components/{sidebar-navigation-screen-library => sidebar-navigation-screen-patterns}/index.js (59%) create mode 100644 packages/edit-site/src/components/sidebar-navigation-screen-patterns/style.scss rename packages/edit-site/src/components/{sidebar-navigation-screen-library => sidebar-navigation-screen-patterns}/use-default-pattern-categories.js (100%) create mode 100644 packages/edit-site/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js rename packages/edit-site/src/components/{sidebar-navigation-screen-library => sidebar-navigation-screen-patterns}/use-pattern-categories.js (69%) rename packages/edit-site/src/components/{sidebar-navigation-screen-library => sidebar-navigation-screen-patterns}/use-template-part-areas.js (100%) rename packages/edit-site/src/components/{sidebar-navigation-screen-library => sidebar-navigation-screen-patterns}/use-theme-patterns.js (96%) create mode 100644 packages/edit-site/src/components/welcome-guide/page.js create mode 100644 packages/edit-site/src/components/welcome-guide/template.js diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md index 20d6ebfe5291aa..8b0f24e60fb7bf 100644 --- a/docs/reference-guides/data/data-core-block-editor.md +++ b/docs/reference-guides/data/data-core-block-editor.md @@ -538,7 +538,6 @@ _Parameters_ - _state_ `Object`: Editor state. - _rootClientId_ `?string`: Optional root client ID of block list. -- _syncStatus_ `?string`: Optional sync status to filter pattern blocks by. _Returns_ diff --git a/docs/reference-guides/data/data-core.md b/docs/reference-guides/data/data-core.md index 8db3a26dd09772..a66c0991e3d274 100644 --- a/docs/reference-guides/data/data-core.md +++ b/docs/reference-guides/data/data-core.md @@ -329,18 +329,6 @@ _Returns_ - `any`: The entity record's save error. -### getNavigationFallbackId - -Retrieve the fallback Navigation. - -_Parameters_ - -- _state_ `State`: Data state. - -_Returns_ - -- `EntityRecordKey | undefined`: The ID for the fallback Navigation post. - ### getRawEntityRecord Returns the entity's record object by key, with its attributes mapped to their raw values. diff --git a/lib/compat/wordpress-6.3/block-template-utils.php b/lib/compat/wordpress-6.3/block-template-utils.php index cdd870db2d0813..cc367f66dd42d9 100644 --- a/lib/compat/wordpress-6.3/block-template-utils.php +++ b/lib/compat/wordpress-6.3/block-template-utils.php @@ -29,7 +29,7 @@ function gutenberg_get_default_block_template_types( $default_template_types ) { } if ( isset( $default_template_types['home'] ) ) { $default_template_types['home'] = array( - 'title' => _x( 'Home', 'Template name', 'gutenberg' ), + 'title' => _x( 'Blog Home', 'Template name', 'gutenberg' ), 'description' => __( 'Displays the latest posts as either the site homepage or as the "Posts page" as defined under reading settings. If it exists, the Front Page template overrides this template when posts are shown on the homepage.', 'gutenberg' diff --git a/packages/block-editor/src/components/block-mobile-toolbar/block-actions-menu.native.js b/packages/block-editor/src/components/block-mobile-toolbar/block-actions-menu.native.js index e896d6054a8ff0..48be5cb8a9c00b 100644 --- a/packages/block-editor/src/components/block-mobile-toolbar/block-actions-menu.native.js +++ b/packages/block-editor/src/components/block-mobile-toolbar/block-actions-menu.native.js @@ -213,16 +213,12 @@ const BlockActionsMenu = ( { id: 'convertToRegularBlocksOption', label: innerBlockCount > 1 - ? __( 'Convert to regular blocks' ) - : __( 'Convert to regular block' ), + ? __( 'Detach patterns' ) + : __( 'Detach pattern' ), value: 'convertToRegularBlocksOption', onSelect: () => { - const successNotice = - innerBlockCount > 1 - ? /* translators: %s: name of the reusable block */ - __( '%s converted to regular blocks' ) - : /* translators: %s: name of the reusable block */ - __( '%s converted to regular block' ); + /* translators: %s: name of the synced block */ + const successNotice = __( '%s detached' ); createSuccessNotice( sprintf( successNotice, diff --git a/packages/block-editor/src/components/block-removal-warning-modal/index.js b/packages/block-editor/src/components/block-removal-warning-modal/index.js index 2e16d2834d2ce3..2ed65481f68959 100644 --- a/packages/block-editor/src/components/block-removal-warning-modal/index.js +++ b/packages/block-editor/src/components/block-removal-warning-modal/index.js @@ -8,7 +8,7 @@ import { Button, __experimentalHStack as HStack, } from '@wordpress/components'; -import { __, _n } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -75,11 +75,9 @@ export function BlockRemovalWarningModal() { ) }

- { _n( - 'Removing this block is not advised.', - 'Removing these blocks is not advised.', - blockNamesForPrompt.length - ) } + { blockNamesForPrompt.length > 1 + ? __( 'Removing these blocks is not advised.' ) + : __( 'Removing this block is not advised.' ) }

diff --git a/packages/block-editor/src/components/list-view/style.scss b/packages/block-editor/src/components/list-view/style.scss index 0924e98b3f5d45..ab041af51aa1e9 100644 --- a/packages/block-editor/src/components/list-view/style.scss +++ b/packages/block-editor/src/components/list-view/style.scss @@ -408,8 +408,7 @@ $block-navigation-max-indent: 8; .block-editor-list-view-drop-indicator__line { background: var(--wp-admin-theme-color); - height: 6px; - border: 1px solid $white; + height: 4px; border-radius: 4px; } } diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 05d00f65b1fd34..fc314636d11951 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -1945,7 +1945,6 @@ const buildBlockTypeItem = * * @param {Object} state Editor state. * @param {?string} rootClientId Optional root client ID of block list. - * @param {?string} syncStatus Optional sync status to filter pattern blocks by. * * @return {WPEditorInserterItem[]} Items that appear in inserter. * @@ -1962,11 +1961,7 @@ const buildBlockTypeItem = * @property {number} frecency Heuristic that combines frequency and recency. */ export const getInserterItems = createSelector( - ( state, rootClientId = null, syncStatus ) => { - const buildBlockTypeInserterItem = buildBlockTypeItem( state, { - buildScope: 'inserter', - } ); - + ( state, rootClientId = null ) => { /* * Matches block comment delimiters amid serialized content. * @@ -2031,13 +2026,7 @@ export const getInserterItems = createSelector( }; }; - const blockTypeInserterItems = getBlockTypes() - .filter( ( blockType ) => - canIncludeBlockTypeInInserter( state, blockType, rootClientId ) - ) - .map( buildBlockTypeInserterItem ); - - const reusableBlockInserterItems = canInsertBlockTypeUnmemoized( + const syncedPatternInserterItems = canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId @@ -2045,13 +2034,25 @@ export const getInserterItems = createSelector( ? getReusableBlocks( state ) .filter( ( reusableBlock ) => - syncStatus === reusableBlock.meta?.sync_status || - ( ! syncStatus && - reusableBlock.meta?.sync_status === '' ) + // Filter to either fully synced patterns (sync_status === 'fully'), + // or old school reusable blocks (sync_status === ''). + reusableBlock.meta?.sync_status === 'fully' || + reusableBlock.meta?.sync_status === '' || + ! reusableBlock.meta?.sync_status ) .map( buildReusableBlockInserterItem ) : []; + const buildBlockTypeInserterItem = buildBlockTypeItem( state, { + buildScope: 'inserter', + } ); + + const blockTypeInserterItems = getBlockTypes() + .filter( ( blockType ) => + canIncludeBlockTypeInInserter( state, blockType, rootClientId ) + ) + .map( buildBlockTypeInserterItem ); + const items = blockTypeInserterItems.reduce( ( accumulator, item ) => { const { variations = [] } = item; // Exclude any block type item that is to be replaced by a default variation. @@ -2082,7 +2083,7 @@ export const getInserterItems = createSelector( { core: [], noncore: [] } ); const sortedBlockTypes = [ ...coreItems, ...nonCoreItems ]; - return [ ...sortedBlockTypes, ...reusableBlockInserterItems ]; + return [ ...sortedBlockTypes, ...syncedPatternInserterItems ]; }, ( state, rootClientId ) => [ state.blockListSettings[ rootClientId ], @@ -2306,10 +2307,32 @@ const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => { return true; }; +function getUnsyncedPatterns( state ) { + const reusableBlocks = + state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY; + + return reusableBlocks + .filter( + ( reusableBlock ) => reusableBlock.meta?.sync_status === 'unsynced' + ) + .map( ( reusableBlock ) => { + return { + name: `core/block/${ reusableBlock.id }`, + title: reusableBlock.title.raw, + categories: [ 'custom' ], + content: reusableBlock.content.raw, + }; + } ); +} + export const __experimentalGetParsedPattern = createSelector( ( state, patternName ) => { const patterns = state.settings.__experimentalBlockPatterns; - const pattern = patterns.find( ( { name } ) => name === patternName ); + const unsyncedPatterns = getUnsyncedPatterns( state ); + + const pattern = [ ...patterns, ...unsyncedPatterns ].find( + ( { name } ) => name === patternName + ); if ( ! pattern ) { return null; } @@ -2320,14 +2343,20 @@ export const __experimentalGetParsedPattern = createSelector( } ), }; }, - ( state ) => [ state.settings.__experimentalBlockPatterns ] + ( state ) => [ + state.settings.__experimentalBlockPatterns, + state.settings.__experimentalReusableBlocks, + ] ); const getAllAllowedPatterns = createSelector( ( state ) => { const patterns = state.settings.__experimentalBlockPatterns; + const unsyncedPatterns = getUnsyncedPatterns( state ); + const { allowedBlockTypes } = getSettings( state ); - const parsedPatterns = patterns + + const parsedPatterns = [ ...patterns, ...unsyncedPatterns ] .filter( ( { inserter = true } ) => !! inserter ) .map( ( { name } ) => __experimentalGetParsedPattern( state, name ) @@ -2339,6 +2368,7 @@ const getAllAllowedPatterns = createSelector( }, ( state ) => [ state.settings.__experimentalBlockPatterns, + state.settings.__experimentalReusableBlocks, state.settings.allowedBlockTypes, ] ); @@ -2365,6 +2395,7 @@ export const __experimentalGetAllowedPatterns = createSelector( }, ( state, rootClientId ) => [ state.settings.__experimentalBlockPatterns, + state.settings.__experimentalReusableBlocks, state.settings.allowedBlockTypes, state.settings.templateLock, state.blockListSettings[ rootClientId ], diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index cc1ec16aeedc24..0b1f3b01b75b9d 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -119,8 +119,8 @@ export default function ReusableBlockEdit( { attributes: { ref }, clientId } ) { onClick={ () => convertBlockToStatic( clientId ) } label={ innerBlockCount > 1 - ? __( 'Convert to regular blocks' ) - : __( 'Convert to regular block' ) + ? __( 'Detach patterns' ) + : __( 'Detach pattern' ) } icon={ ungroup } showTooltip diff --git a/packages/block-library/src/block/edit.native.js b/packages/block-library/src/block/edit.native.js index e72aee3858eaf2..3466baa6bad713 100644 --- a/packages/block-library/src/block/edit.native.js +++ b/packages/block-library/src/block/edit.native.js @@ -132,12 +132,8 @@ export default function ReusableBlockEdit( { } const onConvertToRegularBlocks = useCallback( () => { - const successNotice = - innerBlockCount > 1 - ? /* translators: %s: name of the reusable block */ - __( '%s converted to regular blocks' ) - : /* translators: %s: name of the reusable block */ - __( '%s converted to regular block' ); + /* translators: %s: name of the synced block */ + const successNotice = __( '%s detached' ); createSuccessNotice( sprintf( successNotice, title ) ); clearSelectedBlock(); @@ -182,17 +178,17 @@ export default function ReusableBlockEdit( { { innerBlockCount > 1 ? __( - 'Alternatively, you can detach and edit these blocks separately by tapping “Convert to regular blocks”.' + 'Alternatively, you can detach and edit these blocks separately by tapping “Detach patterns”.' ) : __( - 'Alternatively, you can detach and edit this block separately by tapping “Convert to regular block”.' + 'Alternatively, you can detach and edit this block separately by tapping “Detach pattern”.' ) } 1 - ? __( 'Convert to regular blocks' ) - : __( 'Convert to regular block' ) + ? __( 'Detach patterns' ) + : __( 'Detach pattern' ) } separatorType="topFullWidth" onPress={ onConvertToRegularBlocks } diff --git a/packages/block-library/src/footnotes/index.php b/packages/block-library/src/footnotes/index.php index b7be0542d7a0f3..e4bd8dcdeaac2e 100644 --- a/packages/block-library/src/footnotes/index.php +++ b/packages/block-library/src/footnotes/index.php @@ -59,15 +59,17 @@ function render_block_core_footnotes( $attributes, $content, $block ) { * Registers the `core/footnotes` block on the server. */ function register_block_core_footnotes() { - register_post_meta( - 'post', - 'footnotes', - array( - 'show_in_rest' => true, - 'single' => true, - 'type' => 'string', - ) - ); + foreach ( array( 'post', 'page' ) as $post_type ) { + register_post_meta( + $post_type, + 'footnotes', + array( + 'show_in_rest' => true, + 'single' => true, + 'type' => 'string', + ) + ); + } register_block_type_from_metadata( __DIR__ . '/footnotes', array( diff --git a/packages/block-library/src/footnotes/style.scss b/packages/block-library/src/footnotes/style.scss index b5540b70e6f0fd..4debba0560f173 100644 --- a/packages/block-library/src/footnotes/style.scss +++ b/packages/block-library/src/footnotes/style.scss @@ -3,7 +3,7 @@ counter-reset: footnotes; } -.fn { +[data-fn].fn { vertical-align: super; font-size: smaller; counter-increment: footnotes; @@ -11,7 +11,7 @@ text-indent: -9999999px; } -.fn::after { +[data-fn].fn::after { content: "[" counter(footnotes) "]"; text-indent: 0; float: left; diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index 539e1c6d92a982..b91015313f4039 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -35,10 +35,7 @@ import { } from '@wordpress/dom'; import { decodeEntities } from '@wordpress/html-entities'; import { link as linkIcon, addSubmenu } from '@wordpress/icons'; -import { - store as coreStore, - useResourcePermissions, -} from '@wordpress/core-data'; +import { store as coreStore } from '@wordpress/core-data'; import { useMergeRefs } from '@wordpress/compose'; /** @@ -184,9 +181,6 @@ export default function NavigationLinkEdit( { const itemLabelPlaceholder = __( 'Add label…' ); const ref = useRef(); - const pagesPermissions = useResourcePermissions( 'pages' ); - const postsPermissions = useResourcePermissions( 'posts' ); - const { innerBlocks, isAtMaxNesting, @@ -322,13 +316,6 @@ export default function NavigationLinkEdit( { setIsLinkOpen( false ); } - let userCanCreate = false; - if ( ! type || type === 'page' ) { - userCanCreate = pagesPermissions.canCreate; - } else if ( type === 'post' ) { - userCanCreate = postsPermissions.canCreate; - } - const { textColor, customTextColor, @@ -589,7 +576,6 @@ export default function NavigationLinkEdit( { link={ attributes } onClose={ () => setIsLinkOpen( false ) } anchor={ popoverAnchor } - hasCreateSuggestion={ userCanCreate } onRemove={ removeLink } onChange={ ( updatedValue ) => { updateAttributes( diff --git a/packages/block-library/src/navigation-link/link-ui.js b/packages/block-library/src/navigation-link/link-ui.js index 782d1fff4a01bf..950cac9cfb87bb 100644 --- a/packages/block-library/src/navigation-link/link-ui.js +++ b/packages/block-library/src/navigation-link/link-ui.js @@ -10,7 +10,10 @@ import { store as blockEditorStore, } from '@wordpress/block-editor'; import { createInterpolateElement, useMemo } from '@wordpress/element'; -import { store as coreStore } from '@wordpress/core-data'; +import { + store as coreStore, + useResourcePermissions, +} from '@wordpress/core-data'; import { decodeEntities } from '@wordpress/html-entities'; import { switchToBlockType } from '@wordpress/blocks'; import { useSelect, useDispatch } from '@wordpress/data'; @@ -125,6 +128,8 @@ function LinkControlTransforms( { clientId } ) { export function LinkUI( props ) { const { saveEntityRecord } = useDispatch( coreStore ); + const pagesPermissions = useResourcePermissions( 'pages' ); + const postsPermissions = useResourcePermissions( 'posts' ); async function handleCreate( pageTitle ) { const postType = props.link.type || 'page'; @@ -155,6 +160,13 @@ export function LinkUI( props ) { const { label, url, opensInNewTab, type, kind } = props.link; + let userCanCreate = false; + if ( ! type || type === 'page' ) { + userCanCreate = pagesPermissions.canCreate; + } else if ( type === 'post' ) { + userCanCreate = postsPermissions.canCreate; + } + // Memoize link value to avoid overriding the LinkControl's internal state. // This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407. const link = useMemo( @@ -179,7 +191,7 @@ export function LinkUI( props ) { className={ props.className } value={ link } showInitialSuggestions={ true } - withCreateSuggestion={ props.hasCreateSuggestion } + withCreateSuggestion={ userCanCreate } createSuggestion={ handleCreate } createSuggestionButtonText={ ( searchTerm ) => { let format; diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index 2fe86825bb6b11..7ec990d5b7389c 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -69,7 +69,6 @@ import ManageMenusButton from './manage-menus-button'; import MenuInspectorControls from './menu-inspector-controls'; import DeletedNavigationWarning from './deleted-navigation-warning'; import { unlock } from '../../lock-unlock'; - const { useBlockEditingMode } = unlock( blockEditorPrivateApis ); function Navigation( { @@ -224,7 +223,7 @@ function Navigation( { // that automatically saves the menu as an entity when changes are made to the inner blocks. const hasUnsavedBlocks = hasUncontrolledInnerBlocks && ! isEntityAvailable; - const { getNavigationFallbackId } = useSelect( coreStore ); + const { getNavigationFallbackId } = unlock( useSelect( coreStore ) ); const navigationFallbackId = ! ( ref || hasUnsavedBlocks ) ? getNavigationFallbackId() diff --git a/packages/block-library/src/navigation/edit/menu-inspector-controls.js b/packages/block-library/src/navigation/edit/menu-inspector-controls.js index 8743b51fc6720c..9fd4bc3e33d41e 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -60,7 +60,6 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) { onClose={ () => { setInsertedBlock( null ); } } - hasCreateSuggestion={ false } onChange={ ( updatedValue ) => { updateAttributes( updatedValue, diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index 1e5c4cf5de6fbd..51ed9374c9bcdf 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -47,8 +47,8 @@ function render_block_core_social_link( $attributes, $content, $block ) { $icon = block_core_social_link_get_icon( $service ); $wrapper_attributes = get_block_wrapper_attributes( array( - 'class' => esc_attr( 'wp-social-link wp-social-link-' . $service . block_core_social_link_get_color_classes( $block->context ) ), - 'style' => esc_attr( block_core_social_link_get_color_styles( $block->context ) ), + 'class' => 'wp-social-link wp-social-link-' . $service . block_core_social_link_get_color_classes( $block->context ), + 'style' => block_core_social_link_get_color_styles( $block->context ), ) ); diff --git a/packages/components/src/guide/icons.tsx b/packages/components/src/guide/icons.tsx index 1c47180ae0b11a..36146611dc299a 100644 --- a/packages/components/src/guide/icons.tsx +++ b/packages/components/src/guide/icons.tsx @@ -3,13 +3,8 @@ */ import { SVG, Circle } from '@wordpress/primitives'; -export const PageControlIcon = ( { isSelected }: { isSelected: boolean } ) => ( +export const PageControlIcon = () => ( - + ); diff --git a/packages/components/src/guide/index.tsx b/packages/components/src/guide/index.tsx index 38f8d07d8c0efc..e6a2d4c1252eb8 100644 --- a/packages/components/src/guide/index.tsx +++ b/packages/components/src/guide/index.tsx @@ -111,6 +111,7 @@ function Guide( { 1 } onRequestClose={ onFinish } onKeyDown={ ( event ) => { if ( event.code === 'ArrowLeft' ) { @@ -144,6 +145,7 @@ function Guide( { { canGoBack && (