File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ yarn add react-native-cn-richtext-editor
2121
2222Here is a simple overview of our components usage.
2323
24- ```
24+ ``` jsx
2525import React , { Component } from ' react' ;
2626import { View , StyleSheet , Keyboard
2727, TouchableWithoutFeedback , Text
@@ -176,8 +176,10 @@ Also be noticed that this example is writen with expo and required 'react-native
176176| onSelectedTagChanged | this event triggers when selected tag of editor is changed. | No |
177177| onSelectedStyleChanged | this event triggers when selected style of editor is changed. | No |
178178| onValueChanged | this event triggers when value of editor is changed. | No |
179+ | onRemoveImage | this event triggers when an image is removed. Callback param in the form ` { uri, id } ` . | No |
179180| value | an array object which keeps value of the editor | Yes |
180181| styleList | an object consist of styles name and values (use getDefaultStyles function) | Yes |
182+ | ImageComponent | a React component (class or functional) which will be used to render images. Will be passed ` style ` and ` source ` props. | No |
181183
182184### CNToolbar
183185
Original file line number Diff line number Diff line change @@ -450,7 +450,7 @@ class CNRichTextEditor extends Component {
450450 const { width, height } = image . size ;
451451 let myHeight = ( this . state . layoutWidth - 4 < width ) ? height * ( ( this . state . layoutWidth - 4 ) / width ) : height ;
452452 let myWidth = ( this . state . layoutWidth - 4 < width ) ? this . state . layoutWidth - 4 : width ;
453-
453+ const { ImageComponent = Image } = this . props
454454 return (
455455 < View key = { `image${ index } ` }
456456 style = { {
@@ -468,15 +468,14 @@ class CNRichTextEditor extends Component {
468468 onPress = { ( ) => this . onImageClicked ( index ) }
469469
470470 >
471- < Image
471+ < ImageComponent
472472 style = { { width : myWidth , height : myHeight
473473 , opacity : this . state . imageHighLightedInex === index ? .8 : 1
474474 } }
475475 source = { { uri : image . url } }
476476 />
477477 </ TouchableWithoutFeedback >
478478 < TextInput
479-
480479 onKeyPress = { ( event ) => this . handleKeyDown ( event , index ) }
481480 //onSelectionChange={(event) =>this.onSelectionChange(event, index)}
482481 multiline = { false }
Original file line number Diff line number Diff line change @@ -69,11 +69,10 @@ class CNRichTextView extends Component {
6969 renderImage ( image , index ) {
7070 const { width, height } = image . size ;
7171 const { layoutWidth } = this . state ;
72-
72+ const { ImageComponent = Image } = this . props
7373 let myHeight = ( layoutWidth - 4 < width ) ? height * ( ( layoutWidth - 4 ) / width ) : height ;
7474 let myWidth = ( layoutWidth - 4 < width ) ? layoutWidth - 4 : width ;
7575
76-
7776 return (
7877 < View key = { `image${ index } ` }
7978 style = { {
@@ -82,8 +81,7 @@ class CNRichTextView extends Component {
8281 } }
8382 >
8483 < View >
85- < Image
86-
84+ < ImageComponent
8785 style = { {
8886 width : myWidth , height : myHeight
8987 , opacity : this . state . imageHighLightedInex === index ? .8 : 1
You can’t perform that action at this time.
0 commit comments