Skip to content

Commit

Permalink
Receive unsupported block fallback message.
Browse files Browse the repository at this point in the history
This is used to display a web view rendering the unsuported block.

At first we might show the full post loading gutenberg-web, but ideally we would show just the requested block.
  • Loading branch information
etoledom committed Mar 25, 2020
1 parent 345a89c commit 2dbb663
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions react-native-gutenberg-bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ export function requestMediaPicker( source, filter, multiple, callback ) {
RNReactNativeGutenbergBridge.requestMediaPickFrom( source, filter, multiple, callback );
}

/**
* Request to render an unsuported block.
*
* A way to show unsupported blocks to the user is to render it on a web view.
*
* @param {string} htmlContent Raw html content of the block.
*/
export function requestUnsupportedBlockFallback( htmlContent ) {
RNReactNativeGutenbergBridge.requestUnsupportedBlockFallback( htmlContent );
}

export function requestMediaImport( url, callback ) {
return RNReactNativeGutenbergBridge.requestMediaImport( url, callback );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,15 @@ public protocol GutenbergBridgeDelegate: class {
/// Tells the delegate that the editor needs to log a custom event
/// - Parameter event: The event key to be logged
func gutenbergDidLogUserEvent(_ event: GutenbergUserEvent)

/// Tells the delegate that the editor needs to render an unsupported block
func gutenbergDidRequestUnsupportedBlockFallback(with content: String)
}

// MARK: - Optional GutenbergBridgeDelegate methods

public extension GutenbergBridgeDelegate {
func gutenbergDidLoad() { }
func gutenbergDidLayout() { }
func gutenbergDidRequestUnsupportedBlockFallback(with content: String) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject)
RCT_EXTERN_METHOD(requestImageFullscreenPreview:(NSString *)currentImageUrlString originalImageUrlString:(NSString *)originalImageUrlString)
RCT_EXTERN_METHOD(requestMediaEditor:(NSString *)mediaUrl callback:(RCTResponseSenderBlock)callback)
RCT_EXTERN_METHOD(logUserEvent:(NSString *)event properties:(NSDictionary *)properties)
RCT_EXTERN_METHOD(requestUnsupportedBlockFallback:(NSString *)content)

@end
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter {
}
}

@objc
func requestUnsupportedBlockFallback(_ content: String) {
DispatchQueue.main.async {
self.delegate?.gutenbergDidRequestUnsupportedBlockFallback(with: content)
}
}

@objc
func getOtherMediaOptions(_ filter: [String]?, callback: @escaping RCTResponseSenderBlock) {
guard let dataSource = dataSource else {
Expand Down

0 comments on commit 2dbb663

Please sign in to comment.