auto-patch 638-dev-dev01-2024-05-14T20_44_36

This commit is contained in:
root
2024-05-14 20:44:36 +00:00
parent a941559057
commit 5dbb0b284e
1812 changed files with 29671 additions and 14588 deletions
+81 -48
View File
@@ -32883,7 +32883,8 @@ function layout_addAttribute(settings) {
}
function BlockWithLayoutStyles({
block: BlockListBlock,
props
props,
layoutClasses
}) {
const {
name,
@@ -32900,7 +32901,6 @@ function BlockWithLayoutStyles({
...layout,
type: 'constrained'
} : layout || defaultBlockLayout || {};
const layoutClasses = useLayoutClasses(attributes, name);
const {
kebabCase
} = unlock(external_wp_components_namespaceObject.privateApis);
@@ -32942,7 +32942,12 @@ function BlockWithLayoutStyles({
* @return {Function} Wrapped component.
*/
const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
const {
name,
attributes
} = props;
const blockSupportsLayout = hasLayoutBlockSupport(props.name);
const layoutClasses = useLayoutClasses(attributes, name);
const shouldRenderLayoutStyles = (0,external_wp_data_namespaceObject.useSelect)(select => {
// The callback returns early to avoid block editor subscription.
if (!blockSupportsLayout) {
@@ -32952,12 +32957,14 @@ const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrde
}, [blockSupportsLayout]);
if (!shouldRenderLayoutStyles) {
return (0,external_React_.createElement)(BlockListBlock, {
...props
...props,
__unstableLayoutClassNames: blockSupportsLayout ? layoutClasses : undefined
});
}
return (0,external_React_.createElement)(BlockWithLayoutStyles, {
block: BlockListBlock,
props: props
props: props,
layoutClasses: layoutClasses
});
}, 'withLayoutStyles');
(0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute);
@@ -41962,12 +41969,14 @@ function Pagination({
variant: "tertiary",
onClick: () => changePage(1),
disabled: currentPage === 1,
"aria-label": (0,external_wp_i18n_namespaceObject.__)('First page')
"aria-label": (0,external_wp_i18n_namespaceObject.__)('First page'),
__experimentalIsFocusable: true
}, (0,external_React_.createElement)("span", null, "\xAB")), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
variant: "tertiary",
onClick: () => changePage(currentPage - 1),
disabled: currentPage === 1,
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Previous page')
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Previous page'),
__experimentalIsFocusable: true
}, (0,external_React_.createElement)("span", null, "\u2039"))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, {
variant: "muted"
}, (0,external_wp_i18n_namespaceObject.sprintf)(
@@ -41980,13 +41989,15 @@ function Pagination({
variant: "tertiary",
onClick: () => changePage(currentPage + 1),
disabled: currentPage === numPages,
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Next page')
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Next page'),
__experimentalIsFocusable: true
}, (0,external_React_.createElement)("span", null, "\u203A")), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
variant: "tertiary",
onClick: () => changePage(numPages),
disabled: currentPage === numPages,
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Last page'),
size: "default"
size: "default",
__experimentalIsFocusable: true
}, (0,external_React_.createElement)("span", null, "\xBB")))));
}
@@ -42439,11 +42450,13 @@ function PatternsListHeader({
function PatternList({
searchValue,
selectedCategory,
patternCategories
patternCategories,
rootClientId
}) {
const container = (0,external_wp_element_namespaceObject.useRef)();
const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
rootClientId,
shouldFocusBlock: true
});
const [patterns,, onClickPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
@@ -42589,7 +42602,8 @@ function PatternsExplorer({
searchValue: searchValue,
selectedCategory: selectedCategory,
patternCategories: patternCategories,
patternSourceFilter: patternSourceFilter
patternSourceFilter: patternSourceFilter,
rootClientId: rootClientId
}));
}
function PatternsExplorerModal({
@@ -54045,9 +54059,14 @@ function useListViewDropZone({
const ref = (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
dropZoneElement,
onDrop(event) {
throttled.cancel();
if (target) {
onBlockDrop(event);
}
// Use `undefined` value to indicate that the drag has concluded.
// This allows styling rules that are active only when a user is
// dragging to be removed.
setTarget(undefined);
},
onDragLeave() {
throttled.cancel();
@@ -60705,7 +60724,8 @@ const ImageURLInputUI = ({
rel,
showLightboxSetting,
lightboxEnabled,
onSetLightbox
onSetLightbox,
resetLightbox
}) => {
const [isOpen, setIsOpen] = (0,external_wp_element_namespaceObject.useState)(false);
// Use internal state instead of a ref to make sure that the component
@@ -60866,8 +60886,52 @@ const ImageURLInputUI = ({
onChange: onSetLinkClass
}));
const linkEditorValue = urlInput !== null ? urlInput : url;
const showLinkEditor = (!linkEditorValue && !lightboxEnabled) === true;
const hideLightboxPanel = !lightboxEnabled || lightboxEnabled && !showLightboxSetting;
const showLinkEditor = !linkEditorValue && hideLightboxPanel;
const urlLabel = (getLinkDestinations().find(destination => destination.linkDestination === linkDestination) || {}).title;
const PopoverChildren = () => {
if (lightboxEnabled && showLightboxSetting && !url && !isEditingLink) {
return (0,external_React_.createElement)("div", {
className: "block-editor-url-popover__expand-on-click"
}, (0,external_React_.createElement)(build_module_icon, {
icon: library_fullscreen
}), (0,external_React_.createElement)("div", {
className: "text"
}, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Expand on click')), (0,external_React_.createElement)("p", {
className: "description"
}, (0,external_wp_i18n_namespaceObject.__)('Scales the image with a lightbox effect'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
icon: link_off,
label: (0,external_wp_i18n_namespaceObject.__)('Disable expand on click'),
onClick: () => {
onSetLightbox(false);
},
size: "compact"
}));
} else if (!url || isEditingLink) {
return (0,external_React_.createElement)(url_popover.LinkEditor, {
className: "block-editor-format-toolbar__link-container-content",
value: linkEditorValue,
onChangeInputValue: setUrlInput,
onSubmit: onSubmitLinkChange(),
autocompleteRef: autocompleteRef
});
} else if (url && !isEditingLink) {
return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(url_popover.LinkViewer, {
className: "block-editor-format-toolbar__link-container-content",
url: url,
onEditLinkClick: startEditLink,
urlLabel: urlLabel
}), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
icon: link_off,
label: (0,external_wp_i18n_namespaceObject.__)('Remove link'),
onClick: () => {
onLinkRemove();
resetLightbox();
},
size: "compact"
}));
}
};
return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
icon: library_link,
className: "components-toolbar__control",
@@ -60875,13 +60939,13 @@ const ImageURLInputUI = ({
"aria-expanded": isOpen,
onClick: openLinkUI,
ref: setPopoverAnchor,
isActive: !!url || lightboxEnabled
isActive: !!url || lightboxEnabled && showLightboxSetting
}), isOpen && (0,external_React_.createElement)(url_popover, {
ref: wrapperRef,
anchor: popoverAnchor,
onFocusOutside: onFocusOutside(),
onClose: closeLinkUI,
renderSettings: !lightboxEnabled ? () => advancedOptions : null,
renderSettings: hideLightboxPanel ? () => advancedOptions : null,
additionalControls: showLinkEditor && (0,external_React_.createElement)(external_wp_components_namespaceObject.NavigableMenu, null, getLinkDestinations().map(link => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, {
key: link.linkDestination,
icon: link.icon,
@@ -60908,38 +60972,7 @@ const ImageURLInputUI = ({
}
}, (0,external_wp_i18n_namespaceObject.__)('Expand on click'))),
offset: 13
}, (!url || isEditingLink) && !lightboxEnabled && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(url_popover.LinkEditor, {
className: "block-editor-format-toolbar__link-container-content",
value: linkEditorValue,
onChangeInputValue: setUrlInput,
onSubmit: onSubmitLinkChange(),
autocompleteRef: autocompleteRef
})), url && !isEditingLink && !lightboxEnabled && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(url_popover.LinkViewer, {
className: "block-editor-format-toolbar__link-container-content",
url: url,
onEditLinkClick: startEditLink,
urlLabel: urlLabel
}), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
icon: link_off,
label: (0,external_wp_i18n_namespaceObject.__)('Remove link'),
onClick: onLinkRemove,
size: "compact"
})), !url && !isEditingLink && lightboxEnabled && (0,external_React_.createElement)("div", {
className: "block-editor-url-popover__expand-on-click"
}, (0,external_React_.createElement)(build_module_icon, {
icon: library_fullscreen
}), (0,external_React_.createElement)("div", {
className: "text"
}, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Expand on click')), (0,external_React_.createElement)("p", {
className: "description"
}, (0,external_wp_i18n_namespaceObject.__)('Scales the image with a lightbox effect'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
icon: link_off,
label: (0,external_wp_i18n_namespaceObject.__)('Disable expand on click'),
onClick: () => {
onSetLightbox(false);
},
size: "compact"
}))));
}, PopoverChildren()));
};
@@ -62395,12 +62428,12 @@ const DeprecatedExperimentalRecursionProvider = props => {
...props
});
};
const DeprecatedExperimentalUseHasRecursion = props => {
const DeprecatedExperimentalUseHasRecursion = (...args) => {
external_wp_deprecated_default()('wp.blockEditor.__experimentalUseHasRecursion', {
since: '6.5',
alternative: 'wp.blockEditor.useHasRecursion'
});
return useHasRecursion(...props);
return useHasRecursion(...args);
};
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
File diff suppressed because one or more lines are too long
+59 -12
View File
@@ -25964,6 +25964,23 @@ function image_Image({
});
}
}
function resetLightbox() {
// When deleting a link from an image while lightbox settings
// are enabled by default, we should disable the lightbox,
// otherwise the resulting UX looks like a mistake.
// See https://github.com/WordPress/gutenberg/pull/59890/files#r1532286123.
if (lightboxSetting?.enabled && lightboxSetting?.allowEditing) {
setAttributes({
lightbox: {
enabled: false
}
});
} else {
setAttributes({
lightbox: undefined
});
}
}
function onSetTitle(value) {
// This is the HTML title attribute, separate from the media object
// title.
@@ -26031,7 +26048,10 @@ function image_Image({
availableUnits: ['px']
});
const [lightboxSetting] = (0,external_wp_blockEditor_namespaceObject.useSettings)('lightbox');
const showLightboxSetting = !!lightbox || lightboxSetting?.allowEditing === true;
const showLightboxSetting =
// If a block-level override is set, we should give users the option to
// remove that override, even if the lightbox UI is disabled in the settings.
!!lightbox && lightbox?.enabled !== lightboxSetting?.enabled || lightboxSetting?.allowEditing;
const lightboxChecked = !!lightbox?.enabled || !lightbox && !!lightboxSetting?.enabled;
const dimensionsControl = (0,external_React_namespaceObject.createElement)(DimensionsTool, {
value: {
@@ -26138,7 +26158,8 @@ function image_Image({
rel: rel,
showLightboxSetting: showLightboxSetting,
lightboxEnabled: lightboxChecked,
onSetLightbox: onSetLightbox
onSetLightbox: onSetLightbox,
resetLightbox: resetLightbox
}), allowCrop && (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
onClick: () => setIsEditingImage(true),
icon: library_crop,
@@ -45021,7 +45042,15 @@ const useUnsupportedBlocks = clientId => {
const blocks = {};
getClientIdsOfDescendants(clientId).forEach(descendantClientId => {
const blockName = getBlockName(descendantClientId);
if (!blockName.startsWith('core/')) {
/*
* Client side navigation can be true in two states:
* - supports.interactivity = true;
* - supports.interactivity.clientNavigation = true;
*/
const blockSupportsInteractivity = Object.is((0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, 'interactivity'), true);
const blockSupportsInteractivityClientNavigation = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, 'interactivity.clientNavigation');
const blockInteractivity = blockSupportsInteractivity || blockSupportsInteractivityClientNavigation;
if (!blockInteractivity) {
blocks.hasBlocksFromPlugins = true;
} else if (blockName === 'core/post-content') {
blocks.hasPostContentBlock = true;
@@ -45897,7 +45926,7 @@ function EnhancedPaginationModal({
};
let notice = (0,external_wp_i18n_namespaceObject.__)('If you still want to prevent full page reloads, remove that block, then disable "Force page reload" again in the Query Block settings.');
if (hasBlocksFromPlugins) {
notice = (0,external_wp_i18n_namespaceObject.__)('Currently, avoiding full page reloads is not possible when blocks from plugins are present inside the Query block.') + ' ' + notice;
notice = (0,external_wp_i18n_namespaceObject.__)('Currently, avoiding full page reloads is not possible when non-interactive or non-clientNavigation compatible blocks from plugins are present inside the Query block.') + ' ' + notice;
} else if (hasPostContentBlock) {
notice = (0,external_wp_i18n_namespaceObject.__)('Currently, avoiding full page reloads is not possible when a Content block is present inside the Query block.') + ' ' + notice;
}
@@ -48945,6 +48974,30 @@ function setBlockEditMode(setEditMode, blocks, mode) {
block.name === block_name ? 'disabled' : mode);
});
}
function RecursionWarning() {
const blockProps = (0,external_wp_blockEditor_namespaceObject.useBlockProps)();
return (0,external_React_namespaceObject.createElement)("div", {
...blockProps
}, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Block cannot be rendered inside itself.')));
}
// Wrap the main Edit function for the pattern block with a recursion wrapper
// that allows short-circuiting rendering as early as possible, before any
// of the other effects in the block edit have run.
function ReusableBlockEditRecursionWrapper(props) {
const {
ref
} = props.attributes;
const hasAlreadyRendered = (0,external_wp_blockEditor_namespaceObject.useHasRecursion)(ref);
if (hasAlreadyRendered) {
return (0,external_React_namespaceObject.createElement)(RecursionWarning, null);
}
return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
uniqueId: ref
}, (0,external_React_namespaceObject.createElement)(ReusableBlockEdit, {
...props
}));
}
function ReusableBlockEdit({
name,
attributes: {
@@ -48956,7 +49009,6 @@ function ReusableBlockEdit({
setAttributes
}) {
const registry = (0,external_wp_data_namespaceObject.useRegistry)();
const hasAlreadyRendered = (0,external_wp_blockEditor_namespaceObject.useHasRecursion)(ref);
const {
record,
editedRecord,
@@ -49094,18 +49146,13 @@ function ReusableBlockEdit({
}
};
let children = null;
if (hasAlreadyRendered) {
children = (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Block cannot be rendered inside itself.'));
}
if (isMissing) {
children = (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Block has been deleted or is unavailable.'));
}
if (!hasResolved) {
children = (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null));
}
return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
uniqueId: ref
}, userCanEdit && onNavigateToEntityRecord && (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, userCanEdit && onNavigateToEntityRecord && (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
onClick: handleEditOriginal
}, (0,external_wp_i18n_namespaceObject.__)('Edit original')))), canOverrideBlocks && (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
onClick: resetContent,
@@ -49286,7 +49333,7 @@ const {
const block_settings = {
deprecated: block_deprecated,
edit: ReusableBlockEdit,
edit: ReusableBlockEditRecursionWrapper,
icon: library_symbol,
__experimentalLabel: ({
ref
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -56545,7 +56545,7 @@ const DayButton = /*#__PURE__*/emotion_styled_base_browser_esm(build_module_butt
justify-self: end;
`, " ", props => props.disabled && `
pointer-events: none;
`, " &&&{border-radius:100%;height:", space(8), ";width:", space(8), ";", props => props.isSelected && `
`, " &&&{border-radius:100%;height:", space(7), ";width:", space(7), ";", props => props.isSelected && `
background: ${COLORS.theme.accent};
color: ${COLORS.white};
`, " ", props => !props.isSelected && props.isToday && `
File diff suppressed because one or more lines are too long
+24 -6
View File
@@ -3490,26 +3490,44 @@ function areMetaBoxesInitialized(state) {
* @return {Object?} Post Template.
*/
const getEditedPostTemplate = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
const {
id: postId,
type: postType,
slug
} = select(external_wp_editor_namespaceObject.store).getCurrentPost();
const {
getSite,
getEditedEntityRecord,
getEntityRecords
} = select(external_wp_coreData_namespaceObject.store);
const siteSettings = getSite();
// First check if the current page is set as the posts page.
const isPostsPage = +postId === siteSettings?.page_for_posts;
if (isPostsPage) {
const defaultTemplateId = select(external_wp_coreData_namespaceObject.store).getDefaultTemplateId({
slug: 'home'
});
return getEditedEntityRecord('postType', 'wp_template', defaultTemplateId);
}
const currentTemplate = select(external_wp_editor_namespaceObject.store).getEditedPostAttribute('template');
if (currentTemplate) {
const templateWithSameSlug = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
const templateWithSameSlug = getEntityRecords('postType', 'wp_template', {
per_page: -1
})?.find(template => template.slug === currentTemplate);
if (!templateWithSameSlug) {
return templateWithSameSlug;
}
return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', 'wp_template', templateWithSameSlug.id);
return getEditedEntityRecord('postType', 'wp_template', templateWithSameSlug.id);
}
const post = select(external_wp_editor_namespaceObject.store).getCurrentPost();
let slugToCheck;
// In `draft` status we might not have a slug available, so we use the `single`
// post type templates slug(ex page, single-post, single-product etc..).
// Pages do not need the `single` prefix in the slug to be prioritized
// through template hierarchy.
if (post.slug) {
slugToCheck = post.type === 'page' ? `${post.type}-${post.slug}` : `single-${post.type}-${post.slug}`;
if (slug) {
slugToCheck = postType === 'page' ? `${postType}-${slug}` : `single-${postType}-${slug}`;
} else {
slugToCheck = post.type === 'page' ? 'page' : `single-${post.type}`;
slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
}
const defaultTemplateId = select(external_wp_coreData_namespaceObject.store).getDefaultTemplateId({
slug: slugToCheck
File diff suppressed because one or more lines are too long
+111 -71
View File
@@ -9658,6 +9658,45 @@ function useSupportedStyles(name, element) {
return supportedPanels;
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/set-nested-value.js
/**
* Sets the value at path of object.
* If a portion of path doesnt exist, its created.
* Arrays are created for missing index properties while objects are created
* for all other missing properties.
*
* This function intentionally mutates the input object.
*
* Inspired by _.set().
*
* @see https://lodash.com/docs/4.17.15#set
*
* @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
*
* @param {Object} object Object to modify
* @param {Array} path Path of the property to set.
* @param {*} value Value to set.
*/
function setNestedValue(object, path, value) {
if (!object || typeof object !== 'object') {
return object;
}
path.reduce((acc, key, idx) => {
if (acc[key] === undefined) {
if (Number.isInteger(path[idx + 1])) {
acc[key] = [];
} else {
acc[key] = {};
}
}
if (idx === path.length - 1) {
acc[key] = value;
}
return acc[key];
}, object);
return object;
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/push-changes-to-global-styles/index.js
/**
@@ -9679,6 +9718,7 @@ function useSupportedStyles(name, element) {
*/
const {
cleanEmptyObject,
GlobalStylesContext
@@ -9877,44 +9917,6 @@ function useChangesToPush(name, attributes, userConfig) {
return changes;
}, [supports, attributes, blockUserConfig]);
}
/**
* Sets the value at path of object.
* If a portion of path doesnt exist, its created.
* Arrays are created for missing index properties while objects are created
* for all other missing properties.
*
* This function intentionally mutates the input object.
*
* Inspired by _.set().
*
* @see https://lodash.com/docs/4.17.15#set
*
* @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
*
* @param {Object} object Object to modify
* @param {Array} path Path of the property to set.
* @param {*} value Value to set.
*/
function setNestedValue(object, path, value) {
if (!object || typeof object !== 'object') {
return object;
}
path.reduce((acc, key, idx) => {
if (acc[key] === undefined) {
if (Number.isInteger(path[idx + 1])) {
acc[key] = [];
} else {
acc[key] = {};
}
}
if (idx === path.length - 1) {
acc[key] = value;
}
return acc[key];
}, object);
return object;
}
function cloneDeep(object) {
return !object ? {} : JSON.parse(JSON.stringify(object));
}
@@ -17917,6 +17919,7 @@ function useResolveEditedEntityAndContext({
const {
hasLoadedAllDependencies,
homepageId,
postsPageId,
url,
frontPageTemplateId
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
@@ -17930,16 +17933,20 @@ function useResolveEditedEntityAndContext({
const templates = getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, {
per_page: -1
});
let _frontPateTemplateId;
const _homepageId = siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_on_front) && !!+siteData.page_on_front // We also need to check if it's not zero(`0`).
? siteData.page_on_front.toString() : null;
const _postsPageId = siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_for_posts) ? siteData.page_for_posts.toString() : null;
let _frontPageTemplateId;
if (templates) {
const frontPageTemplate = templates.find(t => t.slug === 'front-page');
_frontPateTemplateId = frontPageTemplate ? frontPageTemplate.id : false;
_frontPageTemplateId = frontPageTemplate ? frontPageTemplate.id : false;
}
return {
hasLoadedAllDependencies: !!base && !!siteData,
homepageId: siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_on_front) ? siteData.page_on_front.toString() : null,
homepageId: _homepageId,
postsPageId: _postsPageId,
url: base?.home,
frontPageTemplateId: _frontPateTemplateId
frontPageTemplateId: _frontPageTemplateId
};
}, []);
@@ -17977,6 +17984,10 @@ function useResolveEditedEntityAndContext({
if (!editedEntity) {
return undefined;
}
// Check if the current page is the posts page.
if (postTypeToResolve === 'page' && postsPageId === postIdToResolve) {
return __experimentalGetTemplateForLink(editedEntity.link)?.id;
}
// First see if the post/page has an assigned template and fetch it.
const currentTemplateSlug = editedEntity.template;
if (currentTemplateSlug) {
@@ -18028,7 +18039,7 @@ function useResolveEditedEntityAndContext({
const template = __experimentalGetTemplateForLink(url);
return template?.id;
}
}, [homepageId, hasLoadedAllDependencies, url, postId, postType, path, frontPageTemplateId]);
}, [homepageId, postsPageId, hasLoadedAllDependencies, url, postId, postType, path, frontPageTemplateId]);
const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
if (postTypesWithoutParentTemplate.includes(postType)) {
return {};
@@ -26985,12 +26996,13 @@ const {
} = unlock(external_wp_blockEditor_namespaceObject.privateApis);
const FontLibraryContext = (0,external_wp_element_namespaceObject.createContext)({});
function FontLibraryProvider({
children
}) {
const {
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
saveEntityRecord
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
const {
globalStylesId
@@ -27031,9 +27043,25 @@ function FontLibraryProvider({
// theme.json file font families
const [baseFontFamilies] = context_useGlobalSetting('typography.fontFamilies', undefined, 'base');
// Save font families to the global styles post in the database.
const saveFontFamilies = () => {
saveSpecifiedEntityEdits('root', 'globalStyles', globalStylesId, ['settings.typography.fontFamilies']);
/*
* Save the font families to the database.
* This function is called when the user activates or deactivates a font family.
* It only updates the global styles post content in the database for new font families.
* This avoids saving other styles/settings changed by the user using other parts of the editor.
*
* It uses the font families from the param to avoid using the font families from an outdated state.
*
* @param {Array} fonts - The font families that will be saved to the database.
*/
const saveFontFamilies = async fonts => {
// Gets the global styles database post content.
const updatedGlobalStyles = globalStyles.record;
// Updates the database version of global styles with the edited font families in the client.
setNestedValue(updatedGlobalStyles, ['settings', 'typography', 'fontFamilies'], fonts);
// Saves a new version of the global styles in the database.
await saveEntityRecord('root', 'globalStyles', updatedGlobalStyles);
};
// Library Fonts
@@ -27176,10 +27204,9 @@ function FontLibraryProvider({
installationErrors = installationErrors.reduce((unique, item) => unique.includes(item.message) ? unique : [...unique, item.message], []);
if (fontFamiliesToActivate.length > 0) {
// Activate the font family (add the font family to the global styles).
activateCustomFontFamilies(fontFamiliesToActivate);
const activeFonts = activateCustomFontFamilies(fontFamiliesToActivate);
// Save the global styles to the database.
await saveSpecifiedEntityEdits('root', 'globalStyles', globalStylesId, ['settings.typography.fontFamilies']);
await saveFontFamilies(activeFonts);
refreshLibrary();
}
if (installationErrors.length > 0) {
@@ -27200,9 +27227,9 @@ function FontLibraryProvider({
// Deactivate the font family if delete request is successful
// (Removes the font family from the global styles).
if (uninstalledFontFamily.deleted) {
deactivateFontFamily(fontFamilyToUninstall);
const activeFonts = deactivateFontFamily(fontFamilyToUninstall);
// Save the global styles to the database.
await saveSpecifiedEntityEdits('root', 'globalStyles', globalStylesId, ['settings.typography.fontFamilies']);
await saveFontFamilies(activeFonts);
}
// Refresh the library (the library font families from database).
@@ -27220,19 +27247,35 @@ function FontLibraryProvider({
// We want to save as active all the theme fonts at the beginning
const initialCustomFonts = (_fontFamilies$font$so = fontFamilies?.[font.source]) !== null && _fontFamilies$font$so !== void 0 ? _fontFamilies$font$so : [];
const newCustomFonts = initialCustomFonts.filter(f => f.slug !== font.slug);
setFontFamilies({
const activeFonts = {
...fontFamilies,
[font.source]: newCustomFonts
});
};
setFontFamilies(activeFonts);
if (font.fontFace) {
font.fontFace.forEach(face => {
unloadFontFaceInBrowser(face, 'all');
});
}
return activeFonts;
};
const activateCustomFontFamilies = fontsToAdd => {
// Removes the id from the families and faces to avoid saving that to global styles post content.
const fontsToActivate = fontsToAdd.map(({
const fontsToActivate = cleanFontsForSave(fontsToAdd);
const activeFonts = {
...fontFamilies,
// Merge the existing custom fonts with the new fonts.
custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
};
// Activate the fonts by set the new custom fonts array.
setFontFamilies(activeFonts);
loadFontsInBrowser(fontsToActivate);
return activeFonts;
};
// Removes the id from the families and faces to avoid saving that to global styles post content.
const cleanFontsForSave = fonts => {
return fonts.map(({
id: _familyDbId,
fontFace,
...font
@@ -27245,16 +27288,10 @@ function FontLibraryProvider({
}) => face)
} : {})
}));
// Activate the fonts by set the new custom fonts array.
setFontFamilies({
...fontFamilies,
// Merge the existing custom fonts with the new fonts.
custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
});
};
const loadFontsInBrowser = fonts => {
// Add custom fonts to the browser.
fontsToActivate.forEach(font => {
fonts.forEach(font => {
if (font.fontFace) {
font.fontFace.forEach(face => {
// Load font faces just in the iframe because they already are in the document.
@@ -27324,6 +27361,7 @@ function FontLibraryProvider({
value: {
libraryFontSelected,
handleSetLibraryFontSelected,
fontFamilies,
themeFonts,
baseThemeFonts,
customFonts,
@@ -27622,7 +27660,8 @@ function InstalledFonts() {
getFontFacesActivated,
fontFamiliesHasChanges,
notice,
setNotice
setNotice,
fontFamilies
} = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext);
const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0,external_wp_element_namespaceObject.useState)(false);
const customFontFamilyId = libraryFontSelected?.source === 'custom' && libraryFontSelected?.id;
@@ -27700,9 +27739,7 @@ function InstalledFonts() {
onClick: () => {
handleSetLibraryFontSelected(font);
}
}))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
margin: 16
})), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
})))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
path: "/fontFamily"
}, (0,external_React_.createElement)(ConfirmDeleteDialog, {
font: libraryFontSelected,
@@ -27752,7 +27789,9 @@ function InstalledFonts() {
onClick: handleUninstallClick
}, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, {
variant: "primary",
onClick: saveFontFamilies,
onClick: () => {
saveFontFamilies(fontFamilies);
},
disabled: !fontFamiliesHasChanges,
__experimentalIsFocusable: true
}, (0,external_wp_i18n_namespaceObject.__)('Update'))));
@@ -28188,6 +28227,7 @@ function FontCollection({
isSmall: true,
onClick: () => {
setSelectedFont(null);
setNotice(null);
},
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
}), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
@@ -32375,7 +32415,7 @@ const {
} = unlock(external_wp_components_namespaceObject.privateApis);
const DEFAULT_TAB = {
id: 'installed-fonts',
title: (0,external_wp_i18n_namespaceObject.__)('Library')
title: (0,external_wp_i18n_namespaceObject._x)('Library', 'Font library')
};
const UPLOAD_TAB = {
id: 'upload-fonts',
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -15925,7 +15925,7 @@ function DocumentTools({
variant: "unstyled"
}, (0,external_React_.createElement)("div", {
className: "editor-document-tools__left"
}, (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
}, !isDistractionFree && (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
ref: inserterButton,
as: external_wp_components_namespaceObject.Button,
className: "editor-document-tools__inserter-toggle",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long