Block Editor: Include the fixes targetted for WordPress 5.8 RC3.

This includes the following fixes:
 - Safari: see if compositing layer size is more reasonable when position fixed divs are not inserted into content.
 - Site Logo Block: update Site Logo block UI and option syncing.
 - Fix moving inner blocks in the Widgets Customizer.
 - Allow themes to provide empty values for color.duotone and spacing.units
 - Update getTermsInfo() to workaround parsing issue for translatable strings.
 - Specify what settings can be part of settings.layout.
 - Update conditions to hide duotone panel.
 - Prevent entering invalid values in the Query Loop block config.
 - Prevent color panel from showing as empty.
 - Avoid calling gutenberg_ functions within code shipped through WordPress Core.

Props desrosj.
See #53397.

Built from https://develop.svn.wordpress.org/trunk@51421


git-svn-id: http://core.svn.wordpress.org/trunk@51032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
youknowriad 2021-07-13 16:41:28 +00:00
parent 8b2e5e7843
commit e270f4f0f3
22 changed files with 309 additions and 296 deletions

File diff suppressed because one or more lines are too long

View File

@ -86,63 +86,3 @@ function register_block_core_post_template() {
);
}
add_action( 'init', 'register_block_core_post_template' );
/**
* Renders the legacy `core/query-loop` block on the server.
* It triggers a developer warning and then calls the renamed
* block's `render_callback` function output.
*
* This can be removed when WordPress 5.9 is released.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.
*/
function render_legacy_query_loop_block( $attributes, $content, $block ) {
trigger_error(
/* translators: %1$s: Block type */
sprintf( __( 'Block %1$s has been renamed to Post Template. %1$s will be supported until WordPress version 5.9.' ), $block->name ),
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
);
return render_block_core_post_template( $attributes, $content, $block );
}
/**
* Complements the renaming of `Query Loop` to `Post Template`.
* This ensures backwards compatibility for any users running the Gutenberg
* plugin who have used Query Loop prior to its renaming.
*
* This can be removed when WordPress 5.9 is released.
*
* @see https://github.com/WordPress/gutenberg/pull/32514
*/
function gutenberg_register_legacy_query_loop_block() {
$registry = WP_Block_Type_Registry::get_instance();
if ( $registry->is_registered( 'core/query-loop' ) ) {
unregister_block_type( 'core/query-loop' );
}
register_block_type(
'core/query-loop',
array(
'category' => 'design',
'uses_context' => array(
'queryId',
'query',
'queryContext',
'displayLayout',
'templateSlug',
),
'supports' => array(
'reusable' => false,
'html' => false,
'align' => true,
),
'style' => 'wp-block-post-template',
'render_callback' => 'render_legacy_query_loop_block',
'skip_inner_blocks' => true,
)
);
}
add_action( 'init', 'gutenberg_register_legacy_query_loop_block' );

View File

