From 0cb20369397f0db033a9891f9b89805e7928925e Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 26 Dec 2023 16:27:45 +0400 Subject: [PATCH] Video: Hide some controls when multi-editing blocks --- packages/block-library/src/video/edit.js | 61 +++++++++++++++--------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/packages/block-library/src/video/edit.js b/packages/block-library/src/video/edit.js index 88b2669e66f56..db1fbb197126a 100644 --- a/packages/block-library/src/video/edit.js +++ b/packages/block-library/src/video/edit.js @@ -75,10 +75,20 @@ function VideoEdit( { const posterImageButton = useRef(); const { id, controls, poster, src, tracks } = attributes; const isTemporaryVideo = ! id && isBlobURL( src ); - const mediaUpload = useSelect( - ( select ) => select( blockEditorStore ).getSettings().mediaUpload, - [] - ); + const { mediaUpload, multiVideoSelection } = useSelect( ( select ) => { + const { getSettings, getMultiSelectedBlockClientIds, getBlockName } = + select( blockEditorStore ); + const multiSelectedClientIds = getMultiSelectedBlockClientIds(); + + return { + mediaUpload: getSettings().mediaUpload, + multiVideoSelection: + multiSelectedClientIds.length && + multiSelectedClientIds.every( + ( _clientId ) => getBlockName( _clientId ) === 'core/video' + ), + }; + }, [] ); useEffect( () => { if ( ! id && isBlobURL( src ) ) { @@ -185,25 +195,29 @@ function VideoEdit( { return ( <> - - { - setAttributes( { tracks: newTracks } ); - } } - /> - - - - + { ! multiVideoSelection && ( + <> + + { + setAttributes( { tracks: newTracks } ); + } } + /> + + + + + + ) }