Skip to content

Commit 35a56b8

Browse files
committed
Update to 1.0.30
layout size added to state
1 parent ce8d63c commit 35a56b8

4 files changed

Lines changed: 15 additions & 17 deletions

File tree

expo-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"expo": "^31.0.2",
1111
"react": "16.5.0",
1212
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
13-
"react-native-cn-richtext-editor": "^1.0.29",
13+
"react-native-cn-richtext-editor": "^1.0.30",
1414
"react-native-popup-menu": "^0.14.2"
1515
},
1616
"devDependencies": {

expo-demo/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,10 +3730,10 @@ react-native-branch@2.2.5:
37303730
version "2.2.5"
37313731
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-2.2.5.tgz#4074dd63b4973e6397d9ce50e97b57c77a518e9d"
37323732

3733-
react-native-cn-richtext-editor@^1.0.29:
3734-
version "1.0.29"
3735-
resolved "https://registry.yarnpkg.com/react-native-cn-richtext-editor/-/react-native-cn-richtext-editor-1.0.29.tgz#98e9b2cd38c1a932ffda39dc18f4ddff5e6a85e5"
3736-
integrity sha512-t3wdl4uYPdx+V3qnbtIYxaeUfjHmWea2YdLnRdnlQUu431FBQg7oqXB1HaLq6JcSS/fIfEoSsLb2ZyUv4W92+w==
3733+
react-native-cn-richtext-editor@^1.0.30:
3734+
version "1.0.30"
3735+
resolved "https://registry.yarnpkg.com/react-native-cn-richtext-editor/-/react-native-cn-richtext-editor-1.0.30.tgz#481b255a886aa71d7d2324704627805022bc3984"
3736+
integrity sha512-JTV8gXV6n3KK8IEPC6xMsq4rUOJGoABXYENfcEmKEmCl6JN79L+eilr4eZyNG17Uk2yW63BBBkgTZQfZeNgqbw==
37373737
dependencies:
37383738
diff-match-patch "^1.0.4"
37393739
immutability-helper "^2.8.1"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-cn-richtext-editor",
3-
"version": "1.0.29",
3+
"version": "1.0.30",
44
"description": "RichText Editor for React-Native",
55
"main": "index.js",
66
"scripts": {
@@ -28,8 +28,8 @@
2828
"url": "git+https://github.com/imnapo/react-native-cn-richtext-editor.git"
2929
},
3030
"contributors": [
31-
"Narbe HS <imnapo@gmail.com> (http://learncode.net)",
32-
"Christ Kho <christ.khodabakhshi@gmail.com> (http://learncode.net)"
31+
"Christ Kho <christ.khodabakhshi@gmail.com> (http://learncode.net)",
32+
"Narbe HS <imnapo@gmail.com> (http://learncode.net)"
3333
],
3434
"author": "Narbe HS <imnapo@gmail.com> (http://learncode.net)",
3535
"license": "ISC",

src/CNRichTextEditor.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ const shortid = require('shortid');
1313
class CNRichTextEditor extends Component {
1414

1515
state = {
16-
1716
imageHighLightedInex: -1,
18-
17+
layoutWidth: 400,
1918
styles: [],
2019
selection:{ start : 0, end: 0},
2120
justToolAdded: false,
2221
avoidUpdateText: false,
2322
focusInputIndex: 0,
24-
2523
};
2624

2725
constructor(props) {
@@ -35,16 +33,13 @@ class CNRichTextEditor extends Component {
3533
this.upComingStype = null;
3634
this.focusOnNextUpdate = -1;
3735
this.selectionOnFocus = null;
38-
this.layoutWidth = 400;
3936
}
4037

4138
componentDidMount() {
4239

4340
}
4441

4542
componentDidUpdate(prevProps, prevState) {
46-
47-
4843
if(this.focusOnNextUpdate != -1 && this.textInputs.length > this.focusOnNextUpdate) {
4944
let ref = this.textInputs[this.focusOnNextUpdate];
5045
ref.focus(this.selectionOnFocus);
@@ -453,8 +448,8 @@ class CNRichTextEditor extends Component {
453448

454449
renderImage(image, index) {
455450
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;
451+
let myHeight = (this.state.layoutWidth - 4 < width) ? height * ((this.state.layoutWidth - 4) / width) : height;
452+
let myWidth = (this.state.layoutWidth - 4 < width) ? this.state.layoutWidth - 4 : width;
458453

459454
return (
460455
<View key={`image${index}`}
@@ -526,7 +521,10 @@ class CNRichTextEditor extends Component {
526521
width,
527522
height
528523
} = event.nativeEvent.layout;
529-
this.layoutWidth = width;
524+
525+
this.setState({
526+
layoutWidth: width
527+
});
530528
}
531529

532530
render() {

0 commit comments

Comments
 (0)