From 0eac83bb5b458c526fb5f275ccfd508a11273ff0 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 16 Feb 2021 14:35:58 +0200 Subject: [PATCH 1/7] Release script: Update react-native-editor version to 1.47.0 --- packages/react-native-aztec/package.json | 2 +- packages/react-native-bridge/package.json | 58 +++++++++++------------ packages/react-native-editor/package.json | 4 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/react-native-aztec/package.json b/packages/react-native-aztec/package.json index 2f3eeb9486dc1..2431d2fb69efa 100644 --- a/packages/react-native-aztec/package.json +++ b/packages/react-native-aztec/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-aztec", - "version": "1.46.0", + "version": "1.47.0", "description": "Aztec view for react-native.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-bridge/package.json b/packages/react-native-bridge/package.json index 98b321afb216d..21dcfb9b395a5 100644 --- a/packages/react-native-bridge/package.json +++ b/packages/react-native-bridge/package.json @@ -1,31 +1,31 @@ { - "name": "@wordpress/react-native-bridge", - "version": "1.46.0", - "description": "Native bridge library used to integrate the block editor into a native App.", - "private": true, - "author": "The WordPress Contributors", - "license": "GPL-2.0-or-later", - "keywords": [ - "react-native" - ], - "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/react-native-bridge/README.md", - "repository": { - "type": "git", - "url": "https://github.com/WordPress/gutenberg.git", - "directory": "packages/react-native-bridge" - }, - "bugs": { - "url": "https://github.com/WordPress/gutenberg/issues" - }, - "main": "index.js", - "react-native": "index", - "dependencies": { - "@wordpress/react-native-aztec": "file:../react-native-aztec" - }, - "peerDependencies": { - "react-native": "*" - }, - "publishConfig": { - "access": "public" - } + "name": "@wordpress/react-native-bridge", + "version": "1.47.0", + "description": "Native bridge library used to integrate the block editor into a native App.", + "private": true, + "author": "The WordPress Contributors", + "license": "GPL-2.0-or-later", + "keywords": [ + "react-native" + ], + "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/react-native-bridge/README.md", + "repository": { + "type": "git", + "url": "https://github.com/WordPress/gutenberg.git", + "directory": "packages/react-native-bridge" + }, + "bugs": { + "url": "https://github.com/WordPress/gutenberg/issues" + }, + "main": "index.js", + "react-native": "index", + "dependencies": { + "@wordpress/react-native-aztec": "file:../react-native-aztec" + }, + "peerDependencies": { + "react-native": "*" + }, + "publishConfig": { + "access": "public" + } } diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index 54f6a8bcf3dca..21ddec8240c56 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-editor", - "version": "1.46.0", + "version": "1.47.0", "description": "Mobile WordPress gutenberg editor.", "author": "The WordPress Contributors", "license": "GPL-2.0-or-later", @@ -79,7 +79,7 @@ "access": "public" }, "scripts": { - "start": "echo \"\\x1b[33mThe start command is not available in this project. It is strongly recommended to use \\x1b[1:33mstart:reset\\x1b[0m\\x1b[33m to perform some cleanup when starting the metro bundler.\nOr you may use \\x1b[1:33mstart:quick\\x1b[0m\\x1b[33m for a quicker startup, but this may lead to unexpected javascript errors when running the app.\\x1b[0m\"", + "start": "echo \"\\x1b[33mThe start command is not available in this project. It is strongly recommended to use \\x1b[1:33mstart:reset\\x1b[0m\\x1b[33m to perform some cleanup when starting the metro bundler.\nOr you may use \\x1b[1:33mstart:quick\\x1b[0m\\x1b[33m for a quicker startup, but this may lead to unexpected javascript errors when running the app.\\x1b[0m\"", "start:debug": "node --inspect-brk node_modules/.bin/react-native start", "start:reset": "npm run clean:runtime && npm run start:quick -- --reset-cache", "start:quick": "react-native start", From a55eb933b75e8e4b636cc34d1bdb3fc373f7be4b Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 16 Feb 2021 14:36:22 +0200 Subject: [PATCH 2/7] Release script: Update with changes from 'npm run core preios' --- packages/react-native-editor/ios/Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native-editor/ios/Podfile.lock b/packages/react-native-editor/ios/Podfile.lock index 9431858f4554b..cfd132e6961af 100644 --- a/packages/react-native-editor/ios/Podfile.lock +++ b/packages/react-native-editor/ios/Podfile.lock @@ -21,7 +21,7 @@ PODS: - DoubleConversion - glog - glog (0.3.5) - - Gutenberg (1.46.0): + - Gutenberg (1.47.0): - React-Core (= 0.61.5) - React-CoreModules (= 0.61.5) - React-RCTImage (= 0.61.5) @@ -253,7 +253,7 @@ PODS: - React-Core - RNSVG (9.13.6-gb): - React-Core - - RNTAztecView (1.46.0): + - RNTAztecView (1.47.0): - React-Core - WordPress-Aztec-iOS (~> 1.19.3) - WordPress-Aztec-iOS (1.19.3) @@ -402,7 +402,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75 Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 glog: 1f3da668190260b06b429bb211bfbee5cd790c28 - Gutenberg: ddf8773fb7cb17282b990a92bb4bb689f5561778 + Gutenberg: 103a9ebea785a8e1dd4c8bd4378d4a8a70efa678 RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1 RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320 React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78 @@ -435,7 +435,7 @@ SPEC CHECKSUMS: RNReanimated: f05baf4cd76b6eab2e4d7e2b244424960b968918 RNScreens: 953633729a42e23ad0c93574d676b361e3335e8b RNSVG: 46c4b680fe18237fa01eb7d7b311d77618fde31f - RNTAztecView: 70085b41b999a670bc94d13e58adfd6c7f46fa2a + RNTAztecView: 9c5552d00636833f452d88509421697869b1d13a WordPress-Aztec-iOS: b7ac8b30f746992e85d9668453ac87c2cdcecf4f Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b From 6cae6295d5f0c5c11a1b571c5f5431bcc499742c Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Tue, 16 Feb 2021 09:06:44 -0300 Subject: [PATCH 3/7] [RNMobile] Ignore column width attribute when empty (#29015) * Ignore empty width attribute in columns The editor was crashing when attempting to render a column block which contained an empty width attribute (i.e ``. The exception occurred when accessing a property of an undefined object, so adding a default object (`|| {}`) fixes this by allowing the property to be accessed. * Update react-native-editor changelog * Add missing dependency to useSelect in columns block Co-authored-by: Carlos Garcia --- packages/block-library/src/columns/edit.native.js | 2 +- .../src/mobile/utils/use-unit-converter-to-mobile.native.js | 2 +- packages/react-native-editor/CHANGELOG.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/columns/edit.native.js b/packages/block-library/src/columns/edit.native.js index cf9cabea944be..59560192bf87f 100644 --- a/packages/block-library/src/columns/edit.native.js +++ b/packages/block-library/src/columns/edit.native.js @@ -476,7 +476,7 @@ const ColumnsEdit = ( props ) => { editorSidebarOpened: isSelected && isEditorSidebarOpened(), }; }, - [ clientId ] + [ clientId, isSelected ] ); const memoizedInnerWidths = useMemo( () => { diff --git a/packages/components/src/mobile/utils/use-unit-converter-to-mobile.native.js b/packages/components/src/mobile/utils/use-unit-converter-to-mobile.native.js index cf8a77b8d0e56..fda7ff8efc912 100644 --- a/packages/components/src/mobile/utils/use-unit-converter-to-mobile.native.js +++ b/packages/components/src/mobile/utils/use-unit-converter-to-mobile.native.js @@ -37,7 +37,7 @@ const getValueAndUnit = ( value, unit ) => { const convertUnitToMobile = ( containerSize, globalStyles, value, unit ) => { const { width, height } = containerSize; - const { valueToConvert, valueUnit } = getValueAndUnit( value, unit ); + const { valueToConvert, valueUnit } = getValueAndUnit( value, unit ) || {}; const { fontSize = 16 } = globalStyles || {}; switch ( valueUnit ) { diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 096bb7821627b..ed3a399481b22 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -12,6 +12,7 @@ For each user feature we should also add a importance categorization label to i ## Unreleased * [**] Make inserter long-press options "add to beginning" and "add to end" always available. [#28610] * [**] Add support for setting Cover block focal point. [#25810] +* [*] Fix crash when Column block width attribute was empty. [#29015] ## 1.46.0 * [***] New Block: Audio [#27401, #27467, #28594] From 181da849a0b05fe1f788f828e08333350ecfdcb6 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 16 Feb 2021 08:16:23 -0600 Subject: [PATCH 4/7] Update editor changelog --- packages/react-native-editor/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index ed3a399481b22..6aae87971d163 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -10,6 +10,8 @@ For each user feature we should also add a importance categorization label to i --> ## Unreleased + +## 1.47.0 * [**] Make inserter long-press options "add to beginning" and "add to end" always available. [#28610] * [**] Add support for setting Cover block focal point. [#25810] * [*] Fix crash when Column block width attribute was empty. [#29015] From 064262fea768d2fe52557b6aac44e16609bc5c39 Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Wed, 17 Feb 2021 13:40:54 +0100 Subject: [PATCH 5/7] Mobile - RichText - Restore onSelectionChange when its focused (#29074) --- packages/rich-text/src/component/index.native.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/rich-text/src/component/index.native.js b/packages/rich-text/src/component/index.native.js index 0f1041631f260..6185f53b1bdf8 100644 --- a/packages/rich-text/src/component/index.native.js +++ b/packages/rich-text/src/component/index.native.js @@ -756,6 +756,12 @@ export class RichText extends Component { if ( isSelected && ! prevIsSelected ) { this._editor.focus(); + // Update selection props explicitly when component is selected as Aztec won't call onSelectionChange + // if its internal value hasn't change. When created, default value is 0, 0 + this.onSelectionChange( + this.props.selectionStart || 0, + this.props.selectionEnd || 0 + ); } else if ( ! isSelected && prevIsSelected ) { this._editor.blur(); } From 086cbfabfaa77372b610278083b512b1044666df Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Wed, 17 Feb 2021 14:38:59 +0200 Subject: [PATCH 6/7] Adds null check before function call --- packages/components/src/color-palette/index.native.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/src/color-palette/index.native.js b/packages/components/src/color-palette/index.native.js index 4a2ffc8aec563..152845b80d2fc 100644 --- a/packages/components/src/color-palette/index.native.js +++ b/packages/components/src/color-palette/index.native.js @@ -105,7 +105,8 @@ function ColorPalette( { }, [ currentSegment ] ); function isSelectedCustom() { - const isWithinColors = activeColor && colors.includes( activeColor ); + const isWithinColors = + activeColor && colors && colors.includes( activeColor ); if ( activeColor ) { if ( isGradientSegment ) { return isGradientColor && ! isWithinColors; From f1340dfaa7e8827b988b1453dbd73fb1a30e746d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 17 Feb 2021 20:05:47 +0100 Subject: [PATCH 7/7] [RNMobile] Merge 1.46.1 beta fix release to 1.47.0 (#29044) * Release script: Update react-native-editor version to 1.46.1 * Release script: Update with changes from 'npm run core preios' * Update react-native-editor CHANGELOG * [RNMobile] Add capability to bridge to show/hide audio block (#28952) * [RNMobile] Ignore column width attribute when empty (#29015) * Update react-native-editor CHANGELOG * Fixes minor changelog alignement issue * Add Stories bridge methods for iOS (#29083) Add missing bridge methods for the Stories block. The absence of these threw an error, even though Stories block isn't fully supported for iOS just yet. Co-authored-by: Ceyhun Ozugur Co-authored-by: Paul Von Schrottky Co-authored-by: Antonis Lilis Co-authored-by: David Calhoun --- .../mobile/WPAndroidGlue/GutenbergProps.kt | 3 +++ .../ios/GutenbergBridgeDelegate.swift | 3 ++- .../ios/RNReactNativeGutenbergBridge.m | 2 +- .../ios/RNReactNativeGutenbergBridge.swift | 4 ++-- packages/react-native-editor/CHANGELOG.md | 4 +++- .../main/java/com/gutenberg/MainActivity.java | 1 + .../GutenbergDemo/GutenbergViewController.swift | 3 ++- packages/react-native-editor/src/index.js | 16 ++++++++++++++++ 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt index 933288ff19c88..dd33c571acc05 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt @@ -9,6 +9,7 @@ data class GutenbergProps @JvmOverloads constructor( val enableXPosts: Boolean, val enableUnsupportedBlockEditor: Boolean, val canEnableUnsupportedBlockEditor: Boolean, + val enableAudioBlock: Boolean, val localeSlug: String, val postType: String, val editorTheme: Bundle?, @@ -44,6 +45,7 @@ data class GutenbergProps @JvmOverloads constructor( putBoolean(PROP_CAPABILITIES_MEDIAFILES_COLLECTION_BLOCK, enableMediaFilesCollectionBlocks) putBoolean(PROP_CAPABILITIES_UNSUPPORTED_BLOCK_EDITOR, enableUnsupportedBlockEditor) putBoolean(PROP_CAPABILITIES_CAN_ENABLE_UNSUPPORTED_BLOCK_EDITOR, canEnableUnsupportedBlockEditor) + putBoolean(PROP_CAPABILITIES_AUDIO_BLOCK, enableAudioBlock) } companion object { @@ -74,5 +76,6 @@ data class GutenbergProps @JvmOverloads constructor( const val PROP_CAPABILITIES_XPOSTS = "xposts" const val PROP_CAPABILITIES_UNSUPPORTED_BLOCK_EDITOR = "unsupportedBlockEditor" const val PROP_CAPABILITIES_CAN_ENABLE_UNSUPPORTED_BLOCK_EDITOR = "canEnableUnsupportedBlockEditor" + const val PROP_CAPABILITIES_AUDIO_BLOCK = "audioBlock" } } diff --git a/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift b/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift index de7f97c25c92a..5f05ec115d8a2 100644 --- a/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift +++ b/packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift @@ -22,6 +22,7 @@ public enum Capabilities: String { case xposts case unsupportedBlockEditor case canEnableUnsupportedBlockEditor + case audioBlock } /// Wrapper for single block data @@ -269,5 +270,5 @@ public extension GutenbergBridgeDelegate { func gutenbergDidRequestMediaFilesFailedRetryDialog(_ mediaFiles: [[String: Any]]) { } func gutenbergDidRequestMediaFilesUploadCancelDialog(_ mediaFiles: [[String: Any]]) { } func gutenbergDidRequestMediaFilesSaveCancelDialog(_ mediaFiles: [[String: Any]]) { } - func gutenbergDidRequestMediaFilesBlockReplaceSync() {} + func gutenbergDidRequestMediaFilesBlockReplaceSync(_ mediaFiles: [[String: Any]], clientId: String) {} } diff --git a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m index 0981b73bcbbbf..5ca99e956dc7f 100644 --- a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m +++ b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m @@ -31,6 +31,6 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject) RCT_EXTERN_METHOD(setFocalPointPickerTooltipShown:(BOOL)tooltipShown) RCT_EXTERN_METHOD(actionButtonPressed:(NSString *)buttonType) RCT_EXTERN_METHOD(mediaSaveSync) -RCT_EXTERN_METHOD(mediaFilesBlockReplaceSync) +RCT_EXTERN_METHOD(mediaFilesBlockReplaceSync:(NSArray *)mediaFiles clientId:(NSString *)clientId) @end diff --git a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift index 927f477fcd8a4..302187d23dbcc 100644 --- a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -338,10 +338,10 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { } @objc - func mediaFilesBlockReplaceSync() { + func mediaFilesBlockReplaceSync(_ mediaFiles: [[String: Any]], clientId: String) { DispatchQueue.main.async { if self.hasObservers { - self.delegate?.gutenbergDidRequestMediaFilesBlockReplaceSync() + self.delegate?.gutenbergDidRequestMediaFilesBlockReplaceSync(mediaFiles, clientId: clientId) } } } diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 6aae87971d163..374e8a799d2c9 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -12,8 +12,10 @@ For each user feature we should also add a importance categorization label to i ## Unreleased ## 1.47.0 -* [**] Make inserter long-press options "add to beginning" and "add to end" always available. [#28610] * [**] Add support for setting Cover block focal point. [#25810] + +## 1.46.1 +* [**] Make inserter long-press options "add to beginning" and "add to end" always available. [#28610] * [*] Fix crash when Column block width attribute was empty. [#29015] ## 1.46.0 diff --git a/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainActivity.java b/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainActivity.java index ed3fdb7616676..1946c46b517d5 100644 --- a/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainActivity.java +++ b/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainActivity.java @@ -31,6 +31,7 @@ protected Bundle getLaunchOptions() { capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_MENTIONS, true); capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_XPOSTS, true); capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_UNSUPPORTED_BLOCK_EDITOR, true); + capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_AUDIO_BLOCK, true); bundle.putBundle(GutenbergProps.PROP_CAPABILITIES, capabilities); return bundle; } diff --git a/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift b/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift index 2dafaeebb02b8..8bc821846f416 100644 --- a/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift +++ b/packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift @@ -233,7 +233,7 @@ extension GutenbergViewController: GutenbergBridgeDelegate { print(#function) } - func gutenbergDidRequestMediaFilesBlockReplaceSync() { + func gutenbergDidRequestMediaFilesBlockReplaceSync(_ mediaFiles: [[String: Any]], clientId: String) { print(#function) } @@ -310,6 +310,7 @@ extension GutenbergViewController: GutenbergBridgeDataSource { .unsupportedBlockEditor: unsupportedBlockEnabled, .canEnableUnsupportedBlockEditor: unsupportedBlockCanBeActivated, .mediaFilesCollectionBlock: true, + .audioBlock: true ] } diff --git a/packages/react-native-editor/src/index.js b/packages/react-native-editor/src/index.js index 1c8ffa445b042..48f4b827fe965 100644 --- a/packages/react-native-editor/src/index.js +++ b/packages/react-native-editor/src/index.js @@ -18,6 +18,7 @@ import { validateThemeColors, validateThemeGradients, } from '@wordpress/block-editor'; +import { dispatch } from '@wordpress/data'; const reactNativeSetup = () => { // Disable warnings as they disrupt the user experience in dev mode @@ -99,6 +100,21 @@ const setupInitHooks = () => { }; } ); + + wpHooks.addAction( + 'native.render', + 'core/react-native-editor', + ( props ) => { + const isAudioBlockEnabled = + props.capabilities && props.capabilities.audioBlock; + + if ( isAudioBlockEnabled === true ) { + dispatch( 'core/edit-post' ).showBlockTypes( [ 'core/audio' ] ); + } else { + dispatch( 'core/edit-post' ).hideBlockTypes( [ 'core/audio' ] ); + } + } + ); }; let blocksRegistered = false;