Skip to content

Commit

Permalink
Block Editor: Package updates for 5.8 beta 1.
Browse files Browse the repository at this point in the history
This includes the following fixes:


Widgets Editor:
  - Load widgets.php WordPress/gutenberg#32299
 - Fix Legacy Widget Preview WordPress/gutenberg#32300
 - Fix error when saving empty Legacy Widget block WordPress/gutenberg#32359

Widget blocks in the customizer: 
 - Fix deselection blocks when the inspector is open WordPress/gutenberg#32361
 - Display wide widgets as popovers WordPress/gutenberg#31736

Global Styles:
 - Align classNames generation between client and server WordPress/gutenberg#32352
 - Group typography block supports WordPress/gutenberg#32252 WordPress/gutenberg#32444 WordPress/gutenberg#32459
 - Make theme.json syntax errors more visible to the users WordPress/gutenberg#32404


Template Editor:
  - Update the appearance of the template details WordPress/gutenberg#32042
  - Fix layout definition WordPress/gutenberg#32425
  - Fix grouping post content block WordPress/gutenberg#32453

Miscellaneous:
 - Prevent saving when the post is locked WordPress/gutenberg#32341
 - Fix allowed block patterns selector WordPress/gutenberg#32376
 - Fix wrong results in the Post Author picker WordPress/gutenberg#32344
 - Fix notices position in top toolbar mode WordPress/gutenberg#32238
 - Allow non-latin characters in post slugs WordPress/gutenberg#32232
 - Fix Random collapse of the color settings panel WordPress/gutenberg#32388
 - Fix theme logo theme mode not being removed on theme removal WordPress/gutenberg#32370
 - Fix block alignment styles in the editor WordPress/gutenberg#32454
 - Fix some block toolbar overlaps WordPress/gutenberg#32424
 - Fix content loss when switching list types WordPress/gutenberg#32432


Performance:
 - Improve the performance of buttons block WordPress/gutenberg#32356
 - Improve the performance of the container blocks WordPress/gutenberg#32380

Props noisysocks, nosolosw, jorgefilipecosta.
See #52991.

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


git-svn-id: https://core.svn.wordpress.org/trunk@50698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
youknowriad committed Jun 8, 2021
1 parent 10b9132 commit b914570
Show file tree
Hide file tree
Showing 64 changed files with 1,093 additions and 854 deletions.
2 changes: 1 addition & 1 deletion wp-includes/assets/script-loader-packages.php

Large diffs are not rendered by default.

92 changes: 46 additions & 46 deletions wp-includes/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,26 @@ function wp_register_typography_support( $block_type ) {
return;
}

$has_font_size_support = _wp_array_get( $block_type->supports, array( 'fontSize' ), false );
$has_font_style_support = _wp_array_get( $block_type->supports, array( '__experimentalFontStyle' ), false );
$has_font_weight_support = _wp_array_get( $block_type->supports, array( '__experimentalFontWeight' ), false );
$has_line_height_support = _wp_array_get( $block_type->supports, array( 'lineHeight' ), false );
$has_text_decoration_support = _wp_array_get( $block_type->supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $block_type->supports, array( '__experimentalTextTransform' ), false );

$has_typography_support = $has_font_size_support
|| $has_font_weight_support
$typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
if ( ! $typography_supports ) {
return;
}

$has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
$has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
$has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
$has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
$has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
$has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );

$has_typography_support = $has_font_family_support
|| $has_font_size_support
|| $has_font_style_support
|| $has_font_weight_support
|| $has_line_height_support
|| $has_text_transform_support
|| $has_text_decoration_support;
|| $has_text_decoration_support
|| $has_text_transform_support;

if ( ! $block_type->attributes ) {
$block_type->attributes = array();
Expand Down Expand Up @@ -68,40 +75,41 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
return array();
}

$typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
if ( ! $typography_supports ) {
return array();
}

$skip_typography_serialization = _wp_array_get( $typography_supports, array( '__experimentalSkipSerialization' ), false );
if ( $skip_typography_serialization ) {
return array();
}

$attributes = array();
$classes = array();
$styles = array();

$has_font_family_support = _wp_array_get( $block_type->supports, array( '__experimentalFontFamily' ), false );
$has_font_style_support = _wp_array_get( $block_type->supports, array( '__experimentalFontStyle' ), false );
$has_font_weight_support = _wp_array_get( $block_type->supports, array( '__experimentalFontWeight' ), false );
$has_font_size_support = _wp_array_get( $block_type->supports, array( 'fontSize' ), false );
$has_line_height_support = _wp_array_get( $block_type->supports, array( 'lineHeight' ), false );
$has_text_decoration_support = _wp_array_get( $block_type->supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $block_type->supports, array( '__experimentalTextTransform' ), false );

