Skip to content

Commit 5441c1b

Browse files
author
Tal Kol
committed
Update README.md
1 parent f19b1f9 commit 5441c1b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ React Native Wrapper for [WordPress Rich Text Editor](https://github.com/wordpre
44

55
> Current experimental implementation is for iOS only.
66
7+
<br>
8+
<p align="left">
9+
<img src="http://i.imgur.com/nFDjKO5.png" width="350"/>
10+
</p>
11+
712
### Dependencies
813

914
* [native code for the original editor](https://github.com/wordpress-mobile/WordPress-Editor-iOS) (a git submodule) - actually taken from this [leaner fork](https://github.com/wix/WordPress-Editor-iOS)
@@ -18,6 +23,8 @@ In order to integrate a `UIViewController` with RN, we have to turn to the libra
1823

1924
### Installation
2025

26+
* Make sure your project relies on React Native >= 0.25
27+
2128
* Make sure your project uses **react-native-navigation** and that you've followed the **Installation** instructions [there](https://github.com/wix/react-native-navigation)
2229

2330
* In your RN project root run:<br>`npm install react-native-wordpress-editor --save`
@@ -26,3 +33,61 @@ In order to integrate a `UIViewController` with RN, we have to turn to the libra
2633

2734
### Usage
2835

36+
#### For a fully working example look [here](example)
37+
38+
First, create a placeholder screen for the editor. The main purpose of this screen is to handle navigation events. See an example [here](https://github.com/wix/react-native-wordpress-editor/blob/master/example/EditorScreen.js).
39+
40+
> Note: Make sure your screen component has been registered with `Navigation.registerComponent` like all react-native-navigation screens need to be, [example](https://github.com/wix/react-native-wordpress-editor/blob/master/example/index.ios.js).
41+
42+
Now, to display your screen, from within one of your other app screens, push the editor:
43+
44+
```js
45+
this.props.navigator.push({
46+
screen: 'example.EditorScreen',
47+
title: 'Preview',
48+
passProps: {
49+
externalNativeScreenClass: 'RNWordPressEditorViewController',
50+
externalNativeScreenProps: {
51+
// the post to open in the editor, leave empty for no post
52+
post: {
53+
// title of the post
54+
title: 'Hello WorldPress',
55+
// html body of the post
56+
body: 'cool HTML body <br><br> <img src="https://www.wpshrug.com/wp-content/uploads/2016/05/wordpress-winning-meme.jpg" />'
57+
},
58+
// if no post shown, these placeholders will appear in the relevant fields
59+
placeHolders: {
60+
title: 'title',
61+
body: 'body'
62+
}
63+
}
64+
}
65+
});
66+
```
67+
68+
### API Reference
69+
70+
Once the editor screen is displayed, you can communicate with it using a JS interface.
71+
72+
```js
73+
import EditorManager from 'react-native-wordpress-editor';
74+
```
75+
76+
* **`EditorManager.setEditingState(editing: boolean)`**
77+
<br>Switch between editing and preview modes (accepts a boolean).
78+
79+
* **`EditorManager.resetStateToInitial()`**
80+
<br>Reset to the initial state right after the screen was pushed (with original props).
81+
82+
* **`EditorManager.isPostChanged(): Promise<boolean>`**
83+
<br>Returns a promise of a boolean (since it's async) whether the state is still the initial one.
84+
85+
* **`EditorManager.getPostData(): Promise<{title: string, body: string}>`**
86+
<br>Returns a promise of a simple object holding the `title` and HTML `body` of the post.
87+
88+
* **`EditorManager.addImages(images: Array<{url: string}>)`**
89+
<br>Adds images at the current cursor location in the editor, takes an array of simple objects with the `url` of each image.
90+
91+
### License
92+
93+
Code in this git repo is licensed MIT, please consider the licenses of the [dependencies](https://github.com/wordpress-mobile/WordPress-Editor-iOS) separately.

0 commit comments

Comments
 (0)