Skip to content

Commit

Permalink
[RNMobile] Enable embed block (#33452)
Browse files Browse the repository at this point in the history
* Remove embed thumbnail preview

* Enable embed block
  • Loading branch information
fluiddot authored Jul 20, 2021
1 parent 3b85572 commit 94ab1a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 43 deletions.
9 changes: 1 addition & 8 deletions packages/block-library/src/embed/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ import { View } from '@wordpress/primitives';

const EmbedEdit = ( props ) => {
const {
attributes: {
providerNameSlug,
previewable,
responsive,
url: attributesUrl,
},
attributes: { providerNameSlug, responsive, url: attributesUrl },
attributes,
isSelected,
onReplace,
Expand Down Expand Up @@ -191,8 +186,6 @@ const EmbedEdit = ( props ) => {
insertBlocksAfter={ insertBlocksAfter }
isSelected={ isSelected }
label={ title }
preview={ preview }
previewable={ previewable }
url={ url }
/>
</View>
Expand Down
37 changes: 7 additions & 30 deletions packages/block-library/src/embed/embed-preview.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { TouchableWithoutFeedback, Image } from 'react-native';
import { TouchableWithoutFeedback } from 'react-native';
import { isEmpty } from 'lodash';

/**
Expand All @@ -17,7 +17,6 @@ import { useState } from '@wordpress/element';
* Internal dependencies
*/
import EmbedNoPreview from './embed-no-preview';
import styles from './styles.scss';

const EmbedPreview = ( {
clientId,
Expand All @@ -27,8 +26,6 @@ const EmbedPreview = ( {
label,
onBlur,
onFocus,
preview,
previewable,
} ) => {
const [ isCaptionSelected, setIsCaptionSelected ] = useState( false );

Expand Down Expand Up @@ -56,39 +53,19 @@ const EmbedPreview = ( {
}
}

const cannotShowThumbnail =
! previewable ||
! preview ||
! preview.thumbnail_url?.length ||
! preview.height ||
! preview.width;

return (
<TouchableWithoutFeedback
accessible={ ! isSelected }
onPress={ onEmbedPreviewPress }
disabled={ ! isSelected }
>
<View>
{ cannotShowThumbnail ? (
<EmbedNoPreview
label={ label }
icon={ icon }
isSelected={ isSelected }
onPress={ () => setIsCaptionSelected( false ) }
/>
) : (
<Image
style={ [
styles[ 'embed-preview__image' ],
{ aspectRatio: preview.width / preview.height },
] }
source={ {
uri: preview.thumbnail_url,
} }
resizeMode="cover"
/>
) }
<EmbedNoPreview
label={ label }
icon={ icon }
isSelected={ isSelected }
onPress={ () => setIsCaptionSelected( false ) }
/>
<BlockCaption
accessibilityLabelCreator={ accessibilityLabelCreator }
accessible
Expand Down
4 changes: 0 additions & 4 deletions packages/block-library/src/embed/styles.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@
background-color: $background-dark-secondary;
}

.embed-preview__image {
flex: 1 1 auto;
}

.embed-no-preview__container {
flex-direction: column;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const registerCoreBlocks = () => {
audio,
reusableBlock,
search,
devOnly( embed ),
embed,
].forEach( registerBlock );

registerBlockVariations( socialLink );
Expand Down

0 comments on commit 94ab1a6

Please sign in to comment.