-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.js
35 lines (25 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/** @format */
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
const { RNReactNativeGutenbergBridge } = NativeModules;
const isIOS = Platform.OS === 'ios';
const gutenbergBridgeEvents = new NativeEventEmitter( RNReactNativeGutenbergBridge );
// Send messages
export function sendNativeEditorDidLayout() {
// For now, this is only needed on iOS to solve layout issues with the toolbar.
// If this become necessary on Android in the future, we can try to build a registration API from Native
// to register messages it wants to receive, similar to the Native -> JS messages listener system.
if ( isIOS ) {
RNReactNativeGutenbergBridge.editorDidLayout();
}
}
// Register listeners
export function subscribeParentGetHtml( callback ) {
return gutenbergBridgeEvents.addListener( 'requestGetHtml', callback );
}
export function subscribeParentToggleHTMLMode( callback ) {
return gutenbergBridgeEvents.addListener( 'toggleHTMLMode', callback );
}
export function subscribeUpdateHtml( callback ) {
return gutenbergBridgeEvents.addListener( 'updateHtml', callback );
}
export default RNReactNativeGutenbergBridge;