Skip to content

Commit ee63b03

Browse files
committed
update
1 parent 99387a3 commit ee63b03

File tree

6 files changed

+54
-37
lines changed

6 files changed

+54
-37
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ const MyApp = () => (
3131

3232
AppRegistry.registerComponent('MyApp', () => MyApp);
3333
```
34+
35+
UPDATE:
36+
## 1.0.1
37+
* Fix the image auto height crop problem.
38+
* Fix fontSize can not be over 14 bug.
39+
* Increase the Text padding size to 2.

src/components/AtomicView.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ const AtomicView = (props: AtomicViewPropsType): any => {
3030
}
3131
switch(entity.type) {
3232
case 'IMAGE': {
33-
const inputImageStyle = {
34-
height: entity.data.height === 'auto' ? 300 : Number(entity.data.height),
35-
width: entity.data.width === 'auto' ? '100%' : Number(entity.data.width)
33+
let inputImageStyle = {}
34+
if (entity.data.height !== 'auto') {
35+
inputImageStyle.height = Number(entity.data.height)
36+
}
37+
if (entity.data.width !== 'auto') {
38+
inputImageStyle.width = Number(entity.data.width)
39+
} else {
40+
inputImageStyle.width = '100%'
3641
}
3742
return (
3843
<Image

src/components/TextStyled.js

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,24 @@ const styles = StyleSheet.flatten({
3636
subscript: {
3737
// WIP
3838
},
39-
"fontsize-14": {
40-
fontSize: 20,
41-
fontFamily: 'Georgia'
42-
},
43-
"fontsize-12": {
44-
fontSize: 18
45-
},
46-
"fontsize-11": {
47-
fontSize: 16
48-
},
49-
"fontsize-10": {
50-
fontSize: 14
51-
},
52-
"fontsize-9": {
53-
fontSize: 12
54-
},
55-
"fontsize-8": {
56-
fontSize: 10
57-
},
39+
// "fontsize-14": {
40+
// fontSize: 20
41+
// },
42+
// "fontsize-12": {
43+
// fontSize: 18
44+
// },
45+
// "fontsize-11": {
46+
// fontSize: 16
47+
// },
48+
// "fontsize-10": {
49+
// fontSize: 14
50+
// },
51+
// "fontsize-9": {
52+
// fontSize: 12
53+
// },
54+
// "fontsize-8": {
55+
// fontSize: 10
56+
// },
5857
"fontfamily-georgia": {
5958
fontFamily: Platform.OS === 'ios' ? 'Georgia' : 'sans-serif'
6059
},
@@ -73,19 +72,19 @@ const styles = StyleSheet.flatten({
7372
});
7473

7574
const getStyles = (itemType: any, customStyles: Object): any => {
76-
console.log(itemType)
77-
console.log(itemType.includes('bgcolor'))
78-
if (itemType.includes('bgcolor')) {
79-
return [StyleSheet.flatten({
80-
backgroundColor: itemType.split('-')[1]
81-
}), customStyles[itemType]]
82-
}
83-
if (typeof itemType === 'string') return [styles[itemType], customStyles[itemType]];
75+
console.log("ITEM TYPE", itemType)
76+
// if (itemType.includes('bgcolor')) {
77+
// return [StyleSheet.flatten({
78+
// backgroundColor: itemType.split('-')[1]
79+
// }), customStyles[itemType]]
80+
// }
81+
// if (typeof itemType === 'string') return [styles[itemType], customStyles[itemType]];
8482

8583
let defaultTextStyles = {};
8684
let customTextStyles = {};
8785
let bgcolorStyle = {}
8886
let colorStyle = {}
87+
let fontsizeStyle = {}
8988
itemType.forEach((i: string) => {
9089
if (i.includes('bgcolor')) {
9190
bgcolorStyle = StyleSheet.flatten({
@@ -97,10 +96,17 @@ const getStyles = (itemType: any, customStyles: Object): any => {
9796
color: i.split('-')[1]
9897
})
9998
}
99+
if (i.split('-')[0] === 'fontsize') {
100+
let fontSize = Number(i.split('-')[1])
101+
fontsizeStyle = StyleSheet.flatten({
102+
lineHeight: fontSize + 10,
103+
fontSize: fontSize
104+
})
105+
}
100106
Object.assign(defaultTextStyles, styles[i]);
101107
Object.assign(customTextStyles, customStyles[i]);
102108
});
103-
const newStyles = [defaultTextStyles, customTextStyles, colorStyle, bgcolorStyle];
109+
const newStyles = [defaultTextStyles, customTextStyles, colorStyle, bgcolorStyle, fontsizeStyle];
104110
return newStyles;
105111
};
106112

src/components/defaultStyles.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ const defaultStyles = StyleSheet.create({
1212
fontWeight: 'normal',
1313
},
1414
unstyled: {
15+
textAlign: 'justify',
16+
lineHeight: 26,
1517
fontSize: 16,
16-
paddingTop: 1,
17-
paddingBottom: 1,
18+
paddingTop: 10,
19+
paddingBottom: 10,
1820
fontWeight: 'normal',
1921
fontFamily: 'PingFangSC-Regular'
2022
},

src/helpers/getItemType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const getItemType = (item: Object): string => {
55
if (Array.isArray(item.style)) {
66
return item.style.map((i: string): string => i.toLowerCase());
77
}
8-
return item.style.toLowerCase();
8+
return [ item.style.toLowerCase() ];
99
}
10-
return '';
10+
return [];
1111
};
1212

1313
export default getItemType;

src/loadAttributes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ const loadAttributes = (
3434
if (attributes.length) {
3535
const attrs = flatAttributesList(attributes);
3636

37-
console.log(attrs)
38-
3937
if (attrs[0].offset > 0) {
4038
elementList.push(<Text key={generateKey()}>{text.substring(0, attrs[0].offset)}</Text>);
4139
}

0 commit comments

Comments
 (0)