@@ -236,16 +236,14 @@ class CNRichTextEditor extends Component {
236236 const { value } = this . props ;
237237 let index = focusInputIndex + 1 ;
238238
239- let myHeight = ( this . layoutWidth - 4 < width ) ? height * ( ( this . layoutWidth - 4 ) / width ) : height ;
240-
241239 const item = {
242240 id : shortid . generate ( ) ,
243241 imageId : id ,
244242 component : 'image' ,
245243 url : url ,
246244 size : {
247- height : myHeight ,
248- width : ( this . layoutWidth - 4 < width ) ? this . layoutWidth - 4 : width
245+ height : height ,
246+ width : width
249247 }
250248 } ;
251249
@@ -314,9 +312,7 @@ class CNRichTextEditor extends Component {
314312
315313
316314
317- if ( height != null && width != null ) {
318-
319-
315+ if ( height != null && width != null ) {
320316 this . addImageContent ( url , id , height , width ) ;
321317 }
322318 else {
@@ -456,6 +452,9 @@ class CNRichTextEditor extends Component {
456452 }
457453
458454 renderImage ( image , index ) {
455+ const { width, height } = image . size ;
456+ let myHeight = ( this . layoutWidth - 4 < width ) ? height * ( ( this . layoutWidth - 4 ) / width ) : height ;
457+ let myWidth = ( this . layoutWidth - 4 < width ) ? this . layoutWidth - 4 : width ;
459458
460459 return (
461460 < View key = { `image${ index } ` }
@@ -467,16 +466,15 @@ class CNRichTextEditor extends Component {
467466 paddingLeft : 2 ,
468467 paddingRight : 2 ,
469468 paddingTop : 2 ,
470- paddingBottom : 2 ,
469+ paddingBottom : 2
471470 } }
472471 >
473472 < TouchableWithoutFeedback
474473 onPress = { ( ) => this . onImageClicked ( index ) }
475474
476475 >
477476 < Image
478-
479- style = { { width : image . size . width , height : image . size . height
477+ style = { { width : myWidth , height : myHeight
480478 , opacity : this . state . imageHighLightedInex === index ? .8 : 1
481479 } }
482480 source = { { uri : image . url } }
@@ -488,7 +486,7 @@ class CNRichTextEditor extends Component {
488486 //onSelectionChange={(event) =>this.onSelectionChange(event, index)}
489487 multiline = { false }
490488 style = { {
491- fontSize : image . size . height * .65 ,
489+ fontSize : myHeight * .65 ,
492490 borderWidth : 0 ,
493491 paddingBottom :1 ,
494492 width : 1
0 commit comments