mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 22:45:39 +00:00
Editor: Update WordPress packages for 6.0 RC 4
Included cherry-picked commits from the Gutenberg plugin that fix bugs discovered after WordPress 6.0 RC 3. Props zieladam. See #55567. Built from https://develop.svn.wordpress.org/trunk@53420 git-svn-id: http://core.svn.wordpress.org/trunk@53009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b020766e3d
commit
cbcf19d09d
File diff suppressed because one or more lines are too long
@ -43,7 +43,7 @@ function wp_register_layout_support( $block_type ) {
|
||||
* @param boolean $should_skip_gap_serialization Whether to skip applying the user-defined value set in the editor.
|
||||
* @return string CSS style.
|
||||
*/
|
||||
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false ) {
|
||||
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em' ) {
|
||||
$layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default';
|
||||
|
||||
$style = '';
|
||||
@ -102,14 +102,14 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
|
||||
$style .= 'display: flex;';
|
||||
if ( $has_block_gap_support ) {
|
||||
if ( is_array( $gap_value ) ) {
|
||||
$gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : '0.5em';
|
||||
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : '0.5em';
|
||||
$gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap_value;
|
||||
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap_value;
|
||||
$gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
|
||||
}
|
||||
$gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : 'var( --wp--style--block-gap, 0.5em )';
|
||||
$gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : "var( --wp--style--block-gap, $fallback_gap_value )";
|
||||
$style .= "gap: $gap_style;";
|
||||
} else {
|
||||
$style .= 'gap: 0.5em;';
|
||||
$style .= "gap: $fallback_gap_value;";
|
||||
}
|
||||
|
||||
$style .= "flex-wrap: $flex_wrap;";
|
||||
@ -182,10 +182,12 @@ function wp_render_layout_support_flag( $block_content, $block ) {
|
||||
$gap_value = $gap_value && preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value;
|
||||
}
|
||||
|
||||
$fallback_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' );
|
||||
|
||||
// If a block's block.json skips serialization for spacing or spacing.blockGap,
|
||||
// don't apply the user-defined value to the styles.
|
||||
$should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' );
|
||||
$style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization );
|
||||
$style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization, $fallback_gap_value );
|
||||
// This assumes the hook only applies to blocks with a single wrapper.
|
||||
// I think this is a reasonable limitation for that particular hook.
|
||||
$content = preg_replace(
|
||||
|
@ -28,7 +28,9 @@
|
||||
}
|
||||
},
|
||||
"spacing": {
|
||||
"blockGap": true,
|
||||
"blockGap": {
|
||||
"__experimentalDefault": "2em"
|
||||
},
|
||||
"margin": [ "top", "bottom" ],
|
||||
"padding": true,
|
||||
"__experimentalDefaultControls": {
|
||||
|
@ -48,7 +48,14 @@ function block_core_gallery_render( $attributes, $content ) {
|
||||
// Skip if gap value contains unsupported characters.
|
||||
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
|
||||
// because we only want to match against the value, not the CSS attribute.
|
||||
$gap = preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
|
||||
if ( is_array( $gap ) ) {
|
||||
foreach ( $gap as $key => $value ) {
|
||||
$gap[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;
|
||||
}
|
||||
} else {
|
||||
$gap = $gap && preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
|
||||
}
|
||||
|
||||
$class = wp_unique_id( 'wp-block-gallery-' );
|
||||
$content = preg_replace(
|
||||
'/' . preg_quote( 'class="', '/' ) . '/',
|
||||
@ -56,10 +63,22 @@ function block_core_gallery_render( $attributes, $content ) {
|
||||
$content,
|
||||
1
|
||||
);
|
||||
|
||||
// --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
|
||||
// gap on the gallery.
|
||||
$gap_value = $gap ? $gap : 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )';
|
||||
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '; gap: ' . $gap_value . '}';
|
||||
$fallback_gap = 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )';
|
||||
$gap_value = $gap ? $gap : $fallback_gap;
|
||||
$gap_column = $gap_value;
|
||||
|
||||
if ( is_array( $gap_value ) ) {
|
||||
$gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap;
|
||||
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap;
|
||||
$gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
|
||||
}
|
||||
|
||||
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
|
||||
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
|
||||
|
||||
// Ideally styles should be loaded in the head, but blocks may be parsed
|
||||
// after that, so loading in the footer for now.
|
||||
// See https://core.trac.wordpress.org/ticket/53494.
|
||||
|
26
wp-includes/js/dist/block-editor.js
vendored
26
wp-includes/js/dist/block-editor.js
vendored
@ -10770,7 +10770,7 @@ const useIsDimensionsDisabled = function () {
|
||||
return gapDisabled && paddingDisabled && marginDisabled;
|
||||
};
|
||||
/**
|
||||
* Custom hook to retrieve which padding/margin is supported
|
||||
* Custom hook to retrieve which padding/margin/blockGap is supported
|
||||
* e.g. top, right, bottom or left.
|
||||
*
|
||||
* Sides are opted into by default. It is only if a specific side is set to
|
||||
@ -10779,18 +10779,28 @@ const useIsDimensionsDisabled = function () {
|
||||
* @param {string} blockName Block name.
|
||||
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
||||
*
|
||||
* @return {Object} Sides supporting custom margin.
|
||||
* @return {?string[]} Strings representing the custom sides available.
|
||||
*/
|
||||
|
||||
|
||||
function useCustomSides(blockName, feature) {
|
||||
var _support$feature;
|
||||
|
||||
const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
|
||||
|
||||
if (!support || typeof support[feature] === 'boolean') {
|
||||
return;
|
||||
}
|
||||
} // Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
||||
|
||||
|
||||
if (Array.isArray(support[feature])) {
|
||||
return support[feature];
|
||||
} // Finally, attempt to return `.sides` if the setting is an object.
|
||||
|
||||
|
||||
if ((_support$feature = support[feature]) !== null && _support$feature !== void 0 && _support$feature.sides) {
|
||||
return support[feature].sides;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Custom hook to determine whether the sides configured in the
|
||||
@ -11266,6 +11276,7 @@ const JustifyToolbar = props => {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
@ -11357,10 +11368,11 @@ const flexWrapOptions = ['wrap', 'nowrap'];
|
||||
orientation = 'horizontal'
|
||||
} = layout;
|
||||
const blockGapSupport = useSetting('spacing.blockGap');
|
||||
const fallbackValue = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, ['spacing', 'blockGap', '__experimentalDefault']) || '0.5em';
|
||||
const hasBlockGapStylesSupport = blockGapSupport !== null; // If a block's block.json skips serialization for spacing or spacing.blockGap,
|
||||
// don't apply the user-defined value to the styles.
|
||||
|
||||
const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, '0.5em') : 'var( --wp--style--block-gap, 0.5em )';
|
||||
const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, fallbackValue) : `var( --wp--style--block-gap, ${fallbackValue} )`;
|
||||
const justifyContent = justifyContentMap[layout.justifyContent] || justifyContentMap.left;
|
||||
const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap';
|
||||
const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment] || verticalAlignmentMap.center;
|
||||
@ -11378,7 +11390,7 @@ const flexWrapOptions = ['wrap', 'nowrap'];
|
||||
${appendSelectors(selector)} {
|
||||
display: flex;
|
||||
flex-wrap: ${flexWrap};
|
||||
gap: ${hasBlockGapStylesSupport ? blockGapValue : '0.5em'};
|
||||
gap: ${hasBlockGapStylesSupport ? blockGapValue : fallbackValue};
|
||||
${orientation === 'horizontal' ? rowOrientation : columnOrientation}
|
||||
}
|
||||
|
||||
@ -44754,7 +44766,6 @@ const MediaReplaceFlow = _ref => {
|
||||
onSelect,
|
||||
onSelectURL,
|
||||
onFilesUpload = external_lodash_namespaceObject.noop,
|
||||
onCloseModal = external_lodash_namespaceObject.noop,
|
||||
name = (0,external_wp_i18n_namespaceObject.__)('Replace'),
|
||||
createNotice,
|
||||
removeNotice,
|
||||
@ -44870,7 +44881,6 @@ const MediaReplaceFlow = _ref => {
|
||||
value: multiple ? mediaIds : mediaId,
|
||||
onSelect: media => selectMedia(media, onClose),
|
||||
allowedTypes: allowedTypes,
|
||||
onClose: onCloseModal,
|
||||
render: _ref5 => {
|
||||
let {
|
||||
open
|
||||
@ -45191,7 +45201,6 @@ function MediaPlaceholder(_ref2) {
|
||||
onDoubleClick,
|
||||
onFilesPreUpload = external_lodash_namespaceObject.noop,
|
||||
onHTMLDrop = external_lodash_namespaceObject.noop,
|
||||
onClose = external_lodash_namespaceObject.noop,
|
||||
children,
|
||||
mediaLibraryButton,
|
||||
placeholder,
|
||||
@ -45431,7 +45440,6 @@ function MediaPlaceholder(_ref2) {
|
||||
gallery: multiple && onlyAllowsImages(),
|
||||
multiple: multiple,
|
||||
onSelect: onSelect,
|
||||
onClose: onClose,
|
||||
allowedTypes: allowedTypes,
|
||||
value: Array.isArray(value) ? value.map(_ref7 => {
|
||||
let {
|
||||
|
2
wp-includes/js/dist/block-editor.min.js
vendored
2
wp-includes/js/dist/block-editor.min.js
vendored
File diff suppressed because one or more lines are too long
254
wp-includes/js/dist/block-library.js
vendored
254
wp-includes/js/dist/block-library.js
vendored
@ -7198,7 +7198,9 @@ const columns_metadata = {
|
||||
}
|
||||
},
|
||||
spacing: {
|
||||
blockGap: true,
|
||||
blockGap: {
|
||||
__experimentalDefault: "2em"
|
||||
},
|
||||
margin: ["top", "bottom"],
|
||||
padding: true,
|
||||
__experimentalDefaultControls: {
|
||||
@ -15846,9 +15848,19 @@ function GapStyles(_ref) {
|
||||
const styleElement = (0,external_wp_element_namespaceObject.useContext)(external_wp_blockEditor_namespaceObject.BlockList.__unstableElementContext); // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
|
||||
// gap on the gallery.
|
||||
|
||||
const gapValue = blockGap ? blockGap : `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`;
|
||||
const fallbackValue = `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`;
|
||||
let gapValue = fallbackValue;
|
||||
let column = fallbackValue;
|
||||
let row; // Check for the possibility of split block gap values. See: https://github.com/WordPress/gutenberg/pull/37736
|
||||
|
||||
if (!!blockGap) {
|
||||
row = typeof blockGap === 'string' ? blockGap : (blockGap === null || blockGap === void 0 ? void 0 : blockGap.top) || fallbackValue;
|
||||
column = typeof blockGap === 'string' ? blockGap : (blockGap === null || blockGap === void 0 ? void 0 : blockGap.left) || fallbackValue;
|
||||
gapValue = row === column ? row : `${row} ${column}`;
|
||||
}
|
||||
|
||||
const gap = `#block-${clientId} {
|
||||
--wp--style--unstable-gallery-gap: ${gapValue};
|
||||
--wp--style--unstable-gallery-gap: ${column};
|
||||
gap: ${gapValue}
|
||||
}`;
|
||||
|
||||
@ -20059,14 +20071,12 @@ function Image(_ref) {
|
||||
isSelected,
|
||||
insertBlocksAfter,
|
||||
onReplace,
|
||||
onCloseModal,
|
||||
onSelectImage,
|
||||
onSelectURL,
|
||||
onUploadError,
|
||||
containerRef,
|
||||
context,
|
||||
clientId,
|
||||
onImageLoadError
|
||||
clientId
|
||||
} = _ref;
|
||||
const imageRef = (0,external_wp_element_namespaceObject.useRef)();
|
||||
const captionRef = (0,external_wp_element_namespaceObject.useRef)();
|
||||
@ -20192,20 +20202,16 @@ function Image(_ref) {
|
||||
}
|
||||
|
||||
function onImageError() {
|
||||
// Check if there's an embed block that handles this URL, e.g., instagram URL.
|
||||
// See: https://github.com/WordPress/gutenberg/pull/11472
|
||||
// Check if there's an embed block that handles this URL.
|
||||
const embedBlock = createUpgradedEmbedBlock({
|
||||
attributes: {
|
||||
url
|
||||
}
|
||||
});
|
||||
const shouldReplace = undefined !== embedBlock;
|
||||
|
||||
if (shouldReplace) {
|
||||
if (undefined !== embedBlock) {
|
||||
onReplace(embedBlock);
|
||||
}
|
||||
|
||||
onImageLoadError(shouldReplace);
|
||||
}
|
||||
|
||||
function onSetHref(props) {
|
||||
@ -20284,10 +20290,6 @@ function Image(_ref) {
|
||||
if (!isSelected) {
|
||||
setIsEditingImage(false);
|
||||
}
|
||||
|
||||
if (isSelected && isMediaDestroyed(id)) {
|
||||
onImageLoadError();
|
||||
}
|
||||
}, [isSelected]);
|
||||
const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
|
||||
const allowCrop = !multiImageSelection && canEditImage && !isEditingImage;
|
||||
@ -20331,8 +20333,7 @@ function Image(_ref) {
|
||||
accept: "image/*",
|
||||
onSelect: onSelectImage,
|
||||
onSelectURL: onSelectURL,
|
||||
onError: onUploadError,
|
||||
onCloseModal: onCloseModal
|
||||
onError: onUploadError
|
||||
})), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InspectorControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Image settings')
|
||||
}, !multiImageSelection && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextareaControl, {
|
||||
@ -20590,23 +20591,7 @@ const isExternalImage = (id, url) => url && !id && !(0,external_wp_blob_namespac
|
||||
function hasDefaultSize(image, defaultSize) {
|
||||
return (0,external_lodash_namespaceObject.has)(image, ['sizes', defaultSize, 'url']) || (0,external_lodash_namespaceObject.has)(image, ['media_details', 'sizes', defaultSize, 'source_url']);
|
||||
}
|
||||
/**
|
||||
* Checks if a media attachment object has been "destroyed",
|
||||
* that is, removed from the media library. The core Media Library
|
||||
* adds a `destroyed` property to a deleted attachment object in the media collection.
|
||||
*
|
||||
* @param {number} id The attachment id.
|
||||
*
|
||||
* @return {boolean} Whether the image has been destroyed.
|
||||
*/
|
||||
|
||||
|
||||
function isMediaDestroyed(id) {
|
||||
var _wp, _wp$media;
|
||||
|
||||
const attachment = ((_wp = wp) === null || _wp === void 0 ? void 0 : (_wp$media = _wp.media) === null || _wp$media === void 0 ? void 0 : _wp$media.attachment(id)) || {};
|
||||
return attachment.destroyed;
|
||||
}
|
||||
function ImageEdit(_ref) {
|
||||
let {
|
||||
attributes,
|
||||
@ -20648,36 +20633,7 @@ function ImageEdit(_ref) {
|
||||
getSettings
|
||||
} = select(external_wp_blockEditor_namespaceObject.store);
|
||||
return (0,external_lodash_namespaceObject.pick)(getSettings(), ['imageDefaultSize', 'mediaUpload']);
|
||||
}, []); // A callback passed to MediaUpload,
|
||||
// fired when the media modal closes.
|
||||
|
||||
function onCloseModal() {
|
||||
if (isMediaDestroyed(attributes === null || attributes === void 0 ? void 0 : attributes.id)) {
|
||||
setAttributes({
|
||||
url: undefined,
|
||||
id: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
/*
|
||||
Runs an error callback if the image does not load.
|
||||
If the error callback is triggered, we infer that that image
|
||||
has been deleted.
|
||||
*/
|
||||
|
||||
|
||||
function onImageError() {
|
||||
let isReplaced = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||
|
||||
// If the image block was not replaced with an embed,
|
||||
// clear the attributes and trigger the placeholder.
|
||||
if (!isReplaced) {
|
||||
setAttributes({
|
||||
url: undefined,
|
||||
id: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
function onUploadError(message) {
|
||||
noticeOperations.removeAllNotices();
|
||||
@ -20691,7 +20647,7 @@ function ImageEdit(_ref) {
|
||||
}
|
||||
|
||||
function onSelectImage(media) {
|
||||
var _wp2, _wp2$media, _wp2$media$view, _wp2$media$view$setti, _wp2$media$view$setti2;
|
||||
var _wp, _wp$media, _wp$media$view, _wp$media$view$settin, _wp$media$view$settin2;
|
||||
|
||||
if (!media || !media.url) {
|
||||
setAttributes({
|
||||
@ -20742,7 +20698,7 @@ function ImageEdit(_ref) {
|
||||
// Use the WordPress option to determine the proper default.
|
||||
// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.
|
||||
// TODO: fix this in a follow up PR, requires updating media-text and ui component.
|
||||
switch (((_wp2 = wp) === null || _wp2 === void 0 ? void 0 : (_wp2$media = _wp2.media) === null || _wp2$media === void 0 ? void 0 : (_wp2$media$view = _wp2$media.view) === null || _wp2$media$view === void 0 ? void 0 : (_wp2$media$view$setti = _wp2$media$view.settings) === null || _wp2$media$view$setti === void 0 ? void 0 : (_wp2$media$view$setti2 = _wp2$media$view$setti.defaultProps) === null || _wp2$media$view$setti2 === void 0 ? void 0 : _wp2$media$view$setti2.link) || constants_LINK_DESTINATION_NONE) {
|
||||
switch (((_wp = wp) === null || _wp === void 0 ? void 0 : (_wp$media = _wp.media) === null || _wp$media === void 0 ? void 0 : (_wp$media$view = _wp$media.view) === null || _wp$media$view === void 0 ? void 0 : (_wp$media$view$settin = _wp$media$view.settings) === null || _wp$media$view$settin === void 0 ? void 0 : (_wp$media$view$settin2 = _wp$media$view$settin.defaultProps) === null || _wp$media$view$settin2 === void 0 ? void 0 : _wp$media$view$settin2.link) || constants_LINK_DESTINATION_NONE) {
|
||||
case 'file':
|
||||
case constants_LINK_DESTINATION_MEDIA:
|
||||
linkDestination = constants_LINK_DESTINATION_MEDIA;
|
||||
@ -20868,9 +20824,7 @@ function ImageEdit(_ref) {
|
||||
onUploadError: onUploadError,
|
||||
containerRef: ref,
|
||||
context: context,
|
||||
clientId: clientId,
|
||||
onCloseModal: onCloseModal,
|
||||
onImageLoadError: onImageError
|
||||
clientId: clientId
|
||||
}), !url && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, {
|
||||
group: "block"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockAlignmentControl, {
|
||||
@ -20884,7 +20838,6 @@ function ImageEdit(_ref) {
|
||||
onSelectURL: onSelectURL,
|
||||
notices: noticeUI,
|
||||
onError: onUploadError,
|
||||
onClose: onCloseModal,
|
||||
accept: "image/*",
|
||||
allowedTypes: constants_ALLOWED_MEDIA_TYPES,
|
||||
value: {
|
||||
@ -26408,89 +26361,12 @@ function Navigation(_ref) {
|
||||
replaceInnerBlocks(clientId, []);
|
||||
}
|
||||
});
|
||||
}, [clientId, ref]); // If the block has inner blocks, but no menu id, then these blocks are either:
|
||||
// - inserted via a pattern.
|
||||
// - inserted directly via Code View (or otherwise).
|
||||
// - from an older version of navigation block added before the block used a wp_navigation entity.
|
||||
// Consider this state as 'unsaved' and offer an uncontrolled version of inner blocks,
|
||||
// that automatically saves the menu as an entity when changes are made to the inner blocks.
|
||||
|
||||
const hasUnsavedBlocks = hasUncontrolledInnerBlocks && !isEntityAvailable;
|
||||
|
||||
if (hasUnsavedBlocks) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)(TagName, blockProps, (0,external_wp_element_namespaceObject.createElement)(ResponsiveWrapper, {
|
||||
id: clientId,
|
||||
onToggle: setResponsiveMenuVisibility,
|
||||
isOpen: isResponsiveMenuOpen,
|
||||
isResponsive: 'never' !== overlayMenu,
|
||||
isHiddenByDefault: 'always' === overlayMenu,
|
||||
classNames: overlayClassnames,
|
||||
styles: overlayStyles
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(UnsavedInnerBlocks, {
|
||||
blockProps: blockProps,
|
||||
blocks: uncontrolledInnerBlocks,
|
||||
clientId: clientId,
|
||||
navigationMenus: navigationMenus,
|
||||
hasSelection: isSelected || isInnerBlockSelected,
|
||||
hasSavedUnsavedInnerBlocks: hasSavedUnsavedInnerBlocks,
|
||||
onSave: post => {
|
||||
// Set some state used as a guard to prevent the creation of multiple posts.
|
||||
setHasSavedUnsavedInnerBlocks(true); // Switch to using the wp_navigation entity.
|
||||
|
||||
setRef(post.id);
|
||||
showNavigationMenuCreateNotice((0,external_wp_i18n_namespaceObject.__)(`New Navigation Menu created.`));
|
||||
}
|
||||
})));
|
||||
} // Show a warning if the selected menu is no longer available.
|
||||
// TODO - the user should be able to select a new one?
|
||||
|
||||
|
||||
if (ref && isNavigationMenuMissing) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)("div", blockProps, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Navigation menu has been deleted or is unavailable. '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
onClick: resetToEmptyBlock,
|
||||
variant: "link"
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Create a new menu?'))));
|
||||
}
|
||||
|
||||
if (isEntityAvailable && hasAlreadyRendered) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)("div", blockProps, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Block cannot be rendered inside itself.')));
|
||||
}
|
||||
|
||||
const PlaceholderComponent = CustomPlaceholder ? CustomPlaceholder : NavigationPlaceholder;
|
||||
}, [clientId, ref]);
|
||||
const isResponsive = 'never' !== overlayMenu;
|
||||
const overlayMenuPreviewClasses = classnames_default()('wp-block-navigation__overlay-menu-preview', {
|
||||
open: overlayMenuPreview
|
||||
});
|
||||
|
||||
if (isPlaceholder) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)(TagName, blockProps, (0,external_wp_element_namespaceObject.createElement)(PlaceholderComponent, {
|
||||
isSelected: isSelected,
|
||||
currentMenuId: ref,
|
||||
clientId: clientId,
|
||||
canUserCreateNavigationMenu: canUserCreateNavigationMenu,
|
||||
isResolvingCanUserCreateNavigationMenu: isResolvingCanUserCreateNavigationMenu,
|
||||
onFinish: handleSelectNavigation,
|
||||
onCreateEmpty: () => createNavigationMenu('', [])
|
||||
}));
|
||||
}
|
||||
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
|
||||
kind: "postType",
|
||||
type: "wp_navigation",
|
||||
id: ref
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(RecursionProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, !isDraftNavigationMenu && isEntityAvailable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
|
||||
className: "wp-block-navigation__toolbar-menu-selector"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(navigation_menu_selector, {
|
||||
ref: navigationSelectorRef,
|
||||
currentMenuId: ref,
|
||||
clientId: clientId,
|
||||
onSelect: handleSelectNavigation,
|
||||
onCreateNew: resetToEmptyBlock
|
||||
/* translators: %s: The name of a menu. */
|
||||
,
|
||||
actionLabel: (0,external_wp_i18n_namespaceObject.__)("Switch to '%s'"),
|
||||
showManageActions: true
|
||||
}))), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InspectorControls, null, hasSubmenuIndicatorSetting && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
|
||||
const stylingInspectorControls = (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InspectorControls, null, hasSubmenuIndicatorSetting && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Display')
|
||||
}, isResponsive && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
className: overlayMenuPreviewClasses,
|
||||
@ -26571,7 +26447,85 @@ function Navigation(_ref) {
|
||||
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ContrastChecker, {
|
||||
backgroundColor: detectedOverlayBackgroundColor,
|
||||
textColor: detectedOverlayColor
|
||||
})))), isEntityAvailable && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InspectorControls, {
|
||||
})))); // If the block has inner blocks, but no menu id, then these blocks are either:
|
||||
// - inserted via a pattern.
|
||||
// - inserted directly via Code View (or otherwise).
|
||||
// - from an older version of navigation block added before the block used a wp_navigation entity.
|
||||
// Consider this state as 'unsaved' and offer an uncontrolled version of inner blocks,
|
||||
// that automatically saves the menu as an entity when changes are made to the inner blocks.
|
||||
|
||||
const hasUnsavedBlocks = hasUncontrolledInnerBlocks && !isEntityAvailable;
|
||||
|
||||
if (hasUnsavedBlocks) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)(TagName, blockProps, stylingInspectorControls, (0,external_wp_element_namespaceObject.createElement)(ResponsiveWrapper, {
|
||||
id: clientId,
|
||||
onToggle: setResponsiveMenuVisibility,
|
||||
isOpen: isResponsiveMenuOpen,
|
||||
isResponsive: 'never' !== overlayMenu,
|
||||
isHiddenByDefault: 'always' === overlayMenu,
|
||||
classNames: overlayClassnames,
|
||||
styles: overlayStyles
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(UnsavedInnerBlocks, {
|
||||
blockProps: blockProps,
|
||||
blocks: uncontrolledInnerBlocks,
|
||||
clientId: clientId,
|
||||
navigationMenus: navigationMenus,
|
||||
hasSelection: isSelected || isInnerBlockSelected,
|
||||
hasSavedUnsavedInnerBlocks: hasSavedUnsavedInnerBlocks,
|
||||
onSave: post => {
|
||||
// Set some state used as a guard to prevent the creation of multiple posts.
|
||||
setHasSavedUnsavedInnerBlocks(true); // Switch to using the wp_navigation entity.
|
||||
|
||||
setRef(post.id);
|
||||
showNavigationMenuCreateNotice((0,external_wp_i18n_namespaceObject.__)(`New Navigation Menu created.`));
|
||||
}
|
||||
})));
|
||||
} // Show a warning if the selected menu is no longer available.
|
||||
// TODO - the user should be able to select a new one?
|
||||
|
||||
|
||||
if (ref && isNavigationMenuMissing) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)("div", blockProps, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Navigation menu has been deleted or is unavailable. '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
onClick: resetToEmptyBlock,
|
||||
variant: "link"
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Create a new menu?'))));
|
||||
}
|
||||
|
||||
if (isEntityAvailable && hasAlreadyRendered) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)("div", blockProps, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, null, (0,external_wp_i18n_namespaceObject.__)('Block cannot be rendered inside itself.')));
|
||||
}
|
||||
|
||||
const PlaceholderComponent = CustomPlaceholder ? CustomPlaceholder : NavigationPlaceholder;
|
||||
|
||||
if (isPlaceholder) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)(TagName, blockProps, (0,external_wp_element_namespaceObject.createElement)(PlaceholderComponent, {
|
||||
isSelected: isSelected,
|
||||
currentMenuId: ref,
|
||||
clientId: clientId,
|
||||
canUserCreateNavigationMenu: canUserCreateNavigationMenu,
|
||||
isResolvingCanUserCreateNavigationMenu: isResolvingCanUserCreateNavigationMenu,
|
||||
onFinish: handleSelectNavigation,
|
||||
onCreateEmpty: () => createNavigationMenu('', [])
|
||||
}));
|
||||
}
|
||||
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
|
||||
kind: "postType",
|
||||
type: "wp_navigation",
|
||||
id: ref
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(RecursionProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, !isDraftNavigationMenu && isEntityAvailable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
|
||||
className: "wp-block-navigation__toolbar-menu-selector"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(navigation_menu_selector, {
|
||||
ref: navigationSelectorRef,
|
||||
currentMenuId: ref,
|
||||
clientId: clientId,
|
||||
onSelect: handleSelectNavigation,
|
||||
onCreateNew: resetToEmptyBlock
|
||||
/* translators: %s: The name of a menu. */
|
||||
,
|
||||
actionLabel: (0,external_wp_i18n_namespaceObject.__)("Switch to '%s'"),
|
||||
showManageActions: true
|
||||
}))), stylingInspectorControls, isEntityAvailable && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InspectorControls, {
|
||||
__experimentalGroup: "advanced"
|
||||
}, hasResolvedCanUserUpdateNavigationMenu && canUserUpdateNavigationMenu && (0,external_wp_element_namespaceObject.createElement)(NavigationMenuNameControl, null), hasResolvedCanUserDeleteNavigationMenu && canUserDeleteNavigationMenu && (0,external_wp_element_namespaceObject.createElement)(NavigationMenuDeleteControl, {
|
||||
onDelete: function () {
|
||||
|
2
wp-includes/js/dist/block-library.min.js
vendored
2
wp-includes/js/dist/block-library.min.js
vendored
File diff suppressed because one or more lines are too long
15
wp-includes/js/dist/edit-site.js
vendored
15
wp-includes/js/dist/edit-site.js
vendored
@ -7940,11 +7940,22 @@ const StylesPreview = _ref => {
|
||||
color
|
||||
} = _ref2;
|
||||
return color !== backgroundColor && color !== headingColor;
|
||||
}).slice(0, 2);
|
||||
}).slice(0, 2); // Reset leaked styles from WP common.css.
|
||||
|
||||
const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
if (styles) {
|
||||
return [...styles, {
|
||||
css: 'body{min-width: 0;}',
|
||||
isGlobalStyles: true
|
||||
}];
|
||||
}
|
||||
|
||||
return styles;
|
||||
}, [styles]);
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, {
|
||||
className: "edit-site-global-styles-preview__iframe",
|
||||
head: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
|
||||
styles: styles
|
||||
styles: editorStyles
|
||||
}),
|
||||
style: {
|
||||
height: normalizedHeight * ratio,
|
||||
|
2
wp-includes/js/dist/edit-site.min.js
vendored
2
wp-includes/js/dist/edit-site.min.js
vendored
File diff suppressed because one or more lines are too long
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-alpha-53419';
|
||||
$wp_version = '6.1-alpha-53420';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user