@ -14,7 +14,7 @@
*/
function render_block_core_site_logo( $attributes ) {
$adjust_width_height_filter = function ( $image ) use ( $attributes ) {
if ( empty( $attributes['width'] ) ) {
if ( empty( $attributes['width'] ) || empty( $image ) ) {
return $image;
}
$height = (float) $attributes['width'] / ( (float) $image[1] / (float) $image[2] );
@ -111,54 +111,52 @@ add_filter( 'theme_mod_custom_logo', '_override_custom_logo_theme_mod' );
/**
* Updates the site_logo option when the custom_logo theme-mod gets updated.
*
* This function is hooked on "update_option_theme_mods_$theme" and not
* "pre_set_theme_mod_custom_logo" because by hooking in `update_option`
* the function accounts for remove_theme_mod() as well.
*
* @param mixed $old_value The old option value.
* @param mixed $value The new option value.
* @param mixed $value Attachment ID of the custom logo or an empty value.
* @return mixed
*/
function _sync_custom_logo_to_site_logo( $old_value, $value ) {
// Delete the option when the custom logo does not exist or was removed.
// This step ensures the option stays in sync.
if ( empty( $value['custom_logo'] ) ) {
function _sync_custom_logo_to_site_logo( $value ) {
if ( empty( $value ) ) {
delete_option( 'site_logo' );
} else {
remove_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo' );
update_option( 'site_logo', $value['custom_logo'] );
add_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo', 10, 2 );
update_option( 'site_logo', $value );
}
return $value;
}
add_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
/**
* Deletes the site_logo when the custom_logo theme mod is removed.
*
* @param array $old_value Previous theme mod settings.
* @param array $value Updated theme mod settings.
*/
function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) {
// If the custom_logo is being unset, it's being removed from theme mods.
if ( isset( $old_value['custom_logo'] ) && ! isset( $value['custom_logo'] ) ) {
delete_option( 'site_logo' );
}
}
/**
* Hooks `_sync_custom_logo_to_site_logo` in `update_option_theme_mods_$theme`.
* Deletes the site logo when all theme mods are being removed.
*/
function _delete_site_logo_on_remove_theme_mods() {
if ( false !== get_theme_support( 'custom-logo' ) ) {
delete_option( 'site_logo' );
}
}
/**
* Hooks `_delete_site_logo_on_remove_custom_logo` in `update_option_theme_mods_$theme`.
* Hooks `_delete_site_logo_on_remove_theme_mods` in `delete_option_theme_mods_$theme`.
*
* Runs on `setup_theme` to account for dynamically-switched themes in the Customizer.
*/
function _sync_custom_logo_to_site_logo_on_setup_theme() {
function _delete_site_logo_on_remove_custom_logo_on_setup_theme() {
$theme = get_option( 'stylesheet' );
add_action( "update_option_theme_mods_$theme", '_sync_custom_logo_to_site_logo', 10, 2 );
add_action( "update_option_theme_mods_$theme", '_delete_site_logo_on_remove_custom_logo', 10, 2 );
add_action( "delete_option_theme_mods_$theme", '_delete_site_logo_on_remove_theme_mods' );
}
add_action( 'setup_theme', '_sync_custom_logo_to_site_logo_on_setup_theme', 11 );
/**
* Updates the custom_logo theme-mod when the site_logo option gets updated.
*
* @param mixed $old_value The old option value.
* @param mixed $value The new option value.
*
* @return void
*/
function _sync_site_logo_to_custom_logo( $old_value, $value ) {
// Delete the option when the custom logo does not exist or was removed.
// This step ensures the option stays in sync.
if ( empty( $value ) ) {
remove_theme_mod( 'custom_logo' );
} else {
remove_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
set_theme_mod( 'custom_logo', $value );
add_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
}
}
add_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo', 10, 2 );
add_action( 'setup_theme', '_delete_site_logo_on_remove_custom_logo_on_setup_theme', 11 );

View File

@ -100,14 +100,17 @@
max-width: 100%;
}
.wp-block-site-logo .components-placeholder {
justify-content: flex-start;
min-height: auto;
height: 120px;
padding: 8px;
padding: 12px;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label {
margin-top: 12px;
white-space: nowrap;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon {
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon,
.wp-block-site-logo .components-placeholder .components-placeholder__label > svg {
margin-left: 4px;
}
.wp-block-site-logo .components-placeholder .components-form-file-upload {
@ -127,22 +130,3 @@
.wp-block-site-logo .components-placeholder .components-drop-zone__content-text {
display: none;
}
.editor-styles-wrapper .site-logo_placeholder {
display: flex;
flex-direction: row;
align-items: flex-start;
border-radius: 2px;
background-color: #fff;
box-shadow: inset 0 0 0 1px #1e1e1e;
padding: 12px;
}
.editor-styles-wrapper .site-logo_placeholder svg {
margin-left: 12px;
}
.editor-styles-wrapper .site-logo_placeholder p {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 13px;
margin: 0;
line-height: initial;
}

View File

@ -1 +1 @@
.wp-block[data-align=center]>.wp-block-site-logo{margin-right:auto;margin-left:auto;text-align:center}.wp-block-site-logo a{pointer-events:none}.wp-block-site-logo:not(.is-default-size){display:table}.wp-block-site-logo.is-default-size{width:120px}.wp-block-site-logo.is-default-size img{width:100%}.wp-block-site-logo .custom-logo-link{cursor:inherit}.wp-block-site-logo .custom-logo-link:focus{box-shadow:none}.wp-block-site-logo .custom-logo-link.is-transient img{opacity:.3}.wp-block-site-logo img{display:block;max-width:100%}.wp-block-site-logo .components-placeholder{min-height:auto;height:120px;padding:8px}.wp-block-site-logo .components-placeholder .components-placeholder__label{white-space:nowrap}.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon{margin-left:4px}.wp-block-site-logo .components-placeholder .components-form-file-upload{display:none}.wp-block-site-logo .components-placeholder .components-placeholder__preview{position:absolute;top:4px;left:4px;bottom:4px;right:4px;background:hsla(0,0%,100%,.8);display:flex;align-items:center;justify-content:center}.wp-block-site-logo .components-placeholder .components-drop-zone__content-text{display:none}.editor-styles-wrapper .site-logo_placeholder{display:flex;flex-direction:row;align-items:flex-start;border-radius:2px;background-color:#fff;box-shadow:inset 0 0 0 1px #1e1e1e;padding:12px}.editor-styles-wrapper .site-logo_placeholder svg{margin-left:12px}.editor-styles-wrapper .site-logo_placeholder p{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;margin:0;line-height:normal}
.wp-block[data-align=center]>.wp-block-site-logo{margin-right:auto;margin-left:auto;text-align:center}.wp-block-site-logo a{pointer-events:none}.wp-block-site-logo:not(.is-default-size){display:table}.wp-block-site-logo.is-default-size{width:120px}.wp-block-site-logo.is-default-size img{width:100%}.wp-block-site-logo .custom-logo-link{cursor:inherit}.wp-block-site-logo .custom-logo-link:focus{box-shadow:none}.wp-block-site-logo .custom-logo-link.is-transient img{opacity:.3}.wp-block-site-logo img{display:block;max-width:100%}.wp-block-site-logo .components-placeholder{justify-content:flex-start;min-height:auto;height:120px;padding:12px}.wp-block-site-logo .components-placeholder .components-placeholder__label{margin-top:12px;white-space:nowrap}.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon,.wp-block-site-logo .components-placeholder .components-placeholder__label>svg{margin-left:4px}.wp-block-site-logo .components-placeholder .components-form-file-upload{display:none}.wp-block-site-logo .components-placeholder .components-placeholder__preview{position:absolute;top:4px;left:4px;bottom:4px;right:4px;background:hsla(0,0%,100%,.8);display:flex;align-items:center;justify-content:center}.wp-block-site-logo .components-placeholder .components-drop-zone__content-text{display:none}

View File

@ -100,14 +100,17 @@
max-width: 100%;
}
.wp-block-site-logo .components-placeholder {
justify-content: flex-start;
min-height: auto;
height: 120px;
padding: 8px;
padding: 12px;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label {
margin-top: 12px;
white-space: nowrap;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon {
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon,
.wp-block-site-logo .components-placeholder .components-placeholder__label > svg {
margin-right: 4px;
}
.wp-block-site-logo .components-placeholder .components-form-file-upload {
@ -127,22 +130,3 @@
.wp-block-site-logo .components-placeholder .components-drop-zone__content-text {
display: none;
}
.editor-styles-wrapper .site-logo_placeholder {
display: flex;
flex-direction: row;
align-items: flex-start;
border-radius: 2px;
background-color: #fff;
box-shadow: inset 0 0 0 1px #1e1e1e;
padding: 12px;
}
.editor-styles-wrapper .site-logo_placeholder svg {
margin-right: 12px;
}
.editor-styles-wrapper .site-logo_placeholder p {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 13px;
margin: 0;
line-height: initial;
}

View File

@ -1 +1 @@
.wp-block[data-align=center]>.wp-block-site-logo{margin-left:auto;margin-right:auto;text-align:center}.wp-block-site-logo a{pointer-events:none}.wp-block-site-logo:not(.is-default-size){display:table}.wp-block-site-logo.is-default-size{width:120px}.wp-block-site-logo.is-default-size img{width:100%}.wp-block-site-logo .custom-logo-link{cursor:inherit}.wp-block-site-logo .custom-logo-link:focus{box-shadow:none}.wp-block-site-logo .custom-logo-link.is-transient img{opacity:.3}.wp-block-site-logo img{display:block;max-width:100%}.wp-block-site-logo .components-placeholder{min-height:auto;height:120px;padding:8px}.wp-block-site-logo .components-placeholder .components-placeholder__label{white-space:nowrap}.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon{margin-right:4px}.wp-block-site-logo .components-placeholder .components-form-file-upload{display:none}.wp-block-site-logo .components-placeholder .components-placeholder__preview{position:absolute;top:4px;right:4px;bottom:4px;left:4px;background:hsla(0,0%,100%,.8);display:flex;align-items:center;justify-content:center}.wp-block-site-logo .components-placeholder .components-drop-zone__content-text{display:none}.editor-styles-wrapper .site-logo_placeholder{display:flex;flex-direction:row;align-items:flex-start;border-radius:2px;background-color:#fff;box-shadow:inset 0 0 0 1px #1e1e1e;padding:12px}.editor-styles-wrapper .site-logo_placeholder svg{margin-right:12px}.editor-styles-wrapper .site-logo_placeholder p{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;margin:0;line-height:normal}
.wp-block[data-align=center]>.wp-block-site-logo{margin-left:auto;margin-right:auto;text-align:center}.wp-block-site-logo a{pointer-events:none}.wp-block-site-logo:not(.is-default-size){display:table}.wp-block-site-logo.is-default-size{width:120px}.wp-block-site-logo.is-default-size img{width:100%}.wp-block-site-logo .custom-logo-link{cursor:inherit}.wp-block-site-logo .custom-logo-link:focus{box-shadow:none}.wp-block-site-logo .custom-logo-link.is-transient img{opacity:.3}.wp-block-site-logo img{display:block;max-width:100%}.wp-block-site-logo .components-placeholder{justify-content:flex-start;min-height:auto;height:120px;padding:12px}.wp-block-site-logo .components-placeholder .components-placeholder__label{margin-top:12px;white-space:nowrap}.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon,.wp-block-site-logo .components-placeholder .components-placeholder__label>svg{margin-right:4px}.wp-block-site-logo .components-placeholder .components-form-file-upload{display:none}.wp-block-site-logo .components-placeholder .components-placeholder__preview{position:absolute;top:4px;right:4px;bottom:4px;left:4px;background:hsla(0,0%,100%,.8);display:flex;align-items:center;justify-content:center}.wp-block-site-logo .components-placeholder .components-drop-zone__content-text{display:none}

View File

@ -181,6 +181,7 @@ class WP_Theme_JSON {
const ALLOWED_SETTINGS = array(
'color' => array(
'custom' => null,
'customDuotone' => null,
'customGradient' => null,
'duotone' => null,
'gradients' => null,
@ -188,7 +189,10 @@ class WP_Theme_JSON {
'palette' => null,
),
'custom' => null,
'layout' => null,
'layout' => array(
'contentSize' => null,
'wideSize' => null,
),
'spacing' => array(
'customMargin' => null,
'customPadding' => null,

View File

@ -1780,14 +1780,17 @@ body.admin-bar .wp-block-navigation__responsive-container.is-menu-open {
max-width: 100%;
}
.wp-block-site-logo .components-placeholder {
justify-content: flex-start;
min-height: auto;
height: 120px;
padding: 8px;
padding: 12px;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label {
margin-top: 12px;
white-space: nowrap;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon {
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon,
.wp-block-site-logo .components-placeholder .components-placeholder__label > svg {
margin-left: 4px;
}
.wp-block-site-logo .components-placeholder .components-form-file-upload {
@ -1808,25 +1811,6 @@ body.admin-bar .wp-block-navigation__responsive-container.is-menu-open {
display: none;
}
.editor-styles-wrapper .site-logo_placeholder {
display: flex;
flex-direction: row;
align-items: flex-start;
border-radius: 2px;
background-color: #fff;
box-shadow: inset 0 0 0 1px #1e1e1e;
padding: 12px;
}
.editor-styles-wrapper .site-logo_placeholder svg {
margin-left: 12px;
}
.editor-styles-wrapper .site-logo_placeholder p {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 13px;
margin: 0;
line-height: initial;
}
.wp-block-site-tagline__placeholder {
padding: 1em 0;
border: 1px dashed;

File diff suppressed because one or more lines are too long

View File

@ -1785,14 +1785,17 @@ body.admin-bar .wp-block-navigation__responsive-container.is-menu-open {
max-width: 100%;
}
.wp-block-site-logo .components-placeholder {
justify-content: flex-start;
min-height: auto;
height: 120px;
padding: 8px;
padding: 12px;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label {
margin-top: 12px;
white-space: nowrap;
}
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon {
.wp-block-site-logo .components-placeholder .components-placeholder__label .block-editor-block-icon,
.wp-block-site-logo .components-placeholder .components-placeholder__label > svg {
margin-right: 4px;
}
.wp-block-site-logo .components-placeholder .components-form-file-upload {
@ -1813,25 +1816,6 @@ body.admin-bar .wp-block-navigation__responsive-container.is-menu-open {
display: none;
}
.editor-styles-wrapper .site-logo_placeholder {
display: flex;
flex-direction: row;
align-items: flex-start;
border-radius: 2px;
background-color: #fff;
box-shadow: inset 0 0 0 1px #1e1e1e;
padding: 12px;
}
.editor-styles-wrapper .site-logo_placeholder svg {
margin-right: 12px;
}
.editor-styles-wrapper .site-logo_placeholder p {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 13px;
margin: 0;
line-height: initial;
}
.wp-block-site-tagline__placeholder {
padding: 1em 0;
border: 1px dashed;

File diff suppressed because one or more lines are too long

View File

@ -15057,9 +15057,11 @@ function ColorEdit(props) {
name: blockName,
attributes
} = props;
const isLinkColorEnabled = useSetting('color.link');
const colors = useSetting('color.palette') || color_EMPTY_ARRAY;
const gradients = useSetting('color.gradients') || color_EMPTY_ARRAY; // Shouldn't be needed but right now the ColorGradientsPanel
const solids = useSetting('color.palette') || color_EMPTY_ARRAY;
const gradients = useSetting('color.gradients') || color_EMPTY_ARRAY;
const areCustomSolidsEnabled = useSetting('color.custom');
const areCustomGradientsEnabled = useSetting('color.customGradient');
const isLinkEnabled = useSetting('color.link'); // Shouldn't be needed but right now the ColorGradientsPanel
// can trigger both onChangeColor and onChangeBackground
// synchronously causing our two callbacks to override changes
// from each other.
@ -15073,8 +15075,15 @@ function ColorEdit(props) {
return null;
}
const hasBackground = hasBackgroundColorSupport(blockName);
const hasGradient = hasGradientSupport(blockName);
const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
const hasTextColor = hasTextColorSupport(blockName) && (solids.length > 0 || areCustomSolidsEnabled);
const hasBackgroundColor = hasBackgroundColorSupport(blockName) && (solids.length > 0 || areCustomSolidsEnabled);
const hasGradientColor = hasGradientSupport(blockName) && (gradients.length > 0 || areCustomGradientsEnabled);
if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
return null;
}
const {
style,
textColor,
@ -15083,9 +15092,9 @@ function ColorEdit(props) {
} = attributes;
let gradientValue;
if (hasGradient && gradient) {
if (hasGradientColor && gradient) {
gradientValue = getGradientValueBySlug(gradients, gradient);
} else if (hasGradient) {
} else if (hasGradientColor) {
var _style$color5;
gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient;
@ -15094,7 +15103,7 @@ function ColorEdit(props) {
const onChangeColor = name => value => {
var _localAttributes$curr, _localAttributes$curr2;
const colorObject = getColorObjectByColorValue(colors, value);
const colorObject = getColorObjectByColorValue(solids, value);
const attributeName = name + 'Color';
const newStyle = { ...localAttributes.current.style,
color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color),
@ -15149,7 +15158,7 @@ function ColorEdit(props) {
};
const onChangeLinkColor = value => {
const colorObject = getColorObjectByColorValue(colors, value);
const colorObject = getColorObjectByColorValue(solids, value);
const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
const newStyle = immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue);
props.setAttributes({
@ -15161,20 +15170,20 @@ function ColorEdit(props) {
enableContrastChecking: // Turn on contrast checker for web only since it's not supported on mobile yet.
external_wp_element_["Platform"].OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color6 = style.color) !== null && _style$color6 !== void 0 && _style$color6.gradient),
clientId: props.clientId,
settings: [...(hasTextColorSupport(blockName) ? [{
settings: [...(hasTextColor ? [{
label: Object(external_wp_i18n_["__"])('Text color'),
onColorChange: onChangeColor('text'),
colorValue: getColorObjectByAttributeValues(colors, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color
}] : []), ...(hasBackground || hasGradient ? [{
colorValue: getColorObjectByAttributeValues(solids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color
}] : []), ...(hasBackgroundColor || hasGradientColor ? [{
label: Object(external_wp_i18n_["__"])('Background color'),
onColorChange: hasBackground ? onChangeColor('background') : undefined,
colorValue: getColorObjectByAttributeValues(colors, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
colorValue: getColorObjectByAttributeValues(solids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
gradientValue,
onGradientChange: hasGradient ? onChangeGradient : undefined
}] : []), ...(isLinkColorEnabled && hasLinkColorSupport(blockName) ? [{
onGradientChange: hasGradientColor ? onChangeGradient : undefined
}] : []), ...(hasLinkColor ? [{
label: Object(external_wp_i18n_["__"])('Link Color'),
onColorChange: onChangeLinkColor,
colorValue: getLinkColorFromAttributeValue(colors, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
colorValue: getLinkColorFromAttributeValue(solids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
clearable: !!(style !== null && style !== void 0 && (_style$elements3 = style.elements) !== null && _style$elements3 !== void 0 && (_style$elements3$link = _style$elements3.link) !== null && _style$elements3$link !== void 0 && (_style$elements3$link2 = _style$elements3$link.color) !== null && _style$elements3$link2 !== void 0 && _style$elements3$link2.text)
}] : [])]
});
@ -17031,7 +17040,8 @@ function DuotonePickerPopover({
onToggle,
duotonePalette,
colorPalette,
disableCustomColors
disableCustomColors,
disableCustomDuotone
}) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
className: "block-editor-duotone-control__popover",
@ -17043,6 +17053,7 @@ function DuotonePickerPopover({
colorPalette: colorPalette,
duotonePalette: duotonePalette,
disableCustomColors: disableCustomColors,
disableCustomDuotone: disableCustomDuotone,
value: value,
onChange: onChange
})));
@ -17070,15 +17081,12 @@ function DuotoneControl({
colorPalette,
duotonePalette,
disableCustomColors,
disableCustomDuotone,
value,
onChange
}) {
const [isOpen, setIsOpen] = Object(external_wp_element_["useState"])(false);
if (!duotonePalette) {
return null;
}
const onToggle = () => {
setIsOpen(prev => !prev);
};
@ -17107,7 +17115,8 @@ function DuotoneControl({
onToggle: onToggle,
duotonePalette: duotonePalette,
colorPalette: colorPalette,
disableCustomColors: disableCustomColors
disableCustomColors: disableCustomColors,
disableCustomDuotone: disableCustomDuotone
}));
}
@ -17135,6 +17144,7 @@ function DuotoneControl({
*/
const duotone_EMPTY_ARRAY = [];
/**
* Convert a list of colors to an object of R, G, and B values.
*
@ -17234,14 +17244,21 @@ function DuotonePanel({
const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
const duotonePalette = useSetting('color.duotone');
const colorPalette = useSetting('color.palette');
const duotonePalette = useSetting('color.duotone') || duotone_EMPTY_ARRAY;
const colorPalette = useSetting('color.palette') || duotone_EMPTY_ARRAY;
const disableCustomColors = !useSetting('color.custom');
const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
return null;
}
return Object(external_wp_element_["createElement"])(block_controls, {
group: "block"
}, Object(external_wp_element_["createElement"])(duotone_control, {
duotonePalette: duotonePalette,
colorPalette: colorPalette,
disableCustomDuotone: disableCustomDuotone,
disableCustomColors: disableCustomColors,
value: duotone,
onChange: newDuotone => {
@ -17381,7 +17398,7 @@ function LayoutPanel({
return getSettings().supportsLayout;
}, []);
const units = Object(external_wp_components_["__experimentalUseCustomUnits"])({
availableUnits: useSetting('layout.units') || ['%', 'px', 'em', 'rem', 'vw']
availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
});
if (!themeSupportsLayout) {
@ -38672,14 +38689,6 @@ function use_multi_selection_useMultiSelection() {
*/
/**
* Useful for positioning an element within the viewport so focussing the
* element does not scroll the page.
*/
const PREVENT_SCROLL_ON_FOCUS = {
position: 'fixed'
};
function isFormElement(element) {
const {
@ -38727,14 +38736,12 @@ function useTabNav() {
const before = Object(external_wp_element_["createElement"])("div", {
ref: focusCaptureBeforeRef,
tabIndex: focusCaptureTabIndex,
onFocus: onFocusCapture,
style: PREVENT_SCROLL_ON_FOCUS
onFocus: onFocusCapture
});
const after = Object(external_wp_element_["createElement"])("div", {
ref: focusCaptureAfterRef,
tabIndex: focusCaptureTabIndex,
onFocus: onFocusCapture,
style: PREVENT_SCROLL_ON_FOCUS
onFocus: onFocusCapture
});
const ref = Object(external_wp_compose_["useRefEffect"])(node => {
function onKeyDown(event) {
@ -38774,17 +38781,59 @@ function useTabNav() {
// doesn't refocus this block and so it allows default behaviour
// (moving focus to the next tabbable element).
noCapture.current = true;
next.current.focus();
noCapture.current = true; // Focusing the focus capture element, which is located above and
// below the editor, should not scroll the page all the way up or
// down.
next.current.focus({
preventScroll: true
});
}
function onFocusOut(event) {
lastFocus.current = event.target;
} // When tabbing back to an element in block list, this event handler prevents scrolling if the
// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
// top or bottom of the document.
//
// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
function preventScrollOnTab(event) {
var _event$target;
if (event.keyCode !== external_wp_keycodes_["TAB"]) {
return;
}
if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role')) === 'region') {
return;
}
if (container.current === event.target) {
return;
}
const isShift = event.shiftKey;
const direction = isShift ? 'findPrevious' : 'findNext';
const target = external_wp_dom_["focus"].tabbable[direction](event.target); // only do something when the next tabbable is a focus capture div (before/after)
if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) {
event.preventDefault();
target.focus({
preventScroll: true
});
}
}
node.ownerDocument.defaultView.addEventListener('keydown', preventScrollOnTab);
node.addEventListener('keydown', onKeyDown);
node.addEventListener('focusout', onFocusOut);
return () => {
node.ownerDocument.defaultView.removeEventListener('keydown', preventScrollOnTab);
node.removeEventListener('keydown', onKeyDown);
node.removeEventListener('focusout', onFocusOut);
};

File diff suppressed because one or more lines are too long

View File

@ -12536,7 +12536,7 @@ function ColumnEdit({
[`is-vertically-aligned-${verticalAlignment}`]: verticalAlignment
});
const units = Object(external_wp_components_["__experimentalUseCustomUnits"])({
availableUnits: Object(external_wp_blockEditor_["useSetting"])('layout.units') || ['%', 'px', 'em', 'rem', 'vw']
availableUnits: Object(external_wp_blockEditor_["useSetting"])('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
});
const {
columnsIds,
@ -28135,7 +28135,8 @@ function LogoEdit({
siteLogoId,
canUserEdit,
url,
mediaItemData
mediaItemData,
isRequestingMediaItem
} = Object(external_wp_data_["useSelect"])(select => {
const {
canUser,
@ -28157,6 +28158,10 @@ function LogoEdit({
context: 'view'
});
const _isRequestingMediaItem = _siteLogoId && !select(external_wp_coreData_["store"]).hasFinishedResolution('getEntityRecord', ['root', 'media', _siteLogoId, {
context: 'view'
}]);
return {
siteLogoId: _siteLogoId,
canUserEdit: _canUserEdit,
@ -28164,7 +28169,8 @@ function LogoEdit({
mediaItemData: mediaItem && {
url: mediaItem.source_url,
alt: mediaItem.alt_text
}
},
isRequestingMediaItem: _isRequestingMediaItem
};
}, []);
const {
@ -28218,7 +28224,7 @@ function LogoEdit({
const label = Object(external_wp_i18n_["__"])('Site Logo');
let logoImage;
const isLoading = siteLogoId === undefined || siteLogoId && !logoUrl;
const isLoading = siteLogoId === undefined || isRequestingMediaItem;
if (isLoading) {
logoImage = Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null);
@ -28244,11 +28250,13 @@ function LogoEdit({
ref,
className: classes
});
return Object(external_wp_element_["createElement"])("div", blockProps, controls, !!logoUrl && logoImage, !logoUrl && !canUserEdit && Object(external_wp_element_["createElement"])("div", {
className: "site-logo_placeholder"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Icon"], {
icon: site_logo
}), Object(external_wp_element_["createElement"])("p", null, " ", Object(external_wp_i18n_["__"])('Site Logo'))), !logoUrl && canUserEdit && Object(external_wp_element_["createElement"])(external_wp_blockEditor_["MediaPlaceholder"], {
return Object(external_wp_element_["createElement"])("div", blockProps, controls, !!logoUrl && logoImage, !logoUrl && !canUserEdit && Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
className: "site-logo_placeholder",
icon: site_logo,
label: label
}, isLoading && Object(external_wp_element_["createElement"])("span", {
className: "components-placeholder__preview"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null))), !logoUrl && canUserEdit && Object(external_wp_element_["createElement"])(external_wp_blockEditor_["MediaPlaceholder"], {
icon: Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockIcon"], {
icon: site_logo
}),
@ -28762,10 +28770,12 @@ function QueryToolbar({
min: 1,
max: 100,
onChange: value => {
var _value;
if (isNaN(value) || value < 1 || value > 100) {
return;
}
return setQuery({
perPage: (_value = +value) !== null && _value !== void 0 ? _value : -1
setQuery({
perPage: value
});
},
step: "1",
@ -28777,9 +28787,15 @@ function QueryToolbar({
labelPosition: "edge",
min: 0,
max: 100,
onChange: value => setQuery({
offset: +value
}),
onChange: value => {
if (isNaN(value) || value < 0 || value > 100) {
return;
}
setQuery({
offset: value
});
},
step: "1",
value: query.offset,
isDragEnabled: false
@ -28792,9 +28808,15 @@ function QueryToolbar({
label: Object(external_wp_i18n_["__"])('Max page to show'),
labelPosition: "edge",
min: 0,
onChange: value => setQuery({
pages: +value
}),
onChange: value => {
if (isNaN(value) || value < 0) {
return;
}
setQuery({
pages: value
});
},
step: "1",
value: query.pages,
isDragEnabled: false
@ -28846,9 +28868,8 @@ function QueryToolbar({
* @return {QueryTermsInfo} The object with the terms information.
*/
const getTermsInfo = terms => ({
terms,
...(terms === null || terms === void 0 ? void 0 : terms.reduce((accumulator, term) => {
const getTermsInfo = terms => {
const mapping = terms === null || terms === void 0 ? void 0 : terms.reduce((accumulator, term) => {
const {
mapById,
mapByName,
@ -28862,8 +28883,12 @@ const getTermsInfo = terms => ({
mapById: {},
mapByName: {},
names: []
}))
});
return {
terms,
...mapping
};
};
/**
* Returns a helper object that contains:
* 1. An `options` object from the available post types, to be passed to a `SelectControl`.

File diff suppressed because one or more lines are too long

View File

@ -32708,6 +32708,7 @@ function DuotonePicker({
colorPalette,
duotonePalette,
disableCustomColors,
disableCustomDuotone,
value,
onChange
}) {
@ -32742,10 +32743,10 @@ function DuotonePicker({
actions: Object(external_wp_element_["createElement"])(CircularOptionPicker.ButtonAction, {
onClick: () => onChange(undefined)
}, Object(external_wp_i18n_["__"])('Clear'))
}, !disableCustomColors && Object(external_wp_element_["createElement"])(CustomDuotoneBar, {
}, !disableCustomColors && !disableCustomDuotone && Object(external_wp_element_["createElement"])(CustomDuotoneBar, {
value: value,
onChange: onChange
}), colorPalette && Object(external_wp_element_["createElement"])(color_list_picker, {
}), !disableCustomDuotone && Object(external_wp_element_["createElement"])(color_list_picker, {
labels: [Object(external_wp_i18n_["__"])('Shadows'), Object(external_wp_i18n_["__"])('Highlights')],
colors: colorPalette,
value: value,

File diff suppressed because one or more lines are too long

View File

@ -938,19 +938,44 @@ function useInserter(inserter) {
var external_wp_isShallowEqual_ = __webpack_require__("rl8x");
var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js
/**
* External dependencies
*/
// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/utils.js
// @ts-check
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
/**
* Convert settingId to widgetId.
*
* @param {string} settingId The setting id.
* @return {string} The widget id.
*/
function settingIdToWidgetId(settingId) {
const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/);
if (matches) {
const idBase = matches[1];
const number = parseInt(matches[2], 10);
return `${idBase}-${number}`;
}
return settingId;
}
/**
* Transform a block to a customizable widget.
*
* @param {WPBlock} block The block to be transformed from.
* @param {Object} existingWidget The widget to be extended from.
* @return {Object} The transformed widget.
*/
function blockToWidget(block, existingWidget = null) {
let widget;
@ -999,6 +1024,16 @@ function blockToWidget(block, existingWidget = null) {
...widget
};
}
/**
* Transform a widget to a block.
*
* @param {Object} widget The widget to be transformed from.
* @param {string} widget.id The widget id.
* @param {string} widget.idBase The id base of the widget.
* @param {number} widget.number The number/index of the widget.
* @param {Object} widget.instance The instance of the widget.
* @return {WPBlock} The transformed block.
*/
function widgetToBlock({
id,
@ -1038,6 +1073,24 @@ function widgetToBlock({
return Object(external_wp_widgets_["addWidgetIdToBlock"])(block, id);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function widgetsToBlocks(widgets) {
return widgets.map(widget => widgetToBlock(widget));
}
@ -1118,27 +1171,6 @@ function useSidebarBlockEditor(sidebar) {
return [blocks, onChangeBlocks, onChangeBlocks];
}
// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/utils.js
// @ts-check
/**
* Convert settingId to widgetId.
*
* @param {string} settingId The setting id.
* @return {string} The widget id.
*/
function settingIdToWidgetId(settingId) {
const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/);
if (matches) {
const idBase = matches[1];
const number = parseInt(matches[2], 10);
return `${idBase}-${number}`;
}
return settingId;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/focus-control/index.js
@ -2349,25 +2381,52 @@ var external_wp_hooks_ = __webpack_require__("g56x");
*/
const withMoveToSidebarToolbarItem = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => props => {
const widgetId = Object(external_wp_widgets_["getWidgetIdFromBlock"])(props);
let widgetId = Object(external_wp_widgets_["getWidgetIdFromBlock"])(props);
const sidebarControls = useSidebarControls();
const activeSidebarControl = useActiveSidebarControl();
const hasMultipleSidebars = (sidebarControls === null || sidebarControls === void 0 ? void 0 : sidebarControls.length) > 1;
const blockName = props.name;
const clientId = props.clientId;
const canInsertBlockInSidebar = Object(external_wp_data_["useSelect"])(select => {
// Use an empty string to represent the root block list, which
// in the customizer editor represents a sidebar/widget area.
return select(external_wp_blockEditor_["store"]).canInsertBlockType(blockName, '');
}, [blockName]);
const block = Object(external_wp_data_["useSelect"])(select => select(external_wp_blockEditor_["store"]).getBlock(clientId), [clientId]);
const {
removeBlock
} = Object(external_wp_data_["useDispatch"])(external_wp_blockEditor_["store"]);
const [, focusWidget] = useFocusControl();
function moveToSidebar(sidebarControlId) {
const newSidebarControl = sidebarControls.find(sidebarControl => sidebarControl.id === sidebarControlId);
if (widgetId) {
/**
* If there's a widgetId, move it to the other sidebar.
*/
const oldSetting = activeSidebarControl.setting;
const newSetting = newSidebarControl.setting;
oldSetting(Object(external_lodash_["without"])(oldSetting(), widgetId));
newSetting([...newSetting(), widgetId]);
newSidebarControl.expand();
} else {
/**
* If there isn't a widgetId, it's most likely a inner block.
* First, remove the block in the original sidebar,
* then, create a new widget in the new sidebar and get back its widgetId.
*/
const sidebarAdapter = newSidebarControl.sidebarAdapter;
removeBlock(clientId);
const addedWidgetIds = sidebarAdapter.setWidgets([...sidebarAdapter.getWidgets(), blockToWidget(block)]); // The last non-null id is the added widget's id.
widgetId = addedWidgetIds.reverse().find(id => !!id);
} // Move focus to the moved widget and expand the sidebar.
focusWidget(widgetId);
}
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockEdit, props), hasMultipleSidebars && canInsertBlockInSidebar && Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockControls"], null, Object(external_wp_element_["createElement"])(external_wp_widgets_["MoveToWidgetArea"], {

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,9 @@
"settings": {
"color": {
"custom": true,
"customDuotone": true,
"customGradient": true,
"link": false,
"duotone": [
{
"name": "Dark grayscale" ,
@ -108,7 +110,6 @@
"slug": "midnight"
}
],
"link": false,
"palette": [
{
"name": "Black",

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51419';
$wp_version = '5.9-alpha-51421';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.