Skip to content

Commit 89ddc8e

Browse files
committed
updates to library, customisable toolbar
1 parent 2cad334 commit 89ddc8e

File tree

93 files changed

+11455
-615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+11455
-615
lines changed

.eslintrc

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"extends": ["airbnb", "prettier", "prettier/flowtype", "prettier/react"],
3+
"parser": "babel-eslint",
4+
"rules": {
5+
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }],
6+
"global-require": "off",
7+
"no-console": "off",
8+
"import/no-extraneous-dependencies": "off",
9+
"import/extensions": "off",
10+
"import/no-unresolved": "off",
11+
"jsx-a11y/anchor-is-valid": "off",
12+
"no-underscore-dangle": "off",
13+
"prefer-promise-reject-errors": "off",
14+
"no-nested-ternary": "off",
15+
"react/no-multi-comp": "off",
16+
"import/newline-after-import": "off",
17+
"spaced-comment": "off",
18+
"react/prefer-stateless-function": "off",
19+
"react/prop-types": "off",
20+
"import/first": "off",
21+
"class-methods-use-this": "off",
22+
"prefer-destructuring": "off",
23+
"consistent-return": "off",
24+
"import/prefer-default-export": "off",
25+
"react/no-unescaped-entities": "off",
26+
"react/sort-comp": "off",
27+
"import/no-named-as-default":"off",
28+
"react/forbid-prop-types": "off"
29+
},
30+
"globals": {
31+
"fetch": true
32+
}
33+
}

example/__tests__/App.js

-12
This file was deleted.

example/android/.project

-17
This file was deleted.

example/android/.settings/org.eclipse.buildship.core.prefs

-2
This file was deleted.

example/android/app/.classpath

-6
This file was deleted.

example/android/app/.project

-23
This file was deleted.

example/android/app/.settings/org.eclipse.buildship.core.prefs

-2
This file was deleted.

example/android/app/src/main/res/values/strings.xml

-3
This file was deleted.

example/app.json

-4
This file was deleted.

example/ios/example/AppDelegate.h

-16
This file was deleted.
File renamed without changes.
File renamed without changes.

example/.flowconfig exampleapp/.flowconfig

+12-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
; Ignore polyfills
1717
.*/Libraries/polyfills/.*
1818

19+
; Ignore metro
20+
.*/node_modules/metro/.*
21+
1922
[include]
2023

2124
[libs]
2225
node_modules/react-native/Libraries/react-native/react-native-interface.js
2326
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
2428

2529
[options]
2630
emoji=true
@@ -31,18 +35,20 @@ munge_underscores=true
3135

3236
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
3337

38+
module.file_ext=.js
39+
module.file_ext=.jsx
40+
module.file_ext=.json
41+
module.file_ext=.native.js
42+
3443
suppress_type=$FlowIssue
3544
suppress_type=$FlowFixMe
3645
suppress_type=$FlowFixMeProps
3746
suppress_type=$FlowFixMeState
38-
suppress_type=$FixMe
3947

40-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
41-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
4250
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4351
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4452

45-
unsafe.enable_getters_and_setters=true
46-
4753
[version]
48-
^0.57.0
54+
^0.67.0
File renamed without changes.

example/.gitignore exampleapp/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ buck-out/
5151
*/fastlane/report.xml
5252
*/fastlane/Preview.html
5353
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle
File renamed without changes.

example/app.js exampleapp/App.js

+35-36
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
import React, { Component } from 'react';
22
import {
33
StyleSheet,
4-
Text,
54
View,
65
Platform
76
} from 'react-native';
8-
import {RichTextEditor, RichTextToolbar} from 'react-native-zss-rich-text-editor';
7+
import {Editor, ToolBar, ToolBarStyled} from 'react-native-zss-rich-text-editor';
98
import KeyboardSpacer from 'react-native-keyboard-spacer';
9+
// import CustomToolBar from './CustomToolBar';
10+
11+
const styles = StyleSheet.create({
12+
container: {
13+
flex: 1,
14+
flexDirection: 'column',
15+
backgroundColor: '#ffffff',
16+
paddingTop: 40
17+
},
18+
richText: {
19+
alignItems:'center',
20+
justifyContent: 'center',
21+
backgroundColor: 'transparent',
22+
},
23+
});
1024

