From 57c5b9a9ccaac4ae88dff8d4044702146ba563df Mon Sep 17 00:00:00 2001 From: Amit Raj <77401999+amitraj2203@users.noreply.github.com> Date: Mon, 6 May 2024 09:24:51 +0530 Subject: [PATCH 1/2] Embeds: Add Bluesky variation (#61352) * Feat: Adds the bluesky variation * Changed the SVG Icon for Bluesky * Removed the responsive property from Bluesky variation * Fixed pattern regular expression Co-authored-by: amitraj2203 Co-authored-by: swissspidy Co-authored-by: t-hamano --- packages/block-library/src/embed/icons.js | 9 +++++++++ packages/block-library/src/embed/variations.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/block-library/src/embed/icons.js b/packages/block-library/src/embed/icons.js index 21a3b20ae278ad..2e9386373f083a 100644 --- a/packages/block-library/src/embed/icons.js +++ b/packages/block-library/src/embed/icons.js @@ -178,3 +178,12 @@ export const embedPocketCastsIcon = { ), }; + +export const embedBlueskyIcon = ( + + + +); diff --git a/packages/block-library/src/embed/variations.js b/packages/block-library/src/embed/variations.js index 6083ea1adc90b3..e770c12ddfd97d 100644 --- a/packages/block-library/src/embed/variations.js +++ b/packages/block-library/src/embed/variations.js @@ -27,6 +27,7 @@ import { embedPinterestIcon, embedWolframIcon, embedPocketCastsIcon, + embedBlueskyIcon, } from './icons'; /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */ @@ -360,6 +361,14 @@ const variations = [ patterns: [ /^https?:\/\/(www\.)?wolframcloud\.com\/obj\/.+/i ], attributes: { providerNameSlug: 'wolfram-cloud', responsive: true }, }, + { + name: 'bluesky', + title: 'Bluesky', + icon: embedBlueskyIcon, + description: __( 'Embed a Bluesky post.' ), + patterns: [ /^https?:\/\/bsky\.app\/profile\/.+\/post\/.+/i ], + attributes: { providerNameSlug: 'bluesky' }, + }, ]; /** From ccf9d3382203881b7fb5df70cf50499d5fe54e84 Mon Sep 17 00:00:00 2001 From: Ramon Date: Mon, 6 May 2024 17:24:40 +1000 Subject: [PATCH 2/2] Background images: remove required "file" prop (#61387) * Remove file prop from background block supports, and always default to file Co-authored-by: ramonjd Co-authored-by: andrewserong --- lib/block-supports/background.php | 4 ++-- .../global-styles/test/get-global-styles-changes.js | 2 -- packages/block-editor/src/hooks/background.js | 2 +- packages/style-engine/src/styles/background/index.ts | 6 +----- packages/style-engine/src/test/index.js | 1 - phpunit/class-wp-theme-json-test.php | 3 +-- schemas/json/theme.json | 6 ------ 7 files changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/block-supports/background.php b/lib/block-supports/background.php index 70957897229595..8e3c06159a1201 100644 --- a/lib/block-supports/background.php +++ b/lib/block-supports/background.php @@ -53,10 +53,10 @@ function gutenberg_render_background_support( $block_content, $block ) { } $background_styles = array(); - $background_styles['backgroundSize'] = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover'; $background_styles['backgroundImage'] = isset( $block_attributes['style']['background']['backgroundImage'] ) ? $block_attributes['style']['background']['backgroundImage'] : array(); - if ( isset( $background_styles['backgroundImage']['source'] ) && 'file' === $background_styles['backgroundImage']['source'] && isset( $background_styles['backgroundImage']['url'] ) ) { + if ( ! empty( $background_styles['backgroundImage'] ) ) { + $background_styles['backgroundSize'] = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover'; $background_styles['backgroundPosition'] = isset( $block_attributes['style']['background']['backgroundPosition'] ) ? $block_attributes['style']['background']['backgroundPosition'] : null; $background_styles['backgroundRepeat'] = isset( $block_attributes['style']['background']['backgroundRepeat'] ) ? $block_attributes['style']['background']['backgroundRepeat'] : null; diff --git a/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js b/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js index 6eb4974ec041aa..9c220da7ead12e 100644 --- a/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js +++ b/packages/block-editor/src/components/global-styles/test/get-global-styles-changes.js @@ -20,7 +20,6 @@ describe( 'getGlobalStylesChanges and utils', () => { background: { backgroundImage: { url: 'https://example.com/image.jpg', - source: 'file', }, backgroundSize: 'contain', backgroundPosition: '30% 30%', @@ -96,7 +95,6 @@ describe( 'getGlobalStylesChanges and utils', () => { background: { backgroundImage: { url: 'https://example.com/image_new.jpg', - source: 'file', }, backgroundSize: 'contain', backgroundPosition: '40% 77%', diff --git a/packages/block-editor/src/hooks/background.js b/packages/block-editor/src/hooks/background.js index 3d47f42645afca..3e23efcbf5fc96 100644 --- a/packages/block-editor/src/hooks/background.js +++ b/packages/block-editor/src/hooks/background.js @@ -59,7 +59,7 @@ export function setBackgroundStyleDefaults( backgroundStyle ) { let backgroundStylesWithDefaults; // Set block background defaults. - if ( backgroundImage?.source === 'file' && !! backgroundImage?.url ) { + if ( !! backgroundImage?.url ) { if ( ! backgroundStyle?.backgroundSize ) { backgroundStylesWithDefaults = { backgroundSize: 'cover', diff --git a/packages/style-engine/src/styles/background/index.ts b/packages/style-engine/src/styles/background/index.ts index 748cb15b4f3099..a8c8679888e153 100644 --- a/packages/style-engine/src/styles/background/index.ts +++ b/packages/style-engine/src/styles/background/index.ts @@ -8,11 +8,7 @@ const backgroundImage = { name: 'backgroundImage', generate: ( style: Style, options: StyleOptions ) => { const _backgroundImage = style?.background?.backgroundImage; - if ( - typeof _backgroundImage === 'object' && - _backgroundImage?.source === 'file' && - _backgroundImage?.url - ) { + if ( typeof _backgroundImage === 'object' && _backgroundImage?.url ) { return [ { selector: options.selector, diff --git a/packages/style-engine/src/test/index.js b/packages/style-engine/src/test/index.js index 5869c4a349baab..fbccc8c48bc92b 100644 --- a/packages/style-engine/src/test/index.js +++ b/packages/style-engine/src/test/index.js @@ -226,7 +226,6 @@ describe( 'getCSSRules', () => { { background: { backgroundImage: { - source: 'file', url: 'https://example.com/image.jpg', }, backgroundPosition: '50% 50%', diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 8df33334e82d03..00799b7ba0b478 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -4812,8 +4812,7 @@ public function test_get_top_level_background_image_styles() { 'core/paragraph' => array( 'background' => array( 'backgroundImage' => array( - 'url' => 'http://example.org/image.png', - 'source' => 'file', + 'url' => 'http://example.org/image.png', ), 'backgroundSize' => 'cover', 'backgroundRepeat' => 'no-repeat', diff --git a/schemas/json/theme.json b/schemas/json/theme.json index 755fb09e57e3c7..773419d472f330 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -2331,12 +2331,6 @@ { "type": "object", "properties": { - "source": { - "description": "The origin of the image. 'file' denotes that the 'url' is a path to an image or other file.", - "type": "string", - "enum": [ "file" ], - "default": "file" - }, "url": { "description": "A URL to an image file.", "type": "string"