From 3d9c14018ab88efb24a7b7f394fa5246c0c03558 Mon Sep 17 00:00:00 2001 From: Wagner Trezub Date: Fri, 23 Aug 2024 16:39:48 +0200 Subject: [PATCH] fix: added caption for videos --- .../Blocks/VideoGallery/Block/EditBlock.jsx | 7 +- .../Blocks/VideoGallery/Block/ViewBlock.jsx | 92 +++++++++++-------- .../ItaliaTheme/Blocks/VideoGallery/Edit.jsx | 1 + .../ItaliaTheme/Blocks/VideoGallery/View.jsx | 5 +- 4 files changed, 66 insertions(+), 39 deletions(-) diff --git a/src/components/ItaliaTheme/Blocks/VideoGallery/Block/EditBlock.jsx b/src/components/ItaliaTheme/Blocks/VideoGallery/Block/EditBlock.jsx index cf2004a0e..0f26d0e49 100644 --- a/src/components/ItaliaTheme/Blocks/VideoGallery/Block/EditBlock.jsx +++ b/src/components/ItaliaTheme/Blocks/VideoGallery/Block/EditBlock.jsx @@ -32,10 +32,13 @@ class EditBlock extends SubblockEdit { if (__SERVER__) { return
; } - return ( - + {(!this.props.data?.url || this.props.data?.url.length === 0) && (
{this.props.intl.formatMessage(messages.noVideoUrl)}
)} diff --git a/src/components/ItaliaTheme/Blocks/VideoGallery/Block/ViewBlock.jsx b/src/components/ItaliaTheme/Blocks/VideoGallery/Block/ViewBlock.jsx index 49d34e8e9..e2ec64443 100644 --- a/src/components/ItaliaTheme/Blocks/VideoGallery/Block/ViewBlock.jsx +++ b/src/components/ItaliaTheme/Blocks/VideoGallery/Block/ViewBlock.jsx @@ -32,7 +32,12 @@ const messages = defineMessages({ * @class ViewBlock * @extends Component */ -const ViewBlock = ({ data, index, isEditMode = false }) => { +const ViewBlock = ({ + data, + showVideoCaption = false, + index, + isEditMode = false, +}) => { const intl = useIntl(); let placeholder = data.preview_image ? isInternalURL(data.preview_image) @@ -89,52 +94,67 @@ const ViewBlock = ({ data, index, isEditMode = false }) => { {data.url.match('youtu') ? ( <> {data.url.match('list') ? ( - + <> + + {showVideoCaption &&

{data.title}

} + ) : ( - + <> + + {showVideoCaption &&

{data.title}

} + )} ) : ( <> {data.url.match('vimeo') ? ( - + <> + + {showVideoCaption &&

{data.title}

} + ) : ( <> {data.url.match('.mp4') ? ( // eslint-disable-next-line jsx-a11y/media-has-caption -