diff --git a/includes/FigmaBlock/Block.php b/includes/FigmaBlock/Block.php index 8b92d1e..f7222d5 100644 --- a/includes/FigmaBlock/Block.php +++ b/includes/FigmaBlock/Block.php @@ -24,6 +24,8 @@ public function setup() { add_action( 'enqueue_block_editor_assets', [ $this, 'block_editor_assets' ] ); add_filter( 'rest_request_after_callbacks', [ $this, 'filter_rest_request_after_callbacks' ], 10, 3 ); + + add_filter( 'embed_defaults', [ $this, 'embed_defaults_for_figma_block' ], 10, 2 ); } /** @@ -105,4 +107,35 @@ public function filter_rest_request_after_callbacks( $response, array $handler, return $response; } + + /** + * Modify the embed default size for the case of Figma Embed blocks to allow supporting wide view using the native + * aspect ratio classes provided by the editor. + * + * @param int[] $size { + * Indexed array of the embed width and height in pixels. + * + * @type int $0 The embed width. + * @type int $1 The embed height. + * } + * @param string $url The URL that should be embedded. + * + * @return int[] + */ + public function embed_defaults_for_figma_block( $size, $url ) { + if ( empty( $url ) ) { + return $size; + } + + $domain = parse_url( $url, PHP_URL_HOST ); + + if ( 'www.figma.com' !== $domain ) { + return $size; + } + + return [ + 'width' => 600, + 'height' => 452 + ]; + } } diff --git a/src/assets/js/icon.js b/src/assets/js/icon.js index c38990c..c3f7642 100644 --- a/src/assets/js/icon.js +++ b/src/assets/js/icon.js @@ -83,7 +83,7 @@ export const IconColor = () => ( width="95.0226" height="142.534" fill="black" - fill-opacity="0" + fillOpacity="0" transform="translate(1.46603 2.19946) scale(3)" />