Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video: Hide some controls when multi-editing blocks #57375

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 38 additions & 23 deletions packages/block-library/src/video/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -185,25 +195,29 @@ function VideoEdit( {

return (
<>
<BlockControls>
<TracksEditor
tracks={ tracks }
onChange={ ( newTracks ) => {
setAttributes( { tracks: newTracks } );
} }
/>
</BlockControls>
<BlockControls group="other">
<MediaReplaceFlow
mediaId={ id }
mediaURL={ src }
allowedTypes={ ALLOWED_MEDIA_TYPES }
accept="video/*"
onSelect={ onSelectVideo }
onSelectURL={ onSelectURL }
onError={ onUploadError }
/>
</BlockControls>
{ ! multiVideoSelection && (
<>
<BlockControls>
<TracksEditor
tracks={ tracks }
onChange={ ( newTracks ) => {
setAttributes( { tracks: newTracks } );
} }
/>
</BlockControls>
<BlockControls group="other">
<MediaReplaceFlow
mediaId={ id }
mediaURL={ src }
allowedTypes={ ALLOWED_MEDIA_TYPES }
accept="video/*"
onSelect={ onSelectVideo }
onSelectURL={ onSelectURL }
onError={ onUploadError }
/>
</BlockControls>
</>
) }
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<VideoCommonSettings
Expand Down Expand Up @@ -284,6 +298,7 @@ function VideoEdit( {
isSelected={ isSelected }
insertBlocksAfter={ insertBlocksAfter }
label={ __( 'Video caption text' ) }
showToolbarButton={ ! multiVideoSelection }
/>
</figure>
</>
Expand Down
Loading