From e98c06d20b6fcdf9be4ff7d61931639f02917bbf Mon Sep 17 00:00:00 2001 From: benazeer-ben Date: Thu, 14 Nov 2024 12:25:53 +0530 Subject: [PATCH 1/5] Doc Build --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/rss/block.json | 17 +++++++++++- packages/block-library/src/rss/edit.js | 6 +++++ packages/block-library/src/rss/index.php | 4 +++ packages/block-library/src/rss/style.scss | 33 +++++++++++++++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index a27de8211c824a..090a166fc287a0 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -801,7 +801,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres - **Name:** core/rss - **Category:** widgets -- **Supports:** align, interactivity (clientNavigation), ~~html~~ +- **Supports:** align, interactivity (c,lientNavigation), typography (fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform), ~~html~~ - **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow ## Search diff --git a/packages/block-library/src/rss/block.json b/packages/block-library/src/rss/block.json index 36d70e7b7ccb98..b125d10f6db851 100644 --- a/packages/block-library/src/rss/block.json +++ b/packages/block-library/src/rss/block.json @@ -45,7 +45,22 @@ "align": true, "html": false, "interactivity": { - "clientNavigation": true + "c,lientNavigation": true + }, + "typography": { + "fontSize": true, + "lineHeight": true, + "fontFamily": true, + "fontWeight": true, + "fontStyle": true, + "textTransform": true, + "letterSpacing": true, + "textDecoration": true, + "__experimentalSkipSerialization": [ "textDecoration" ], + "__experimentalDefaultControls": { + "fontSize": true, + "textDecoration": true + } } }, "editorStyle": "wp-block-rss-editor", diff --git a/packages/block-library/src/rss/edit.js b/packages/block-library/src/rss/edit.js index b67cb4f9193df1..316762221c2aad 100644 --- a/packages/block-library/src/rss/edit.js +++ b/packages/block-library/src/rss/edit.js @@ -57,6 +57,7 @@ export default function RSSEdit( { attributes, setAttributes } ) { } const blockProps = useBlockProps(); + const textDecoration = attributes.style?.typography?.textDecoration; const label = __( 'RSS URL' ); @@ -190,6 +191,11 @@ export default function RSSEdit( { attributes, setAttributes } ) { diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index 85e4e63c9dbf7a..02094c803cec8b 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -104,6 +104,10 @@ function render_block_core_rss( $attributes ) { if ( $attributes['displayExcerpt'] ) { $classnames[] = 'has-excerpts'; } + // Manually add block support text decoration as CSS class. + $text_decoration = $attributes['style']['typography']['textDecoration'] ?? null; + $text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration ); + $classnames[] = $text_decoration ? $text_decoration_class : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) ); diff --git a/packages/block-library/src/rss/style.scss b/packages/block-library/src/rss/style.scss index f7360ec76f85ac..b858c58521ff84 100644 --- a/packages/block-library/src/rss/style.scss +++ b/packages/block-library/src/rss/style.scss @@ -26,7 +26,40 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl width: 100%; } } + // The following rules provide class based application of user selected text + // decoration via block supports. + &.has-text-decoration-underline li.wp-block-rss__item a { + text-decoration: underline; + &:focus, + &:active { + text-decoration: underline; + } + } + + &.has-text-decoration-line-through li.wp-block-rss__item a { + text-decoration: line-through; + + &:focus, + &:active { + text-decoration: line-through; + } + } + + &.has-text-decoration-none li.wp-block-rss__item a { + text-decoration: none; + + &:focus, + &:active { + text-decoration: none; + } + } + + & :where(a), + & :where(a:focus), + & :where(a:active) { + text-decoration: none; + } @include break-small { @for $i from 2 through 6 { &.columns-#{ $i } li { From 462ff484afad2722fdfbe3bced319118a7af0f3e Mon Sep 17 00:00:00 2001 From: benazeer-ben Date: Tue, 19 Nov 2024 13:50:35 +0530 Subject: [PATCH 2/5] Adding selectors --- packages/block-library/src/rss/block.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/block-library/src/rss/block.json b/packages/block-library/src/rss/block.json index b125d10f6db851..725e7ea513f804 100644 --- a/packages/block-library/src/rss/block.json +++ b/packages/block-library/src/rss/block.json @@ -63,6 +63,9 @@ } } }, + "selectors": { + "typography": ".wp-block-rss li a" + }, "editorStyle": "wp-block-rss-editor", "style": "wp-block-rss" } From d4c3bc7e4e220520ae378b6af2141222cc8e9580 Mon Sep 17 00:00:00 2001 From: benazeer-ben Date: Wed, 20 Nov 2024 17:40:50 +0530 Subject: [PATCH 3/5] Skip serialisation of textDecoration --- packages/block-library/src/rss/block.json | 2 +- packages/block-library/src/rss/edit.js | 6 ----- packages/block-library/src/rss/index.php | 14 +++++++---- packages/block-library/src/rss/style.scss | 30 +---------------------- 4 files changed, 11 insertions(+), 41 deletions(-) diff --git a/packages/block-library/src/rss/block.json b/packages/block-library/src/rss/block.json index 725e7ea513f804..351147c812a2a0 100644 --- a/packages/block-library/src/rss/block.json +++ b/packages/block-library/src/rss/block.json @@ -64,7 +64,7 @@ } }, "selectors": { - "typography": ".wp-block-rss li a" + "typography": ".wp-block-rss__item" }, "editorStyle": "wp-block-rss-editor", "style": "wp-block-rss" diff --git a/packages/block-library/src/rss/edit.js b/packages/block-library/src/rss/edit.js index 316762221c2aad..b67cb4f9193df1 100644 --- a/packages/block-library/src/rss/edit.js +++ b/packages/block-library/src/rss/edit.js @@ -57,7 +57,6 @@ export default function RSSEdit( { attributes, setAttributes } ) { } const blockProps = useBlockProps(); - const textDecoration = attributes.style?.typography?.textDecoration; const label = __( 'RSS URL' ); @@ -191,11 +190,6 @@ export default function RSSEdit( { attributes, setAttributes } ) { diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index 02094c803cec8b..0c5671f1b09620 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -73,6 +73,14 @@ function render_block_core_rss( $attributes ) { $excerpt = ''; $description = $item->get_description(); + + // Manually add block support text decoration as CSS class. + $text_decoration = $attributes['style']['typography']['textDecoration'] ?? null; + $inline_style = ''; + if ( $text_decoration ) { + $inline_style = sprintf( 'text-decoration: %s;', $text_decoration ); + } + if ( $attributes['displayExcerpt'] && ! empty( $description ) ) { $excerpt = html_entity_decode( $description, ENT_QUOTES, get_option( 'blog_charset' ) ); $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' […]' ) ); @@ -85,7 +93,7 @@ function render_block_core_rss( $attributes ) { $excerpt = '
' . esc_html( $excerpt ) . '
'; } - $list_items .= "
  • {$title}{$date}{$author}{$excerpt}
  • "; + $list_items .= "
  • {$title}{$date}{$author}{$excerpt}
  • "; } $classnames = array(); @@ -104,10 +112,6 @@ function render_block_core_rss( $attributes ) { if ( $attributes['displayExcerpt'] ) { $classnames[] = 'has-excerpts'; } - // Manually add block support text decoration as CSS class. - $text_decoration = $attributes['style']['typography']['textDecoration'] ?? null; - $text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration ); - $classnames[] = $text_decoration ? $text_decoration_class : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) ); diff --git a/packages/block-library/src/rss/style.scss b/packages/block-library/src/rss/style.scss index b858c58521ff84..857b85789ded42 100644 --- a/packages/block-library/src/rss/style.scss +++ b/packages/block-library/src/rss/style.scss @@ -26,35 +26,7 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl width: 100%; } } - // The following rules provide class based application of user selected text - // decoration via block supports. - &.has-text-decoration-underline li.wp-block-rss__item a { - text-decoration: underline; - - &:focus, - &:active { - text-decoration: underline; - } - } - - &.has-text-decoration-line-through li.wp-block-rss__item a { - text-decoration: line-through; - - &:focus, - &:active { - text-decoration: line-through; - } - } - - &.has-text-decoration-none li.wp-block-rss__item a { - text-decoration: none; - - &:focus, - &:active { - text-decoration: none; - } - } - + // This is to prevent default a tag styling from being applied to the rss block. & :where(a), & :where(a:focus), & :where(a:active) { From d404f184ca8b903476b265a14b094bf9e65296fe Mon Sep 17 00:00:00 2001 From: benazeer-ben Date: Wed, 20 Nov 2024 17:46:07 +0530 Subject: [PATCH 4/5] Doc Build --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/rss/block.json | 2 +- packages/block-library/src/rss/style.scss | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 090a166fc287a0..f23f0bd291067d 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -801,7 +801,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres - **Name:** core/rss - **Category:** widgets -- **Supports:** align, interactivity (c,lientNavigation), typography (fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform), ~~html~~ +- **Supports:** align, interactivity (clientNavigation), typography (fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform), ~~html~~ - **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow ## Search diff --git a/packages/block-library/src/rss/block.json b/packages/block-library/src/rss/block.json index 351147c812a2a0..dbd3571a4cae87 100644 --- a/packages/block-library/src/rss/block.json +++ b/packages/block-library/src/rss/block.json @@ -45,7 +45,7 @@ "align": true, "html": false, "interactivity": { - "c,lientNavigation": true + "clientNavigation": true }, "typography": { "fontSize": true, diff --git a/packages/block-library/src/rss/style.scss b/packages/block-library/src/rss/style.scss index 857b85789ded42..21c94af6a4bdf0 100644 --- a/packages/block-library/src/rss/style.scss +++ b/packages/block-library/src/rss/style.scss @@ -26,6 +26,7 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl width: 100%; } } + // This is to prevent default a tag styling from being applied to the rss block. & :where(a), & :where(a:focus), @@ -46,3 +47,4 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl display: block; font-size: 0.8125em; } + From 28f2e9d89b51affceec2188d5ea2658db49e458d Mon Sep 17 00:00:00 2001 From: benazeer-ben Date: Wed, 20 Nov 2024 19:30:09 +0530 Subject: [PATCH 5/5] php code changes --- packages/block-library/src/rss/index.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index 0c5671f1b09620..e8e64336d57ebe 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -76,10 +76,7 @@ function render_block_core_rss( $attributes ) { // Manually add block support text decoration as CSS class. $text_decoration = $attributes['style']['typography']['textDecoration'] ?? null; - $inline_style = ''; - if ( $text_decoration ) { - $inline_style = sprintf( 'text-decoration: %s;', $text_decoration ); - } + $inline_style = $text_decoration ? sprintf( 'text-decoration: %s;', $text_decoration ) : ''; if ( $attributes['displayExcerpt'] && ! empty( $description ) ) { $excerpt = html_entity_decode( $description, ENT_QUOTES, get_option( 'blog_charset' ) );