Skip to content

Commit 575eaf1

Browse files
authored
Merge pull request #1 from mzupek/master
Fixed PropTypes var names, added more styling prop support
2 parents 8857f98 + 831a742 commit 575eaf1

File tree

3 files changed

+62
-25
lines changed

3 files changed

+62
-25
lines changed

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,28 @@ import CKEditor5 from 'react-native-ckeditor5';
2424

2525
Creating a CKEditor5 editor:
2626

27+
```jsx harmony
28+
const colors = {
29+
backgroundColor: '{your color code here}',
30+
offContentBackgroundColor: '{your secondary color code here}',
31+
color: '{font color code here}',
32+
bg5: '{your toolbar button active and hover color}'
33+
}
34+
```
2735

2836
```jsx harmony
29-
<CKEditor
30-
initialData={this.state.test}
31-
onChange={value => this.setState({ test: value })}
32-
editorConfig={{ toolbar: ['bold', 'italic', 'underline', 'bulletedList', 'numberedList', '|', 'undo', 'redo'] }}
33-
onFocus={() => {}}
34-
onBlur={() => {}}
35-
fontFamily="Arial, Helvetica, sans-serif"
36-
/>
37+
<CKEditor5
38+
initialData={inputValue}
39+
onChange={value => onTextChange(value)}
40+
editorConfig={{ toolbar: ['bold', 'italic', 'underline', 'bulletedList', 'numberedList', '|', 'undo', 'redo'] }}
41+
onFocus={() => {}}
42+
onBlur={() => {}}
43+
fontFamily={device.isIOS ? "-apple-system, 'Helvetica Neue', 'Lucida Grande'" : "'Roboto', sans-serif"}
44+
style={{ backgroundColor: 'transparent' }}
45+
height={utils.scaleByVertical(685)}
46+
colors={colors}
47+
toolbarBorderSize="0px"
48+
editorFocusBorderSize="0px"
49+
placeHolderText="Enter text here..."
50+
/>
3751
```

index.js

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@ class CKEditor5 extends PureComponent {
1212
onError: PropTypes.func,
1313
renderError: PropTypes.func,
1414
renderLoading: PropTypes.func,
15-
onChange: propTypes.func,
16-
initialData: propTypes.string,
17-
maxHeight: propTypes.number,
18-
editorConfig: propTypes.object,
19-
style: propTypes.object,
20-
onFocus: propTypes.func,
21-
onBlur: propTypes.func,
22-
disableTooltips: propTypes.bool,
23-
height: propTypes.number,
24-
androidHardwareAccelerationDisabled: propTypes.bool,
25-
fontFamily: propTypes.string,
15+
onChange: PropTypes.func,
16+
initialData: PropTypes.string,
17+
maxHeight: PropTypes.number,
18+
editorConfig: PropTypes.object,
19+
style: PropTypes.object,
20+
onFocus: PropTypes.func,
21+
onBlur: PropTypes.func,
22+
disableTooltips: PropTypes.bool,
23+
height: PropTypes.number,
24+
androidHardwareAccelerationDisabled: PropTypes.bool,
25+
fontFamily: PropTypes.string,
26+
colors: PropTypes.object,
27+
toolbarBorderSize: PropTypes.string,
28+
editorFocusBorderSize: PropTypes.string,
29+
placeHolderText: PropTypes.string
2630
}
2731

2832
static defaultProps = {
@@ -69,7 +73,7 @@ class CKEditor5 extends PureComponent {
6973
render() {
7074
const {
7175
maxHeight, editorConfig, style, initialData, renderLoading, disableTooltips, height,
72-
androidHardwareAccelerationDisabled, fontFamily,
76+
androidHardwareAccelerationDisabled, fontFamily, colors, toolbarBorderSize, editorFocusBorderSize, placeHolderText
7377
} = this.props;
7478
return (
7579
<WebView
@@ -99,19 +103,38 @@ class CKEditor5 extends PureComponent {
99103
height: ${height}px;
100104
max-height: ${maxHeight || height}px;
101105
}
106+
.ck.ck-editor__main>.ck-editor__editable {
107+
background: ${colors.backgroundColor};
108+
color: ${colors.white};
109+
font-family: ${fontFamily || '-apple-system, "Helvetica Neue", "Lucida Grande"'};
110+
border-style: none;
111+
}
112+
.ck .ck-toolbar {
113+
background: ${colors.offContentBackground};
114+
border: ${toolbarBorderSize};
115+
}
116+
.ck.ck-reset_all, .ck.ck-reset_all * {
117+
color: ${colors.white}
118+
}
119+
.ck.ck-editor__editable:not(.ck-editor__nested-editable).ck-focused {
120+
border: ${editorFocusBorderSize};
121+
}
122+
.ck-toolbar .ck-on .ck.ck-icon, .ck-toolbar .ck-on .ck.ck-icon * {
123+
color: ${colors.bg5} !important;
124+
}
125+
.ck-toolbar .ck-button:hover .ck.ck-icon, .ck-toolbar .ck-button:hover .ck.ck-icon * {
126+
color: ${colors.bg5};
127+
}
102128
${disableTooltips ? `
103129
.ck.ck-button .ck.ck-tooltip {
104130
display: none;
105131
}
106-
body {
107-
font-family: ${fontFamily || 'Arial, Helvetica, sans-serif'};
108-
}
109132
` : ''}
110133
</style>
111134
</head>
112135

113136
<body>
114-
<textarea name="editor1" id="editor1"></textarea>
137+
<textarea name="editor1" placeholder="${placeHolderText}" id="editor1"></textarea>
115138
<script>
116139
ClassicEditor
117140
.create( document.querySelector( '#editor1' ), ${JSON.stringify(editorConfig || {})} )

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-ckeditor5",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "React Native CKEditor5 WebView wrapper",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)