$skip_font_size_support_serialization = _wp_array_get( $block_type->supports, array( '__experimentalSkipFontSizeSerialization' ), false );

// Covers all typography features _except_ font size.
$skip_typography_serialization = _wp_array_get( $block_type->supports, array( '__experimentalSkipTypographySerialization' ), false );
$has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
$has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
$has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
$has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
$has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
$has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );

// Font Size.
if ( $has_font_size_support && ! $skip_font_size_support_serialization ) {
if ( $has_font_size_support ) {
$has_named_font_size = array_key_exists( 'fontSize', $block_attributes );
$has_custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] );

// Apply required class or style.
if ( $has_named_font_size ) {
$classes[] = sprintf( 'has-%s-font-size', $block_attributes['fontSize'] );
} elseif ( $has_custom_font_size ) {
$styles[] = sprintf( 'font-size: %s;', $block_attributes['style']['typography']['fontSize'] );
}
}

// Font Family.
if ( $has_font_family_support && ! $skip_typography_serialization ) {
if ( $has_font_family_support ) {
$has_font_family = isset( $block_attributes['style']['typography']['fontFamily'] );
// Apply required class and style.
if ( $has_font_family ) {
$font_family = $block_attributes['style']['typography']['fontFamily'];
if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) {
Expand All @@ -115,44 +123,36 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
}
}

// Font style.
if ( $has_font_style_support && ! $skip_typography_serialization ) {
// Apply font style.
$font_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'fontStyle', 'font-style' );
if ( $has_font_style_support ) {
$font_style = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'fontStyle', 'font-style' );
if ( $font_style ) {
$styles[] = $font_style;
}
}

// Font weight.
if ( $has_font_weight_support && ! $skip_typography_serialization ) {
// Apply font weight.
$font_weight = wp_typography_get_css_variable_inline_style( $block_attributes, 'fontWeight', 'font-weight' );
if ( $has_font_weight_support ) {
$font_weight = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'fontWeight', 'font-weight' );
if ( $font_weight ) {
$styles[] = $font_weight;
}
}

// Line Height.
if ( $has_line_height_support && ! $skip_typography_serialization ) {
if ( $has_line_height_support ) {
$has_line_height = isset( $block_attributes['style']['typography']['lineHeight'] );
// Add the style (no classes for line-height).
if ( $has_line_height ) {
$styles[] = sprintf( 'line-height: %s;', $block_attributes['style']['typography']['lineHeight'] );
}
}

// Text Decoration.
if ( $has_text_decoration_support && ! $skip_typography_serialization ) {
$text_decoration_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'textDecoration', 'text-decoration' );
if ( $has_text_decoration_support ) {
$text_decoration_style = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'textDecoration', 'text-decoration' );
if ( $text_decoration_style ) {
$styles[] = $text_decoration_style;
}
}

// Text Transform.
if ( $has_text_transform_support && ! $skip_typography_serialization ) {
$text_transform_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'textTransform', 'text-transform' );
if ( $has_text_transform_support ) {
$text_transform_style = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'textTransform', 'text-transform' );
if ( $text_transform_style ) {
$styles[] = $text_transform_style;
}
Expand Down
26 changes: 26 additions & 0 deletions wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,32 @@ function block_has_support( $block_type, $feature, $default = false ) {
return true === $block_support || is_array( $block_support );
}

function wp_migrate_old_typography_shape( $metadata ) {
$typography_keys = array(
'__experimentalFontFamily',
'__experimentalFontStyle',
'__experimentalFontWeight',
'__experimentalLetterSpacing',
'__experimentalTextDecoration',
'__experimentalTextTransform',
'fontSize',
'lineHeight',
);
foreach ( $typography_keys as $typography_key ) {
$support_for_key = _wp_array_get( $metadata['supports'], array( $typography_key ), null );
if ( null !== $support_for_key ) {
trigger_error(
/* translators: %1$s: Block type, %2$s: typography supports key e.g: fontSize, lineHeight etc... */
sprintf( __( 'Block %1$s is declaring %2$s support on block.json under supports.%2$s. %2$s support is now declared under supports.typography.%2$s.', 'gutenberg' ), $metadata['name'], $typography_key ),
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
);
gutenberg_experimental_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key );
unset( $metadata['supports'][ $typography_key ] );
}
}
return $metadata;
}

