Skip to content

Commit

Permalink
Editor: Merge Editor bug fixes ahead of 6.5 RC4.
Browse files Browse the repository at this point in the history
This merges several high priority bug fixes for the editor ahead of WordPress 6.5:
- WordPress/gutenberg#60180
- WordPress/gutenberg#60093
- WordPress/gutenberg#60071
- WordPress/gutenberg#60130
- WordPress/gutenberg#59959
- WordPress/gutenberg#60167

Props youknowriad, annezazu, mcsf, jsnajdr, mmaattiiaass, get_dave, scruffian, mikachan, grantmkin, andraganescu, scruffian, antosguillamot, fabiankaegy, huzaifaalmesbah, krupajnanda, colorful-tones, liviopv, mamaduka, kim88, poena, peterwilsoncc, wildworks, swissspidy, desrosj, jorbin.
Fixes #60315.
Built from https://develop.svn.wordpress.org/trunk@57888


git-svn-id: http://core.svn.wordpress.org/trunk@57389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
desrosj committed Mar 28, 2024
1 parent 3e244ae commit 3bf6493
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 21 deletions.
2 changes: 1 addition & 1 deletion wp-includes/assets/script-loader-packages.min.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wp-includes/assets/script-loader-packages.php

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions wp-includes/blocks/navigation.php
Expand Up @@ -1472,6 +1472,14 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
return $post;
}

/**
* Skip meta generation when consumers intentionally update specific Navigation fields
* and omit the content update.
*/
if ( ! isset( $post->post_content ) ) {
return $post;
}

