rn-rich-text-editor 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Editor.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-rich-text-editor",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A rich text editor component for React Native",
5
5
  "keywords": [
6
6
  "react-native",
package/src/Editor.js CHANGED
@@ -277,6 +277,9 @@ export default class Editor extends Component {
277
277
  }
278
278
  if (disabled !== prevProps.disabled) {
279
279
  this.setDisable(disabled);
280
+ const { editorStyle } = this.props;
281
+ const baseBg = editorStyle?.backgroundColor ?? '#FFF';
282
+ this.setContentStyle(disabled ? { backgroundColor: '#C9CED7' } : { backgroundColor: baseBg });
280
283
  }
281
284
  if (placeholder !== prevProps.placeholder) {
282
285
  this.setPlaceholder(placeholder);
@@ -338,13 +341,18 @@ export default class Editor extends Component {
338
341
  const { useContainer, style, errorMessage, readOnly, disabled } = this.props;
339
342
  const errorStyle = !readOnly && errorMessage ? { borderWidth: 1, borderColor: '#d92d20' } : {};
340
343
  const disabledStyle = disabled ? { backgroundColor: '#C9CED7' } : {};
344
+ const readOnlyStyle = readOnly ? { borderWidth: 0 } : {};
345
+ // overflow: 'hidden' prevents the WebView from visually cutting off the container border at corners
346
+ // disabledStyle last so it overrides user's backgroundColor when disabled
347
+ const containerStyle = [style, errorStyle, readOnlyStyle, { overflow: 'hidden' }, disabledStyle];
348
+ if (useContainer) containerStyle.push({ height });
341
349
 
342
350
  return useContainer ? (
343
- <View style={[disabledStyle, style, { height }, errorStyle]} onLayout={this.onViewLayout}>
351
+ <View style={containerStyle} onLayout={this.onViewLayout}>
344
352
  {this.renderWebView()}
345
353
  </View>
346
354
  ) : (
347
- <View style={[disabledStyle, style, errorStyle]}>
355
+ <View style={containerStyle}>
348
356
  {this.renderWebView()}
349
357
  </View>
350
358
  );
@@ -492,6 +500,9 @@ export default class Editor extends Component {
492
500
  initialContentHTML && that.setContentHTML(initialContentHTML);
493
501
  placeholder && that.setPlaceholder(placeholder);
494
502
  that.setDisable(disabled);
503
+ if (disabled) {
504
+ that.setContentStyle({ backgroundColor: '#C9CED7' });
505
+ }
495
506
  editorInitializedCallback();
496
507
 
497
508
  // initial request focus