Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry Pick changes for WordPress 6.5 RC2 #59756

Merged
merged 20 commits into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dcce36d
Interactivity API: Fix context object proxy references (#59553)
DAreRodz Mar 4, 2024
59e7d64
Font Library: Load/Unload the font face in browser when toggling the …
arthur791004 Mar 4, 2024
b455d76
Navigation Block: Fix erroneous escaping of ampersands (etc) (#59561)
ockham Mar 5, 2024
3c42446
Change fillRule property (#59598)
SantosGuillamot Mar 5, 2024
984ede0
Site Editor: Fix Global Styles outdated output (#59628)
youknowriad Mar 6, 2024
4e8563f
Add pattern title in create modal in post editor (#59550)
ntsekouras Mar 6, 2024
4958400
Fix typo in Dataviews Pagination and Font Collection components (#59656)
rcoll Mar 7, 2024
b3c9f8b
Font Library: Fix typo in upload text (#59655)
mujuonly Mar 7, 2024
c66577a
List view: fix stuck moving animation on Enter (#59644)
ellatrix Mar 7, 2024
67b216a
Site Editor: Restore the back button when navigating to the template …
youknowriad Mar 7, 2024
00fcb56
Site editor: Fix opening of save panel when using the `save` shortcut…
ntsekouras Mar 8, 2024
b78d306
Code block: preserve newlines (#59627)
ellatrix Mar 11, 2024
dee8699
Implement pattern overrides behind `IS_GUTENBERG_PLUGIN` flag (#59702)
talldan Mar 11, 2024
77aff9d
Ensure that errors reported from uploading font files are not duplica…
pbking Mar 11, 2024
e67cb2f
Dataviews: Fix sticky table headers (#59467)
jameskoster Mar 5, 2024
588cc8b
Interactivity: Restore scope on thrown exception in async callback (#…
sirreal Mar 11, 2024
7719a93
Font Library: Refactors the upload handler in order to check if files…
vcanales Mar 11, 2024
7080b67
Fix allow mouse users to edit link text when Link UI is active (#59635)
getdave Mar 11, 2024
b2128cd
Fix create menu after menu switch (#59630)
draganescu Mar 11, 2024
e5f7dd6
Site Editor: Fix selected featured image when opening media library (…
ntsekouras Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/load.php
Expand Up @@ -122,9 +122,13 @@ function gutenberg_is_experiment_enabled( $name ) {
}
require __DIR__ . '/compat/wordpress-6.5/block-bindings/block-bindings.php';
require __DIR__ . '/compat/wordpress-6.5/block-bindings/post-meta.php';
require __DIR__ . '/compat/wordpress-6.5/block-bindings/pattern-overrides.php';
require __DIR__ . '/compat/wordpress-6.5/script-loader.php';

// Not to be included in WordPress 6.5.
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
require __DIR__ . '/compat/wordpress-6.6/block-bindings/pattern-overrides.php';
}

// Experimental features.
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
require __DIR__ . '/experimental/blocks.php';
Expand Down
3 changes: 3 additions & 0 deletions packages/base-styles/_z-index.scss
Expand Up @@ -201,6 +201,9 @@ $z-layers: (

// Ensure modal footer actions appear above modal contents
".edit-site-start-template-options__modal__actions": 1,

// Ensure checkbox + actions don't overlap table header
".dataviews-view-table thead": 1,
);

@function z-index( $key ) {
Expand Down
Expand Up @@ -1194,34 +1194,32 @@ export function useGlobalStylesOutputWithConfig( mergedConfig = {} ) {

const isTemplate = blockContext?.templateSlug !== undefined;

const getBlockStyles = useSelect( ( select ) => {
return select( blocksStore ).getBlockStyles;
}, [] );
const { getBlockStyles } = useSelect( blocksStore );

return useMemo( () => {
if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
return [];
}
mergedConfig = updateConfigWithSeparator( mergedConfig );
const updatedConfig = updateConfigWithSeparator( mergedConfig );

const blockSelectors = getBlockSelectors(
getBlockTypes(),
getBlockStyles
);

const customProperties = toCustomProperties(
mergedConfig,
updatedConfig,
blockSelectors
);
const globalStyles = toStyles(
mergedConfig,
updatedConfig,
blockSelectors,
hasBlockGapSupport,
hasFallbackGapSupport,
disableLayoutStyles,
isTemplate
);
const svgs = toSvgFilters( mergedConfig, blockSelectors );
const svgs = toSvgFilters( updatedConfig, blockSelectors );

const styles = [
{
Expand All @@ -1234,7 +1232,7 @@ export function useGlobalStylesOutputWithConfig( mergedConfig = {} ) {
},
// Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
{
css: mergedConfig.styles.css ?? '',
css: updatedConfig.styles.css ?? '',
isGlobalStyles: true,
},
{
Expand All @@ -1248,24 +1246,26 @@ export function useGlobalStylesOutputWithConfig( mergedConfig = {} ) {
// If there are, get the block selector and push the selector together with
// the CSS value to the 'stylesheets' array.
getBlockTypes().forEach( ( blockType ) => {
if ( mergedConfig.styles.blocks[ blockType.name ]?.css ) {
if ( updatedConfig.styles.blocks[ blockType.name ]?.css ) {
const selector = blockSelectors[ blockType.name ].selector;
styles.push( {
css: processCSSNesting(
mergedConfig.styles.blocks[ blockType.name ]?.css,
updatedConfig.styles.blocks[ blockType.name ]?.css,
selector
),
isGlobalStyles: true,
} );
}
} );

return [ styles, mergedConfig.settings ];
return [ styles, updatedConfig.settings ];
}, [
hasBlockGapSupport,
hasFallbackGapSupport,
mergedConfig,
disableLayoutStyles,
isTemplate,
getBlockStyles,
] );
}

Expand Down
Expand Up @@ -142,6 +142,7 @@ function useMovingAnimation( { triggerAnimationOnChange, clientId } ) {

return () => {
controller.stop();
controller.set( { x: 0, y: 0 } );
};
}, [
previous,
Expand Down
53 changes: 38 additions & 15 deletions packages/block-library/src/block/edit.js
Expand Up @@ -28,7 +28,7 @@ import {
BlockControls,
} from '@wordpress/block-editor';
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
import { parse, cloneBlock } from '@wordpress/blocks';
import { parse, cloneBlock, store as blocksStore } from '@wordpress/blocks';
import { RichTextData } from '@wordpress/rich-text';

/**
Expand Down Expand Up @@ -265,6 +265,7 @@ export default function ReusableBlockEdit( {
getBlockEditingMode,
onNavigateToEntityRecord,
editingMode,
hasPatternOverridesSource,
} = useSelect(
( select ) => {
const { canUser } = select( coreStore );
Expand All @@ -273,6 +274,7 @@ export default function ReusableBlockEdit( {
getSettings,
getBlockEditingMode: _getBlockEditingMode,
} = select( blockEditorStore );
const { getBlockBindingsSource } = unlock( select( blocksStore ) );
const blocks = getBlocks( patternClientId );
const canEdit = canUser( 'update', 'blocks', ref );

Expand All @@ -284,6 +286,9 @@ export default function ReusableBlockEdit( {
onNavigateToEntityRecord:
getSettings().onNavigateToEntityRecord,
editingMode: _getBlockEditingMode( patternClientId ),
hasPatternOverridesSource: !! getBlockBindingsSource(
'core/pattern-overrides'
),
};
},
[ patternClientId, ref ]
Expand All @@ -295,13 +300,20 @@ export default function ReusableBlockEdit( {
setBlockEditingMode,
innerBlocks,
// Disable editing if the pattern itself is disabled.
editingMode === 'disabled' ? 'disabled' : undefined
editingMode === 'disabled' || ! hasPatternOverridesSource
? 'disabled'
: undefined
);
}, [ editingMode, innerBlocks, setBlockEditingMode ] );
}, [
editingMode,
innerBlocks,
setBlockEditingMode,
hasPatternOverridesSource,
] );

const canOverrideBlocks = useMemo(
() => hasOverridableBlocks( innerBlocks ),
[ innerBlocks ]
() => hasPatternOverridesSource && hasOverridableBlocks( innerBlocks ),
[ hasPatternOverridesSource, innerBlocks ]
);

const initialBlocks = useMemo(
Expand Down Expand Up @@ -329,19 +341,21 @@ export default function ReusableBlockEdit( {
registry.batch( () => {
setBlockEditingMode( patternClientId, 'default' );
syncDerivedUpdates( () => {
replaceInnerBlocks(
patternClientId,
applyInitialContentValuesToInnerBlocks(
initialBlocks,
initialContent.current,
defaultContent.current,
legacyIdMap.current
)
);
const blocks = hasPatternOverridesSource
? applyInitialContentValuesToInnerBlocks(
initialBlocks,
initialContent.current,
defaultContent.current,
legacyIdMap.current
)
: initialBlocks;

replaceInnerBlocks( patternClientId, blocks );
} );
setBlockEditingMode( patternClientId, originalEditingMode );
} );
}, [
hasPatternOverridesSource,
__unstableMarkNextChangeAsNotPersistent,
patternClientId,
initialBlocks,
Expand Down Expand Up @@ -377,6 +391,9 @@ export default function ReusableBlockEdit( {
// Sync the `content` attribute from the updated blocks to the pattern block.
// `syncDerivedUpdates` is used here to avoid creating an additional undo level.
useEffect( () => {
if ( ! hasPatternOverridesSource ) {
return;
}
const { getBlocks } = registry.select( blockEditorStore );
let prevBlocks = getBlocks( patternClientId );
return registry.subscribe( () => {
Expand All @@ -394,7 +411,13 @@ export default function ReusableBlockEdit( {
} );
}
}, blockEditorStore );
}, [ syncDerivedUpdates, patternClientId, registry, setAttributes ] );
}, [
hasPatternOverridesSource,
syncDerivedUpdates,
patternClientId,
registry,
setAttributes,
] );

const handleEditOriginal = () => {
onNavigateToEntityRecord( {
Expand Down
8 changes: 7 additions & 1 deletion packages/block-library/src/code/save.js
Expand Up @@ -16,7 +16,13 @@ export default function save( { attributes } ) {
// To do: `escape` encodes characters in shortcodes and URLs to
// prevent embedding in PHP. Ideally checks for the code block,
// or pre/code tags, should be made on the PHP side?
value={ escape( attributes.content.toString() ) }
value={ escape(
typeof attributes.content === 'string'
? attributes.content
: attributes.content.toHTMLString( {
preserveWhiteSpace: true,
} )
) }
/>
</pre>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation/edit/index.js
Expand Up @@ -153,8 +153,8 @@ function Navigation( {
isError: createNavigationMenuIsError,
} = useCreateNavigationMenu( clientId );

const createUntitledEmptyNavigationMenu = () => {
createNavigationMenu( '' );
const createUntitledEmptyNavigationMenu = async () => {
await createNavigationMenu( '' );
};

const {
Expand Down
Expand Up @@ -49,7 +49,7 @@ function NavigationMenuSelector( {
/* translators: %s: The name of a menu. */
const createActionLabel = __( "Create from '%s'" );

const [ isCreatingMenu, setIsCreatingMenu ] = useState( false );
const [ isUpdatingMenuRef, setIsUpdatingMenuRef ] = useState( false );

actionLabel = actionLabel || createActionLabel;

Expand Down Expand Up @@ -82,10 +82,20 @@ function NavigationMenuSelector( {
value: id,
label,
ariaLabel: sprintf( actionLabel, label ),
disabled:
isUpdatingMenuRef ||
isResolvingNavigationMenus ||
! hasResolvedNavigationMenus,
};
} ) || []
);
}, [ navigationMenus, actionLabel ] );
}, [
navigationMenus,
actionLabel,
isResolvingNavigationMenus,
hasResolvedNavigationMenus,
isUpdatingMenuRef,
] );

const hasNavigationMenus = !! navigationMenus?.length;
const hasClassicMenus = !! classicMenus?.length;
Expand All @@ -99,7 +109,7 @@ function NavigationMenuSelector( {

let selectorLabel = '';

if ( isCreatingMenu || isResolvingNavigationMenus ) {
if ( isResolvingNavigationMenus ) {
selectorLabel = __( 'Loading…' );
} else if ( noMenuSelected || noBlockMenus || menuUnavailable ) {
// Note: classic Menus may be available.
Expand All @@ -111,17 +121,17 @@ function NavigationMenuSelector( {

useEffect( () => {
if (
isCreatingMenu &&
isUpdatingMenuRef &&
( createNavigationMenuIsSuccess || createNavigationMenuIsError )
) {
setIsCreatingMenu( false );
setIsUpdatingMenuRef( false );
}
}, [
hasResolvedNavigationMenus,
createNavigationMenuIsSuccess,
canUserCreateNavigationMenu,
createNavigationMenuIsError,
isCreatingMenu,
isUpdatingMenuRef,
menuUnavailable,
noBlockMenus,
noMenuSelected,
Expand All @@ -140,12 +150,10 @@ function NavigationMenuSelector( {
<MenuItemsChoice
value={ currentMenuId }
onSelect={ ( menuId ) => {
setIsCreatingMenu( true );
onSelectNavigationMenu( menuId );
onClose();
} }
choices={ menuChoices }
disabled={ isCreatingMenu }
/>
</MenuGroup>
) }
Expand All @@ -155,17 +163,22 @@ function NavigationMenuSelector( {
const label = decodeEntities( menu.name );
return (
<MenuItem
onClick={ () => {
setIsCreatingMenu( true );
onSelectClassicMenu( menu );
onClick={ async () => {
setIsUpdatingMenuRef( true );
await onSelectClassicMenu( menu );
setIsUpdatingMenuRef( false );
onClose();
} }
key={ menu.id }
aria-label={ sprintf(
createActionLabel,
label
) }
disabled={ isCreatingMenu }
disabled={
isUpdatingMenuRef ||
isResolvingNavigationMenus ||
! hasResolvedNavigationMenus
}
>
{ label }
</MenuItem>
Expand All @@ -177,12 +190,17 @@ function NavigationMenuSelector( {
{ canUserCreateNavigationMenu && (
<MenuGroup label={ __( 'Tools' ) }>
<MenuItem
disabled={ isCreatingMenu }
onClick={ () => {
onClick={ async () => {
setIsUpdatingMenuRef( true );
await onCreateNew();
setIsUpdatingMenuRef( false );
onClose();
onCreateNew();
setIsCreatingMenu( true );
} }
disabled={
isUpdatingMenuRef ||
isResolvingNavigationMenus ||
! hasResolvedNavigationMenus
}
>
{ __( 'Create new menu' ) }
</MenuItem>
Expand Down