/*
* We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
* all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
Expand Down
14 changes: 12 additions & 2 deletions wp-includes/blocks/navigation/view.js
Expand Up @@ -74,10 +74,20 @@ const {
} = (0,interactivity_namespaceObject.getContext)();
if (type === 'submenu' &&
// Only open on hover if the overlay is closed.
Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) actions.openMenu('hover');
Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) {
actions.openMenu('hover');
}
},
closeMenuOnHover() {
actions.closeMenu('hover');
const {
type,
overlayOpenedBy
} = (0,interactivity_namespaceObject.getContext)();
if (type === 'submenu' &&
// Only close on hover if the overlay is closed.
Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) {
actions.closeMenu('hover');
}
},
openMenuOnClick() {
const ctx = (0,interactivity_namespaceObject.getContext)();
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/blocks/navigation/view.min.js

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

2 changes: 1 addition & 1 deletion wp-includes/js/dist/block-editor.js
Expand Up @@ -49267,7 +49267,7 @@ const BlockSwitcher = ({
invalidBlocks: true
};
}
const rootClientId = getBlockRootClientId(clientIds);
const rootClientId = getBlockRootClientId(Array.isArray(clientIds) ? clientIds[0] : clientIds);
const [{
name: firstBlockName
}] = _blocks;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/js/dist/block-editor.min.js

Large diffs are not rendered by default.

69 changes: 58 additions & 11 deletions wp-includes/js/dist/edit-site.js
Expand Up @@ -26792,8 +26792,26 @@ function makeFontFacesFormData(font) {
}
}
async function batchInstallFontFaces(fontFamilyId, fontFacesData) {
const promises = fontFacesData.map(faceData => fetchInstallFontFace(fontFamilyId, faceData));
const responses = await Promise.allSettled(promises);
const responses = [];

/*
* Uses the same response format as Promise.allSettled, but executes requests in sequence to work
* around a race condition that can cause an error when the fonts directory doesn't exist yet.
*/
for (const faceData of fontFacesData) {
try {
const response = await fetchInstallFontFace(fontFamilyId, faceData);
responses.push({
status: 'fulfilled',
value: response
});
} catch (error) {
responses.push({
status: 'rejected',
reason: error
});
}
}
const results = {
errors: [],
successes: []
Expand Down Expand Up @@ -27021,12 +27039,23 @@ function FontLibraryProvider({
// Library Fonts
const [modalTabOpen, setModalTabOpen] = (0,external_wp_element_namespaceObject.useState)(false);
const [libraryFontSelected, setLibraryFontSelected] = (0,external_wp_element_namespaceObject.useState)(null);
const baseThemeFonts = baseFontFamilies?.theme ? baseFontFamilies.theme.map(f => setUIValuesNeeded(f, {
source: 'theme'
})).sort((a, b) => a.name.localeCompare(b.name)) : [];

// Themes Fonts are the fonts defined in the global styles (database persisted theme.json data).
const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map(f => setUIValuesNeeded(f, {
source: 'theme'
})).sort((a, b) => a.name.localeCompare(b.name)) : [];
const themeFontsSlugs = new Set(themeFonts.map(f => f.slug));

/*
* Base Theme Fonts are the fonts defined in the theme.json *file*.
*
* Uses the fonts from global styles + the ones from the theme.json file that hasn't repeated slugs.
* Avoids incosistencies with the fonts listed in the font library modal as base (unactivated).
* These inconsistencies can happen when the active theme fonts in global styles aren't defined in theme.json file as when a theme style variation is applied.
*/
const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(baseFontFamilies.theme.filter(f => !themeFontsSlugs.has(f.slug)).map(f => setUIValuesNeeded(f, {
source: 'theme'
})).sort((a, b) => a.name.localeCompare(b.name))) : [];
const customFonts = fontFamilies?.custom ? fontFamilies.custom.map(f => setUIValuesNeeded(f, {
source: 'custom'
})).sort((a, b) => a.name.localeCompare(b.name)) : [];
Expand All @@ -27046,7 +27075,7 @@ function FontLibraryProvider({
setLibraryFontSelected(null);
return;
}
const fonts = font.source === 'theme' ? baseThemeFonts : baseCustomFonts;
const fonts = font.source === 'theme' ? themeFonts : baseCustomFonts;

// Tries to find the font in the installed fonts
const fontSelected = fonts.find(f => f.slug === font.slug);
Expand Down Expand Up @@ -27127,8 +27156,10 @@ function FontLibraryProvider({
// Use the sucessfully installed font faces
// As well as any font faces that were already installed (those will be activated)
if (sucessfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) {
fontFamilyToInstall.fontFace = [...sucessfullyInstalledFontFaces, ...alreadyInstalledFontFaces];
fontFamiliesToActivate.push(fontFamilyToInstall);
// Use font data from REST API not from client to ensure
// correct font information is used.
installedFontFamily.fontFace = [...sucessfullyInstalledFontFaces];
fontFamiliesToActivate.push(installedFontFamily);
}

// If it's a system font but was installed successfully, activate it.
Expand Down Expand Up @@ -27200,14 +27231,30 @@ function FontLibraryProvider({
}
};
const activateCustomFontFamilies = fontsToAdd => {
// Merge the existing custom fonts with the new fonts.
// Removes the id from the families and faces to avoid saving that to global styles post content.
const fontsToActivate = fontsToAdd.map(({
id: _familyDbId,
fontFace,
...font
}) => ({
...font,
...(fontFace && fontFace.length > 0 ? {
fontFace: fontFace.map(({
id: _faceDbId,
...face
}) => face)
} : {})
}));

// Activate the fonts by set the new custom fonts array.
setFontFamilies({
...fontFamilies,
custom: mergeFontFamilies(fontFamilies?.custom, fontsToAdd)
// Merge the existing custom fonts with the new fonts.
custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
});

// Add custom fonts to the browser.
fontsToAdd.forEach(font => {
fontsToActivate.forEach(font => {
if (font.fontFace) {
font.fontFace.forEach(face => {
// Load font faces just in the iframe because they already are in the document.
Expand Down
4 changes: 2 additions & 2 deletions wp-includes/js/dist/edit-site.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-57887';
$wp_version = '6.6-alpha-57888';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 3bf6493

Please sign in to comment.