1125
export default class RichTextExample extends Component {
1226

@@ -16,24 +30,6 @@ export default class RichTextExample extends Component {
1630
this.setFocusHandlers = this.setFocusHandlers.bind(this);
1731
}
1832

19-
render() {
20-
return (
21-
<View style={styles.container}>
22-
<RichTextEditor
23-
ref={(r)=>this.richtext = r}
24-
style={styles.richText}
25-
initialTitleHTML={'Title!!'}
26-
initialContentHTML={'Hello <b>World</b> <p>this is a new paragraph</p> <p>this is another new paragraph</p>'}
27-
editorInitializedCallback={() => this.onEditorInitialized()}
28-
/>
29-
<RichTextToolbar
30-
getEditor={() => this.richtext}
31-
/>
32-
{Platform.OS === 'ios' && <KeyboardSpacer/>}
33-
</View>
34-
);
35-
}
36-
3733
onEditorInitialized() {
3834
this.setFocusHandlers();
3935
this.getHTML();
@@ -42,7 +38,7 @@ export default class RichTextExample extends Component {
4238
async getHTML() {
4339
const titleHtml = await this.richtext.getTitleHtml();
4440
const contentHtml = await this.richtext.getContentHtml();
45-
//alert(titleHtml + ' ' + contentHtml)
41+
// alert(titleHtml + ' ' + contentHtml) //eslint-disable-line
4642
}
4743

4844
setFocusHandlers() {
@@ -53,19 +49,22 @@ export default class RichTextExample extends Component {
5349
//alert('content focus');
5450
});
5551
}
56-
}
57-
58-
const styles = StyleSheet.create({
59-
container: {
60-
flex: 1,
61-
flexDirection: 'column',
62-
backgroundColor: '#ffffff',
63-
paddingTop: 40
64-
},
65-
richText: {
66-
alignItems:'center',
67-
justifyContent: 'center',
68-
backgroundColor: 'transparent',
69-
},
70-
});
7152

53+
render() {
54+
return (
55+
<View style={styles.container}>
56+
<Editor
57+
ref={(r)=>{ this.richtext = r}}
58+
style={styles.richText}
59+
initialTitleHTML="Title!!"
60+
initialContentHTML={'Hello <b>World</b> <p>this is a new paragraph</p> <p>this is another new paragraph</p>'}
61+
editorInitializedCallback={() => this.onEditorInitialized()}
62+
/>
63+
<ToolBar getEditor={() => this.richtext}>
64+
{props => <ToolBarStyled {...props}/>}
65+
</ToolBar>
66+
{Platform.OS === 'ios' && <KeyboardSpacer/>}
67+
</View>
68+
);
69+
}
70+
}

exampleapp/CustomToolBar.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import * as ZSSEditor from 'react-native-zss-rich-text-editor'
4+
export const Wrapper = styled.ScrollView`
5+
max-height: 50;
6+
background: ${({bg}) => bg};
7+
`;
8+
9+
const ActionWrapper = styled.TouchableOpacity`
10+
height: 50;
11+
width: 50;
12+
justify-content: center;
13+
background: ${({selected, selectedColor, bg}) => selected ? selectedColor : bg};
14+
`
15+
16+
const DEFAULT_ICONS = {
17+
[ZSSEditor.actions.insertImage]: require('./img/icon_format_media.png'),
18+
[ZSSEditor.actions.setBold]: require('./img/icon_format_bold.png'),
19+
[ZSSEditor.actions.setItalic]: require('./img/icon_format_italic.png'),
20+
[ZSSEditor.actions.insertBulletsList]: require('./img/icon_format_ul.png'),
21+
[ZSSEditor.actions.insertOrderedList]: require('./img/icon_format_ol.png'),
22+
[ZSSEditor.actions.insertLink]: require('./img/icon_format_link.png'),
23+
};
24+
25+
const Image = styled.Image``;
26+
27+
28+
const Action = ({onPress, action, icons, bg, selected, selectedColor}) =>
29+
<ActionWrapper onPress={() => onPress(action)} bg={bg} selected={selected} selectedColor={selectedColor}>
30+
{icons[action] && <Image source={icons[action]} style={{tintColor: 'white'}}/>}
31+
</ActionWrapper>
32+
33+
34+
const DefaultToolbar = ({onPressAction, actions, bg, selectedColor, icons}) =>
35+
<Wrapper
36+
contentContainerStyle={{
37+
alignItems: 'center',
38+
flexDirection: 'row',
39+
}}
40+
horizontal
41+
bg={bg}>
42+
{actions.map(action =>
43+
<Action
44+
onPress={onPressAction}
45+
key={action.action}
46+
action={action.action}
47+
selected={action.selected}
48+
selectedColor={selectedColor}
49+
bg={bg}
50+
icons={icons}
51+
/>)}
52+
</Wrapper>
53+
54+
55+
DefaultToolbar.defaultProps = {
56+
bg: '#D3D3D3',
57+
selectedColor: 'red',
58+
selectedIconColor: 'green',
59+
icons: DEFAULT_ICONS,
60+
}
61+
62+
export default DefaultToolbar;

example/android/app/BUCK exampleapp/android/app/BUCK

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ android_library(
4545

4646
android_build_config(
4747
name = "build_config",
48-
package = "com.example",
48+
package = "com.exampleapp",
4949
)
5050

5151
android_resource(
5252
name = "res",
53-
package = "com.example",
53+
package = "com.exampleapp",
5454
res = "src/main/res",
5555
)
5656

example/android/app/build.gradle exampleapp/android/app/build.gradle

+3-4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ android {
9898
buildToolsVersion "23.0.1"
9999

100100
defaultConfig {
101-
applicationId "com.example"
101+
applicationId "com.exampleapp"
102102
minSdkVersion 16
103103
targetSdkVersion 22
104104
versionCode 1
@@ -140,14 +140,13 @@ dependencies {
140140
compile fileTree(dir: "libs", include: ["*.jar"])
141141
compile "com.android.support:appcompat-v7:23.0.1"
142142
compile "com.facebook.react:react-native:+" // From node_modules
143-
compile project(':react-native-webview-bridge')
144143
}
145144

146145
// Run this once to be able to run the application with BUCK
147146
// puts all compile dependencies into folder libs for BUCK to use
148147
task copyDownloadableDepsToLibs(type: Copy) {
149-
from configurations.compile
150-
into 'libs'
148+
from configurations.compile
149+
into 'libs'
151150
}
152151

153152
project.afterEvaluate {

0 commit comments

Comments
 (0)