Skip to content

Commit

Permalink
[RNMobile] Merge 1.46.1 beta fix release to 1.47.0 (#29044)
Browse files Browse the repository at this point in the history
* 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 <ceyhunozugur@gmail.com>
Co-authored-by: Paul Von Schrottky <paul.von.schrottky@automattic.com>
Co-authored-by: Antonis Lilis <antonis.lilis@automattic.com>
Co-authored-by: David Calhoun <dpcalhoun@gmail.com>
  • Loading branch information
5 people authored Feb 17, 2021
1 parent 086cbfa commit f1340df
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum Capabilities: String {
case xposts
case unsupportedBlockEditor
case canEnableUnsupportedBlockEditor
case audioBlock
}

/// Wrapper for single block data
Expand Down Expand Up @@ -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) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSDictionary *> *)mediaFiles clientId:(NSString *)clientId)

@end
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
print(#function)
}

func gutenbergDidRequestMediaFilesBlockReplaceSync() {
func gutenbergDidRequestMediaFilesBlockReplaceSync(_ mediaFiles: [[String: Any]], clientId: String) {
print(#function)
}

Expand Down Expand Up @@ -310,6 +310,7 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
.unsupportedBlockEditor: unsupportedBlockEnabled,
.canEnableUnsupportedBlockEditor: unsupportedBlockCanBeActivated,
.mediaFilesCollectionBlock: true,
.audioBlock: true
]
}

Expand Down
16 changes: 16 additions & 0 deletions packages/react-native-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f1340df

Please sign in to comment.