forked from reggie3/react-native-webview-quilljs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
107 lines (99 loc) · 2.52 KB
/
App.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import React from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import { Constants } from 'expo';
import WebViewQuillEditor from './WebViewQuillEditor';
import WebViewQuillViewer from './WebViewQuillViewer';
// example content to display
/* const contentToDisplay = {
ops: [{ insert: 'Hello\n' }, { insert: 'This is another line' }]
}; */
export default class App extends React.Component {
constructor() {
super();
this.state = {
messageDelta: {}
};
}
getEditorDelta = () => {
this.webViewQuillEditor.getDelta();
};
getDeltaCallback = response => {
console.log('getDeltaCallback');
console.log(response.delta);
this.webViewQuillViewer.sendContentToViewer(response.delta);
};
onDeltaChangeCallback = delta => {
console.log('onDeltaChangeCallback: ', delta);
};
render() {
return (
<View
style={{
...StyleSheet.absoluteFillObject,
backgroundColor: '#e2e2e2'
}}
>
<View style={styles.statusBar} />
<Text
style={{
paddingHorizontal: 10,
paddingVertical: 5,
fontSize: 20,
backgroundColor: '#9be1ff',
color: 'black'
}}
>
React Native Webview Quill-js
</Text>
<View
style={{
flex: 1,
padding: 5,
}}
>
<WebViewQuillEditor
ref={component => (this.webViewQuillEditor = component)}
getDeltaCallback={this.getDeltaCallback}
onDeltaChangeCallback={this.onDeltaChangeCallback}
backgroundColor={'#fffbea'}
/>
</View>
<View
style={{
margin: 5
}}
>
<Button
onPress={this.getEditorDelta}
title="Get Text"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
</View>
<View
style={{
flex: 1,
padding: 5
}}
>
<WebViewQuillViewer
ref={component => (this.webViewQuillViewer = component)}
contentToDisplay={this.state.messageDelta}
backgroundColor={'#fffbea'}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
backgroundColor: '#ccccff',
display: 'flex'
},
statusBar: {
height: Constants.statusBarHeight,
backgroundColor: '#9be1ff'
}
});