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

[RNMobile][Embed block] Add device's locale to preview content #33858

Merged
merged 5 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 7 additions & 2 deletions packages/block-library/src/embed/embed-preview.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import classnames from 'classnames/dedupe';
* WordPress dependencies
*/
import { View } from '@wordpress/primitives';

import { BlockCaption } from '@wordpress/block-editor';
import {
BlockCaption,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import { memo, useState } from '@wordpress/element';
import { SandBox } from '@wordpress/components';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -38,6 +41,7 @@ const EmbedPreview = ( {
url,
} ) => {
const [ isCaptionSelected, setIsCaptionSelected ] = useState( false );
const { locale } = useSelect( blockEditorStore ).getSettings();

const wrapperStyle = styles[ 'embed-preview__wrapper' ];
const wrapperAlignStyle =
Expand Down Expand Up @@ -105,6 +109,7 @@ const EmbedPreview = ( {
>
<PreviewContent
html={ html }
lang={ locale }
title={ iframeTitle }
type={ sandboxClassnames }
providerUrl={ providerUrl }
Expand Down
6 changes: 2 additions & 4 deletions packages/components/src/sandbox/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ const EMPTY_ARRAY = [];

function Sandbox( {
containerStyle,
html = '',
customJS,
html = '',
lang = 'en',
providerUrl = '',
scripts = EMPTY_ARRAY,
styles = EMPTY_ARRAY,
Expand All @@ -179,9 +180,6 @@ function Sandbox( {
} );

function getHtmlDoc() {
// TODO: Use the device's locale
const lang = 'en';

// Put the html snippet into a html document, and update the state to refresh the WebView,
// we can use this in the future to inject custom styles or scripts.
// Scripts go into the body rather than the head, to support embedded content such as Instagram
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class NativeEditorProvider extends Component {
componentDidMount() {
const {
capabilities,
locale,
updateSettings,
galleryWithImageBlocks,
} = this.props;
Expand All @@ -100,6 +101,7 @@ class NativeEditorProvider extends Component {
...capabilities,
...{ __unstableGalleryWithImageBlocks: galleryWithImageBlocks },
...this.getThemeColors( this.props ),
locale,
} );

this.subscriptionParentGetHtml = subscribeParentGetHtml( () => {
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ For each user feature we should also add a importance categorization label to i
-->

## Unreleased
- [*] Embed block: Add device's locale to preview content [https://github.com/WordPress/gutenberg/pull/33858]

## 1.61.0
- [**] Enable embed preview for a list of providers (for now only YouTube and Twitter) [#34446]
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const setupInitHooks = () => {
rawStyles,
rawFeatures,
galleryWithImageBlocks,
locale,
} = props;

if ( initialData === undefined && __DEV__ ) {
Expand Down Expand Up @@ -112,6 +113,7 @@ const setupInitHooks = () => {
rawStyles,
rawFeatures,
galleryWithImageBlocks,
locale,
};
}
);
Expand Down