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] Enable new block in Gutenberg Mobile #47836

Merged
merged 5 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data class GutenbergProps @JvmOverloads constructor(
val enableContactInfoBlock: Boolean,
val enableLayoutGridBlock: Boolean,
val enableTiledGalleryBlock: Boolean,
val enableVideoPressBlock: Boolean,
val enableFacebookEmbed: Boolean,
val enableInstagramEmbed: Boolean,
val enableLoomEmbed: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum Capabilities: String {
case contactInfoBlock
case layoutGridBlock
case tiledGalleryBlock
case videoPressBlock
case mediaFilesCollectionBlock
case mentions
case xposts
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function ( api ) {
'../../node_modules/@babel/plugin-proposal-async-generator-functions'
),
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-named-capturing-groups-regex',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new block makes use of regex named capture groups, which is only supported in the version of Hermes available in RN 0.71 (see facebook/hermes#696 for more details). This resulted in the following error:

bundle/android/App.text.js:3647:961: error: Invalid regular expression: Quantifier has nothing to repeat
...atch(/^https?:\/\/(?<host>video(?:\.word|s\.files\.word)?press\.com)(?:\/v|\/embed)?\/(?<guid>[a-zA-Z\d]{8})/);ret...

The use of @babel/plugin-transform-named-capturing-groups-regex is a workaround to that error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I was wondering if we'd need to add this package as a dependency but noticed in the documentation that is already included when using @babel/preset-env, which is a dependency in Gutenberg (reference).

[
'react-native-platform-specific-extensions',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
.canEnableUnsupportedBlockEditor: unsupportedBlockCanBeActivated,
.mediaFilesCollectionBlock: true,
.tiledGalleryBlock: true,
.videoPressBlock: true,
.isAudioBlockMediaUploadEnabled: true,
.reusableBlock: false,
.facebookEmbed: true,
Expand Down