From 02f3b46d2313b4ee2df791d39f728019543b6033 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Tue, 3 May 2022 14:51:17 +1000 Subject: [PATCH] Alternate approach to handling border support in editor The use of ResizableBox within the Cover block wrapper causes problems when the wrapper may have a border applied to it. Additionally, clipping the content via overflow: hidden also cuts off the drag handle. The approach in this commit attempts to avoid these. --- packages/block-library/src/cover/block.json | 15 ++- packages/block-library/src/cover/edit.js | 97 +++++++++++--------- packages/block-library/src/cover/editor.scss | 59 ++++++++++++ packages/block-library/src/cover/save.js | 6 +- packages/block-library/src/cover/style.scss | 2 + 5 files changed, 134 insertions(+), 45 deletions(-) diff --git a/packages/block-library/src/cover/block.json b/packages/block-library/src/cover/block.json index f908f544fb2974..75c2fd30fecd22 100644 --- a/packages/block-library/src/cover/block.json +++ b/packages/block-library/src/cover/block.json @@ -87,8 +87,21 @@ "padding": true } }, + "__experimentalBorder": { + "color": true, + "radius": true, + "style": true, + "width": true, + "__experimentalSkipSerialization": true, + "__experimentalDefaultControls": { + "color": true, + "radius": true, + "style": true, + "width": true + } + }, "color": { - "__experimentalDuotone": "> .wp-block-cover__image-background, > .wp-block-cover__video-background", + "__experimentalDuotone": "> .wp-block-cover__image-background, > .wp-block-cover__video-background, > .block-library-cover__border-wrapper > .wp-block-cover__video-background, > .block-library-cover__border-wrapper > .wp-block-cover__image-background", "text": false, "background": false } diff --git a/packages/block-library/src/cover/edit.js b/packages/block-library/src/cover/edit.js index 7481bf46407699..53b05e09d11780 100644 --- a/packages/block-library/src/cover/edit.js +++ b/packages/block-library/src/cover/edit.js @@ -51,6 +51,7 @@ import { __experimentalPanelColorGradientSettings as PanelColorGradientSettings, __experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl, __experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl, + __experimentalUseBorderProps as useBorderProps, store as blockEditorStore, } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; @@ -315,6 +316,8 @@ function CoverEdit( { templateLock, } = attributes; + const borderProps = useBorderProps( attributes ); + const [ featuredImage ] = useEntityProp( 'postType', postType, @@ -756,53 +759,61 @@ function CoverEdit( { showHandle={ isSelected } /> -