/**
* Helper function that constructs a WP_Query args array from
* a `Query` block properties.
Expand Down
6 changes: 4 additions & 2 deletions wp-includes/blocks/button/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@
"__experimentalSkipSerialization": true,
"gradients": true
},
"fontSize": true,
"typography": {
"fontSize": true,
"__experimentalFontFamily": true
},
"reusable": false,
"__experimentalBorder": {
"radius": true,
"__experimentalSkipSerialization": true
},
"__experimentalFontFamily": true,
"__experimentalSelector": ".wp-block-button__link"
},
"styles": [
Expand Down
4 changes: 3 additions & 1 deletion wp-includes/blocks/code/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
},
"supports": {
"anchor": true,
"fontSize": true
"typography": {
"fontSize": true
}
},
"style": "wp-block-code"
}
7 changes: 5 additions & 2 deletions wp-includes/blocks/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
"color": {
"link": true
},
"fontSize": true,
"lineHeight": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontWeight": true
},
"__experimentalSelector": "h1,h2,h3,h4,h5,h6",
"__unstablePasteTextInline": true
},
Expand Down
5 changes: 5 additions & 0 deletions wp-includes/blocks/legacy-widget/editor-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,9 @@
.interface-complementary-area .wp-block-legacy-widget-inspector-card__name {
margin: 0 0 5px;
font-weight: 500;
}

.is-selected .wp-block-legacy-widget__container {
padding: 8px 12px;
min-height: 50px;
}
2 changes: 1 addition & 1 deletion wp-includes/blocks/legacy-widget/editor-rtl.min.css

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

5 changes: 5 additions & 0 deletions wp-includes/blocks/legacy-widget/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,9 @@
.interface-complementary-area .wp-block-legacy-widget-inspector-card__name {
margin: 0 0 5px;
font-weight: 500;
}

.is-selected .wp-block-legacy-widget__container {
padding: 8px 12px;
min-height: 50px;
}
2 changes: 1 addition & 1 deletion wp-includes/blocks/legacy-widget/editor.min.css

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

5 changes: 4 additions & 1 deletion wp-includes/blocks/list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"supports": {
"anchor": true,
"className": false,
"fontSize": true,
"typography": {
"fontSize": true,
"__experimentalFontFamily": true
},
"color": {
"gradients": true
},
Expand Down
4 changes: 3 additions & 1 deletion wp-includes/blocks/loginout/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
},
"supports": {
"className": true,
"fontSize": false
"typography": {
"fontSize": false
}
}
}
6 changes: 4 additions & 2 deletions wp-includes/blocks/paragraph/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
"color": {
"link": true
},
"fontSize": true,
"lineHeight": true,
"typography": {
"fontSize": true,
"lineHeight": true
},
"__experimentalSelector": "p",
"__unstablePasteTextInline": true
},
Expand Down
6 changes: 4 additions & 2 deletions wp-includes/blocks/post-date/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true
"typography": {
"fontSize": true,
"lineHeight": true
}
}
}
6 changes: 4 additions & 2 deletions wp-includes/blocks/post-excerpt/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"fontSize": true,
"color": {
"gradients": true,
"link": true
},
"lineHeight": true
"typography": {
"fontSize": true,
"lineHeight": true
}
},
"editorStyle": "wp-block-post-excerpt-editor",
"style": "wp-block-post-excerpt"
Expand Down
6 changes: 4 additions & 2 deletions wp-includes/blocks/post-terms/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"fontSize": true,
"color": {
"gradients": true,
"link": true
},
"lineHeight": true
"typography": {
"lineHeight": true,
"fontSize": true
}
}
}
8 changes: 5 additions & 3 deletions wp-includes/blocks/post-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true
}
},
"style": "wp-block-post-title"
}
4 changes: 3 additions & 1 deletion wp-includes/blocks/preformatted/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"color": {
"gradients": true
},
"fontSize": true
"typography": {
"fontSize": true
}
},
"style": "wp-block-preformatted"
}
6 changes: 4 additions & 2 deletions wp-includes/blocks/query-pagination-next/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true
"typography": {
"fontSize": true,
"lineHeight": true
}
}
}
6 changes: 4 additions & 2 deletions wp-includes/blocks/query-pagination-previous/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true
"typography": {
"fontSize": true,
"lineHeight": true
}
}
}
Loading

0 comments on commit b914570

Please sign in to comment.